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 / 问题 / 572120
Accepted
Andreas Hartmann
Andreas Hartmann
Asked: 2015-01-11 05:39:28 +0800 CST2015-01-11 05:39:28 +0800 CST 2015-01-11 05:39:28 +0800 CST

如何在同一音频设备上同时使用 JACK 和 Pulseaudio/ALSA?

  • 772

每当我启动 Hydrogen 时,它会破坏所有其他使用 Pulse 的应用程序中的音频,例如,在启动 Hydrogen 一次后,我无法再在 Chrome 中播放视频,直到我重新启动我的 PC 或执行 sudo alsa force-reload。我发现有人有类似的问题,但没有解决这个问题的实际指南,通常有指向 http://jackaudio.org/pulseaudio_and_jack 的链接(已移至http://jackaudio.org/faq/pulseaudio_and_jack.html)我我正在使用 Ubuntu Studio 14.04 64 位。

或者,如果这真的不可能实现,有人能告诉我如何在一个声卡上使用 Jack 而在另一个声卡上使用 Pulse 吗?这样我就可以只在需要 JACK 时插入 USB 声卡。

请不要让我使用Windows。

pulseaudio
  • 11 11 个回答
  • 140478 Views

11 个回答

  • Voted
  1. Best Answer
    José Micó
    2016-05-25T20:41:02+08:002016-05-25T20:41:02+08:00

    从 16.04 开始,事情变得简单多了:)

    只需安装qjackctl和pulseaudio-module-jack模块:

    apt-get install qjackctl pulseaudio-module-jack
    

    然后配置qjackctl启动后运行如下命令。将其复制到“设置...”>“选项”>“启动后执行脚本”:

    pacmd set-default-sink jack_out
    

    就是这样。Pulseaudio 将识别(通过 D-Bus)JACK 启动,并自动将音频路由到它。当 JACK 停止时,Pulseaudio 将恢复正常路由并再次开始将音频直接发送到卡。

    所以(几乎)默认情况下,Pulseaudio 实现了上面由 mmv-ru 详述的设置。

    • 56
  2. RobinsSea
    2015-10-04T03:02:56+08:002015-10-04T03:02:56+08:00

    这个 Youtube 视频:“Jack and PulseAudio Together as Friends - Linux”似乎有一些答案:

    解决方案的关键似乎是确保 pulseaudio-module-jack 安装了:

    aptitude install pulseaudio-module-jack
    

    然后 sudo 编辑 /etc/pulse/default.pa 文件以在手动加载音频驱动程序部分下包含两行:

    load-module module-jack-sink
    load-module module-jack-source
    

    然后 - 我认为 - 重新启动 pulseaudio。我刚刚重新启动了 PC(懒惰,我知道)并且它很有用......启动 Ardor 不再杀死 pulseaudio,他们一起玩得很开心。

    • 21
  3. mmv-ru
    2016-02-29T15:36:57+08:002016-02-29T15:36:57+08:00

    我的解决方案适用于 Fedora 23。

    dnf install jack-audio-connection-kit jack-audio-connection-kit-dbus qjackctl
    

    不要碰 /etc/pulse/default.pa !

    配置qjackctl

    设置

    ~/.config/rncbc.org/QjackCtl.conf 的相关片段:

    [Settings]
    Server=jack_control start
    Driver=alsa
    InDevice="hw:PCH,0"
    OutDevice="hw:PCH,0"
    

    选项

    pactl 的接收器名称可以通过以下方式找到:

    pacmd list-sinks
    

    这是 ~/.config/rncbc.org/QjackCtl.conf 的另一片段,用于显示完整命令

    [Options]
    ...
    StartupScript=true
    StartupScriptShell=pactl suspend-sink alsa_output.pci-0000_00_1b.0.analog-stereo 1
    PostStartupScript=true
    PostStartupScriptShell=pactl set-default-sink jack_out
    ShutdownScript=false
    ShutdownScriptShell="pactl unload-module module-jack-sink; pactl load-module module-jack-source"
    PostShutdownScript=true
    PostShutdownScriptShell="pactl suspend-sink alsa_output.pci-0000_00_1b.0.analog-stereo 0; pactl set-default-sink alsa_output.pci-0000_00_1b.0.analog-stereo"
    

    杂项 “启用 D-Bus 接口”对 Qjackctl 本身很重要。

    这个怎么运作

    现在启动时,PC 仅使用 PulseAudio 运行,一切都自动运行,就像没有 Jack 一样。

    启动Qjackctl后,

    1. Qjackctl 启动脚本暂停 Pulseaudio 中的主声卡并允许 Jack 访问它:pactl suspend-sink alsa_output.pci-0000_00_1b.0.analog-stereo 1
    2. Jack 通过 d-bus 启动:jack_control start
    3. Pulse 自动检测 D-Bus 上的插孔启动并加载插孔接收器和插孔源。
    4. 启动脚本后的Qjackctl将Pulse中的默认sink更改为jack_out:(pactl set-default-sink jack_out起初看起来没有必要,因为所有正在运行的PA客户端都切换到新的sink,但是如果没有这个命令,新的应用程序将卡在暂停的sink上)

    因此系统被重新配置为使用“Pulse on top of Jack”。(我跳过了硬件输入挂起,因为我根本不用它)

    如果未选中“应用程序退出时停止 JACK 音频服务器”,我可以关闭 Qjackctl 并重新运行它而不会干扰设置。

    在通过 Qjackctl 阻止 Jack 之后,一切都恢复到简洁的 Pulse!

    1. Jackd 被 Qjackctl 通过 dbus 停止 - “启用 D-bus 接口”选项。
    2. jack-source 和 jack-sink 被 d-bus 自动从 Pulseaudio 中移除
    3. Pulse 音频中的默认接收器切换到声卡,因为插孔消失了
    4. 关闭脚本后的 Qjackctl 在 Pulseaudio 中重新激活声卡:pactl suspend-sink alsa_output.pci-0000_00_1b.0.analog-stereo 1

    使用的工具

    1. jackd(来自 pulseaudio-utils 包)
    2. jack_control(来自包 ack-audio-connection-kit-dbus)
    3. Qjackctl(来自 pulseaudio-utils 包)
    4. pactl 从脚本控制 Pulseaudio(来自包 pulseaudio-utils)
    5. LANG=C pacmd list-sinks|grep -E "index:|name:|alsa.long_card_name =|alsa.name ="或LANG=C pactl list sinks|grep -E "(Sink #|Name:|alsa.long_card_name =|alsa.name =)"检测 alsa 设备名称
    • 11
  4. laugeo
    2015-01-11T10:34:39+08:002015-01-11T10:34:39+08:00
    • 问题是 Hydrogen(如 Ardour)在启动时启动 jackd 但在退出时不关闭它:
      但是您可以killall jackd在 Hydrogen 退出后在终端中运行。

    • 同时使用 Jack 和 pulseaudio 软件的复杂方法是​​安装“pulseaudio-module-jack”(如果不存在,还安装 qjackctl(jackd 的 gui)和 pavucontrol)。重启脉冲音频pulseaudio -k。
      现在关闭音频应用程序(Jack 和 pulseaudio),
      使用 qjackctl(单击开始按钮)运行 jackd(必须在 qjackctl 设置的最后一个选项卡中选择 dbus 选项)。
      在 Pavucontrol“输出设备”选项卡中,点击“jack sink”附近的绿色“默认设备”按钮
      现在 pulseaudio 软件和 Hydrogen 应该同时运行。

    • 使用 qjackctl,在第一个“设置”选项卡中,您可以更改 Jackd 音频设备。

    • 8
  5. Fahad Hasan Pathik
    2019-01-22T09:56:08+08:002019-01-22T09:56:08+08:00

    路由所有系统以使用 jack 运行的最简单方法:

    安装

    sudo apt-get install qjackctl pulseaudio-module-jack
    

    打开qjackctl。在设置>选项>

    检查启动后执行脚本并粘贴:

    pacmd load-module module-jack-source channels=2; pacmd load-module module-jack-sink channels=2;
    

    检查关机后执行脚本并粘贴:

    killall jackd
    

    现在启动 qjack 并打开您的声音设置。您会找到 Pulse Audio Jack Sink Output 端口。选择它,所有系统将同步。如果您停止 Jack 服务器/qjack,声音将再次回到您的默认端口。

    [这里是整体视图]

    在此处输入图像描述

    • 7
  6. Jérôme
    2020-02-28T16:34:00+08:002020-02-28T16:34:00+08:00

    2020 年更新。Debian 克星。希望也适用于 Ubuntu。

    无需再使用任何脚本。

    安装pulseaudio-module-jack。它包含一个模块,负责检测 jack 何时启动并从中获取/下沉。

    您可以在 pulseaudio 配置文件中检查:

    /etc/脉冲/default.pa

    ### Automatically connect sink and source if JACK server is present
    .ifexists module-jackdbus-detect.so
    .nofail
    load-module module-jackdbus-detect channels=2
    .fail
    .endif
    

    确保 jackdbus 已启动。如果使用 qjackctl 启动 jack,请在设置 -> 杂项中选中 dbus 复选框。

    这应该是它所需要的。

    • 7
  7. Bruno Grieder
    2020-06-10T22:45:21+08:002020-06-10T22:45:21+08:00

    Ubuntu 20.04,我发现它是各种答案的混合体

    1. 安装 JACK 和 QJackCtl 以及 JACK 的 pulseaudio sink 和 source
    sudo apt-get install qjackctl pulseaudio-module-jack
    
    1. 启动 QJackCtl 并在Setup...--> Options-->中Execute script after Startup粘贴以下内容:
    pactl load-module module-jack-sink channels=2; pactl load-module module-jack-source; pacmd set-default-sink jack_out
    

    在此处输入图像描述

    1. 启动 JACK,在 QJackCtl 中,PulseAudio Sink 和 Source 应该连接到系统 在此处输入图像描述

    2. 在 Ubuntu 设置中,选择 JACK Sink 作为输出

    在此处输入图像描述

    • 6
  8. Kim Tucker
    2017-09-06T08:12:13+08:002017-09-06T08:12:13+08:00

    现在可能容易多了。在全新安装 Linux Mint 18.2(Ubuntu 16.04 软件包基础)之后,今天对我有用的是:满足我真正的基本需求:

    1. 使用 Synaptic 安装 QSynth 和 QJackCtl。

    2. 将所需的声音字体复制到适当的文件夹中,例如/usr/share/sounds/sf2/

    3. 在QSynth 设置中:在Audio选项卡下将Audio Driver更改为pulseaudio。

    4. 在QSynth Setup 中:在SoundFonts下:Open ... 并根据需要选择一个。

    5. 在QJackCtl Setup > Settings > Advanced 中:

      服务器前缀:pasuspsender --/usr/bin/jackd

    6. 在QJackCtl 设置 > 选项中:

      启动后执行脚本:

      pactl load-module module-jack-sink channels=2; pactl load-module module-jack-source; pacmd set-default-sink jack_out
      
    7. 在QJackCtl Connect: ALSA中:将左侧的键盘条目连接到右侧的FLUID Synth。

    8. 在声音的主要系统设置中,选择所需的输出设备。

    现在我可以在观看视频的同时弹奏键盘(例如在 YouTube 上使用 Firefox)——以前我一次只能做其中一个,而没有很多我很少能跟踪的调整。

    希望能帮助某人,或鼓励他们再试一次 :-)。

    • 5
  9. tobiasBora
    2020-12-17T14:34:20+08:002020-12-17T14:34:20+08:00

    有两种方法可以回答这个问题。

    1. 要么尝试让 jack 与 pulseaudio 一起工作......这个问题的其余部分将解释如何做到这一点。
    2. 或者...不要尝试同时使用 pulseaudio 和 jack,只需用 pipewire 替换它们:pipwire 应该是“新的 pulseaudio”(我认为它应该在某些时候取代 pulseaudio,并且已经比 pulseaudio 少了很多错误并支持更多蓝牙选项)。Pipewire 同时模拟 pulseaudio 和 jack,并且可以与 pulseaudio/qjackctl/...我什至不确定我正在使用的应用程序是否正在运行 jack 或 pulseaudio)。如果你真的想要疼痛并使用 pulseaudio + jack ... 这个问题的其余部分是给你的。

    前一段时间我写了一个命令,有人告诉我说在尝试了这里所有的解决方案之后他运气不好。但是这个解决方案对他有用,所以我会把它贴在这里以防其他人能得到帮助。注意:我并不是说这个解决方案是最优雅的解决方案,但它对我来说做得很好:

    • 我可以通过单击开始/停止按钮来启动/停止插孔,并且 pulseaudio 和 pavucontrol 之间的切换是自动的
    • 它会自动将所有当前播放软件连接到 jack(这就是为什么会有这个丑陋的 grep,如果您有更好的解决方案,请告诉我)
    • 它还确保 pulseaudio 应用程序也可以使用麦克风

    This solution may be slighly improved by unloading correctly the modules when quitting Jack, maybe using the ugly grep proposed here, but I didn't really found any benefit for me.

    Note also that I give quite detailed instructions on how to debug such issues.

    My solution (see theory below to understand why it works/fails and debug any potential issue)

    Install:

    $ sudo apt install jack2 pavucontrol qjackctl pulseaudio-module-jack. 
    

    Run qjackctl:

    $ qjackctl
    

    在此处输入图像描述

    Click on Setup, and check that the output Interface is the correct one (if you have an HDMI output for example this check may be important). In my case, I'll just use the default and I'll come back here if I've some issues later. 在此处输入图像描述

    Then, in the advanced tab, I replaced the Server Prefix jackd with pasuspender -- jackd. This is supposed to tell pulseaudio to temporarily let jack manage the sound card. I'm not sure if it's really required, but I guess it cannot hurt: 在此处输入图像描述

    Then, in the tab "Options", put in the Execute script after Startup the following code:

    pactl load-module module-jack-sink && pactl load-module module-jack-source && pactl set-default-sink jack_out && pacmd set-default-source jack_in && pacmd list-sink-inputs | grep index | sed 's/ *index: *//g' | xargs -I{} pacmd move-sink-input "{}" jack_out
    

    The goal of this command is to create new outputs (sink) to pulseaudio that points to jack, to enable this new sink by default (all newly open applications will write to jack), and it also change the output of all the existing applications to make sure they point to jack.

    Then, to make sure pulseaudio restarts when jack is closed, I also added in the field Execute script after Shutdown :

    pacmd suspend false
    

    在此处输入图像描述

    That's it! Now, you just need to save by clicking on Apply and to click on Start to start jack:

    在此处输入图像描述 You should see something like that if it works (and of course no errors): 在此处输入图像描述

    A bit of theory to understand why it works, or why it fails

    So basically, you can't play sound because only one program can play sound at the same time on the same sound card. So when Jack is playing, pulseaudio is blocked. Now, it also turns out that most desktop applications can talk to pulseaudio but not to Jack. So when Jack is on, you just don't have sound anymore. The trick is to route the pulseaudio trafic to Jack with something like that:

    application -> pulseaudio -> Jack -> sound card
    

    Note that all links must be correctly configured. We will see now how they are configured and how to check if they are configured correctly.

    So to create the link pulseaudio -> Jack we are going to load a module that creates a new pulseaudio sink (i.e. a virtual output device) called Jack sink: that way any applications writing in that sink will be redirected on Jack. You could have several already existing sinks, like one for the internal audio, and if you have a bluetooth headset, you can have one sink for it too. To check on which sink an application is actually playing, install and run pavucontrol (pavucontrol is super useful anyway for all sound-related stuff, since you can control basically everything from it). You can see the list of sinks in a tab named like Input devices (sorry if the translation is bad), in my case I have right now 2 sinks (jack is not yet loaded): 在此处输入图像描述

    If you just have one sink, you may not see anything interesting, but if you have several sinks, you can check in the first tab which application is playing on which sink (here you see that firefox is playing on my bluetooth headset), and you can change it if needed:

    在此处输入图像描述

    So if you have some issues, you can:

    1. link pulseaudio -> jack: check that you have a sink corresponding to jack (if not, try to run manually the command pactl load-module module-jack-sink that was supposed to be run automatically. If it fails, make sure you installed the pulseaudio-module-jack, and eventually restart pulseaudio by simply killing it killall pulseaudio. No worries, no need to restart pulseaudio, it respawn automatically.). Also make sure that the volume is not 0%, and that the channel is not muted: 在此处输入图像描述
    2. link application -> pulseaudio: check that your applications are writing on that sink. If not, you can manually change the sink (but the startup script was supposed to change the sink automatically) that way: 在此处输入图像描述
    3. link jack -> sound card: If you still have troubles (this part could also concern a trouble you have with the softwares that write on jack directly like zynaddsubfx), check out the Graph part of jack:

    在此处输入图像描述

    You should start will all nodes packed together, but you can move them to make them easier to see. Then make sure that all applications you want to ear are connected to system (in my case zynaddsubfx was not connected automatically). NB: if you have an older version of QJackctl, then you may have tabs instead of this. But it's the same: you will have green inputs/outputs in the "Jack" tab that you can manually connect, the violet ones will be in the "Alsa" tab, and the red ones in the "MIDI" tab... but in fact all external MIDI devices that you plug will appear in the Alsa tab: the reason is that there are two kinds of "MIDI": the legacy Alsa Midi (ports are global to the system), and the more recent Jack Midi (each application can have its own midi input/outputs).

    在此处输入图像描述

    1. Troubles with MIDI: In theory, to get midi, you can just connect the violet inputs to violet inputs (or in the Alsa tab in the older version, yes I know it's strange that you need to go in Alsa tab and not Midi to get Midi(!!!) but it's because of the difference between Alsa MIDI vs the more recent but less used Jack Midi). However, it turns out that for some strange reasons, zynaddsubfx has some strange defaults values and will appear as "Midi/red" instead of "Alsa/green", making it impossible to connect to an external midi device. More precisely, if you run zynaddsubfx from the command line without any option or with:
    zynaddsubfx -I alsa -O jack
    

    (which means input from Alsa MIDI, output to jack) it should not be a problem, you will be able to connect the MIDI devices:

    在此处输入图像描述

    但是,如果您以图形方式运行它,默认的 Jack 条目会自动运行zynaddsubfx -I jack -O jack...并且会出现zynaddsubfx输入将在红色/MIDI 选项卡中创建,而实际外部 MIDI 设备在紫色/Alsa 中的问题标签。所以这意味着您将无法将外部 MIDI 键盘映射到zynaddsubfx:

    在此处输入图像描述

    因此,解决方案是zynaddsubfx使用不带选项的命令行运行,或者使用命令行运行zynaddsubfx -I alsa -O midi,一切都应该有效!

    • 4
  10. Negru Voda
    2017-11-11T05:24:47+08:002017-11-11T05:24:47+08:00

    当然,如果他们到了需要 jack 的地步,人们会希望同时运行 pulseaudio 和 jack,因为大多数浏览器媒体播放器都不知道 jack!..很遗憾。

    我一直看到一次只运行其中一个的建议,这在我看来是一种可怕的妥协。在我看来,这两个服务(即 jack 和 pulseaudio)虽然都可以独立运行,但 kxstudio 管理不善,至少我正在使用它,这有点悲惨。

    所以会发生什么:

    • jack 在 pulseaudio 运行时无法启动(并且使用它想要使用的声卡驱动程序,这很公平)所以需要先启动它

    • pulseaudio 需要在启动和运行后指向插孔

    很简单..嘿?由于某些原因,我对此感到无尽的悲伤,因为……

    首先,我认为是因为 pulseaudio 4.0 似乎有问题并且弄乱了 alsa 驱动程序,因此在某些情况下它会保持锁定状态,因此即使 pulseaudio 没有运行,jack 也无法启动。(说未能设置捕获参数或类似的 smtg)

    我最后所做的是

    • 完全删除了 jack 和 pulseaudio(在 apt-get purge 之后使用 find 和 rm -rf :D)
    • 安装 pulseaudio 11(来自来源)
    • 安装了 jack 和它的库 (libjack-dev)

    按照这个顺序,然后我终于让它们通过 qjackctl 正常运行,这确保它们以正确的方式启动(在 pulseaudio 中加载插孔接收器,并将其设置为默认值)。

    顺便说一句,我看到 Cadence 被推荐了,我不明白为什么对我来说它与 qjackctl 相比似乎是垃圾。

    无论如何,问题是使用 qjackctl 启动 jack 需要一段时间,为了避免每次启动时的等待时间,您可以使用 kde 的这个救生功能来加载以前的会话。确保您在自动启动中没有 qjackctl,因为无论 singleton = true 设置如何,每次重新启动时您都会多一个实例(整晚都有 buggy buggy)。

    这是因为我不再觉得摆弄它,例如编写一个智能脚本来确保 pulseaudio 已关闭(或暂停)启动插孔并检查它是否正常启动,然后启动 pulseaudio,加载插孔模块等。

    否则依赖操作系统启动守护进程并正确加载配置将是正常的(健康的)场景,但它似乎没有发生。

    玩得开心..

    • 0

相关问题

  • 杰克和脉冲音频

  • 如何使基于 Ubuntu 构建的程序(使用 SDL)在其他系统上运行?

  • 如何将音乐流式传输到我的 AirTunes?

  • 声音小程序消失了

  • 声音,在多个程序之间停止

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