alsa 声音模块 snd_aloop

alsa 声音模块 snd_aloop

我在理解 snd_aloop 模块时遇到了一些麻烦。

我正在尝试通过 alsa 路由所有音频而不使用pulseaudio。如果我启动 jackd,非 alsa 应用程序不会发出声音,但像 Rhythmbox 或任何其他本机 Jack 支持的软件都可以正常工作。

主要原因是我主要做音频编辑,但我也在线听视频。

我读到我可以使用 alsasnd_aloop 模块设置虚拟硬件,我可以通过 alsa_in 和 alsa_out 机制路由我的非插孔应用程序音频,以便与插孔一起正常播放。

我读过很多教程,比如这个,这个查阅了很多文档这里这里以及。

最令我困惑的部分是环回设置以及 alsa_in 和 alsa_out 的工作方式。

例如,对于 snd_aloop 模块,有 2 个设备和 8 个子设备

我的aplay-l样子是这样的

**** List of PLAYBACK Hardware Devices ****
card 0: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 0: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 1: PCH [HDA Intel PCH], device 0: CS4208 Analog [CS4208 Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 1: CS4208 Digital [CS4208 Digital]
  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

如果我尝试像这样设置我的系统:

#jack capture and playback
pcm.jack_capture_1 {
    type plug
        slave.pcm "hw:Loopback,0,0"
}

pcm.jack_playback_1 {
    type plug
        slave.pcm "hw:Loopback,0,1"
}

#alsa capture and playback
pcm.alsa_input_1 {
    type plug
        slave.pcm "hw:Loopback,1,0"
}

pcm.alsa_output_1 {
    type plug
        slave.pcm "hw:Loopback,1,1"
}


#playback devices
pcm.jack_audio_1 {
  type asym
  playback.pcm "jack_playback_1"
  capture.pcm "jack_capture_1"
}

然后做alsa_out -j "playback" -d jack_audio_1 sound.wav

即使在插孔路由图中进行连接后,我仍然没有得到任何输出。

我的问题:看看我的设置,我将环回 jack_capture_1 绑定到 hw:0,0 环回 jack_playback_1 绑定到 hw:0,1

这意味着发送到 jack_capture_1 的任何声音都应该从 jack_playback_1 中回显,正确吗?

alsa_in 也是将进入 jack 会话的 alsa 音频流,而 alsa_out 是 jack 在完成后输出的 alsa 音频流吗?

我已经阅读了 snd_aloop 上所有我能读到的内容,但甚至他们的官方文档似乎有点欠缺。

有人可以帮我解决这个问题吗?

答案1

答案有点晚了,但也许有人觉得这有帮助;)

/etc/modprobe.d/alsa.conf
alias snd-card-8 snd-aloop
options snd_aloop index=8 id=loop0 enable=1

/etc/asound.conf

#### Linrad ####                                                                                                                                                                                                                              

pcm.loop0_0_0 {                                                                                                                                                                                                                               
  type plug                                                                                                                                                                                                                                   
    slave {                                                                                                                                                                                                                                   
      pcm "hw:loop0,0,0"                                                                                                                                                                                                                      
      format FLOAT_LE                                                                                                                                                                                                                         
      rate 96000                                                                                                                                                                                                                              
    }                                                                                                                                                                                                                                         
}                                                                                                                                                                                                                                             

pcm.linrad_alsa {                                                                                                                                                                                                                             
  type asym                                                                                                                                                                                                                                   
  playback.pcm "loop0_0_0"                                                                                                                                                                                                                    
  capture.pcm "loop0_0_0"                                                                                                                                                                                                                     
  hint {                                                                                                                                                                                                                                      
    show on                                                                                                                                                                                                                                   
    description "Linrad: ALSA"                                                                                                                                                                                                                
  }
}

pcm.loop0_1_0 {
  type plug
    slave {
      pcm "hw:loop0,1,0"
      format FLOAT_LE
      rate 96000
    }
}

pcm.linrad_jack {
  type asym
  playback.pcm "loop0_1_0"
  capture.pcm "loop0_1_0"
  hint {
    show on
    description "Linrad: JACK"
  }
}

#### WSJTX ####

pcm.loop0_0_1 {
  type plug
    slave {
      pcm "hw:loop0,0,1"
      format FLOAT_LE
      rate 96000
    }
}

pcm.wsjtx_alsa {
  type asym
  playback.pcm "loop0_0_1"
  capture.pcm "loop0_0_1"
  hint {
    show on
    description "WSJTX: ALSA"
  }
}

pcm.loop0_1_1 {
  type plug
    slave {
      pcm "hw:loop0,1,1"
      format FLOAT_LE
      rate 96000
    }
}

pcm.wsjtx_jack {
  type asym
  playback.pcm "loop0_1_1"
  capture.pcm "loop0_1_1"
  hint {
    show on
    description "WSJTX: JACK"
  }
}

....

对于用于 jack 的管道,类似这样(放置在 jackd 启动后运行的 shell 脚本中)

alsa_in -j "WSJTX source" -d wsjtx_jack -q 1 &> /dev/null &
alsa_out -j "WSJTX sink" -d wsjtx_jack -q 1 &> /dev/null &

相关内容