「PulseAudio/サンプル」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
(ページの作成:「Category:音声/動画 en:PulseAudio/Examples it:PulseAudio/Examples == デフォルトの入力ソースを設定 == List available input sources {{hc|<nowi...」)
 
(同期)
(3人の利用者による、間の17版が非表示)
1行目: 1行目:
[[Category:音声/動画]]
+
[[Category:マルチメディア]]
 
[[en:PulseAudio/Examples]]
 
[[en:PulseAudio/Examples]]
 
[[it:PulseAudio/Examples]]
 
[[it:PulseAudio/Examples]]
  +
[[ru:PulseAudio/Examples]]
  +
{{Related articles start}}
  +
{{Related|PulseAudio}}
  +
{{Related|PulseAudio/トラブルシューティング}}
  +
{{Related articles end}}
 
== デフォルトの入力ソースを設定 ==
 
== デフォルトの入力ソースを設定 ==
   
  +
利用可能な入力ソースの一覧を表示するには:
List available input sources
 
{{hc|<nowiki>$ pacmd list-sources | grep -e device.string -e 'name:'</nowiki>|2=
+
{{hc|$ pacmd list-sources {{!}} grep -e 'index:' -e device.string -e 'name:'|2=
  +
'' ''index: 0
name: <input>
 
  +
name: <input>
device.string = "hw:2"
 
  +
device.string = "hw:2"
name: <oss_input.dsp>
 
  +
* index: 1
device.string = "/dev/dsp"
 
  +
name: <oss_input.dsp>
name: <alsa_output.pci-0000_04_01.0.analog-stereo.monitor>
 
  +
device.string = "/dev/dsp"
name: <combined.monitor>
 
  +
index: 2
  +
name: <alsa_output.pci-0000_04_01.0.analog-stereo.monitor>
 
}}
 
}}
   
  +
インデックスの前の {{ic|*}} は現在のデフォルト入力を示します。
For permanent store in the ''default.pa'' file.
 
   
  +
システム全体のデフォルトとして設定するには、使用する入力ソースを {{ic|/etc/pulse/default.pa}} に追加してください:
Set OSS as input
 
  +
{{hc|/etc/pulse/default.pa|...
load-module module-oss device=/dev/dsp sink_name=alsa_output.pci-0000_04_01.0.analog-stereo mmap=1
 
  +
set-default-source ''alsa_output.pci-0000_04_01.0.analog-stereo.monitor''
Make it default
 
  +
...}}
set-default-source alsa_output.pci-0000_04_01.0.analog-stereo.monitor
 
  +
一時的に使用するには:
  +
$ pacmd "set-default-source alsa_output.pci-0000_04_01.0.analog-stereo.monitor"
  +
{{Tip|デフォルトのソースは、コマンド内で {{ic|@DEFAULT_SOURCE@}} として参照できます。たとえば: {{ic|$ pactl set-source-mute @DEFAULT_SOURCE@ toggle}}。}}
   
  +
== デフォルトの出力ソースを設定 ==
Set ALSA as input
 
load-module module-alsa-source source_name=input device=hw:2
 
Make it default
 
set-default-source input
 
   
  +
index の前に * が付いている新しいソースの名前を確認:
For temporary use
 
  +
{{hc|$ pacmd list-sinks {{!}} grep -e 'name:' -e 'index:'|
$ pacmd "load-module module-alsa-source source_name=input device=hw:2"
 
  +
* index: 0
$ pacmd "set-default-source input"
 
 
== Set the defaulting output source ==
 
{{Note| Use aplay to list devices that is a part of the {{Pkg|alsa-utils}} package and is not required to output to multiple sources. It is required to list playback devices therefore users can remove this package when finished with it.}}
 
 
To select an alternative source as the default output you can list all sources:
 
 
{{hc|<nowiki>$ aplay -l | grep card</nowiki>|
 
card 0: CMI8768 [C-Media CMI8768], device 0: CMI8738-MC8 [C-Media PCI DAC/ADC]
 
card 0: CMI8768 [C-Media CMI8768], device 1: CMI8738-MC8 [C-Media PCI 2nd DAC]
 
card 0: CMI8768 [C-Media CMI8768], device 2: CMI8738-MC8 [C-Media PCI IEC958]
 
card 1: HDMI [HDA Intel HDMI], device 3: HDMI 0 [HDMI 0]
 
card 1: HDMI [HDA Intel HDMI], device 7: HDMI 1 [HDMI 1]
 
card 1: HDMI [HDA Intel HDMI], device 8: HDMI 2 [HDMI 2]}}
 
 
To chose ''card 0, device 0'' edit the {{ic|/etc/pulse/default.pa}} file and add
 
load-module module-alsa-sink device=hw:0,0
 
 
Determine the correct index of the new source:
 
{{hc|<nowiki>$ pacmd list-sinks | grep -e 'name:' -e 'index'</nowiki>|
 
* index: 0
 
 
name: <alsa_output.pci-0000_04_01.0.analog-stereo>
 
name: <alsa_output.pci-0000_04_01.0.analog-stereo>
index: 1
+
index: 1
name: <combined>
+
name: <combined>}}
}}
 
   
For setting it as default in the {{ic|/etc/pulse/default.pa}} you can use
+
システム全体のデフォルトとして設定するには、以下を {{ic|/etc/pulse/default.pa}} に追加してください:
set-default-sink 0
+
{{hc|/etc/pulse/default.pa|...
  +
set-default-sink ''alsa_output.pci-0000_04_01.0.analog-stereo''
  +
...}}
  +
設定したら変更を有効にするためにログアウト/ログインまたは PulseAudio を手動で再起動してください。
   
  +
{{Note|1=<nowiki></nowiki>
When done then you can logout/login or restart PulseAudio manually for these changes to take effect.
 
  +
* デフォルトに設定されている sink には、インデックスの前に {{ic|*}} 印が付きます。
  +
* sink の番号付けは永続的ではないため、{{ic|default.pa}} ファイル内ではすべての sink を名前で識別する必要があります。
  +
* 実行時に素早く識別したい場合 (音量の制御など)、sink 名の代わりに sink index を使用することができます: {{bc|<nowiki>
  +
$ pactl set-sink-volume 0 +3%
  +
$ pactl set-sink-volume 0 -3%
  +
$ pactl set-sink-mute 0 toggle
  +
</nowiki>}}
  +
* 通常の音量 (100%) を不必要に上書きしないようにするには、サウンドを管理するための別のユーティリティを使用する方がよいでしょう。詳細については [https://bbs.archlinux.org/viewtopic.php?id=124513 フォーラムスレッド] を参照してください。}}
   
  +
{{Tip|デフォルトの sink は {{ic|@DEFAULT_SINK@}} で指定することができます。たとえば: {{ic|$ pactl set-sink-volume @DEFAULT_SINK@ +5%}}。}}
{{Note|1=.
 
:* The index number corresponds to the 'alsa_output.hw_0_0' sink.
 
:* The sinks that are set as default are marked with '''*''' in front of index.
 
:* You can use the index number to manage sound volume:
 
{{bc|
 
$ pactl set-sink-volume '''0''' +3%
 
$ pactl set-sink-volume '''0''' -- -3%
 
$ pactl set-sink-mute '''0''' toggle}}
 
:* To avoid unnecessary overriding of 100% normal volume is better to use alternative utilities for managing of sound. See the [https://bbs.archlinux.org/viewtopic.php?id=124513 arch forum] for more info.}}
 
   
 
== HDMI とアナログの同時出力 ==
 
== HDMI とアナログの同時出力 ==
  +
PulseAudio は、複数のソースに同時に出力することができます。例えば、あるアプリケーションでは HDMI を使用するように設定しつつ、別のアプリケーションではアナログを使用するようにすることができます。また、複数のアプリケーションで同時に音声を受け取ることができます。
PulseAudio allows for simultaneous output to multiple sources. In this example, some applications are configured to use HDMI while others are configured to use analog. Multiple applications are able to receive audio at the same time.
 
{{bc|$ aplay -l
 
**** List of PLAYBACK Hardware Devices ****
 
card 0: Intel [HDA Intel], device 0: ALC889A Analog [ALC889A Analog]
 
Subdevices: 0/1
 
Subdevice #0: subdevice #0
 
card 0: Intel [HDA Intel], device 1: ALC889A Digital [ALC889A Digital]
 
Subdevices: 1/1
 
Subdevice #0: subdevice #0
 
card 0: Intel [HDA Intel], device 3: HDMI 0 [HDMI 0]
 
Subdevices: 0/1
 
Subdevice #0: subdevice #0}}
 
   
  +
{{hc|$ aplay -l|
Or by using the the {{ic|pacmd}} command:
 
  +
**** ハードウェアデバイス PLAYBACK のリスト ****
  +
カード 0: Intel [HDA Intel], デバイス 0: ALC889A Analog [ALC889A Analog]
  +
サブデバイス: 0/1
  +
サブデバイス #0: subdevice #0
  +
カード 0: Intel [HDA Intel], デバイス 1: ALC889A Digital [ALC889A Digital]
  +
サブデバイス: 1/1
  +
サブデバイス #0: subdevice #0
  +
カード 0: Intel [HDA Intel], デバイス 3: HDMI 0 [HDMI 0]
  +
サブデバイス: 0/1
  +
サブデバイス #0: subdevice #0}}
  +
  +
もしくは {{ic|pacmd}} コマンドを使用すると:
   
 
{{hc|<nowiki>$ pacmd list-sinks | grep -e 'name:' -e 'alsa.device ' -e 'alsa.subdevice '</nowiki>|<nowiki>
 
{{hc|<nowiki>$ pacmd list-sinks | grep -e 'name:' -e 'alsa.device ' -e 'alsa.subdevice '</nowiki>|<nowiki>
name: <alsa_output.pci-0000_00_1b.0.analog-stereo>
+
name: <alsa_output.pci-0000_00_1b.0.analog-stereo>
alsa.subdevice = "0"
+
alsa.subdevice = "0"
alsa.device = "0"</nowiki>}}
+
alsa.device = "0"</nowiki>}}
  +
このような構成では pavucontrol の Configuration > Internal Audio で選択されているものがデフォルトのデバイスになります。Load pavucontrol > Configuration を選択し、プロファイルとして HDMI を選択してください。
 
The key to a configuration like this is to understand that whatever is selected in pavucontrol under Configuration>Internal AUdio is the default device. Load pavucontrol>Configuration and select HDMI as the profile.
 
   
  +
アナログデバイスをセカンダリソースとして設定するには、{{ic|/etc/pulse/default.pa}} の最初の方に以下の行を追加します (他のモジュールよりも先にロードさせるため):
Add the following to {{ic|/etc/pulse/default.pa}} to setup the analog as a secondary source, just above the line "### Automatically restore the volume of streams and devices":
 
 
### Load analog device
 
### Load analog device
 
load-module module-alsa-sink device=hw:0,0
 
load-module module-alsa-sink device=hw:0,0
98行目: 87行目:
 
set-default-sink combined
 
set-default-sink combined
   
  +
PulseAudio を再起動し pavucontrol を実行して「出力デバイス」タブを選択します。3つの設定が表示されます:
Restart PulseAudio, run pavucontrol and select the "Output Devices" tab. Three settings should be displayed:
 
 
# Internal Audio Digital Stereo (HDMI)
 
# Internal Audio Digital Stereo (HDMI)
 
# Internal Audio
 
# Internal Audio
 
# Simultaneous output to Internal Audio Digital Stereo (HDMI), Internal Audio
 
# Simultaneous output to Internal Audio Digital Stereo (HDMI), Internal Audio
   
  +
MPlayer, VLC, mpd などの PulseAudio を使用するプログラムを起動し「再生」タブに切り替えます。実行中のプログラムからドロップダウンリストを使って3つのソースのうちの1つを選択することができるはずです。
Now start a program that will use PulseAudio such as MPlayer, VLC, mpd, etc. and switch to the "Playback" tab. A drop-down list should be available for the running program to select one of the three sources.
 
   
Also see [https://bbs.archlinux.org/viewtopic.php?id=118026 this thread] for a variation on this theme and [http://www.freedesktop.org/wiki/Software/PulseAudio/FAQ#Can_I_use_PulseAudio_to_playback_music_on_two_sound_cards_simultaneously.3F PulseAudio FAQ].
+
詳しくは [https://www.freedesktop.org/wiki/Software/PulseAudio/FAQ#Can_I_use_PulseAudio_to_playback_music_on_two_sound_cards_simultaneously.3F PulseAudio FAQ] や [https://bbs.archlinux.org/viewtopic.php?id=118026 こちらのスレッド] を参照してください。
   
 
==HDMI 出力の設定==
 
==HDMI 出力の設定==
As outlined in ftp://download.nvidia.com/XFree86/gpu-hdmi-audio-document/gpu-hdmi-audio.html#_issues_in_pulseaudio unless the HDMI port is the first
+
ftp://download.nvidia.com/XFree86/gpu-hdmi-audio-document/gpu-hdmi-audio.html#_issues_in_pulseaudio に書かれているように、HDMI 端子が一番最初の出力端子でないかぎり、PulseAudio は HDMI 音声出力をサポートしている特定のグラフィックカードで音声を鳴らすことができません。最初の HDMI 出力だけが選択されるという PulseAudio のバグが原因です。
output, PulseAudio will not be able to have any audio when using certain graphics cards with HDMI audio support. This is because of a bug in PulseAudio where it will only select the first HDMI output on a device. A work around posted further down is to first find which HDMI output is working by using the aplay utility from ALSA.
 
   
  +
NVIDIA 製のカードで主に発生しますが、[https://bbs.archlinux.org/viewtopic.php?id=133222 フォーラムスレッド] に書かれているように他のカードでも発生することがあります。NVIDIA のカードをケーススタディとして取り上げますが、他のカードでも同じように解決することができます。
The original title for this section indicated the problem is specific to nVidia cards. As seen in [https://bbs.archlinux.org/viewtopic.php?id=133222 this forum thread] other cards are affected as well. The rest of the section will use an nVidia card as a case-study but the solution should carry over for people using other affected cards.
 
   
 
===HDMI 出力の確認===
 
===HDMI 出力の確認===
  +
利用可能なカードを表示して出力を確認してください:
Then find the working output by listing the available cards
 
 
# aplay -l
 
# aplay -l
   
  +
出力例:
sample output:
 
**** List of PLAYBACK Hardware Devices ****
+
**** List of PLAYBACK Hardware Devices ****
card 0: NVidia [HDA NVidia], device 0: ALC1200 Analog [ALC1200 Analog]
+
card 0: NVidia [HDA NVidia], device 0: ALC1200 Analog [ALC1200 Analog]
Subdevices: 1/1
+
Subdevices: 1/1
Subdevice #0: subdevice #0
+
Subdevice #0: subdevice #0
card 0: NVidia [HDA NVidia], device 3: ALC1200 Digital [ALC1200 Digital]
+
card 0: NVidia [HDA NVidia], device 3: ALC1200 Digital [ALC1200 Digital]
Subdevices: 1/1
+
Subdevices: 1/1
Subdevice #0: subdevice #0
+
Subdevice #0: subdevice #0
card 1: NVidia_1 [HDA NVidia], device 3: HDMI 0 [HDMI 0]
+
card 1: NVidia_1 [HDA NVidia], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
+
Subdevices: 1/1
Subdevice #0: subdevice #0
+
Subdevice #0: subdevice #0
card 1: NVidia_1 [HDA NVidia], device 7: HDMI 0 [HDMI 0]
+
card 1: NVidia_1 [HDA NVidia], device 7: HDMI 0 [HDMI 0]
Subdevices: 0/1
+
Subdevices: 0/1
Subdevice #0: subdevice #0
+
Subdevice #0: subdevice #0
card 1: NVidia_1 [HDA NVidia], device 8: HDMI 0 [HDMI 0]
+
card 1: NVidia_1 [HDA NVidia], device 8: HDMI 0 [HDMI 0]
Subdevices: 1/1
+
Subdevices: 1/1
Subdevice #0: subdevice #0
+
Subdevice #0: subdevice #0
card 1: NVidia_1 [HDA NVidia], device 9: HDMI 0 [HDMI 0]
+
card 1: NVidia_1 [HDA NVidia], device 9: HDMI 0 [HDMI 0]
Subdevices: 1/1
+
Subdevices: 1/1
Subdevice #0: subdevice #0
+
Subdevice #0: subdevice #0
   
 
===適切なカードでテスト===
 
===適切なカードでテスト===
  +
どれが TV やモニターに出力しているのかテストする必要があります:
Now a list of the detected cards is known, users will need to test for which one is outputting to the TV/monitor
 
 
# aplay -D plughw:1,3 /usr/share/sounds/alsa/Front_Right.wav
 
# aplay -D plughw:1,3 /usr/share/sounds/alsa/Front_Right.wav
   
  +
1 は前のセクションで確認した card の値、同じく 3 は device に置き換えてください。音がでない場合、別の device で試してみてください。
where 1 is the card and 3 is the device substitute in the values listed from the previous section. If there is no audio, then try substituting a different device (on my card I had to use card 1 device 7)
 
   
 
===PulseAudio を手動で設定して Nvidia HDMI を検出===
 
===PulseAudio を手動で設定して Nvidia HDMI を検出===
151行目: 139行目:
   
 
restart pulse audio
 
restart pulse audio
$ pulseaudio -k
+
$ pulseaudio -k
$ pulseaudio --start
+
$ pulseaudio --start
   
 
open the sound settings manager, make sure that under the hardware tab the graphics cards HDMI audio is set to "Digital Stereo (HDMI) Output" ( My graphics card audio is called "GF100 High Definition Audio Controller"
 
open the sound settings manager, make sure that under the hardware tab the graphics cards HDMI audio is set to "Digital Stereo (HDMI) Output" ( My graphics card audio is called "GF100 High Definition Audio Controller"
159行目: 147行目:
   
 
==サラウンドサウンドシステム==
 
==サラウンドサウンドシステム==
  +
大抵の人はサラウンド対応のサウンドカードを持っていても、2チャンネルのスピーカーしか持っていないため、PulseAudio はサラウンド音声の設定をデフォルトとしません。全てのチャンネルを有効にするには、{{ic|/etc/pulse/daemon.conf}} を編集して default-sample-channels 行をアンコメント (行頭のセミコロンを削除) して、''5.1'' チャンネルなら値を '''6''' に、''7.1'' チャンネルなら '''8''' に設定してください:
Many people have a surround sound card, but have speakers for just two channels, so PulseAudio cannot really default to a surround sound setup. To enable all of the channels, edit {{ic|/etc/pulse/daemon.conf}}: uncomment the default-sample-channels line (i.e. remove the semicolon from the beginning of the line) and set the value to '''6'''. For a ''5.1'' setup, or '''8''' for a ''7.1'' setup etc.
 
 
# Default
 
# Default
 
default-sample-channels=2
 
default-sample-channels=2
167行目: 155行目:
 
default-sample-channels=8
 
default-sample-channels=8
   
  +
チャンネルが正しくマッピングされなかったり、pavucontrol で個々のチャンネルのボリュームコントロールが機能しない場合、HDMI とアナログサウンドカードがあるのであれば、以下の行を {{ic|/etc/pulse/default.pa}} に追加してみてください:
If your channels are not correclty mapped or the volume controls for the individual channels do not work as expected in pavucontrol, and you have a HDMI and an anlog soundcard, then try to add the following line to {{ic|/etc/pulse/default.pa}}
 
   
 
load-module module-combine channels=6 channel_map=front-left,front-right,rear-left,rear-right,front-center,lfe
 
load-module module-combine channels=6 channel_map=front-left,front-right,rear-left,rear-right,front-center,lfe
   
  +
上記は 5.1ch での設定例です。
Note that this example is for a 5.1 setup.
 
   
  +
設定を編集したら PulseAudio を再起動してください。
After doing the edit, restart PulseAudio.
 
   
=== フロント/リアのスプリット ===
+
=== フロント/リアの分割 ===
   
 
Connect speakers to front analog output and headphones to rear output. It would be useful to split front/rear to separate sinks. Add to {{ic|/etc/pulse/default.pa}}:
 
Connect speakers to front analog output and headphones to rear output. It would be useful to split front/rear to separate sinks. Add to {{ic|/etc/pulse/default.pa}}:
   
load-module module-remap-sink sink_name=speakers remix=no master=alsa_output.pci-0000_05_00.0.analog-surround-40 channels=2 master_channel_map=front-left,front-right channel_map=front-left,front-right
+
load-module module-remap-sink sink_name=speakers sink_properties="device.description='Speakers'" remix=no master=alsa_output.pci-0000_05_00.0.analog-surround-40 channels=2 master_channel_map=front-left,front-right channel_map=front-left,front-right
load-module module-remap-sink sink_name=headphones remix=no master=alsa_output.pci-0000_05_00.0.analog-surround-40 channels=2 master_channel_map=rear-left,rear-right channel_map=front-left,front-right
+
load-module module-remap-sink sink_name=headphones sink_properties="device.description='Headphones'" remix=no master=alsa_output.pci-0000_05_00.0.analog-surround-40 channels=2 master_channel_map=rear-left,rear-right channel_map=front-left,front-right
(replace alsa_output.pci-0000_05_00.0.analog-surround-40 in the sound card name shown from 'pacmd list-sinks')
+
alsa_output.pci-0000_05_00.0.analog-surround-40 'pacmd list-sinks' で表示されるサウンドカードの名前に置き換えてください。
   
Now you have 2 additional sinks which can be used separately.
+
Now you have 2 additional sinks which can be used separately. You can choose 'sink_name' freely, as long as there is no sink with that name already. The 'remix' parameter controls whether the audio should be down-/upmixed to match the channels in the sink.
   
  +
{{Tip|pulseaudio が {{ic|master sink not found}} と表示する場合、リマップの行をコメントアウトしてから、PulseAudio を起動してカードの出力が正しく設定されているか確認してください (例: アナログサラウンド 4.0)。もしくは、sink 名の代わりに [[#デフォルトの出力ソースを設定|sink index]] を使ってみてください。}}
{{Note|If pulseaudio fails with {{ic|master sink not found}} use a [[#Defaulting_to_an_analog_output_source|sink index]] instead of a sink name.}}
 
   
===LFE リミックス===
+
===7.1 を 5.1+2.0 に分割===
By default, PulseAudio remixes the number of channels to the default-sample-channels; however, it does not do this for the LFE channel. To enable LFE remixing, uncomment the line:
 
   
  +
上記の例と同じように、7.1 構成を 5.1 サラウンドとステレオ出力に分割することもできます。使用しているカードを 7.1 モードに設定してから、以下の行を {{ic|/etc/pulse/default.pa}} に追加してください:
; enable-lfe-remixing = no
 
  +
load-module module-remap-sink sink_name=Surround sink_properties="device.description='Surround'" remix=no master=alsa_output.pci-0000_00_14.2.analog-surround-71 channels=6 master_channel_map=front-left,front-right,rear-left,rear-right,front-center,lfe channel_map=front-left,front-right,rear-left,rear-right,front-center,lfe
  +
load-module module-remap-sink sink_name=Stereo sink_properties="device.description='Stereo'" remix=no master=alsa_output.pci-0000_00_14.2.analog-surround-71 channels=2 master_channel_map=side-left,side-right channel_map=front-left,front-right
   
  +
{{ic|alsa_output.pci-0000_00_14.2}} は使用しているサウンドカードの名前に置き換えてください ({{ic|pacmd list-sinks}} で確認できます)。上記の設定は 5.1 sink ではフロント/リア/センター+LFE (緑/黒/橙) のジャックを使い stereo sink ではサイドスピーカー (灰) のジャックを使います。stereo sink 用に音声はステレオにダウンミックスされますが、5.1 出力には何も手を加えません。
and replace no with yes:
 
   
  +
{{Tip|pulseaudio が {{ic|master sink not found}} と表示する場合、リマップの行をコメントアウトしてから、PulseAudio を起動してカードの出力がアナログサラウンド 7.1 に設定されているか確認してください。もしくは、sink 名の代わりに [[#デフォルトの出力ソースを設定|sink index]] を使ってみてください。}}
enable-lfe-remixing = yes
 
   
  +
===LFE リミックスの無効化===
then restart Pulseaudio.
 
  +
デフォルトで、PulseAudio はチャンネル数を default-sample-channels にリミックスし、バージョン 7 から LFE チャンネルもリミックスされます。LFE リミックスを無効化したい場合、以下の行をアンコメントして:
  +
  +
; enable-lfe-remixing = yes
  +
  +
以下のように yes を no に置き換えてください:
  +
  +
enable-lfe-remixing = no
  +
  +
設定したら PulseAudio を再起動してください。
  +
  +
===バイノーラルヘッドフォン===
  +
{{AUR|ladspa-bs2b}} にはステレオヘッドホンでサラウンド音声をシミュレートするプラグインが入っています。使用するには、まずヘッドホンを確認:
  +
{{hc|<nowiki>$ pacmd list-sinks | grep -e 'name:'</nowiki>|
  +
name: <alsa_output.pci-0000_00_1b.0.iec958-ac3-surround-51>
  +
name: <alsa_output.pci-0000_00_1b.0.iec958-ac3-surround-51.equalizer>
  +
name: <bluez_sink.00_1F_82_28_93_51>
  +
}}
  +
  +
プラグインをロード (''new'' sink_name is up to you, master=''headphone's sink name''):
  +
pacmd load-module module-ladspa-sink sink_name=binaural master=bluez_sink.00_1F_82_28_93_51 plugin=bs2b label=bs2b control=700,4.5
  +
  +
{{Pkg|pavucontrol}} を使ってストリームを新しい sink に転送、または:
  +
pactl move-sink-input $INPUTID $BINAURALSINKNAME
   
 
==ネットワークを介して PulseAudio==
 
==ネットワークを介して PulseAudio==
  +
PulseAudio のユニークな機能のひとつとして、TCP 経由で LAN 内のサーバーで動作している PulseAudio デーモンにクライアントから音声をストリーミングすることができます。クライアントとサーバーのシステム時刻が正しくないと、音声ストリームが途切れたり音が全く出ないことがあるので注意してください。
One of PulseAudio's unique features is its ability to stream audio from clients over TCP to a server running the PulseAudio daemon reliably within a LAN.
 
   
To accomplish this, one needs to enable module-native-protocol-tcp.
+
ストリーミングを行うには、module-native-protocol-tcp を有効にする必要があります。
   
 
===TCP サポート (networked sound)===
 
===TCP サポート (networked sound)===
  +
TCP モジュールを有効にするために、クライアントとサーバーの両方で {{ic|/etc/pulse/default.pa}} に以下を追加してください (既に行が存在する場合はアンコメント):
To enable the TCP module, add this to (or uncomment, if already there) {{ic|/etc/pulse/default.pa}} on both the client and server:
 
 
load-module module-native-protocol-tcp
 
load-module module-native-protocol-tcp
   
215行目: 227行目:
 
If it is undesirable to copy the cookie file from clients, anonymous clients can access the server by giving these parameters to module-native-protocol-tcp on the server (again in {{ic|/etc/pulse/default.pa}}):
 
If it is undesirable to copy the cookie file from clients, anonymous clients can access the server by giving these parameters to module-native-protocol-tcp on the server (again in {{ic|/etc/pulse/default.pa}}):
   
load-module module-native-protocol-tcp "auth-ip-acl=127.0.0.1;192.168.0.0/24 auth-anonymous=1"
+
load-module module-native-protocol-tcp "auth-ip-acl=127.0.0.1;192.168.0.0/24 auth-anonymous=1"
   
 
Change the LAN IP subnet to match that of the those clients you wish to have access to the server.
 
Change the LAN IP subnet to match that of the those clients you wish to have access to the server.
   
 
===Zeroconf (Avahi) パブリッシング===
 
===Zeroconf (Avahi) パブリッシング===
For the remote PulseAudio server to appear in the PulseAudio Device Chooser ({{ic|pasystray}}), load the appropriate zeroconf modules, and enable the [[Avahi]] [[daemon]].
+
PulseAudio のリモートサーバーを PulseAudio Device Chooser ({{ic|pasystray}}) に表示させるには、適当な zeroconf モジュールをロードして、[[Avahi]] [[デーモン]]を有効化してください。
   
  +
クライアントとサーバーの両方で {{Pkg|pulseaudio-zeroconf}} パッケージをインストールして、{{ic|avahi-daemon}} の systemd ユニットを[[起動]]・[[有効化]]してください。
On both machines, run:
 
  +
$ systemctl start avahi-daemon
 
  +
サーバー側で、{{ic|load-module module-zeroconf-publish}} を {{ic|/etc/pulse/default.pa}} に追加して、クライアント側で、{{ic|load-module module-zeroconf-discover}} を {{ic|/etc/pulse/default.pa}} に追加してください。これで適切な sink を選択することでストリームや音声出力がリモートの PulseAudio サーバーに転送されます。
$ systemctl enable avahi-daemon
 
On the server, add {{ic|load-module module-zeroconf-publish}} to {{ic|/etc/pulse/default.pa}}, on the client, add {{ic|load-module module-zeroconf-discover}} to {{ic|/etc/pulse/default.pa}}. Now redirect any stream or complete audio output to the remote PulseAudio server by selecting the appropriate sink.
 
   
 
If you have issues with the remote syncs appearing on the client, try restarting the Avahi daemon on the server to rebroadcast the available interfaces.
 
If you have issues with the remote syncs appearing on the client, try restarting the Avahi daemon on the server to rebroadcast the available interfaces.
  +
  +
===サーバーの選択===
  +
Run the graphical PulseAudio Volume Control {{ic|pavucontrol}}. Under the '''Output Devices''' tab, you should see the local and remote output devices. Under the '''Playback''' tab, to the left of the "X" Mute Audio button, you should see a box containing the name of an output device. That box is ''actually a button'', which will display a drop-down radio-button list of the available output devices, with one output device selected. Selecting an output device from the list will allow the audio stream to be switched to the PulseAudio server associated with that output device. This control is not at all obvious until you have used it, and is especially useful with a remote Headless sound server.
  +
  +
Similarly, under the '''Input Devices''' tab, local and remote input devices will be seen. And under the '''Recording''' tab, there will be a box, to the left of the "X" Mute Audio button, with the name of an input device which is actually a button which will display a drop-down radio-button list of available input devices.
  +
  +
Run {{ic|pavucontrol}} on the local or remote host associated with the audio stream to be directed. For instance, run {{ic|pavucontrol}} on the remote host to direct the remote audio output to the local host. Run {{ic|pavucontrol}} on the local host to direct the local audio output to some remote host.
  +
  +
Setting up simultaneous inputs or outputs is a different thing. Search about "monitor" and "module-combine-sink" for that.
   
 
===ローカルの X クライアントで使用する PulseAudio サーバーを切り替える===
 
===ローカルの X クライアントで使用する PulseAudio サーバーを切り替える===
  +
X の中からクライアントで使用するサーバーを切り替えるには {{ic|pax11publish}} コマンドを使います。例えば、デフォルトのサーバーからホストネーム foo のサーバーに切り替えるには:
To switch between servers on the client from within X, the {{ic|pax11publish}} command can be used. For example, to switch from the default server to the server at hostname foo:
 
 
$ pax11publish -e -S foo
 
$ pax11publish -e -S foo
   
  +
もしくは、デフォルトのサーバーに戻すには:
Or to switch back to the default:
 
 
$ pax11publish -e -r
 
$ pax11publish -e -r
   
  +
上記のコマンドは (上で説明しているのと同じように) PulseAudio サーバーで音声をストリーミングする代わりに、X11 ルートウィンドウの PulseAudio 変数を編集します。それによって PulseAudio のクライアントライブラリが {{ic|localhost}} 以外の PulseAudio サーバーに接続するようになります。プログラムはローカルの {{ic|pulseaudio}} プロセスに依存しなくなるため、ローカルのプロセスは[[停止]]してかまいません。{{ic|pactl}}, {{ic|pacmd}}, {{ic|pavucontrol}} などのプログラムでリモートの PulseAudio サーバーを制御するには適切な {{ic|PULSE_SERVER}} 変数/X 変数を指定して実行する必要があります。
Note that for the switch to become apparent, the programs using Pulse must be restarted.
 
  +
  +
Note that for the switch to become apparent, the programs using Pulse must be restarted, or their PulseAudio client library otherwise reinitialized (completely stopping and restarting playback may be enough). To make this setting permanent, edit {{ic|default-server}} in {{ic|~/.config/pulse/client.conf}} or {{ic|/etc/pulse/client.conf}}.
   
 
===何もかもが失敗しているような場合===
 
===何もかもが失敗しているような場合===
242行目: 264行目:
   
 
On the server:
 
On the server:
$ paprefs
+
$ paprefs
 
Go to Network Access -> Enable access to local sound devices (Also check both 'Allow discover' and 'Don't require authentication').
 
Go to Network Access -> Enable access to local sound devices (Also check both 'Allow discover' and 'Don't require authentication').
   
 
On the client:
 
On the client:
$ export PULSE_SERVER=server.ip && mplayer test.mp3
+
$ export PULSE_SERVER=server.ip && mplayer test.mp3
   
 
==ALSA モニターのソース==
 
==ALSA モニターのソース==
263行目: 285行目:
   
 
Alternatively, you can use pavucontrol to do this: make sure you have set up the display to "All input devices", then select "Monitor of [your sound card]" as the recording source.
 
Alternatively, you can use pavucontrol to do this: make sure you have set up the display to "All input devices", then select "Monitor of [your sound card]" as the recording source.
  +
  +
== 特定の出力のモニター ==
  +
  +
It is possible to monitor a specific output, for example to stream audio from a music player into a VOIP application.
  +
Simply create a null output device:
  +
  +
pactl load-module module-null-sink sink_name=<name>
  +
  +
In Pulseaudio Volume Control (pavucontrol), under the "Playback" tab, change the output of an application to <name>, and in the recording tab change the input of an application to "Monitor of <name>". Audio will now be outputted from one application into the other.
   
 
==PulseAudio と JACK==
 
==PulseAudio と JACK==
  +
音楽を作曲・編集するときは [[JACK Audio Connection Kit]] が人気があり、Linux のオーディオアプリケーションによって広くサポートされています。PulseAudio と同じような機能を提供しますが、特にプロフェッショナルなオーディオ作業環境に特化しています。音楽をモニタリングするときの遅延を少なくして、マルチ I/O を備えたサウンドデバイスの入出力を多彩に制御できます。
===最新の方法===
 
  +
This configuration only works with jackdbus (JACK2 compiled with D-Bus support). Add to {{ic|/etc/pulse/default.pa}}:
 
  +
=== KXStudio を使う方法 ===
load-module module-jackdbus-detect
 
  +
[https://github.com/jackaudio/jackaudio.github.com/wiki/WalkThrough_User_PulseOnJack JACK の開発者] によって公式に推奨されている方法です。
As described on the [http://trac.jackaudio.org/wiki/JackDbusPackaging Jack-DBUS Packaging] page:
 
  +
  +
{{Pkg|jack2-dbus}} と {{Pkg|jack2}} パッケージの両方で動作します。
  +
  +
JACK には ALSA と PulseAudio、そして JACK とブリッジする機能がネイティブで備わっています。JACK と PulseAudio を両方動かして同時に出力することが可能であり、設定の編集やターミナルコマンドは必要ありません。
  +
  +
{{Pkg|qjackctl}} を使用している場合、先に進む前にアンインストールすることが推奨されます。
  +
  +
まずは {{Pkg|cadence}} と {{Pkg|pulseaudio-jack}} をインストールしてください。インストールして起動したら、ウィンドウ右下の JACK ブリッジ設定を探してください。ALSA の音声ブリッジを ALSA -> PulseAudio -> JACK と設定して PulseAudio のブリッジを有効にしてください。{{ic|pavucontrol}} で Jack sink の全ての出力デバイスと Jack input の全ての入力デバイスをミュートにしてください。Force Restart ボタンを使って JACK を起動して、問題なく起動すれば PulseAudio プログラムは JACK に出力するようになっているはずです。
  +
  +
===sink を手動で設定する方法===
  +
この設定は jackdbus (D-Bus のサポートを有効にしてコンパイルされた JACK2) でのみ機能します。また、{{Pkg|pulseaudio-jack}} パッケージが必要です。{{ic|/etc/pulse/default.pa}} に以下の行を記述してください:
  +
load-module module-jackdbus-detect ''options''
  +
{{ic|''options''}} はモジュールによってサポートされているオプションならなんでもかまいません。通常は {{ic|1=channels=2}} です。
  +
  +
[https://github.com/jackaudio/jackaudio.github.com/wiki/JackDbusPackaging Jack-DBUS Packaging] ページより:
   
 
''Server auto-launching is implemented as D-Bus call that auto-activates JACK D-Bus service, in case it is not already started, and starts the JACK server. Correct interaction with PulseAudio is done using a D-Bus based audio card "acquire/release" mechanism. When JACK server starts, it asks this D-Bus service to acquire the audio card and PulseAudio will unconditionally release it. When JACK server stops, it releases the audio card that can be grabbed again by PulseAudio.''
 
''Server auto-launching is implemented as D-Bus call that auto-activates JACK D-Bus service, in case it is not already started, and starts the JACK server. Correct interaction with PulseAudio is done using a D-Bus based audio card "acquire/release" mechanism. When JACK server starts, it asks this D-Bus service to acquire the audio card and PulseAudio will unconditionally release it. When JACK server stops, it releases the audio card that can be grabbed again by PulseAudio.''
   
{{ic|module-jackdbus-detect.so}} dynamically loads and unloads module-jack-sink and module-jack-source when jackdbus is started and stopped.
+
{{ic|module-jackdbus-detect.so}} jackdbus が起動・停止したときに動的に module-jack-sink module-jack-source をロード・アンロードします。
   
If PulseAudio sound does not work, check with {{ic|pavucontrol}} to see if the relevant programs appear in the playback tab. If not, add the following to {{ic|~/.asound.conf}} or {{ic|/etc/asound.conf}} to redirect ALSA to PulseAudio:
+
PulseAudio の音が鳴らない場合、{{ic|pavucontrol}} で適当なプログラムが再生タブに現れていることを確認してください。存在しない場合、以下を {{ic|~/.asoundrc}} または {{ic|/etc/asound.conf}} に追加して ALSA PulseAudio にリダイレクトしてください:
   
 
pcm.pulse {
 
pcm.pulse {
291行目: 337行目:
 
}
 
}
   
  +
上記の設定で上手く行かない場合、{{ic|pavucontrol}} で再生タブを確認してプログラムがオーディオカード (JACK が制御するため、機能しません) ではなく PulseAudio JACK Sink に出力するようになっているか確認してください。また、JACK のグラフで PulseAudio JACK Source がシステムオーディオ出力に接続されていることを確認してください。
If it still does not work, check with {{ic|pavucontrol}} in the playback tab and make sure the relevant programs are outputting to PulseAudio JACK Sink instead of your audio card (which JACK has control of, so it will not work).
 
  +
  +
===シェルスクリプトを使う方法===
  +
This method allows JACK and PulseAudio to output at the same time. It mostly relies on shell scripts that are automatically run by QJackCTL to manage aspects of how the JACK sinks and PulseAudio behave.
   
===新しい方法===
 
 
The basic idea is that killing PulseAudio is a bad idea because it may crash any apps using PulseAudio and disrupt any audio playing.
 
The basic idea is that killing PulseAudio is a bad idea because it may crash any apps using PulseAudio and disrupt any audio playing.
   
332行目: 380行目:
 
pacmd suspend false
 
pacmd suspend false
   
===古い方法===
+
===PulseAudio を終了する方法===
  +
This method relies on shell scripts to automatically kill PulseAudio when JACK is started, and automatically restart it when JACK is stopped. This will result in lower CPU usage than having both running, but can cause errors in already running PulseAudio application and does not allow simultaneous output of both.
The JACK-Audio-Connection-Kit is popular for audio work, and is widely supported by Linux audio applications. It fills a similar niche as PulseAudio, but with more of an emphasis on professional audio work. In particular, audio applications such as Ardour and Audacity (recently) work well with Jack.
 
  +
 
PulseAudio provides module-jack-source and module-jack-sink which allow PulseAudio to be run as a sound server above the JACK daemon. This allows the usage of per-volume adjustments and the like for the apps which need it, play-back apps for movies and audio, while allowing low-latency and inter-app connectivity for sound-processing apps which connect to JACK. However, this will prevent PulseAudio from directly writing to the sound card buffers, which will increase overall CPU usage.
 
 
To just try PA on top of JACK, have PA load the necessary modules on start:
 
pulseaudio -L module-jack-sink -L module-jack-source
 
 
To use PulseAudio with JACK, JACK must be started before PulseAudio, using whichever method one prefers. PulseAudio then needs to be started loading the two relevant modules. Edit {{ic|/etc/pulse/default.pa}}, and change the following region:
 
### Load audio drivers statically (it is probably better to not load
 
### these drivers manually, but instead use module-hal-detect --
 
### see below -- for doing this automatically)
 
#load-module module-alsa-sink
 
#load-module module-alsa-source device=hw:1,0
 
#load-module module-oss device="/dev/dsp" sink_name=output source_name=input
 
#load-module module-oss-mmap device="/dev/dsp" sink_name=output source_name=input
 
#load-module module-null-sink
 
#load-module module-pipe-sink
 
 
### Automatically load driver modules depending on the hardware available
 
.ifexists module-udev-detect.so
 
load-module module-udev-detect
 
.else
 
### Alternatively use the static hardware detection module (for systems that
 
### lack udev support)
 
load-module module-detect
 
.endif
 
 
to the following:
 
### Load audio drivers statically (it is probably better to not load
 
### these drivers manually, but instead use module-hal-detect --
 
### see below -- for doing this automatically)
 
#load-module module-alsa-sink
 
#load-module module-alsa-source device=hw:1,0
 
#load-module module-oss device="/dev/dsp" sink_name=output source_name=input
 
#load-module module-oss-mmap device="/dev/dsp" sink_name=output source_name=input
 
#load-module module-null-sink
 
#load-module module-pipe-sink
 
load-module module-jack-source
 
load-module module-jack-sink
 
 
### Automatically load driver modules depending on the hardware available
 
#.ifexists module-udev-detect.so
 
#load-module module-udev-detect
 
#.else
 
### Alternatively use the static hardware detection module (for systems that
 
### lack udev support)
 
#load-module module-detect
 
#.endif
 
 
Basically, this prevents module-udev-detect from loading. module-udev-detect will always try to grab the sound card (JACK has already done that, so this will cause an error). Also, the JACK source and sink must be explicitly loaded.
 
 
====QjackCtl とスタートアップ/シャットダウンスクリプト====
 
 
Using the settings listed above, use QjackCtl to execute a script upon startup and shutdown to load/unload PulseAudio. Part of the reason users may wish to do this is that the above changes disable PulseAudio's automatic hardware detection modules. This particular setup is for using PulseAudio in an exclusive fashion with JACK, though the scripts could be modified to unload and load an alternate non-JACK setup, but killing and starting PulseAudio while programs might be using it would become problematic.
 
Using the settings listed above, use QjackCtl to execute a script upon startup and shutdown to load/unload PulseAudio. Part of the reason users may wish to do this is that the above changes disable PulseAudio's automatic hardware detection modules. This particular setup is for using PulseAudio in an exclusive fashion with JACK, though the scripts could be modified to unload and load an alternate non-JACK setup, but killing and starting PulseAudio while programs might be using it would become problematic.
  +
 
 
{{Note|padevchooser in the following example is deprecated. It is replaced by pasystray}}
 
{{Note|padevchooser in the following example is deprecated. It is replaced by pasystray}}
  +
 
The following example could be used and modified as necessary as a startup script that daemonizes PulseAudio and loads the ''padevchooser'' program (optional, needs to be built from AUR) called {{ic|jack_startup}}:
+
The following example could be used and modified as necessary as a startup script that daemonizes PulseAudio and loads the ''padevchooser'' program (optional, needs to be built from AUR) called {{ic|jack_startup}}:
#!/bin/bash
+
#!/bin/bash
 
#Load PulseAudio and PulseAudio Device Chooser
 
#Load PulseAudio and PulseAudio Device Chooser
 
 
pulseaudio -D
 
pulseaudio -D
 
padevchooser&
 
padevchooser&
   
as well as a shutdown script to kill PulseAudio and the Pulse Audio Device Chooser, as another example called {{ic|jack_shutdown}} also in the home directory:
+
as well as a shutdown script to kill PulseAudio and the Pulse Audio Device Chooser, as another example called {{ic|jack_shutdown}} also in the home directory:
#!/bin/bash
+
#!/bin/bash
#Kill PulseAudio and PulseAudio Device Chooser
+
#Kill PulseAudio and PulseAudio Device Chooser
  +
pulseaudio --kill
 
  +
killall padevchooser
pulseaudio --kill
 
killall padevchooser
 
   
Both scripts need to be made executable:
+
Both scripts need to be made executable:
 
chmod +x jack_startup jack_shutdown
 
chmod +x jack_startup jack_shutdown
   
409行目: 405行目:
   
 
==PulseAudio と OSS==
 
==PulseAudio と OSS==
Add the following to {{ic|/etc/pulse/default.pa}}:
+
{{ic|/etc/pulse/default.pa}} に以下を追加してください:
 
load-module module-oss
 
load-module module-oss
   
  +
PulseAudio を再起動して、OSS デバイスの sink と source が定義されていることを確認してください。
Then start PulseAudio as usual, making sure that sinks and sources are defined for OSS devices.
 
   
==chroot から PulseAudio (e.g. 32-bit chroot in 64-bit install)==
+
==chroot から PulseAudio==
 
Since a chroot sets up an alternative root for the running/jailing of applications, PulseAudio must be installed within the chroot itself ({{ic|pacman -S pulseaudio}} within the chroot environment).
 
Since a chroot sets up an alternative root for the running/jailing of applications, PulseAudio must be installed within the chroot itself ({{ic|pacman -S pulseaudio}} within the chroot environment).
   
425行目: 421行目:
 
{{ic|/dev/shm}} should also be mounted for efficiency and good performance. Note that mounting /home would normally also allow sharing of the {{ic|~/.pulse}} folder.
 
{{ic|/dev/shm}} should also be mounted for efficiency and good performance. Note that mounting /home would normally also allow sharing of the {{ic|~/.pulse}} folder.
   
  +
PulseAudio は XDG_RUNTIME_DIR でソケットのパスを選択します。[[sudo]] を使って通常ユーザーとして chroot する場合は注意してください ([[Sudo#環境変数]]を参照)。
PulseAudio selects the path to the socket via XDG_RUNTIME_DIR, so be sure to drag it along when you chroot as a normal user using [[sudo]] (see [[Sudo#Environment_variables]]).
 
   
For specific direction on accomplishing the appropriate mounts, please refer to the wiki on installing a bundled 32-bit system, especially the [[Install_bundled_32-bit_system_in_Arch64#Allowing_32-bit_applications_access_to_64-bit_PulseAudio|additional section]] specific to PulseAudio.
+
For specific direction on accomplishing the appropriate mounts, please refer to the wiki on installing a bundled 32-bit system, especially the [[64ビット環境に32ビット環境をインストール#32ビットアプリケーションから64ビットの PulseAudio にアクセス|additional section]] specific to PulseAudio.
   
 
==PulseAudio サーバーの自動生成を無効化==
 
==PulseAudio サーバーの自動生成を無効化==
Some users may prefer to manually start the PulseAudio server before running certain programs and then stop the PulseAudio server when they are finished. A simple way to accomplish this is to edit {{ic|/etc/pulse/client.conf}} and change {{ic|1=autospawn = yes}} to {{ic|1=autospawn = no}}, and set {{ic|1=daemon-binary = /bin/true}}. Make sure the two lines are uncommented as well.
+
Some users may prefer to manually start the PulseAudio server before running certain programs and then stop the PulseAudio server when they are finished. A simple way to accomplish this is to edit {{ic|~/.config/pulse/client.conf}} or {{ic|/etc/pulse/client.conf}} and change {{ic|1=autospawn = yes}} to {{ic|1=autospawn=no}}. Make sure the line is uncommented as well.
{{hc|/etc/pulse/client.conf|<nowiki>
+
{{hc|~/.config/pulse/client.conf #or /etc/pulse/client.conf|<nowiki>
autospawn = no
+
autospawn=no
daemon-binary = /bin/true
 
 
</nowiki>}}
 
</nowiki>}}
 
Now you can manually start the pulseaudio server with
 
Now you can manually start the pulseaudio server with
439行目: 434行目:
 
and stop it with
 
and stop it with
 
$ pulseaudio --kill
 
$ pulseaudio --kill
  +
You may also have to move or delete a .desktop file in {{ic|/etc/xdg/autostart}} if it exists.
 
  +
This setting is also respected by the default pulseaudio dektop session startup script {{ic|start-pulseaudio-x11}} which is executed from {{ic|/etc/xdg/autostart/pulseaudio.desktop}}.
  +
  +
==pulseaudio デーモンの無効化==
  +
pulseaudio デーモンを完全に無効にして起動しないようにしたい場合、設定ファイル ({{ic|~/.config/pulse/client.conf}} または {{ic|/etc/pulse/client.conf}}) に {{ic|1=daemon-binary=/bin/true}} を追加してください:
  +
{{hc|~/.config/pulse/client.conf|2=daemon-binary=/bin/true}}
   
 
==ステレオからモノにリマップ==
 
==ステレオからモノにリマップ==
 
Remap a stereo input-sink to a mono sink by creating a virtual sink. It would be useful if you only have one speaker. Add to {{ic|/etc/pulse/default.pa}}:
 
Remap a stereo input-sink to a mono sink by creating a virtual sink. It would be useful if you only have one speaker. Add to {{ic|/etc/pulse/default.pa}}:
   
load-module module-remap-sink master=alsa_output.pci-0000_00_1f.5.analog-stereo sink_name=mono channels=2 channel_map=mono,mono
+
load-module module-remap-sink master=alsa_output.pci-0000_00_1f.5.analog-stereo sink_name=mono sink_properties="device.description='Mono'" channels=2 channel_map=mono,mono
 
# Optional: Select new remap as default
 
# Optional: Select new remap as default
 
set-default-sink mono
 
set-default-sink mono
452行目: 452行目:
 
Switch player between virtual mono sink and real stereo sink.
 
Switch player between virtual mono sink and real stereo sink.
   
  +
==左/右チャンネルの交換==
== PulseAudio as a minimal unintrusive dumb pipe to ALSA ==
 
  +
左と右のチャンネルが入れ替わる「リバースステレオ」と同じ設定です。
  +
  +
First, identify the card you want its channels swapped:
  +
$ cat /proc/asound/cards
  +
and use the name string for the device you wish to use (the one in square brackets, e.g. [Intel]).
  +
  +
Edit {{ic|/etc/pulse/default.pa}} and comment out module-hal-detect and module-detect lines.
  +
  +
Search for the commented-out line that starts "#load-module module-alsa-sink", uncomment it and change it to
  +
  +
load-module module-alsa-sink device=hw:[device name] channel_map=right,left
  +
Restart the pulseaudio deamon by running
  +
pulseaudio -k; pulseaudio -D
  +
  +
[https://www.freedesktop.org/wiki/Software/PulseAudio/FAQ/#index34h3 Pulseaudio FAQ: How can I reverse my left and right speaker channels?]
  +
  +
===default.pa を使う===
  +
別の方法でチャンネルを入れ替えることもできます [https://superuser.com/a/144252/161008]:
  +
  +
{{hc|~/.config/pulse/default.pa|2=
  +
#!/usr/bin/pulseaudio -nF
  +
  +
.include /etc/pulse/default.pa
  +
  +
load-module module-remap-sink sink_name=reverse-stereo master=0 channels=2 master_channel_map=front-right,front-left channel_map=front-left,front-right
  +
set-default-sink reverse-stereo
  +
}}
  +
  +
== PulseAudio を ALSA のダムパイプとする ==
 
Some people do not want to run PulseAudio all the time for various reasons. This example will turn the full fledged audio server into an unobstrusive dumb pipe to ALSA devices that automatically starts '''and''' stops itself when done, allowing applications that requires PulseAudio to fully function while not touching any ALSA setting nor setting itself as the default ALSA device.
 
Some people do not want to run PulseAudio all the time for various reasons. This example will turn the full fledged audio server into an unobstrusive dumb pipe to ALSA devices that automatically starts '''and''' stops itself when done, allowing applications that requires PulseAudio to fully function while not touching any ALSA setting nor setting itself as the default ALSA device.
   
499行目: 528行目:
 
.endif
 
.endif
 
</nowiki>}}
 
</nowiki>}}
  +
  +
== スピーカーとヘッドホンを両方とも接続してソフトウェアで切り替える ==
  +
  +
By design, Pulseaudio automatically turns off Line Out when headphones are plugged in and uses Headphone slider instead. You can observe this behavior in {{ic|alsamixer}}. What we want is to have Headphone and Line Out sliders working separately and at the same time. This is extremely useful if you want to remap Realtek's jacks to have, say, Rear Green for headphones and Blue for speakers (with the help of {{ic|hdajackretask}} from {{Pkg|alsa-tools}}).
  +
  +
To achieve this, you should directly edit Pulseaudio mixer's configuration.
  +
  +
1. We tell pulseaudio that headphones are always plugged in. Edit:
  +
  +
{{ic|/usr/share/pulseaudio/alsa-mixer/paths/analog-output-lineout.conf}}
  +
  +
Find:
  +
{{bc|<nowiki>
  +
[Jack Headphone]
  +
state.plugged = no
  +
state.unplugged = unknown
  +
</nowiki>}}
  +
  +
Change {{ic|no}} to {{ic|yes}}
  +
  +
2. By default, Line Out's volume controlled only by Master, and not by Line Out slider itself. We want to merge Line Out with Master.
  +
  +
Add this snippet to the end of the file:
  +
  +
{{bc|<nowiki>
  +
[Element Line Out]
  +
switch = mute
  +
volume = merge
  +
</nowiki>}}
  +
  +
3. We need to completely cut off Line Out when we use headphones. Edit:
  +
  +
{{ic|/usr/share/pulseaudio/alsa-mixer/paths/analog-output-headphones.conf}}
  +
  +
Add this snippet to the end of the file:
  +
  +
{{bc|<nowiki>
  +
[Element Line Out]
  +
switch = off
  +
volume = off
  +
</nowiki>}}
  +
  +
4. Like Pulseaudio, Alsa itself cuts off speakers when headphones are plugged in. Open {{ic|alsamixer}} (in case of Realtek HDA {{ic|alsamixer -c0}}) and change {{ic|Auto-Mute mode}} to {{ic|disabled}}.
  +
  +
5. Restart Pulseaudio
  +
  +
{{bc|<nowiki>
  +
$ pulseaudio -k
  +
$ pulseaudio --start
  +
</nowiki>}}
  +
  +
Now you have two separate ports on the same sink in pulseaudio. They mute each other, so you can switch to headphones and this will mute Line Out, and vice versa.
  +
To switch between ports you can use Gnome or Plasma sound mixer, or install appropriate desktop extension.
  +
  +
== 複数のユーザーが同時に PulseAudio を使えるようにする ==
  +
  +
ときにはデスクトップのメインユーザーとは別のユーザーを使ってソフトウェアを分離したいという場合があります。しかしながら、PulseAudio はデフォルトでは別のユーザーからの接続を拒否します。PulseAudio の UNIX ソケットを作成することで、メインユーザーで動作している PulseAudio デーモンに他のユーザーから接続することができるようになります。
  +
  +
まず、{{ic|/etc/pulse/default.pa}} または {{ic|~/.config/pulse/default.pa}} を編集して unix ソケットのディレクティブを追加してください:
  +
  +
{{hc|1=~/.config/pulse/default.pa|2=load-module module-native-protocol-unix auth-anonymous=1 socket=/tmp/pulse-socket}}
  +
  +
そして、作成した UNIX ソケットを別のユーザーから使うように PulseAudio をクライアントとして設定します:
  +
  +
{{hc|/home/''secondaryuser''/.config/pulse/client.conf|2=default-server = unix:/tmp/pulse-socket}}
  +
  +
PulseAudio デーモンを再起動すると、メインユーザーの PulseAudio デーモンを使って他のユーザーから音声を流すことができるようになります。

2018年6月4日 (月) 23:50時点における版

関連記事

目次

デフォルトの入力ソースを設定

利用可能な入力ソースの一覧を表示するには:

$ pacmd list-sources | grep -e 'index:' -e device.string -e 'name:'
  index: 0
    name: <input>
      device.string = "hw:2"
* index: 1
    name: <oss_input.dsp>
      device.string = "/dev/dsp"
  index: 2
    name: <alsa_output.pci-0000_04_01.0.analog-stereo.monitor>

インデックスの前の * は現在のデフォルト入力を示します。

システム全体のデフォルトとして設定するには、使用する入力ソースを /etc/pulse/default.pa に追加してください:

/etc/pulse/default.pa
...
set-default-source alsa_output.pci-0000_04_01.0.analog-stereo.monitor
...

一時的に使用するには:

$ pacmd "set-default-source alsa_output.pci-0000_04_01.0.analog-stereo.monitor"
ヒント: デフォルトのソースは、コマンド内で @DEFAULT_SOURCE@ として参照できます。たとえば: $ pactl set-source-mute @DEFAULT_SOURCE@ toggle

デフォルトの出力ソースを設定

index の前に * が付いている新しいソースの名前を確認:

$ pacmd list-sinks | grep -e 'name:' -e 'index:'
* index: 0
	name: <alsa_output.pci-0000_04_01.0.analog-stereo>
  index: 1
	name: <combined>

システム全体のデフォルトとして設定するには、以下を /etc/pulse/default.pa に追加してください:

/etc/pulse/default.pa
...
set-default-sink alsa_output.pci-0000_04_01.0.analog-stereo
...

設定したら変更を有効にするためにログアウト/ログインまたは PulseAudio を手動で再起動してください。

ノート:
  • デフォルトに設定されている sink には、インデックスの前に * 印が付きます。
  • sink の番号付けは永続的ではないため、default.pa ファイル内ではすべての sink を名前で識別する必要があります。
  • 実行時に素早く識別したい場合 (音量の制御など)、sink 名の代わりに sink index を使用することができます:
    $ pactl set-sink-volume 0 +3%
    $ pactl set-sink-volume 0 -3%
    $ pactl set-sink-mute 0 toggle
    
  • 通常の音量 (100%) を不必要に上書きしないようにするには、サウンドを管理するための別のユーティリティを使用する方がよいでしょう。詳細については フォーラムスレッド を参照してください。
ヒント: デフォルトの sink は @DEFAULT_SINK@ で指定することができます。たとえば: $ pactl set-sink-volume @DEFAULT_SINK@ +5%

HDMI とアナログの同時出力

PulseAudio は、複数のソースに同時に出力することができます。例えば、あるアプリケーションでは HDMI を使用するように設定しつつ、別のアプリケーションではアナログを使用するようにすることができます。また、複数のアプリケーションで同時に音声を受け取ることができます。

$ aplay -l
**** ハードウェアデバイス PLAYBACK のリスト ****
カード 0: Intel [HDA Intel], デバイス 0: ALC889A Analog [ALC889A Analog]
  サブデバイス: 0/1
  サブデバイス #0: subdevice #0
カード 0: Intel [HDA Intel], デバイス 1: ALC889A Digital [ALC889A Digital]
  サブデバイス: 1/1
  サブデバイス #0: subdevice #0
カード 0: Intel [HDA Intel], デバイス 3: HDMI 0 [HDMI 0]
  サブデバイス: 0/1
  サブデバイス #0: subdevice #0

もしくは pacmd コマンドを使用すると:

$ pacmd list-sinks  | grep -e 'name:'  -e 'alsa.device ' -e 'alsa.subdevice '
name: <alsa_output.pci-0000_00_1b.0.analog-stereo>
	alsa.subdevice = "0"
	alsa.device = "0"

このような構成では pavucontrol の Configuration > Internal Audio で選択されているものがデフォルトのデバイスになります。Load pavucontrol > Configuration を選択し、プロファイルとして HDMI を選択してください。

アナログデバイスをセカンダリソースとして設定するには、/etc/pulse/default.pa の最初の方に以下の行を追加します (他のモジュールよりも先にロードさせるため):

### Load analog device
load-module module-alsa-sink device=hw:0,0
load-module module-combine-sink sink_name=combined
set-default-sink combined

PulseAudio を再起動し pavucontrol を実行して「出力デバイス」タブを選択します。3つの設定が表示されます:

  1. Internal Audio Digital Stereo (HDMI)
  2. Internal Audio
  3. Simultaneous output to Internal Audio Digital Stereo (HDMI), Internal Audio

MPlayer, VLC, mpd などの PulseAudio を使用するプログラムを起動し「再生」タブに切り替えます。実行中のプログラムからドロップダウンリストを使って3つのソースのうちの1つを選択することができるはずです。

詳しくは PulseAudio FAQこちらのスレッド を参照してください。

HDMI 出力の設定

ftp://download.nvidia.com/XFree86/gpu-hdmi-audio-document/gpu-hdmi-audio.html#_issues_in_pulseaudio に書かれているように、HDMI 端子が一番最初の出力端子でないかぎり、PulseAudio は HDMI 音声出力をサポートしている特定のグラフィックカードで音声を鳴らすことができません。最初の HDMI 出力だけが選択されるという PulseAudio のバグが原因です。

NVIDIA 製のカードで主に発生しますが、フォーラムスレッド に書かれているように他のカードでも発生することがあります。NVIDIA のカードをケーススタディとして取り上げますが、他のカードでも同じように解決することができます。

HDMI 出力の確認

利用可能なカードを表示して出力を確認してください:

# aplay -l

出力例:

**** List of PLAYBACK Hardware Devices ****
card 0: NVidia [HDA NVidia], device 0: ALC1200 Analog [ALC1200 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: NVidia [HDA NVidia], device 3: ALC1200 Digital [ALC1200 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia_1 [HDA NVidia], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia_1 [HDA NVidia], device 7: HDMI 0 [HDMI 0]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 1: NVidia_1 [HDA NVidia], device 8: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia_1 [HDA NVidia], device 9: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

適切なカードでテスト

どれが TV やモニターに出力しているのかテストする必要があります:

# aplay -D plughw:1,3 /usr/share/sounds/alsa/Front_Right.wav

1 は前のセクションで確認した card の値、同じく 3 は device に置き換えてください。音がでない場合、別の device で試してみてください。

PulseAudio を手動で設定して Nvidia HDMI を検出

Having identified which HDMI device is working, PulseAudio can be forced to use it via an edit to /etc/pulse/default.pa:

# load-module module-alsa-sink device=hw:1,7

where the 1 is the card and the 7 is the deivce found to work in the previous section

restart pulse audio

$ pulseaudio -k
$ pulseaudio --start

open the sound settings manager, make sure that under the hardware tab the graphics cards HDMI audio is set to "Digital Stereo (HDMI) Output" ( My graphics card audio is called "GF100 High Definition Audio Controller"

Then, open the output tab. There should now be two HDMI outputs for the graphics card. Test which one works by selecting one of them, and then using a program to play audio. For example, use VLC to play a movie, and if it does not work, then select the other.

サラウンドサウンドシステム

大抵の人はサラウンド対応のサウンドカードを持っていても、2チャンネルのスピーカーしか持っていないため、PulseAudio はサラウンド音声の設定をデフォルトとしません。全てのチャンネルを有効にするには、/etc/pulse/daemon.conf を編集して default-sample-channels 行をアンコメント (行頭のセミコロンを削除) して、5.1 チャンネルなら値を 6 に、7.1 チャンネルなら 8 に設定してください:

# Default
default-sample-channels=2
# For 5.1
default-sample-channels=6
# For 7.1
default-sample-channels=8

チャンネルが正しくマッピングされなかったり、pavucontrol で個々のチャンネルのボリュームコントロールが機能しない場合、HDMI とアナログサウンドカードがあるのであれば、以下の行を /etc/pulse/default.pa に追加してみてください:

load-module module-combine channels=6 channel_map=front-left,front-right,rear-left,rear-right,front-center,lfe

上記は 5.1ch での設定例です。

設定を編集したら PulseAudio を再起動してください。

フロント/リアの分割

Connect speakers to front analog output and headphones to rear output. It would be useful to split front/rear to separate sinks. Add to /etc/pulse/default.pa:

load-module module-remap-sink sink_name=speakers sink_properties="device.description='Speakers'" remix=no master=alsa_output.pci-0000_05_00.0.analog-surround-40 channels=2 master_channel_map=front-left,front-right channel_map=front-left,front-right
load-module module-remap-sink sink_name=headphones sink_properties="device.description='Headphones'" remix=no master=alsa_output.pci-0000_05_00.0.analog-surround-40 channels=2 master_channel_map=rear-left,rear-right channel_map=front-left,front-right

alsa_output.pci-0000_05_00.0.analog-surround-40 は 'pacmd list-sinks' で表示されるサウンドカードの名前に置き換えてください。

Now you have 2 additional sinks which can be used separately. You can choose 'sink_name' freely, as long as there is no sink with that name already. The 'remix' parameter controls whether the audio should be down-/upmixed to match the channels in the sink.

ヒント: pulseaudio が master sink not found と表示する場合、リマップの行をコメントアウトしてから、PulseAudio を起動してカードの出力が正しく設定されているか確認してください (例: アナログサラウンド 4.0)。もしくは、sink 名の代わりに sink index を使ってみてください。

7.1 を 5.1+2.0 に分割

上記の例と同じように、7.1 構成を 5.1 サラウンドとステレオ出力に分割することもできます。使用しているカードを 7.1 モードに設定してから、以下の行を /etc/pulse/default.pa に追加してください:

load-module module-remap-sink sink_name=Surround sink_properties="device.description='Surround'" remix=no master=alsa_output.pci-0000_00_14.2.analog-surround-71 channels=6 master_channel_map=front-left,front-right,rear-left,rear-right,front-center,lfe channel_map=front-left,front-right,rear-left,rear-right,front-center,lfe
load-module module-remap-sink sink_name=Stereo sink_properties="device.description='Stereo'" remix=no master=alsa_output.pci-0000_00_14.2.analog-surround-71 channels=2 master_channel_map=side-left,side-right channel_map=front-left,front-right

alsa_output.pci-0000_00_14.2 は使用しているサウンドカードの名前に置き換えてください (pacmd list-sinks で確認できます)。上記の設定は 5.1 sink ではフロント/リア/センター+LFE (緑/黒/橙) のジャックを使い stereo sink ではサイドスピーカー (灰) のジャックを使います。stereo sink 用に音声はステレオにダウンミックスされますが、5.1 出力には何も手を加えません。

ヒント: pulseaudio が master sink not found と表示する場合、リマップの行をコメントアウトしてから、PulseAudio を起動してカードの出力がアナログサラウンド 7.1 に設定されているか確認してください。もしくは、sink 名の代わりに sink index を使ってみてください。

LFE リミックスの無効化

デフォルトで、PulseAudio はチャンネル数を default-sample-channels にリミックスし、バージョン 7 から LFE チャンネルもリミックスされます。LFE リミックスを無効化したい場合、以下の行をアンコメントして:

; enable-lfe-remixing = yes

以下のように yes を no に置き換えてください:

enable-lfe-remixing = no

設定したら PulseAudio を再起動してください。

バイノーラルヘッドフォン

ladspa-bs2bAUR にはステレオヘッドホンでサラウンド音声をシミュレートするプラグインが入っています。使用するには、まずヘッドホンを確認:

$ pacmd list-sinks | grep -e 'name:'
name: <alsa_output.pci-0000_00_1b.0.iec958-ac3-surround-51>
name: <alsa_output.pci-0000_00_1b.0.iec958-ac3-surround-51.equalizer>
name: <bluez_sink.00_1F_82_28_93_51>

プラグインをロード (new sink_name is up to you, master=headphone's sink name):

pacmd load-module module-ladspa-sink sink_name=binaural master=bluez_sink.00_1F_82_28_93_51 plugin=bs2b label=bs2b control=700,4.5

pavucontrol を使ってストリームを新しい sink に転送、または:

pactl move-sink-input $INPUTID $BINAURALSINKNAME

ネットワークを介して PulseAudio

PulseAudio のユニークな機能のひとつとして、TCP 経由で LAN 内のサーバーで動作している PulseAudio デーモンにクライアントから音声をストリーミングすることができます。クライアントとサーバーのシステム時刻が正しくないと、音声ストリームが途切れたり音が全く出ないことがあるので注意してください。

ストリーミングを行うには、module-native-protocol-tcp を有効にする必要があります。

TCP サポート (networked sound)

TCP モジュールを有効にするために、クライアントとサーバーの両方で /etc/pulse/default.pa に以下を追加してください (既に行が存在する場合はアンコメント):

load-module module-native-protocol-tcp

For this to work, it is a requirement that both the client and server share the same cookie. Ensure that the clients and server share the same cookie file found under ~/.config/pulse/cookie. It does not matter whose cookie file you use (the server or a client's), just that the server and client(s) share the same one.

Note: If experiencing trouble connecting, use (on server)

pacmd list-modules

TCP サポートと匿名クライアント

If it is undesirable to copy the cookie file from clients, anonymous clients can access the server by giving these parameters to module-native-protocol-tcp on the server (again in /etc/pulse/default.pa):

load-module module-native-protocol-tcp "auth-ip-acl=127.0.0.1;192.168.0.0/24 auth-anonymous=1"

Change the LAN IP subnet to match that of the those clients you wish to have access to the server.

Zeroconf (Avahi) パブリッシング

PulseAudio のリモートサーバーを PulseAudio Device Chooser (pasystray) に表示させるには、適当な zeroconf モジュールをロードして、Avahi デーモンを有効化してください。

クライアントとサーバーの両方で pulseaudio-zeroconf パッケージをインストールして、avahi-daemon の systemd ユニットを起動有効化してください。

サーバー側で、load-module module-zeroconf-publish/etc/pulse/default.pa に追加して、クライアント側で、load-module module-zeroconf-discover/etc/pulse/default.pa に追加してください。これで適切な sink を選択することでストリームや音声出力がリモートの PulseAudio サーバーに転送されます。

If you have issues with the remote syncs appearing on the client, try restarting the Avahi daemon on the server to rebroadcast the available interfaces.

サーバーの選択

Run the graphical PulseAudio Volume Control pavucontrol. Under the Output Devices tab, you should see the local and remote output devices. Under the Playback tab, to the left of the "X" Mute Audio button, you should see a box containing the name of an output device. That box is actually a button, which will display a drop-down radio-button list of the available output devices, with one output device selected. Selecting an output device from the list will allow the audio stream to be switched to the PulseAudio server associated with that output device. This control is not at all obvious until you have used it, and is especially useful with a remote Headless sound server.

Similarly, under the Input Devices tab, local and remote input devices will be seen. And under the Recording tab, there will be a box, to the left of the "X" Mute Audio button, with the name of an input device which is actually a button which will display a drop-down radio-button list of available input devices.

Run pavucontrol on the local or remote host associated with the audio stream to be directed. For instance, run pavucontrol on the remote host to direct the remote audio output to the local host. Run pavucontrol on the local host to direct the local audio output to some remote host.

Setting up simultaneous inputs or outputs is a different thing. Search about "monitor" and "module-combine-sink" for that.

ローカルの X クライアントで使用する PulseAudio サーバーを切り替える

X の中からクライアントで使用するサーバーを切り替えるには pax11publish コマンドを使います。例えば、デフォルトのサーバーからホストネーム foo のサーバーに切り替えるには:

$ pax11publish -e -S foo

もしくは、デフォルトのサーバーに戻すには:

$ pax11publish -e -r

上記のコマンドは (上で説明しているのと同じように) PulseAudio サーバーで音声をストリーミングする代わりに、X11 ルートウィンドウの PulseAudio 変数を編集します。それによって PulseAudio のクライアントライブラリが localhost 以外の PulseAudio サーバーに接続するようになります。プログラムはローカルの pulseaudio プロセスに依存しなくなるため、ローカルのプロセスは停止してかまいません。pactl, pacmd, pavucontrol などのプログラムでリモートの PulseAudio サーバーを制御するには適切な PULSE_SERVER 変数/X 変数を指定して実行する必要があります。

Note that for the switch to become apparent, the programs using Pulse must be restarted, or their PulseAudio client library otherwise reinitialized (completely stopping and restarting playback may be enough). To make this setting permanent, edit default-server in ~/.config/pulse/client.conf or /etc/pulse/client.conf.

何もかもが失敗しているような場合

The following is a quick fix and NOT a permanent solution

On the server:

$ paprefs 

Go to Network Access -> Enable access to local sound devices (Also check both 'Allow discover' and 'Don't require authentication').

On the client:

$ export PULSE_SERVER=server.ip && mplayer test.mp3

ALSA モニターのソース

To be able to record from a monitor source (a.k.a. "What-U-Hear", "Stereo Mix"), use pactl list to find out the name of the source in PulseAudio (e.g. alsa_output.pci-0000_00_1b.0.analog-stereo.monitor). Then add lines like the following to /etc/asound.conf or ~/.asoundrc:

pcm.pulse_monitor {
  type pulse
  device alsa_output.pci-0000_00_1b.0.analog-stereo.monitor
}

ctl.pulse_monitor {
  type pulse
  device alsa_output.pci-0000_00_1b.0.analog-stereo.monitor
}

Now you can select pulse_monitor as a recording source.

Alternatively, you can use pavucontrol to do this: make sure you have set up the display to "All input devices", then select "Monitor of [your sound card]" as the recording source.

特定の出力のモニター

It is possible to monitor a specific output, for example to stream audio from a music player into a VOIP application. Simply create a null output device:

pactl load-module module-null-sink sink_name=<name>

In Pulseaudio Volume Control (pavucontrol), under the "Playback" tab, change the output of an application to <name>, and in the recording tab change the input of an application to "Monitor of <name>". Audio will now be outputted from one application into the other.

PulseAudio と JACK

音楽を作曲・編集するときは JACK Audio Connection Kit が人気があり、Linux のオーディオアプリケーションによって広くサポートされています。PulseAudio と同じような機能を提供しますが、特にプロフェッショナルなオーディオ作業環境に特化しています。音楽をモニタリングするときの遅延を少なくして、マルチ I/O を備えたサウンドデバイスの入出力を多彩に制御できます。

KXStudio を使う方法

JACK の開発者 によって公式に推奨されている方法です。

jack2-dbusjack2 パッケージの両方で動作します。

JACK には ALSA と PulseAudio、そして JACK とブリッジする機能がネイティブで備わっています。JACK と PulseAudio を両方動かして同時に出力することが可能であり、設定の編集やターミナルコマンドは必要ありません。

qjackctl を使用している場合、先に進む前にアンインストールすることが推奨されます。

まずは cadencepulseaudio-jack をインストールしてください。インストールして起動したら、ウィンドウ右下の JACK ブリッジ設定を探してください。ALSA の音声ブリッジを ALSA -> PulseAudio -> JACK と設定して PulseAudio のブリッジを有効にしてください。pavucontrol で Jack sink の全ての出力デバイスと Jack input の全ての入力デバイスをミュートにしてください。Force Restart ボタンを使って JACK を起動して、問題なく起動すれば PulseAudio プログラムは JACK に出力するようになっているはずです。

sink を手動で設定する方法

この設定は jackdbus (D-Bus のサポートを有効にしてコンパイルされた JACK2) でのみ機能します。また、pulseaudio-jack パッケージが必要です。/etc/pulse/default.pa に以下の行を記述してください:

load-module module-jackdbus-detect options

options はモジュールによってサポートされているオプションならなんでもかまいません。通常は channels=2 です。

Jack-DBUS Packaging ページより:

Server auto-launching is implemented as D-Bus call that auto-activates JACK D-Bus service, in case it is not already started, and starts the JACK server. Correct interaction with PulseAudio is done using a D-Bus based audio card "acquire/release" mechanism. When JACK server starts, it asks this D-Bus service to acquire the audio card and PulseAudio will unconditionally release it. When JACK server stops, it releases the audio card that can be grabbed again by PulseAudio.

module-jackdbus-detect.so は jackdbus が起動・停止したときに動的に module-jack-sink と module-jack-source をロード・アンロードします。

PulseAudio の音が鳴らない場合、pavucontrol で適当なプログラムが再生タブに現れていることを確認してください。存在しない場合、以下を ~/.asoundrc または /etc/asound.conf に追加して ALSA を PulseAudio にリダイレクトしてください:

pcm.pulse {
    type pulse
}

ctl.pulse {
    type pulse
}

pcm.!default {
    type pulse
}
ctl.!default {
    type pulse
}

上記の設定で上手く行かない場合、pavucontrol で再生タブを確認してプログラムがオーディオカード (JACK が制御するため、機能しません) ではなく PulseAudio JACK Sink に出力するようになっているか確認してください。また、JACK のグラフで PulseAudio JACK Source がシステムオーディオ出力に接続されていることを確認してください。

シェルスクリプトを使う方法

This method allows JACK and PulseAudio to output at the same time. It mostly relies on shell scripts that are automatically run by QJackCTL to manage aspects of how the JACK sinks and PulseAudio behave.

The basic idea is that killing PulseAudio is a bad idea because it may crash any apps using PulseAudio and disrupt any audio playing.

The flow of how this setup works:

  1. PulseAudio releases the sound card
  2. JACK grabs sound card and starts up
  3. script redirects PulseAudio to JACK
  4. manually send PulseAudio apps to JACK output (pavucontrol may come in helpful for this)
  5. use JACK programs etc
  6. via script, stop redirecting PulseAudio to JACK
  7. stop JACK and release sound card
  8. PulseAudio grabs sound card and reroutes audio to it directly

With QJackCTL, set up these scripts:

pulse-jack-pre-start.sh set it up as the execute script on startup script

#!/bin/bash
pacmd suspend true

pulse-jack-post-start.sh set this one up as execute script after startup

#!/bin/bash
pactl load-module module-jack-sink channels=2
pactl load-module module-jack-source channels=2
pacmd set-default-sink jack_out
pacmd set-default-source jack_in

pulse-jack-pre-stop.sh "execute script on shutdown"

#!/bin/bash
SINKID=$(pactl list | grep -B 1 "Name: module-jack-sink" | grep Module | sed 's/[^0-9]//g')
SOURCEID=$(pactl list | grep -B 1 "Name: module-jack-source" | grep Module | sed 's/[^0-9]//g')
pactl unload-module $SINKID
pactl unload-module $SOURCEID
sleep 5

pulse-jack-post-stop.sh "execute script after shutdown"

#!/bin/bash
pacmd suspend false

PulseAudio を終了する方法

This method relies on shell scripts to automatically kill PulseAudio when JACK is started, and automatically restart it when JACK is stopped. This will result in lower CPU usage than having both running, but can cause errors in already running PulseAudio application and does not allow simultaneous output of both.

Using the settings listed above, use QjackCtl to execute a script upon startup and shutdown to load/unload PulseAudio. Part of the reason users may wish to do this is that the above changes disable PulseAudio's automatic hardware detection modules. This particular setup is for using PulseAudio in an exclusive fashion with JACK, though the scripts could be modified to unload and load an alternate non-JACK setup, but killing and starting PulseAudio while programs might be using it would become problematic.

ノート: padevchooser in the following example is deprecated. It is replaced by pasystray

The following example could be used and modified as necessary as a startup script that daemonizes PulseAudio and loads the padevchooser program (optional, needs to be built from AUR) called jack_startup:

#!/bin/bash	
#Load PulseAudio and PulseAudio Device Chooser
pulseaudio -D
padevchooser&

as well as a shutdown script to kill PulseAudio and the Pulse Audio Device Chooser, as another example called jack_shutdown also in the home directory:

#!/bin/bash	
#Kill PulseAudio and PulseAudio Device Chooser		
pulseaudio --kill	
killall padevchooser	

Both scripts need to be made executable:

chmod +x jack_startup jack_shutdown

then with QjackCtl loaded, click on the Setup button and then the Options tab and tick both "Execute Script after Startup:" And "Execute Script on Shutdown:" and put either use the ... button or type the path to the scripts (assuming the scripts are in the home directory) ~/jack_startup and ~/jack_shutdown making sure to save the changes.

PulseAudio と OSS

/etc/pulse/default.pa に以下を追加してください:

load-module module-oss

PulseAudio を再起動して、OSS デバイスの sink と source が定義されていることを確認してください。

chroot から PulseAudio

Since a chroot sets up an alternative root for the running/jailing of applications, PulseAudio must be installed within the chroot itself (pacman -S pulseaudio within the chroot environment).

PulseAudio, if not set up to connect to any specific server (this can be done in /etc/pulse/client.conf, through the PULSE_SERVER environment variable, or through publishing to the local X11 properties using module-x11-publish), will attempt to connect to the local pulse server, failing which it will spawn a new pulse server. Each pulse server has a unique ID based on the machine-id value in /var/lib/dbus. To allow for chrooted apps to access the pulse server, the following directories must be mounted within the chroot:-

/run
/var/lib/dbus
/tmp
~/config/.pulse

/dev/shm should also be mounted for efficiency and good performance. Note that mounting /home would normally also allow sharing of the ~/.pulse folder.

PulseAudio は XDG_RUNTIME_DIR でソケットのパスを選択します。sudo を使って通常ユーザーとして chroot する場合は注意してください (Sudo#環境変数を参照)。

For specific direction on accomplishing the appropriate mounts, please refer to the wiki on installing a bundled 32-bit system, especially the additional section specific to PulseAudio.

PulseAudio サーバーの自動生成を無効化

Some users may prefer to manually start the PulseAudio server before running certain programs and then stop the PulseAudio server when they are finished. A simple way to accomplish this is to edit ~/.config/pulse/client.conf or /etc/pulse/client.conf and change autospawn = yes to autospawn=no. Make sure the line is uncommented as well.

~/.config/pulse/client.conf #or /etc/pulse/client.conf
autospawn=no

Now you can manually start the pulseaudio server with

$ pulseaudio --start

and stop it with

$ pulseaudio --kill

This setting is also respected by the default pulseaudio dektop session startup script start-pulseaudio-x11 which is executed from /etc/xdg/autostart/pulseaudio.desktop.

pulseaudio デーモンの無効化

pulseaudio デーモンを完全に無効にして起動しないようにしたい場合、設定ファイル (~/.config/pulse/client.conf または /etc/pulse/client.conf) に daemon-binary=/bin/true を追加してください:

~/.config/pulse/client.conf
daemon-binary=/bin/true

ステレオからモノにリマップ

Remap a stereo input-sink to a mono sink by creating a virtual sink. It would be useful if you only have one speaker. Add to /etc/pulse/default.pa:

load-module module-remap-sink master=alsa_output.pci-0000_00_1f.5.analog-stereo sink_name=mono sink_properties="device.description='Mono'" channels=2 channel_map=mono,mono
# Optional: Select new remap as default
set-default-sink mono

(replace alsa_output.pci-0000_00_1f.5.analog-stereo in the sound card name shown from pacmd list-sinks)

Switch player between virtual mono sink and real stereo sink.

左/右チャンネルの交換

左と右のチャンネルが入れ替わる「リバースステレオ」と同じ設定です。

First, identify the card you want its channels swapped:

$ cat /proc/asound/cards

and use the name string for the device you wish to use (the one in square brackets, e.g. [Intel]).

Edit /etc/pulse/default.pa and comment out module-hal-detect and module-detect lines.

Search for the commented-out line that starts "#load-module module-alsa-sink", uncomment it and change it to

load-module module-alsa-sink device=hw:[device name] channel_map=right,left

Restart the pulseaudio deamon by running

pulseaudio -k; pulseaudio -D

Pulseaudio FAQ: How can I reverse my left and right speaker channels?

default.pa を使う

別の方法でチャンネルを入れ替えることもできます [1]:

~/.config/pulse/default.pa
#!/usr/bin/pulseaudio -nF

.include /etc/pulse/default.pa

load-module module-remap-sink sink_name=reverse-stereo master=0 channels=2 master_channel_map=front-right,front-left channel_map=front-left,front-right
set-default-sink reverse-stereo

PulseAudio を ALSA のダムパイプとする

Some people do not want to run PulseAudio all the time for various reasons. This example will turn the full fledged audio server into an unobstrusive dumb pipe to ALSA devices that automatically starts and stops itself when done, allowing applications that requires PulseAudio to fully function while not touching any ALSA setting nor setting itself as the default ALSA device.

This configuration tells native PA clients to autospawn the daemon when they need it, then the daemon is configured to autoexit as soon as all clients have disconnected. The daemon itself uses a plain simple static configuration that uses your configured pcm.!default ALSA devices and nothing more. No replacement of ALSA's default, no playing with mixer levels, nothing but record/playback. Also make sure pulseaudio-alsa is not installed so standard ALSA clients don't default to pulse. alsamixer functions properly as well as any other ALSA clients. Also make sure common frameworks like Xine, Gstreamer and Phonon are configured to use ALSA: by default if they detect PulseAudio is installed they will try to use it before ALSA.

/etc/pulse/daemon.conf
# Replace these with the proper values
exit-idle-time = 0 # Exit as soon as unneeded
flat-volumes = yes # Prevent messing with the master volume
/etc/pulse/client.conf
# Replace these with the proper values

# Applications that uses PulseAudio *directly* will spawn it,
# use it, and pulse will exit itself when done because of the
# exit-idle-time setting in daemon.conf
autospawn = yes
/etc/pulse/default.pa
# Replace the *entire* content of this file with these few lines and
# read the comments

.fail
    # Set tsched=0 here if you experience glitchy playback. This will
    # revert back to interrupt-based scheduling and should fix it.
    #
    # Replace the device= part if you want pulse to use a specific device
    # such as "dmix" and "dsnoop" so it doesn't lock an hw: device.
    
    # INPUT/RECORD
    load-module module-alsa-source device="default" tsched=1
    
    # OUTPUT/PLAYBACK
    load-module module-alsa-sink device="default" tsched=1 
    
    # Accept clients -- very important
    load-module module-native-protocol-unix

.nofail
.ifexists module-x11-publish.so
    # Publish to X11 so the clients know how to connect to Pulse. Will
    # clear itself on unload.
    load-module module-x11-publish
.endif

スピーカーとヘッドホンを両方とも接続してソフトウェアで切り替える

By design, Pulseaudio automatically turns off Line Out when headphones are plugged in and uses Headphone slider instead. You can observe this behavior in alsamixer. What we want is to have Headphone and Line Out sliders working separately and at the same time. This is extremely useful if you want to remap Realtek's jacks to have, say, Rear Green for headphones and Blue for speakers (with the help of hdajackretask from alsa-tools).

To achieve this, you should directly edit Pulseaudio mixer's configuration.

1. We tell pulseaudio that headphones are always plugged in. Edit:

/usr/share/pulseaudio/alsa-mixer/paths/analog-output-lineout.conf

Find:

[Jack Headphone]
state.plugged = no
state.unplugged = unknown

Change no to yes

2. By default, Line Out's volume controlled only by Master, and not by Line Out slider itself. We want to merge Line Out with Master.

Add this snippet to the end of the file:

[Element Line Out]
switch = mute
volume = merge

3. We need to completely cut off Line Out when we use headphones. Edit:

/usr/share/pulseaudio/alsa-mixer/paths/analog-output-headphones.conf

Add this snippet to the end of the file:

[Element Line Out]
switch = off
volume = off

4. Like Pulseaudio, Alsa itself cuts off speakers when headphones are plugged in. Open alsamixer (in case of Realtek HDA alsamixer -c0) and change Auto-Mute mode to disabled.

5. Restart Pulseaudio

$ pulseaudio -k
$ pulseaudio --start

Now you have two separate ports on the same sink in pulseaudio. They mute each other, so you can switch to headphones and this will mute Line Out, and vice versa. To switch between ports you can use Gnome or Plasma sound mixer, or install appropriate desktop extension.

複数のユーザーが同時に PulseAudio を使えるようにする

ときにはデスクトップのメインユーザーとは別のユーザーを使ってソフトウェアを分離したいという場合があります。しかしながら、PulseAudio はデフォルトでは別のユーザーからの接続を拒否します。PulseAudio の UNIX ソケットを作成することで、メインユーザーで動作している PulseAudio デーモンに他のユーザーから接続することができるようになります。

まず、/etc/pulse/default.pa または ~/.config/pulse/default.pa を編集して unix ソケットのディレクティブを追加してください:

~/.config/pulse/default.pa
load-module module-native-protocol-unix auth-anonymous=1 socket=/tmp/pulse-socket

そして、作成した UNIX ソケットを別のユーザーから使うように PulseAudio をクライアントとして設定します:

/home/secondaryuser/.config/pulse/client.conf
default-server = unix:/tmp/pulse-socket

PulseAudio デーモンを再起動すると、メインユーザーの PulseAudio デーモンを使って他のユーザーから音声を流すことができるようになります。