AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 794542
Accepted
Ryan Budney
Ryan Budney
Asked: 2016-07-04 20:43:45 +0800 CST2016-07-04 20:43:45 +0800 CST 2016-07-04 20:43:45 +0800 CST

mpd -> jackd -> usbaudio 输出

  • 772

我正在尝试使用 mpd 从我的 Android 手机控制我的立体声音响。我有一个通过 USB -> Toslink -> DSP -> amps 路由连接到立体声系统的 Ubuntu 16.04 盒子。我正在尝试通过 mpd 守护进程来驱动 jackd。. . 我遇到了一些麻烦。

到目前为止,我已经能够:

1) 让 mpd 在我的 Ubuntu 机器上本地播放音乐。MPDroid(在我的手机上)在这个级别上与 mpd 配合得很好,在我的 Ubuntu 盒子上驱动音乐。

2) 使用 jack-plumbing 和 mplayer 通过 Ubuntu 盒子中的插孔驱动我的立体声系统。

我强烈怀疑我的问题是我不明白 mpd.conf 需要什么来驱动千斤顶。

这是我当前的 mpd.conf audio_output 部分:

audio_output {
    type      "jack"
    name      "my JACK device"
    device    "hw:1,0"
    autostart "yes"
    destination_ports "playback_9, playback_10"
}

我选择了destination_ports 9 和10,因为这会产生一个Toslink 信号。但我强烈怀疑这是我的格式不正确。

以及在本地播放的版本:

audio_output {
    type            "alsa"
    name            "My ALSA Device"
    device          "hw:0,0"        # optional
    mixer_type      "hardware"      # optional
    mixer_device    "default"       # optional
    mixer_control   "PCM"           # optional
    mixer_index     "0"             # optional
}

以下是一些可能会有所帮助的事情。jack-plumbing 可以很好地将 mplayer 输出连接到我的 USB 音频设备。有效的 .jack-plumbing 文件是:

(connect "MPlayer \[[0-9]+\]:out_0" "system:playback_9")
(connect "MPlayer \[[0-9]+\]:out_1" "system:playback_10")

aplay -l 输出:

**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC269VC Analog [ALC269VC Analog]  
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: USBStreamer [USBStreamer], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

我发现在线 mpd 可用的文档有点难以阅读,而且在将它与 jackd 一起使用时往往会变得有点模糊。有什么建议吗?我想我犯了一个非常简单的错误。谢谢你的帮助。

编辑:使用 /etc/mpd.conf 中 mpd.conf 的“jack”版本,我将其作为“sudo systemctl status mpd”命令的输出:

● mpd.service - Music Player Daemon
   Loaded: loaded (/lib/systemd/system/mpd.service; disabled; vendor preset: enabled)
   Active: active (running) since Sun 2016-07-03 23:58:34 PDT; 52s ago
 Main PID: 3651 (mpd)
   CGroup: /system.slice/mpd.service
       └─3651 /usr/bin/mpd --no-daemon

