如何从特定 PC 列出/访问 USB 声卡的所有可用音频输入和输出端口/通道

skr*_*mit 8 sound alsa soundcard python-2.7

在 Windows 7 中,我曾经使用pymedia,一个 python 库,来列出可用的接口以及使用它们来播放和录制音频。典型的查询如下所示:

声音

现在,我不再使用 Windows 7,因为我已迁移到 Ubuntu 16.04。所以,我使用 ALSA 命令来查看可用的音频接口。以下是相同的输出:

skrowten_hermit@PC-760:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: AD1984A Analog [AD1984A Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 2: AD1984A Alt Analog [AD1984A Alt Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Eight [M-Track Eight], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
skrowten_hermit@PC-760:~$ arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: Intel [HDA Intel], device 0: AD1984A Analog [AD1984A Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 2: AD1984A Alt Analog [AD1984A Alt Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Eight [M-Track Eight], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
Run Code Online (Sandbox Code Playgroud)

正如我们所看到的,我的外部声卡 M-Audio 在这里被列为 ALSA 卡,这意味着它被正确检测到。现在,当我阅读 ALSA 相关文章时,我了解了设备,然后使用-L查看可用设备,如下所示:

skrowten_hermit@PC-760:~$ aplay -L
default
    Playback/recording through the PulseAudio sound server
null
    Discard all samples (playback) or generate zero samples (capture)
pulse
    PulseAudio Sound Server
sysdefault:CARD=Intel
    HDA Intel, AD1984A Analog
    Default Audio Device
front:CARD=Intel,DEV=0
    HDA Intel, AD1984A Analog
    Front speakers
surround21:CARD=Intel,DEV=0
    HDA Intel, AD1984A Analog
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=Intel,DEV=0
    HDA Intel, AD1984A Analog
    4.0 Surround output to Front and Rear speakers
surround41:CARD=Intel,DEV=0
    HDA Intel, AD1984A Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Intel,DEV=0
    HDA Intel, AD1984A Analog
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Intel,DEV=0
    HDA Intel, AD1984A Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Intel,DEV=0
    HDA Intel, AD1984A Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
dmix:CARD=Intel,DEV=0
    HDA Intel, AD1984A Analog
    Direct sample mixing device
dmix:CARD=Intel,DEV=2
    HDA Intel, AD1984A Alt Analog
    Direct sample mixing device
dsnoop:CARD=Intel,DEV=0
    HDA Intel, AD1984A Analog
    Direct sample snooping device
dsnoop:CARD=Intel,DEV=2
    HDA Intel, AD1984A Alt Analog
    Direct sample snooping device
hw:CARD=Intel,DEV=0
    HDA Intel, AD1984A Analog
    Direct hardware device without any conversions
hw:CARD=Intel,DEV=2
    HDA Intel, AD1984A Alt Analog
    Direct hardware device without any conversions
plughw:CARD=Intel,DEV=0
    HDA Intel, AD1984A Analog
    Hardware device with all software conversions
plughw:CARD=Intel,DEV=2
    HDA Intel, AD1984A Alt Analog
    Hardware device with all software conversions
sysdefault:CARD=Eight
    M-Track Eight, USB Audio
    Default Audio Device
front:CARD=Eight,DEV=0
    M-Track Eight, USB Audio
    Front speakers
surround21:CARD=Eight,DEV=0
    M-Track Eight, USB Audio
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=Eight,DEV=0
    M-Track Eight, USB Audio
    4.0 Surround output to Front and Rear speakers
surround41:CARD=Eight,DEV=0
    M-Track Eight, USB Audio
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Eight,DEV=0
    M-Track Eight, USB Audio
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Eight,DEV=0
    M-Track Eight, USB Audio
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Eight,DEV=0
    M-Track Eight, USB Audio
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=Eight,DEV=0
    M-Track Eight, USB Audio
    IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=Eight,DEV=0
    M-Track Eight, USB Audio
    Direct sample mixing device
dsnoop:CARD=Eight,DEV=0
    M-Track Eight, USB Audio
    Direct sample snooping device
hw:CARD=Eight,DEV=0
    M-Track Eight, USB Audio
    Direct hardware device without any conversions
plughw:CARD=Eight,DEV=0
    M-Track Eight, USB Audio
    Hardware device with all software conversions
skrowten_hermit@PC-760:~$ arecord -L
default
    Playback/recording through the PulseAudio sound server
null
    Discard all samples (playback) or generate zero samples (capture)
pulse
    PulseAudio Sound Server
sysdefault:CARD=Intel
    HDA Intel, AD1984A Analog
    Default Audio Device
front:CARD=Intel,DEV=0
    HDA Intel, AD1984A Analog
    Front speakers
surround21:CARD=Intel,DEV=0
    HDA Intel, AD1984A Analog
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=Intel,DEV=0
    HDA Intel, AD1984A Analog
    4.0 Surround output to Front and Rear speakers
surround41:CARD=Intel,DEV=0
    HDA Intel, AD1984A Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Intel,DEV=0
    HDA Intel, AD1984A Analog
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Intel,DEV=0
    HDA Intel, AD1984A Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Intel,DEV=0
    HDA Intel, AD1984A Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
dmix:CARD=Intel,DEV=0
    HDA Intel, AD1984A Analog
    Direct sample mixing device
dmix:CARD=Intel,DEV=2
    HDA Intel, AD1984A Alt Analog
    Direct sample mixing device
dsnoop:CARD=Intel,DEV=0
    HDA Intel, AD1984A Analog
    Direct sample snooping device
dsnoop:CARD=Intel,DEV=2
    HDA Intel, AD1984A Alt Analog
    Direct sample snooping device
hw:CARD=Intel,DEV=0
    HDA Intel, AD1984A Analog
    Direct hardware device without any conversions
hw:CARD=Intel,DEV=2
    HDA Intel, AD1984A Alt Analog
    Direct hardware device without any conversions
plughw:CARD=Intel,DEV=0
    HDA Intel, AD1984A Analog
    Hardware device with all software conversions
plughw:CARD=Intel,DEV=2
    HDA Intel, AD1984A Alt Analog
    Hardware device with all software conversions
sysdefault:CARD=Eight
    M-Track Eight, USB Audio
    Default Audio Device
front:CARD=Eight,DEV=0
    M-Track Eight, USB Audio
    Front speakers
surround21:CARD=Eight,DEV=0
    M-Track Eight, USB Audio
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=Eight,DEV=0
    M-Track Eight, USB Audio
    4.0 Surround output to Front and Rear speakers
surround41:CARD=Eight,DEV=0
    M-Track Eight, USB Audio
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Eight,DEV=0
    M-Track Eight, USB Audio
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Eight,DEV=0
    M-Track Eight, USB Audio
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Eight,DEV=0
    M-Track Eight, USB Audio
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=Eight,DEV=0
    M-Track Eight, USB Audio
    IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=Eight,DEV=0
    M-Track Eight, USB Audio
    Direct sample mixing device
dsnoop:CARD=Eight,DEV=0
    M-Track Eight, USB Audio
    Direct sample snooping device
hw:CARD=Eight,DEV=0
    M-Track Eight, USB Audio
    Direct hardware device without any conversions
plughw:CARD=Eight,DEV=0
    M-Track Eight, USB Audio
    Hardware device with all software conversions
Run Code Online (Sandbox Code Playgroud)

以上是从我所期待的有点不同(我希望得到的通道标识符,而是最终得到的参数,如sysdefaultsurround21dsnoop硬件等)。我的声卡有八个 I/O 对。所以,我期待通道/端口标识符或类似的东西。

在对网络进行了更多挖掘之后,我偶然发现了pyAudiosounddevice python 库。前者给出了以下输出:

skrowten_hermit@PC-760:~$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyaudio
>>> p = pyaudio.PyAudio()
ALSA lib pcm_dmix.c:1029:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_dmix.c:1029:(snd_pcm_dmix_open) unable to open slave
Cannot open PortAudio client
JackShmReadWritePtr1::~JackShmReadWritePtr1 - Init not done for 4294967295, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for 4294967295, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for 4294967295, skipping unlock
>>> for i in range(p.get_device_count()):
...     print p.get_device_info_by_index(i).get('name')
...
HDA Intel: AD1984A Analog (hw:0,0)
HDA Intel: AD1984A Alt Analog (hw:0,2)
M-Track Eight: USB Audio (hw:1,0)
sysdefault
pulse
default
>>> import pyaudio
>>> p = pyaudio.PyAudio()
>>> for i in range(p.get_device_count()):
...     print p.get_device_info_by_index(i)
...
{'defaultSampleRate': 44100.0, 'defaultLowOutputLatency': 0.008707482993197279, 'defaultLowInputLatency': 0.008707482993197279, 'maxInputChannels': 2L, 'structVersion': 2L, 'hostApi': 0L, 'index': 0, 'defaultHighOutputLatency': 0.034829931972789115, 'maxOutputChannels': 2L, 'name': u'HDA Intel: AD1984A Analog (hw:0,0)', 'defaultHighInputLatency': 0.034829931972789115}
{'defaultSampleRate': 44100.0, 'defaultLowOutputLatency': -1.0, 'defaultLowInputLatency': 0.008707482993197279, 'maxInputChannels': 2L, 'structVersion': 2L, 'hostApi': 0L, 'index': 1, 'defaultHighOutputLatency': -1.0, 'maxOutputChannels': 0L, 'name': u'HDA Intel: AD1984A Alt Analog (hw:0,2)', 'defaultHighInputLatency': 0.034829931972789115}
{'defaultSampleRate': 44100.0, 'defaultLowOutputLatency': 0.008707482993197279, 'defaultLowInputLatency': 0.008707482993197279, 'maxInputChannels': 8L, 'structVersion': 2L, 'hostApi': 0L, 'index': 2, 'defaultHighOutputLatency': 0.034829931972789115, 'maxOutputChannels': 8L, 'name': u'M-Track Eight: USB Audio (hw:1,0)', 'defaultHighInputLatency': 0.034829931972789115}
{'defaultSampleRate': 48000.0, 'defaultLowOutputLatency': 0.021333333333333333, 'defaultLowInputLatency': 0.021333333333333333, 'maxInputChannels': 128L, 'structVersion': 2L, 'hostApi': 0L, 'index': 3, 'defaultHighOutputLatency': 0.021333333333333333, 'maxOutputChannels': 128L, 'name': u'sysdefault', 'defaultHighInputLatency': 0.021333333333333333}
{'defaultSampleRate': 44100.0, 'defaultLowOutputLatency': 0.008707482993197279, 'defaultLowInputLatency': -1.0, 'maxInputChannels': 0L, 'structVersion': 2L, 'hostApi': 0L, 'index': 4, 'defaultHighOutputLatency': 0.034829931972789115, 'maxOutputChannels': 2L, 'name': u'front', 'defaultHighInputLatency': -1.0}
{'defaultSampleRate': 44100.0, 'defaultLowOutputLatency': 0.008707482993197279, 'defaultLowInputLatency': -1.0, 'maxInputChannels': 0L, 'structVersion': 2L, 'hostApi': 0L, 'index': 5, 'defaultHighOutputLatency': 0.034829931972789115, 'maxOutputChannels': 2L, 'name': u'surround40', 'defaultHighInputLatency': -1.0}
{'defaultSampleRate': 44100.0, 'defaultLowOutputLatency': 0.008707482993197279, 'defaultLowInputLatency': -1.0, 'maxInputChannels': 0L, 'structVersion': 2L, 'hostApi': 0L, 'index': 6, 'defaultHighOutputLatency': 0.034829931972789115, 'maxOutputChannels': 2L, 'name': u'surround51', 'defaultHighInputLatency': -1.0}
{'defaultSampleRate': 44100.0, 'defaultLowOutputLatency': 0.008707482993197279, 'defaultLowInputLatency': -1.0, 'maxInputChannels': 0L, 'structVersion': 2L, 'hostApi': 0L, 'index': 7, 'defaultHighOutputLatency': 0.034829931972789115, 'maxOutputChannels': 2L, 'name': u'surround71', 'defaultHighInputLatency': -1.0}
{'defaultSampleRate': 44100.0, 'defaultLowOutputLatency': 0.008707482993197279, 'defaultLowInputLatency': 0.008707482993197279, 'maxInputChannels': 32L, 'structVersion': 2L, 'hostApi': 0L, 'index': 8, 'defaultHighOutputLatency': 0.034829931972789115, 'maxOutputChannels': 32L, 'name': u'pulse', 'defaultHighInputLatency': 0.034829931972789115}
{'defaultSampleRate': 48000.0, 'defaultLowOutputLatency': 0.021333333333333333, 'defaultLowInputLatency': -1.0, 'maxInputChannels': 0L, 'structVersion': 2L, 'hostApi': 0L, 'index': 9, 'defaultHighOutputLatency': 0.021333333333333333, 'maxOutputChannels': 2L, 'name': u'dmix', 'defaultHighInputLatency': -1.0}
{'defaultSampleRate': 44100.0, 'defaultLowOutputLatency': 0.008707482993197279, 'defaultLowInputLatency': 0.008707482993197279, 'maxInputChannels': 32L, 'structVersion': 2L, 'hostApi': 0L, 'index': 10, 'defaultHighOutputLatency': 0.034829931972789115, 'maxOutputChannels': 32L, 'name': u'default', 'defaultHighInputLatency': 0.034829931972789115}
Run Code Online (Sandbox Code Playgroud)

以上也不够令人满意。仔细查看设备列表的枚举输出发现,与'name'对应的那个:u'M-Track 8:USB Audio (hw:1,0)'确实表明输入和输出通道的数量是8,但列为单个设备。然后,接下来, sounddevice 给了我以下输出:

skrowten_hermit@PC-760:~$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sounddevice as sd
>>> sd.query_devices()
   0 HDA Intel: AD1984A Analog (hw:0,0), ALSA (2 in, 2 out)
   1 HDA Intel: AD1984A Alt Analog (hw:0,2), ALSA (2 in, 0 out)
   2 M-Track Eight: USB Audio (hw:1,0), ALSA (8 in, 8 out)
   3 sysdefault, ALSA (128 in, 128 out)
   4 front, ALSA (0 in, 2 out)
   5 surround40, ALSA (0 in, 2 out)
   6 surround51, ALSA (0 in, 2 out)
   7 surround71, ALSA (0 in, 2 out)
   8 pulse, ALSA (32 in, 32 out)
   9 dmix, ALSA (0 in, 2 out)
* 10 default, ALSA (32 in, 32 out)
Run Code Online (Sandbox Code Playgroud)

在这里,设备 2 也显示 8 进,8 出。

我不明白的是:

  1. pyaudiosounddevice可以看到我的声卡有 8 对 I/O 通道时,他们为什么不将它们列为单独的设备?
  2. 并且 ALSA 甚至根本没有看到(这是使用 ALSA 命令aplayarecord的基本要求)?
  3. 或者即使我理解设备对应于物理模拟通道/端口,我将连接设备的位置是正确的?
  4. 这是驱动程序的限制吗?

简而言之,我的要求:

  1. 我应该能够将音频播放到我的M-Audio M-Track 8声卡的(任何)输入端口,并记录以及从我的M-Audio M 的(任何)输出端口播放音频-Track 8声卡和播放。 M-Audio M-Track 八说明
  2. 如上所述,我应该能够使用 ALSA 命令进行播放和录制。
  3. 我应该能够在不同的线程中播放和录制。

我怎样才能做到这一点?我可以更清楚地了解 ALSA 及其在此处的作用吗?有什么可用的驱动程序可以满足我的要求?


更新:

我根据~/.asoundrc收到的输入创建了以下内容:

pcm.!default {
    type plug
    slave {
       pcm "hw:1,0"
    }
}

ctl.!default {
    type hw
    card 1
}

pcm_slave.eightchannels {
    pcm "hw:1,0"
    channels 8
    rate 44100
    buffer_size 4096
    period_size 2048
}

pcm.ch12 {
    type asym
    playback.pcm {
        type dshare
        ipc_key 1111
        slave eightchannels
        bindings [ 0 1 ]
    }
    capture.pcm {
        type dsnoop
        ipc_key 1111
        slave eightchannels
        bindings [ 0 1 ]
    }
    hint.description "M-Audio channels 1,2"
}
pcm.ch34 {
    type asym
    playback.pcm {
        type dshare
        ipc_key 2222
        slave eightchannels
        bindings [ 2 3 ]
    }
    capture.pcm {
        type dsnoop
        ipc_key 2222
        slave eightchannels
        bindings [ 2 3 ]
    }
    hint.description "M-Audio channels 3,4"
}
Run Code Online (Sandbox Code Playgroud)

因此,使用上述配置,当我尝试运行时aplay,我收到以下内容:

skrowten_hermit@PC-760:~$ aplay -D ch12 -c 1 -r 8000 male_8k.wav
Playing WAVE 'male_8k.wav' : Signed 16 bit Little Endian, Rate 8000 Hz, Mono
aplay: set_params:1233: Sample format non available
Available formats:
- S32_LE
Run Code Online (Sandbox Code Playgroud)

假设它与所示格式不匹配,我尝试将格式作为参数传递aplay如下:

skrowten_hermit@PC-760:~$ aplay -D ch12 -c 1 -r 8000 -f S32_LE male_8k.wav
Warning: format is changed to S16_LE
Playing WAVE 'male_8k.wav' : Signed 16 bit Little Endian, Rate 8000 Hz, Mono
aplay: set_params:1233: Sample format non available
Available formats:
- S32_LE
Run Code Online (Sandbox Code Playgroud)

此错误是否与 PCM 设备或.wav正在播放的文件有关?

PS:.!defaults是后来添加的。删除它们没有区别!

skr*_*mit 1

经过大量尝试并尝试插件后,我找到了上述问题的解决方案。这只不过是上述答案和我从这里得到的提示的延伸。首先,以下是.asoundrc我用来让它工作的:

pcm.!default {
    type plug
    slave {
       pcm "hw:1,0"
    }
}

ctl.!default {
    type hw
    card 1
}

pcm_slave.m-audio_m-track_eight_1 {
    pcm "hw:1,0"
    channels 8
    rate 44100
    buffer_size 4096
    period_size 1024
}

pcm.outch1 {
    type dshare
    ipc_key 1111
    slave m-audio_m-track_eight_1
    bindings [ 0 ]
    hint.description "M-Audio M-Track Eight output/playback channel 1"
}

pcm.inch1 {
    type dsnoop
    ipc_key 1111
    slave m-audio_m-track_eight_1
    bindings [ 0 ]
    hint.description "M-Audio M-Track Eight input/capture channel 1"
}

pcm.outch2 {
    type dshare
    ipc_key 1111
    slave m-audio_m-track_eight_1
    bindings [ 1 ]
    hint.description "M-Audio M-Track Eight output/playback channel 2"
}

pcm.inch2 {
    type dsnoop
    ipc_key 1111
    slave m-audio_m-track_eight_1
    bindings [ 1 ]
    hint.description "M-Audio M-Track Eight input/capture channel 2"
}

pcm.outch3 {
    type dshare
    ipc_key 1111
    slave m-audio_m-track_eight_1
    bindings [ 2 ]
    hint.description "M-Audio M-Track Eight output/playback channel 3"
}

pcm.inch3 {
    type dsnoop
    ipc_key 1111
    slave m-audio_m-track_eight_1
    bindings [ 2 ]
    hint.description "M-Audio M-Track Eight input/capture channel 3"
}

pcm.outch4 {
    type dshare
    ipc_key 1111
    slave m-audio_m-track_eight_1
    bindings [ 3 ]
    hint.description "M-Audio M-Track Eight output/playback channel 4"
}

pcm.inch4 {
    type dsnoop
    ipc_key 1111
    slave m-audio_m-track_eight_1
    bindings [ 3 ]
    hint.description "M-Audio M-Track Eight input/capture channel 4"
}

pcm.outch5 {
    type dshare
    ipc_key 1111
    slave m-audio_m-track_eight_1
    bindings [ 4 ]
    hint.description "M-Audio M-Track Eight output/playback channel 5"
}

pcm.inch5 {
    type dsnoop
    ipc_key 1111
    slave m-audio_m-track_eight_1
    bindings [ 4 ]
    hint.description "M-Audio M-Track Eight input/capture channel 5"
}

pcm.outch6 {
    type dshare
    ipc_key 1111
    slave m-audio_m-track_eight_1
    bindings [ 5 ]
    hint.description "M-Audio M-Track Eight output/playback channel 6"
}

pcm.inch6 {
    type dsnoop
    ipc_key 1111
    slave m-audio_m-track_eight_1
    bindings [ 5 ]
    hint.description "M-Audio M-Track Eight input/capture channel 6"
}

pcm.outch7 {
    type dshare
    ipc_key 1111
    slave m-audio_m-track_eight_1
    bindings [ 6 ]
    hint.description "M-Audio M-Track Eight output/playback channel 7"
}

pcm.inch7 {
    type dsnoop
    ipc_key 1111
    slave m-audio_m-track_eight_1
    bindings [ 6 ]
    hint.description "M-Audio M-Track Eight input/capture channel 7"
}

pcm.outch8 {
    type dshare
    ipc_key 1111
    slave m-audio_m-track_eight_1
    bindings [ 7 ]
    hint.description "M-Audio M-Track Eight output/playback channel 8"
}

pcm.inch8 {
    type dsnoop
    ipc_key 1111
    slave m-audio_m-track_eight_1
    bindings [ 7 ]
    hint.description "M-Audio M-Track Eight input/capture channel 8"
}
Run Code Online (Sandbox Code Playgroud)

我试图让整个事情变得简单。ALSA 命令aplayarecord分别是命令行声音播放器和录音机,然后允许我执行所需的操作,即播放语音文件以及在一个通道(连接到模拟输出端口)播放语音文件并用另一个单声道(连接到模拟输入端口)进行录制。

为了测试配置文件,我使用了以下aplay命令:

skrowten_hermit@PC-760:~$ aplay -D plug:outch1 -c 1 -r 8000 male_8k.wav
Run Code Online (Sandbox Code Playgroud)

通过上述操作,播放效果就很好了。现在,为了开始正题,并查看播放和捕获是否都正常工作,使用了以下内容:

skrowten_hermit@PC-760:~$ aplay -D plug:outch1 -c 1 -r 8000 /home/sreekanth/Downloads/male_8k.wav | arecord -D plug:inch2 -c 1 -r 8000 -d 10 /home/sreekanth/Downloads/out_12.wav
Run Code Online (Sandbox Code Playgroud)

上面使用通道 1(连接到我的 M-Audio M-Track 八声卡上的模拟输出端口 1)来播放设备,使用通道 2(连接到我的 M-Audio M-Track 八声卡上的模拟输入端口 2)作为录音设备。要使用其他设备,outch1可以替换为outch2outch3outch4outch5outch6outch7outch8中的任意一个,inch2 可以替换为inch1 inch3inch4inch5inch6inch7inch8任意一个(根据定义)在.asoundrc)。

为 ALSA 找到正确且有据可查的文献有点困难。但是,根据我的经验,bindings您需要修改这个参数,以便将音频从模拟端口(可能是客户端通道)路由到 ALSA 通道(如上面定义的从属通道.asoundrc)。

  • 这就是为什么我在 2020 年完全放弃了。真是一团糟。 (2认同)