我有一个 CEL-TEC F5A 耳机。规格说明如下:
蓝牙 4.0,模式:耳机、免提、A2DP、AVRCP/HSP/HFP
它与高保真播放(A2DP 接收器)轮廓。
当我想将音频输入切换到耳机的麦克风时,输出配置文件会自动更改为耳机主机 (HFS/HFP)而且音质很差——就像 8 位声音之类的。当我将其切换回 A2DP 时,输入又回到桌面麦克风。
我读过其他几个问题,似乎 A2DP 不支持输入,对吧?但我猜 HFS/HFP 中的 HFP 部分是高保真播放?听起来它可以用作耳机,但听起来不像 1950 年代的电话。
我如何才能简化配置文件之间的切换,以便我说话时使用 HFS/HFP,听音乐时使用 A2DP?例如一键通。
Ubuntu 17.10,没有声音定制IIRC,一切都是最新的。
https://www.kabelmanie.cz/cel-tec-f5a-active-noise-bluetooth-stereo-sluchatka-s-mikrofonem/
我的输出:
$ pactl list cards
Card #0
Name: alsa_card.pci-0000_00_03.0
...
Card #4
Name: bluez_card.00_19_5D_25_6F_6C
Driver: module-bluez5-device.c
Owner Module: 30
Properties:
device.description = "F5A"
device.string = "00:19:5D:25:6F:6C"
device.api = "bluez"
device.class = "sound"
device.bus = "bluetooth"
device.form_factor = "headset"
bluez.path = "/org/bluez/hci0/dev_00_19_5D_25_6F_6C"
bluez.class = "0x240404"
bluez.alias = "F5A"
device.icon_name = "audio-headset-bluetooth"
device.intended_roles = "phone"
Profiles:
a2dp_sink: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 10, available: yes)
headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 20, available: yes)
off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
Active Profile: a2dp_sink
Ports:
headset-output: Headset (priority: 0, latency offset: 0 usec, available)
Part of profile(s): a2dp_sink, headset_head_unit
headset-input: Headset (priority: 0, latency offset: 0 usec)
Part of profile(s): headset_head_unit
这里的问题不是麦克风不工作,而是激活麦克风后音频质量会变差。
答案1
昂德拉,有非常长的脉冲音频合并请求讨论包含大部分信息。
总结:要让脉冲音频、bluez 和内核正常工作,需要更新(这并非易事)。另外还hsphfpd
需要一个单独的守护进程。
内核更新没有进展,用户对维护人员的输入将有助于推动事情向前发展。考虑提供这样的信息。参见这里。
如果没有内核补丁,使用耳机的麦克风会导致音频质量很差(HSP/HFP 操作模式)。
但有可能只有 Pulse 补丁(以及耳机支持)可以启用 A2DP 双向音频,这对于大多数用途来说应该是没问题的。
目前该补丁进展顺利。提供更多反馈应该不会有什么坏处。
更新:上述拉取请求中的问题迅速升级,似乎 PulseAudio 可能永远不会实现适当的蓝牙支持。让我们期待管线其中已经有一些补丁。
答案2
我原本打算退回耳机并等待蓝牙 5.0 耳机,但后来意识到,这是我的 BT 4.0 笔记本电脑可以获得的最佳功能。所以我保留了它们。
不过,用 16 位 8000 Hz 音频听法国人说话并不是开会的正确方式。几天来,我使用 Ubuntu 的声音设置对话框在两种模式之间切换,但你可以想象这真的非常非常烦人。
所以我编写了这个脚本,利用pacmd
在两种模式之间切换:
- 音频质量很差,麦克风打开
- 接近 CD 品质的音频,麦克风关闭
它不够完善,有一些死代码,而且我使用自己的手机 ID,但它可能会给你的脚本带来灵感。最新版本这里。
#!/bin/bash
#### Restart Bluetooth
if [ "$1" == "resetBT" ] ; then
sudo rfkill block bluetooth && sleep 0.1 && sudo rfkill unblock bluetooth;
exit;
fi;
#### Toggle listen/speak
if [ "$1" == "" -o "$1" == "toggle" ] ; then
LINE=`pacmd list-sinks | grep '\(name:\|alias\)' | grep -B1 F5A | head -1`
if [ "$LINE" == "" ] ; then echo "F5A headset not found"; exit; fi
SINK_NAME="bluez_sink.00_19_5D_25_6F_6C.a2dp_sink"
if $(echo "$LINE" | grep $SINK_NAME &> /dev/null) ; then
echo "Detected quality sound output, that means we can't speak; switch that."
$0 speak;
else
echo "Quality sound not found, switch to the good sound."
$0 listen;
fi
fi
#### Change the output to F5A
if [ "$1" == "listen" ] ; then
LINE=`pacmd list-sinks | grep '\(name:\|alias\)' | grep -B1 F5A | head -1`
if [ "$LINE" == "" ] ; then echo "F5A phones not found"; exit; fi
# name: <bluez_sink.00_19_5D_25_6F_6C.headset_head_unit>
## Get what's between <...>
SINK_NAME=`echo "$LINE" | tr '>' '<' | cut -d'<' -f2`;
## The above gives an ID according to the active profile.
## To set manually:
#SINK_NAME="bluez_sink.00_19_5D_25_6F_6C.headset_head_unit"
#SINK_NAME="bluez_sink.00_19_5D_25_6F_6C.a2dp_sink"
## Switch the output to that.
echo "Switching audio output to $SINK_NAME";
pacmd set-default-sink "$SINK_NAME"
#### Change profile to quality output + no mic. From `pacmd list-cards`:
CARD="bluez_card.00_19_5D_25_6F_6C"
PROFILE="a2dp_sink"
echo "Switching audio profile to $PROFILE";
pacmd set-card-profile $CARD $PROFILE
exit;
fi;
#### Input
if [ "$1" == "speak" ] ; then
## Change profile to crappy output + mic. From `pacmd list-cards`:
CARD="bluez_card.00_19_5D_25_6F_6C"
pacmd set-card-profile $CARD headset_head_unit
LINE=`pacmd list-sources | grep '\(name:\|alias\)' | grep -B1 F5A | head -1`
if [ "$LINE" == "" ] ; then echo "F5A mic not found"; exit; fi
SOURCE_NAME=`echo "$LINE" | tr '>' '<' | cut -d'<' -f2`;
#SOURCE_NAME="bluez_source.00_19_5D_25_6F_6C.headset_head_unit"
#SOURCE_NAME="bluez_sink.00_19_5D_25_6F_6C.a2dp_sink.monitor"
echo "Switching audio input to $SOURCE_NAME";
pacmd set-default-source "$SOURCE_NAME" || echo 'Try `pacmd list-sources`.';
fi;
#### Resources:
## Why this is needed
# https://jimshaver.net/2015/03/31/going-a2dp-only-on-linux/
## My original question
# https://askubuntu.com/questions/1004712/audio-profile-changes-automatically-to-hsp-bad-quality-when-i-change-input-to/1009156#1009156
## Script to monitor plugged earphones and switch when unplugged (Ubuntu does that, but nice script):
# https://github.com/freundTech/linux-helper-scripts/blob/master/padevswitch/padevswitch
希望这对某人有帮助:)
答案3
基于本文我担心蓝牙无法让我同时享受到听到优质声音和通过耳机讲话的乐趣。:/
虽然不接受这个答案,但我仍然希望有人能想出某种办法来做到这一点。
答案4
我编写了一个带有切换按钮的简单 GUI,与 Ondra Žižka 的 GUI 一起使用:https://gist.github.com/weslleyspereira/e8feeb9f1b7008ae1ffad2777e39d0dd
它会创建一个窗口,其中有一个按钮,上面写着“打开麦克风”。按下它,它会切换到“关闭麦克风”,现在耳机麦克风打开,音频质量较低。再次按下它,你会回到“打开麦克风”,音频质量较高,但耳机中的麦克风关闭。
#! /usr/bin/python
''' switchHeadphones.py
Tkinter toggle button to switch microphone On/Off using a script
Modification of the solution proposed in
https://www.daniweb.com/posts/jump/1909448
for the Mic On/Off script from
https://gist.github.com/OndraZizka/2724d353f695dacd73a50883dfdf0fc6
'''
# Define the path for the script below, e.g.,
script = "./switchHeadphones.sh"
try:
# Python2
import Tkinter as tk
except ImportError:
# Python3
import tkinter as tk
import os
__author__ = "Weslley S Pereira"
__email__ = "[email protected]"
def toggle(tog=[0]):
'''
a list default argument has a fixed address
'''
tog[0] = not tog[0]
if tog[0]:
os.system(script+' speak')
t_btn.config(text='Switch Mic Off')
else:
os.system(script+' listen')
t_btn.config(text='Switch Mic On')
root = tk.Tk()
root.title('Headphone ')
t_btn = tk.Button(text='Switch Mic On', width=15, command=toggle)
t_btn.pack(pady=5)
root.mainloop()