Jul 03 23:58:34 rybu-ThinkPad-W530 systemd[1]: Started Music Player Daemon.
Jul 03 23:58:38 rybu-ThinkPad-W530 pulseaudio[3665]: [pulseaudio] module-jackdbus-detect.c: Unable to contact D-Bus session bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Jul 03 23:58:38 rybu-ThinkPad-W530 pulseaudio[3665]: [pulseaudio] module.c: Failed to load module "module-jackdbus-detect" (argument: "channels=2"): initialization failed.
Jul 03 23:58:38 rybu-ThinkPad-W530 pulseaudio[3665]: [pulseaudio] main.c: Module load failed.
Jul 03 23:58:38 rybu-ThinkPad-W530 pulseaudio[3665]: [pulseaudio] server-lookup.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Jul 03 23:58:38 rybu-ThinkPad-W530 pulseaudio[3665]: [pulseaudio] main.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Jul 03 23:58:38 rybu-ThinkPad-W530 pulseaudio[3665]: [pulseaudio] bluez5-util.c: GetManagedObjects() failed: org.freedesktop.DBus.Error.AccessDenied: Rejected send message, 2 matched rules; type="method_call", sender=":1.177" (uid=122 pid=3665 comm="/usr/bin/pulseaudio --start --log-target=syslog ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=1018 comm="/usr/lib/bluetooth/bluetoothd ")

我想我应该提到另一件事。安装 mpd 后,我的系统启动时间明显变慢了。有时它看起来像计算机什么都不做,所以我再次重新启动系统。有时需要 3 次重新启动才能进入登录提示。

编辑2:也许我可以通过完全避免杰克来解决这个问题。这是 /var/lib/alsa/asound.state 文件,与我的 usbaudio 设备相关的部分:

state.USBStreamer {
control.1 {
    iface PCM
    name 'Playback Channel Map'
    value.0 0
    value.1 0
    value.2 0
    value.3 0
    value.4 0
    value.5 0
    value.6 0
    value.7 0
    value.8 0
    value.9 0
    comment {
        access read
        type INTEGER
        count 10
        range '0 - 36'
    }
}
control.2 {
    iface PCM
    name 'Capture Channel Map'
    value.0 0
    value.1 0
    value.2 0
    value.3 0
    value.4 0
    value.5 0
    value.6 0
    value.7 0
    value.8 0
    value.9 0
    comment {
        access read
        type INTEGER
        count 10
        range '0 - 36'
    }
}
control.3 {
    iface MIXER
    name 'USBStreamer Output Playback Switch'
    value.0 true
    value.1 true
    value.2 true
    value.3 true
    value.4 true
    value.5 true
    value.6 true
    value.7 true
    value.8 true
    value.9 true
    comment {
        access 'read write'
        type BOOLEAN
        count 10
    }
}
control.4 {
    iface MIXER
    name 'USBStreamer Output Playback Switch'
    index 1
    value true
    comment {
        access 'read write'
        type BOOLEAN
        count 1
    }
}
control.5 {
    iface MIXER
    name 'USBStreamer Output Playback Volume'
    value.0 255
    value.1 255
    value.2 255
    value.3 255
    value.4 255
    value.5 255
    value.6 255
    value.7 255
    value.8 255
    value.9 255
    comment {
        access 'read write'
        type INTEGER
        count 10
        range '0 - 255'
        dbmin -12750
        dbmax 0
        dbvalue.0 0
        dbvalue.1 0
        dbvalue.2 0
        dbvalue.3 0
        dbvalue.4 0
        dbvalue.5 0
        dbvalue.6 0
        dbvalue.7 0
        dbvalue.8 0
        dbvalue.9 0
    }
}
control.6 {
    iface MIXER
    name 'USBStreamer Output Playback Volume'
    index 1
    value 152
    comment {
        access 'read write'
        type INTEGER
        count 1
        range '0 - 255'
        dbmin -12750
        dbmax 0
        dbvalue.0 -5150
    }
}
control.7 {
    iface MIXER
    name 'USBStreamer Clock Selector'
    value 'USBStreamer Internal Clock'
    comment {
        access 'read write'
        type ENUMERATED
        count 1
        item.0 'USBStreamer Internal Clock'
        item.1 'USBStreamer TOSLINK Clock'
    }
}
control.8 {
    iface MIXER
    name 'Mic Capture Switch'
    value.0 true
    value.1 true
    value.2 true
    value.3 true
    value.4 true
    value.5 true
    value.6 true
    value.7 true
    value.8 true
    value.9 true
    comment {
        access 'read write'
        type BOOLEAN
        count 10
    }
}
control.9 {
    iface MIXER
    name 'Mic Capture Switch'
    index 1
    value true
    comment {
        access 'read write'
        type BOOLEAN
        count 1
    }
}
control.10 {
    iface MIXER
    name 'Mic Capture Volume'
    value.0 255
    value.1 255
    value.2 255
    value.3 255
    value.4 255
    value.5 255
    value.6 255
    value.7 255
    value.8 255
    value.9 255
    comment {
        access 'read write'
        type INTEGER
        count 10
        range '0 - 255'
        dbmin -12750
        dbmax 0
        dbvalue.0 0
        dbvalue.1 0
        dbvalue.2 0
        dbvalue.3 0
        dbvalue.4 0
        dbvalue.5 0
        dbvalue.6 0
        dbvalue.7 0
        dbvalue.8 0
        dbvalue.9 0
    }
}
control.11 {
    iface MIXER
    name 'Mic Capture Volume'
    index 1
    value 255
    comment {
        access 'read write'
        type INTEGER
        count 1
        range '0 - 255'
        dbmin -12750
        dbmax 0
        dbvalue.0 0
    }
}

如果我没看错的话,看起来相关的音频输出通道可能被静音了?通道 8 和 9 是通过 Toslink 电缆与音频输出相关的通道,所以我怀疑我需要修改这些值,也许我可以从 mpd 直接输出 ALSA。

奇怪的是,如果我删除 asound.state,然后使用“sudo alsactl store”命令重新创建它,则通道映射完全不同:

state.USBStreamer {
    control.1 {
            iface PCM
            name 'Playback Channel Map'
            value.0 3
            value.1 4
            value.2 7
            value.3 8
            value.4 5
            value.5 6
            value.6 12
            value.7 13
            value.8 11
            value.9 9
            comment {
                    access read
                    type INTEGER
                    count 10 
                    range '0 - 36'
            }
    }

但它仍然不发出声音。

我正在考虑的另一件事是,由于 JACK可以播放到我的 usbstreamer,并且它正在使用 ALSA,所以也许我可以弄清楚它与 ALSA 一起使用的设置,然后复制它们。/proc/asound/card1 目录有这张卡的当前设置,所以我开始用 jack 和 mplayer 播放它,然后读取文件。

流0:

miniDSP USBStreamer at usb-0000:00:14.0-2, high speed : USB Audio

Playback:
  Status: Running
    Interface = 1
    Altset = 1
    Packet Size = 280
    Momentary freq = 44100 Hz (0x5.8330)
    Feedback Format = 16.16
  Interface 1
    Altset 1
    Format: S32_LE
    Channels: 10
    Endpoint: 1 OUT (ASYNC)
    Rates: 44100, 48000, 88200, 96000, 176400, 192000
    Data packet interval: 125 us

Capture:
  Status: Running
    Interface = 2
    Altset = 1
    Packet Size = 280
    Momentary freq = 44100 Hz (0x5.8333)
  Interface 2
    Altset 1
    Format: S32_LE
    Channels: 10
    Endpoint: 2 IN (ASYNC)
    Rates: 44100, 48000, 88200, 96000, 176400, 192000
    Data packet interval: 125 us

USB总线:

003/005

USB混音器:

USB Mixer: usb_id=0x27520016, ctrlif=0, ctlerr=0
 Card: miniDSP USBStreamer at usb-0000:00:14.0-2, high speed
  Unit: 10
Control: name="USBStreamer Output Playback Volume", index=1
Info: id=10, control=2, cmask=0x0, channels=1, type="S16"
Volume: min=-32640, max=0, dBmin=-12750, dBmax=0
Unit: 10
Control: name="USBStreamer Output Playback Volume", index=0
Info: id=10, control=2, cmask=0x3ff, channels=10, type="S16"
Volume: min=-32640, max=0, dBmin=-12750, dBmax=0
Unit: 10
Control: name="USBStreamer Output Playback Switch", index=1
Info: id=10, control=1, cmask=0x0, channels=1, type="INV_BOOLEAN"
Volume: min=0, max=1, dBmin=0, dBmax=0
Unit: 10
Control: name="USBStreamer Output Playback Switch", index=0
Info: id=10, control=1, cmask=0x3ff, channels=10, type="INV_BOOLEAN"
Volume: min=0, max=1, dBmin=0, dBmax=0
Unit: 11
Control: name="Mic Capture Volume", index=1
Info: id=11, control=2, cmask=0x0, channels=1, type="S16"
Volume: min=-32640, max=0, dBmin=-12750, dBmax=0
Unit: 11
Control: name="Mic Capture Volume", index=0
Info: id=11, control=2, cmask=0x3ff, channels=10, type="S16"
Volume: min=-32640, max=0, dBmin=-12750, dBmax=0
Unit: 11
Control: name="Mic Capture Switch", index=1
Info: id=11, control=1, cmask=0x0, channels=1, type="INV_BOOLEAN"
Volume: min=0, max=1, dBmin=0, dBmax=0
Unit: 11
Control: name="Mic Capture Switch", index=0
Info: id=11, control=1, cmask=0x3ff, channels=10, type="INV_BOOLEAN"
Volume: min=0, max=1, dBmin=0, dBmax=0
Unit: 40
Control: name="USBStreamer Clock Selector", index=0
Info: id=40, control=1, cmask=0x0, channels=1, type="U8"
Volume: min=1, max=2, dBmin=0, dBmax=0

pcm0p/信息:

card: 1
device: 0
subdevice: 0
stream: PLAYBACK
id: USB Audio
name: USB Audio
subname: subdevice #0
class: 0
subclass: 0
subdevices_count: 1
subdevices_avail: 0

pcm0p/sub0/hw_params:

access: MMAP_INTERLEAVED
format: S32_LE
subformat: STD
channels: 10
rate: 44100 (44100/1)
period_size: 1024
buffer_size: 2048

pcm0p/sub0/信息

card: 1
device: 0
subdevice: 0
stream: PLAYBACK
id: USB Audio
name: USB Audio
subname: subdevice #0
class: 0
subclass: 0
subdevices_count: 1
subdevices_avail: 0

pcm0p/sub0/状态

state: RUNNING
owner_pid   : 12545
trigger_time: 50245.966761737
tstamp      : 0.000000000
delay       : 2010
avail       : 72
avail_max   : 1029
----- 
hw_ptr      : 325870664
appl_ptr    : 325872640

pcm0p/sub0/sw_params:

tstamp_mode: NONE
period_step: 1
avail_min: 1024
start_threshold: 0
stop_threshold: 2048
silence_threshold: 0
silence_size: 0
boundary: 4611686018427387904

嗯,如果频道的信息在里面,那就巧妙地隐藏了!

Volker Schatz 描述了设置 ALSA 设备以切换频道。看起来它的完成方式与仅使用播放通道图不同:

http://www.volkerschatz.com/noise/alsa.html

ttable 似乎是用于通道混合的设备,如果您使用整数条目(0 和 1),则用于通道切换。最后,这开始有意义了。ij 符号是对坐标,描述方阵的条目。

编辑:一些进展。“aplay -L”命令给出设备名称列表。对于这个 usbstreamer,它提供:

sysdefault:CARD=USBStreamer
USBStreamer, USB Audio
Default Audio Device
front:CARD=USBStreamer,DEV=0
USBStreamer, USB Audio
Front speakers
surround21:CARD=USBStreamer,DEV=0
USBStreamer, USB Audio
2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=USBStreamer,DEV=0
USBStreamer, USB Audio
4.0 Surround output to Front and Rear speakers
surround41:CARD=USBStreamer,DEV=0
USBStreamer, USB Audio
4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=USBStreamer,DEV=0
USBStreamer, USB Audio
5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=USBStreamer,DEV=0
USBStreamer, USB Audio
5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=USBStreamer,DEV=0
USBStreamer, USB Audio
7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=USBStreamer,DEV=0
USBStreamer, USB Audio
IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=USBStreamer,DEV=0
USBStreamer, USB Audio
Direct sample mixing device
dsnoop:CARD=USBStreamer,DEV=0
USBStreamer, USB Audio
Direct sample snooping device
hw:CARD=USBStreamer,DEV=0
USBStreamer, USB Audio
Direct hardware device without any conversions
plughw:CARD=USBStreamer,DEV=0
USBStreamer, USB Audio
Hardware device with all software conversions

这些设备名称非常方便,您可以从这里运行命令:

speaker-test -c 10 -t sin -F S32_LE -D front:USBStreamer

它贯穿该设备上的所有扬声器。通道 8 和 9(如预期)分别在左右扬声器上产生正弦波声音。

所以我认为这意味着我应该能够使用 asound.state 中的 ttable 结构将 ALSA 直接输出到我的扬声器。我想 Playback Channel Map 也可能允许这样做,但是经过相当多的摆弄之后,我不清楚如何使它工作。

更新:

我将 asound.state 文件的 control.1 部分修改为:

control.1 {
            iface PCM
            name 'Playback Channel Map'
            value.0 0
            value.1 0
            value.2 0
            value.3 0
            value.4 0
            value.5 0
            value.6 0
            value.7 0
            value.8 3
            value.9 4
            comment {
                    access read
                    type INTEGER
                    count 10 
                    range '0 - 36'
            }
    }

它几乎可以工作。Mplayer 不会播放到 alsa:device=hw=1.0 但错误消息是我向设备发送了错误的格式。ALSA认为该设备只接受 S32LE。从技术上讲,我认为它是 S24LE 设备。我会联系制造商来解决这个问题。

所以我在 mplayer 命令行中添加了 -format s32le ,然后扬声器就出来了!只是,有点乱。它播放得太快了,而且。. . 其他事情正在发生。有某种频率失真。我怀疑正在发生的事情是它正在发送 s16le 数据,就好像它是 s32le 数据一样,所以有一点数据的洗牌(时间上)和音高变化,而且播放速度太快。

所以现在要让它工作,我需要知道如何将 s16le 数据转换为正确的 s24le,然后将其格式化为 s32le,这样 USB 设备就可以使用了。

更新:

speaker-test -c 10 -t sin -D plughw:USBStreamer

工作正常,并将 S16_LE 转换为 S32_LE。

很遗憾,

aplay -Dplughw:USBStreamer ./blah.wav

不起作用。_ 也许此设备的通道映射已关闭?

Deadbeef软件可以轻松播放到 usbstreamer。我给它 hw:USBStreamer 设备,并告诉它进行所有 8->16->24 位转换,它就像一个魅力。

alsa
  • 1 1 个回答
  • 1332 Views

1 个回答

  • Voted
  1. Best Answer
    Ryan Budney
    2016-07-11T00:34:48+08:002016-07-11T00:34:48+08:00

    问题解决了。

    pcm.usbSTR { type hw card USBStreamer device 0 } pcm.usbREMAP { type plug slave.pcm usbSTR ttable.0.8 1 ttable.1.9 1 } pcm.!default { type plug slave.pcm usbREMAP } ctl.!default { type plug slave.pcm usbREMAP }

    把上面的内容做成/etc/asound.conf

    该文件(通常)在 Ubuntu 或 LUbuntu 中不存在,但如果您创建它,usbstreamer 将成为默认的 ALSA 设备,并且通道会被适当地映射。

    这允许您将 /etc/mpd.conf 的 audio_output 部分分别设为“type”和“name”字段,“alsa”和“whatever you want”。

    • 0

相关问题

  • 如何监控已经运行的程序的输出?

  • 如何更改 Ubuntu 调整音量混合器级别的方式?

  • 使麦克风静音和取消静音的命令

  • 如何使 Skype 的默认声音输入持久化?

  • 开机后音量总是最大

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve