- Loopback 2 0 0 – Route Audio Between Applications Across Two
- Loopback 2 0 0 – Route Audio Between Applications Across Multiple
- Loopback 2 0 0 – Route Audio Between Applications Across Multiple
- Loopback 2 0 0 – Route Audio Between Applications Across The Country
To Computer / From Computer Audio Streams
MOTU AVB audio interfaces provide powerful mixing and routing options to meet a variety of audio scenarios. The Routing matrix found in the Routing Tab of the MOTU AVB Discovery App allows you to route signal to and from all of the available inputs and outputs on your interface.
R2#show ip ospf neighbor detail Neighbor 192.168.13.1, interface address 192.168.12.1 In the area 0 via interface GigabitEthernet0/1 Neighbor priority is 1, State is FULL, 6 state changes DR is 192.168.12.2 BDR is 192.168.12.1 Options is 0x12 in Hello (E-bit, L-bit) Options is 0x52 in DBD (E-bit, L-bit, O-bit) LLS Options is 0x1 (LR) Dead timer. Loopback 2 review: Elevates the interface for sophisticated sound routing in macOS Pro-level audio input mixer app for Mac is useful for musicians, DJs, audio engineers, and podcasters.
Along with the physical inputs and outputs on the device itself, the built-in 48-channel on-board digital mixer, and any enabled banks of AVB audio streams, the To Computer and From Computer audio streams are important I/O options to be familiar with, as they are required for sending signal to or from your computer.
- Aug 01, 2020 Create virtual audio devices to take the sound from applications and audio input devices, then send it to audio processing applications. Loopback is a software solution that provides the power of a high-end studio mixing board. Virtual audio devices can provide up to 64 channels of input and output.
- It came in 2-track and 16-track versions, and let you route audio output—including from applications—into any track, and then use that as an input to any program, or even the system.
The Audio Interface device preset provides a default setting to send audio to and from your computer, however for further control, a deeper understanding of the relationship between these audio streams and your computer is necessary.
This allows one to route audio from a source directly back to a sink. This module performs adaptive resampling to adjust for slight differences in the clock speeds of the source and sink devices. This prevents the latency from drifting too far from the target specified in the latencymsec parameter.
Before doing any routing, if you intend to send audio to a recording application (like Digital Performer or any other DAW), OR intend to play audio back from your computer in any way (even through applications as simple as iTunes, Quicktime, or when streaming content from the internet), you need to enable To Computer and/or From Computer audio streams. In the Device Tab of the MOTU AVB Web App, scroll down to the Computer Setup section, and set the desired number of To Computer and From Computer audio streams.
Here are a few considerations for deciding how many audio streams are necessary:
Here are a few considerations for deciding how many audio streams are necessary:
- If you are simply playing audio through any application on your computer, other than your DAW, you likely only need two From Computer streams enabled for stereo playback.
- A larger number of From Computer audio streams are necessary when working in your DAW, and you intend for the ability to route tracks in your project to multiple destinations, (more than one stereo stream).
- Enabled To Computer audio streams should at least equal the number of individual audio tracks you would like to record at once in your DAW, (stereo tracks equal 2 streams).
- Generally, there is no issue with enabling more streams than necessary, however this could contribute to high DSP usage if other features on your AVB interface are simultaneously in use.
Via USB Connection*Via ThunderBolt Connection
Note: As of the firmware version v1.2.0, all AVB models have three USB Modes. You can enable 24 channels (in and out) at sample rates 44.1 - 192 kHz, 32 channel at sample rates 44.1 - 96 kHz, or 64 channels at sample rates 44.1 - 48 kHz. You can define which USB Mode the interface is running in from the Configuration Section of the Device Tab. Be sure to download the latest firmware for your unit, which you can find here.
When connecting your AVB interface via ThunderBolt, you can access to up to 128 channels in and out.
When connecting your AVB interface via ThunderBolt, you can access to up to 128 channels in and out.
Once audio streams are enabled in the Computer Setup section, swing over to the Routing Tab of the MOTU AVB Discovery App. You will now find a 'From Computer' bank of inputs listed across the top of the routing grid, and a 'To Computer' bank of outputs listed on the left; (USB) or (TB) will be added to its title to specify the connection method being used between your interface and the computer.
In most examples, you will generally only use the 'From Computer 1-2' audio streams. This stereo pair will carry the audio coming from your computer (if your AVB interface is set as the primary device for system's sound playback), or if you have designated the AVB interface as the device for your DAW's session.
Expand the From Computer input bank to see each From Computer audio stream, and make a connection between the From Computer 1-2 audio streams, and the physical output channels you want to monitor playback through. (It is generally easiest to expand the output bank on the left side as well, so you can see the individual output channels.) For example, click on the intersection between From Computer 1 and Main Out L, as well as the intersection between From Computer 2 and Main Out R to route your computer's playback to the Main Outs, as shown below.
![Loopback 2 0 0 – route audio between applications across multiple Loopback 2 0 0 – route audio between applications across multiple](https://photos5.appleinsider.com/gallery/28726-45311-003-Combining-devices-into-one-source-l.jpg)
Once done, when playing audio through iTunes for example, you will see signal activity on the From Computer 1-2 indicator lights and matching signal on the Main Out 1-2's indicator lights.
Often, you may want the same stereo signal to be sent to multiple outputs at the same time. To quickly achieve this, patch the same From Computer 1-2 audio streams to another pair of physical outputs such as the two sets of Phones and the Monitor outputs on the 1248. This stereo signal can also be sent to the Mix In channels (not shown) to feed the interface's on-board mixer for further processing.
If you are working with a larger number of From Computer audio streams (perhaps to route multiple tracks in your DAW to different physical outputs on your interface), the same theory applies. Each From Computer audio stream can be routed directly to its own physical output.
For example, if you own a 1248, and want to process audio from your DAW through a hardware signal processor, each track in your DAW can be routed to its own From Computer audio stream. Then in the MOTU AVB Web App, route each From Computer audio stream directly to one of the 1248's Analog Outputs as shown below.
Configuring the 'To Computer' audio streams is done in a similar manner and is required for your computer to 'see' any input from your device.
MOTU AVB Theory: When you plug a source into a physical input on your interface, this input is not automatically detected by your DAW or other computer application. This is because your AVB interface can take that input signal and send it anywhere else (on-board mixer, AVB streams, etc.) without the computer ever accessing it. The computer is a specific destination where signal can be sent to, and sending signal to the computer needs to be manually configured. This is why 'To Computer' audio streams are considered outputs.
Expand the 'To Computer' bank on the left, and the bank of physical inputs on your unit you want to record. Click on the intersection between Analog 1 and To Computer 1, Analog 2 and To Computer 2, etc. Now each input is being routed to its own virtual 'To Computer' audio stream, which you can assign as the input to an audio track in your DAW.
Keep in mind, the same input, (Analog 1, for example), can be sent to multiple 'To Computer' audio streams for simultaneous recording on multiple tracks. However, each 'To Computer' audio stream can only receive signal from one input.
To explain this visually, this means you can make vertical lines in the Routing grid when routing inputs to the 'To Computer' streams, but you cannot make horizontal lines.
To check your signal flow when a connection is made, any signal identified by your input channel's indicator lights will also be visible on the 'To Computer' stream's light on the left.
Want to see your tip as a MOTU Tech Tip? Is there a feature, technique, or configuration you would like to learn more about? Send us your tips, or topic suggestions »
< PulseAudio
- 6HDMI output configuration
- 7Surround sound systems
- 8PulseAudio over network
- 11PulseAudio through JACK
- 12PulseAudio through JACK issues
- 20Swap left/right channels
- 24Mixing additional audio into the microphone's audio
Set default input source
List available input sources
The
*
in front of the index indicates the current default input.To set a system wide default, add the source name in the
default.pa
file:For temporary use
Tip: The default source can be referred as
@DEFAULT_SOURCE@
in commands, for example: $ pactl set-source-mute @DEFAULT_SOURCE@ toggle
.Set the default output sink
To list the output sinks available, type the following command:
The
*
in front of the index indicates the current default output.To set a system wide default, add the source name in the
default.pa
file:When done then you can logout/login or restart PulseAudio manually for these changes to take effect.
Note:- The numbering of sinks is not guaranteed to be persistent, so all sinks in the
default.pa
file should be identified by the name. - For quick identification at runtime (e.g. to manage sound volume), you can use the sink index instead of the sink name:
- To avoid unnecessary overriding of 100% normal volume it is better to use alternative utilities for managing of sound. See the forum thread for more information.
Tip: The default sink can be referred as
@DEFAULT_SINK@
in commands, for example: $ pactl set-sink-volume @DEFAULT_SINK@ +5%
.Set the default output sink profile
Sometimes PulseAudio neglects to load the desired profile on start (e.g. a profile for having #Independent analog and digital outputs on the same card). To change the default profile, append the following to
Note:default.pa
:You could also use
<cardindex>
instead of <symbolic-name>
, but using <symbolic-name>
ensures referencing the correct device. <cardindex>
is dynamic, and changes when a new device is plugged in.Find
<symbolic-name>
by running pacmd list-cards
:In this case, I want to use the device with index number 2, so
<symbolic-name>
should be alsa_card.pci-0000_00_14.2
.To find
<profilename>
, set the desired profile manually, then run pacmd list-cards
:In this case,
default.pa
should now be changed to this:You can test your configuration by running
pactl set-card-profile <symbolic-name> <profilename>
.Independent analog and digital outputs on the same card
Sound cards may have both analog and digital (iec958) outputs. Pulseaudio does not generate combined profiles by default, you can choose either digital or analog profiles.
The easiest way to make both outputs available is to add a combined profile to the end of default profile configuration file:
This way a defined profile is added to the end of the list of available profiles.
Although this works, pulseaudio has a nasty habit of falling back to auto-generated profiles, so you may eventually need to set your card back to the combined profile. The best way to overcome this is by writing a custom config with disabled
auto-profiles
. Copy default.conf
to custom-profile.conf
, and edit it to suit your needs (this example is for stereo output/input):Now that you have your custom profile you need to tell pulseaudio to use it. This can be done by defining an udev rule:
First get relevant information about your sound card:
Now create a config file:
Now tell udev to reload sound subsystem
udevadm trigger -ssound
(as the root user) and restart pulseaudio. Your sound card should now use only the defined profile and have both analog and digital outputs available.Simultaneous HDMI and analog output
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.
Or by using the the
pacmd
command: 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.
To setup the analog device as a secondary source, add the following to the
/etc/pulse/default.pa
configuration at the beginning, before any other modules are loaded: Restart PulseAudio, run pavucontrol and select the 'Output Devices' tab. Three settings should be displayed:
- Internal Audio Digital Stereo (HDMI)
- Internal Audio
- Simultaneous output to Internal Audio Digital Stereo (HDMI), Internal Audio
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 this thread for a variation on this theme and PulseAudio FAQ.
HDMI output configuration
As outlined in https://download.nvidia.com/XFree86/gpu-hdmi-audio-document/index.html#_issues_in_pulseaudio unless the HDMI port is the firstoutput, 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.
The original title for this section indicated the problem is specific to nVidia cards. As seen in 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.
Finding HDMI output
Then find the working output by listing the available cards
In case your HDMI port is wired to the NVIDIA card, but aplay does not detect an NVIDIA audio card, follow NVIDIA/Troubleshooting#No audio over HDMI.
Testing for the correct card
Now a list of the detected cards is known, users will need to test for which one is outputting to the TV/monitor
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)
Manually configuring PulseAudio to detect the Nvidia HDMI
Having identified which HDMI device is working, PulseAudio can be forced to use it via an edit to
/etc/pulse/default.pa
:where the 1 is the card and the 7 is the device found to work in the previous section
restart pulse audio
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.
Automatically switch audio to HDMI
Create a script to switch to the desired audio profile if an HDMI cable is plugged in:
Make the script executable:
Create a udev rule to run this script when the status of the HDMI change:
To make the change effective don't forget to reload the udev rules:
A reboot might be required.
Surround sound systems
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
/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.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 analog soundcard, then try to add the following line to
/etc/pulse/default.pa
Note that this example is for a 5.1 setup.
After doing the edit, restart PulseAudio.
Splitting front/rear
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
:Make sure to replace alsa_output.pci-0000_05_00.0.analog-surround-40 with the sound card name shown in '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.
Tip: If pulseaudio fails with
master sink not found
, comment out the remapping lines, start PulseAudio and verify your card output is set to the one you specified (e.g. analog surround 4.0). Alternatively, try using a sink index[broken link: invalid section] instead of a sink name.Splitting 7.1 into 5.1+2.0
Similar to the example above, you can also split a 7.1 configuration into 5.1 surround and stereo output devices.Set your card to 7.1 mode, then add the following lines to
/etc/pulse/default.pa
:Make sure to replace alsa_output.pci-0000_00_14.2 with your sound card name, get it by running 'pacmd list-sinks'.This configuration will use the front/rear/center+lfe (green/black/orange) jacks for the 5.1 sink and the side (grey) jack for the stereo sink.It will also downmix any audio to stereo for the stereo sink, but will not touch the 5.1 output.
Tip: If pulseaudio fails with
master sink not found
, comment out the remapping lines, start PulseAudio and verify your card output is set to analog surround 7.1. Alternatively, try using a sink index[broken link: invalid section] instead of a sink name.Disabling LFE remixing
By default, PulseAudio remixes the number of channels to the default-sample-channels and since version 7 it also remixes the LFE channel. If you wish to disable LFE remixing, uncomment the line:
and replace yes with no:
then restart Pulseaudio.
Binaural Headphones
ladspa-bs2bAUR provides a plugin to simulate surround sound on stereo headphones. To use it, find your headphones with:
Load the plugin (new sink_name is up to you, master=headphone's sink name):
Use pavucontrol to transfer streams to the new sink, or:
PulseAudio over network
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. Ensure that client and server systems agree on the time (i.e., use NTP), or audio streams may be choppy or may not work at all. For a more detailed guide visit the Official PulseAudio Documentation
Enable the TCP module on the server(the computer that actually outputs sound), edit
/etc/pulse/default.pa
to add or uncomment:Or you can use the
paprefs
gui application (root is not required):To make sure module-native-protocol-tcp is loaded on the server, you can use:
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.If it is undesirable to copy the cookie file from clients, anonymous clients can access the server by passing
auth-anonymous
to module-native-protocol-tcp
on the server (again in /etc/pulse/default.pa
):It is also possible to authenticate based on client IP address:
Change the LAN IP subnet to match that of those clients you wish to have access to the server.
Selecting the Server
For a single shell or command you can set the environment variable
$PULSE_SERVER
to the host name or IP address of the desired PulseAudio server.Alternatively you can create or modify
~/.pulse/client.conf
or /etc/pulse/client.conf
to set a default-server persistently.Selecting the Server with Zeroconf
Note: This section is known to be unreliable for some people.
For the remote PulseAudio server to appear in the PulseAudio Device Chooser (
pasystray
), load the appropriate zeroconf modules, and enable the Avahidaemon. On both machines, the client and server, installpulseaudio-zeroconf then start and enableavahi-daemon.service
.On the server, add
load-module module-zeroconf-publish
to /etc/pulse/default.pa
. On the client, add load-module module-zeroconf-discover
to /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.
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.
Switching the PulseAudio server used by local X clients
To switch between servers on the client from within X, the
pax11publish
command can be used. For example, to switch from the default server to the server at hostname foo:Or to switch back to the default:
Instead of telling the PulseAudio server to stream audio (as described above), this will edit PulseAudio variables on the X11 root window, which will instruct the PulseAudio client libraries to connect to a PulseAudio server other than
localhost
. As such, the programs will no longer interact with the local pulseaudio
process, which can then be stopped. Programs such as pactl
, pacmd
or pavucontrol
will need to also run with the appropriate PULSE_SERVER
environment/X variable to control the remote PulseAudio server.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
.When everything else seems to fail
The following is a quick fix and NOT a permanent solution Wifispoof 2 3 2 – change your wifi mac address.
On the server:
Go to Network Access -> Enable access to local sound devices (Also check both 'Allow discover' and 'Don't require authentication').
On the client:
ALSA monitor source
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
: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.
Monitor specific output
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:
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 through JACK
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. It can offer lower latency audio monitoring along with greater control of input and output of multi-i/o sound devices.
The KXStudio method
This configuration requires the jack2 package.
JACK now has native features for bridging between ALSA, PulseAudio, and JACK. This will allow you to simultaneously have JACK and PulseAudio running with both outputting at the same time, with no config editing or terminal commands required.
If you have qjackctl installed, make sure that it is not running (it might be running minified in the system tray). Also ensure that no
jackd
process is running (use ps xw
in a terminal to check).Install cadence, as well as pulseaudio-jack. Once installed and started, JACK bridge configuration is found in the bottom right of the window. The ALSA audio bridge should be set to ALSA -> PulseAudio -> JACK, and the PulseAudio bridge should be enabled. Make sure in
pavucontrol
that all output devices besides Jack sink are muted, and all input devices besides Jack input are muted. Start JACK using the Force Restart button, and if it starts successfully PulseAudio programs should begin outputting to JACK.The manual sink configuration method
This configuration provides a method of allowing JACK and PulseAudio to run at the same time and output to each other. It uses manual configuration of the systems that bridge between JACK and PulseAudio. This configuration has no reliance on scripts or commands and is entirely based in configuration.
This configuration only works with jack2. To use this configuration, just install the pulseaudio-jack package.
/etc/pulse/default.pa
is already configured to load the modules in pulseaudio-jack if they are present. If you want to be sure, open the file and look for the line:Where
options
can be any options supported by this module, usually channels=2
.As described on the Jack-DBUS Packaging page:
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
dynamically loads and unloads module-jack-sink and module-jack-source when jackdbus is started and stopped.If PulseAudio sound does not work, check with
pavucontrol
to see if the relevant programs appear in the playback tab. If not, add the following to ~/.asoundrc
or /etc/asound.conf
to redirect ALSA to PulseAudio:If it still does not work, check with
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). Also ensure that in the JACK graph the PulseAudio JACK Source is connected to the system audio output.The shell script method
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:
- PulseAudio releases the sound card
- JACK grabs sound card and starts up
- script redirects PulseAudio to JACK
- manually send PulseAudio apps to JACK output (pavucontrol may come in helpful for this)
- use JACK programs etc
- via script, stop redirecting PulseAudio to JACK
- stop JACK and release sound card
- 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 scriptpulse-jack-post-start.sh
set this one up as execute script after startuppulse-jack-pre-stop.sh
'execute script on shutdown'pulse-jack-post-stop.sh
'execute script after shutdown'The PulseAudio kill method
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.
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
jack_startup
: 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: Both scripts need to be made executable:
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 through JACK issues
When JACK is started Firefox, Chrome and other apps stop playing video and audio
Firefox/Chrome/etc. is using PulseAudio soundcard sink instead of the JACK sink. Open
pavucontrol
and on the Playback tab switch all audiostreams from something like 'Built-in Audio Analog Stereo' to something like 'Jack sink (PulseAudio JACK Sink)'.After I start JACK the sound from PulseAudio becomes distorted
In QjackCtl click Setup and on the Settings tab, Parameters subtab untick 'Realtime'. In addition, tweaking Sample Rate, Frames/Period and Period/Buffer may help. Look for latency in the bottom right corner, as you still want minimal latency for audio production. Also, I think Sample Rate should match one of the rates supported by your audio interface (
cat /proc/asound/cardN/codec#M
and look for rates
, there could be multiple occurrences).PulseAudio through OSS
Add the following to
/etc/pulse/default.pa
:Then start PulseAudio as usual, making sure that sinks and sources are defined for OSS devices.
PulseAudio from within a chroot
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:-/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 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).
Disabling automatic spawning of PulseAudio server
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.Now you can manually start the pulseaudio server with
and stop it with
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
.Disabling pulseaudio daemon altogether
To disable the pulseaudio daemon completely, and thereby preventing it from starting, one can add
daemon-binary=/bin/true
to the configuration file.Remap stereo to mono
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
:(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.
Remap left or right to mono
Particularly useful in the case an audio stream has different content in the left and right channels, such as Japanese television broadcasts with bilingual audio.
Replace
Note:alsa_output.pci-0000_00_1b.0.iec958-ac3-surround-51
(5.1 AC3 on ALC892 Digital) with your own card (pacmd list-sinks
).- master_channel_map is a list of outputs to be remapped to.
- channel_map is a list of inputs to be remapped from.
- A stereo card will not have to specify as many channels, eg.
channels=1 master_channel_map=mono channel_map=right
Remap for broadcasting software
If you do not want to capture sound from the application you need to create Remap sink:
Note: Replace
SINK_NAME
with the real name of the master sink pacmd list-sinks
.Then restart PulseAudio daemon:
Now you need set the
Remap_sink
as the default sound source in broadcast softwareNote: Use environment variable
PULSE_SINK=SINK_NAME
for applications, sound that does not need to be captured.Swap left/right channels
This is the same as 'reverse stereo', where the left and right channels are to be swapped.
First, identify the card you want its channels swapped:
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
Restart the pulseaudio deamon by running
Using default.pa
Another approach to swapping channels is suggested in [1]:
Using PulseEffects
- Install pulseeffects:
- Using the 'Stereo Tools' application on the left of the PulseEffects UI
- Navigate to the 'Stereo Matrix' page
- Under 'Mode' select 'LR > RL (Stereo Flip Channels)'
The way PulseEffects works is it becomes your primary output device. You'll then need to use the PulseAudio Volume Control pavucontrol tool to set the PulseEffects output to the device you want.
PulseAudio as a minimal unintrusive dumb pipe to 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. Since pulseaudio-alsa contains only a configuration file /etc/asound.conf
, if it's installed as dependency, one could simply comment all contents in /etc/asound.conf
. 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.Having both speakers and headphones plugged in and switching in software on-the-fly
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:
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:
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:
Note: On some systems you might need to use
[Element Front]
instead of [Element Line Out]
.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
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.
Allowing multiple users to use PulseAudio at the same time
It is sometimes desirable to run some programs as another user on the same desktop of the primary user in order to isolate the software. However, PulseAudio will not accept by default connections by the secondary users, since a PulseAudio daemon is already running for the primary user. However, a PulseAudio UNIX socket can be created in order to accept connections from other users to the main PulseAudio daemon run by the primary user.
First, edit
/etc/pulse/default.pa
or ~/.config/pulse/default.pa
and add a directive for the unix socket to be created:Afterwards, set PulseAudio as a client to the UNIX socket just created in the secondary user:
Now, after restarting the PulseAudio daemon, applications running as the secondary user should be able to play sound through the main PulseAudio daemon running as the primary user without problems.
Mixing additional audio into the microphone's audio
Using a setup of null sinks and loopbacks you can mix arbitrary applications' audio output into your microphone's audio, for example to play sound effects or music on voice chat applications.
The setup suggested here will also play your sound effects back to you and use PulseAudio echo cancellation to prevent the effects from feeding back into your microphone.Despite this, using headphones instead of loudspeakers is probably a good idea.
Overview of the targeted PulseAudio configuration
Symbology:
(Application)
, {Audio source}
, [Audio sink]
, {m} = Monitor of audio sink
- {mic_ec}, [spk_ec]
- Echo cancellation 'clones' of the microphone and speakers
- [vsink_fx]
- Virtual sink into which the sound effects are played
- [vsink_fx_mic]
- Virtual sink where the microphone and the sound effects are mixed together
Applications configuration
The applications providing the sound effects must
- Output to 'vsink_fx'
All other applications, including the voice chat, must
- Record audio from 'Monitor of vsink_fx_mic'
- Output to 'spk_ec'
Accordingly, these devices will be set as default source and default sink; ultimately, controlling which application uses which audio source/sink can be done in the
pavucontrol
graphical PulseAudio volume control panel.No application whatsoever must record from, or output to, the 'real' microphone or speakers, as this would bypass the echo cancellation.
Any echo cancellation or other audio processing provided by the voice chat application should be disabled – PulseAudio is doing this already, and as the application is not aware of the sound effects being played on the speakers, it will likely be ineffective in filtering them from the microphone anyway.
Loopback 2 0 0 – Route Audio Between Applications Across Two
Setup steps
As of August 2020 there is pulse-autoconfAUR, a PulseAudio server dynamic configuration daemon that supports this setup with its 'EchoCancellationWithSourcesMix' preset and that dynamically reacts to e.g. a headset being plugged in our unplugged.
If pulse-autoconfAUR does not work out for your use case, here is the manual way:
- Connect your microphone and headphones and make sure PulseAudio is configured correctly for their use, for example in the 'Configuration' tab in
pavucontrol
- First time only:
- Save the template script below to an executable file of your choice
- Find the
name:
s of your microphone and headphones withpacmd list-sources
andpacmd list-sinks
, respectively - In the script, replace the values of 'microphone' and 'speakers' with the names of your microphone/headphones
- Run the script
- Run your voice chat application and, in
pavucontrol
, make it record audio from 'Monitor of vsink_fx_mic' and output audio to 'spk_ec' - Run your sound effects application(s) and, in
pavucontrol
, make them play to 'vsink_fx'
As for applications that can play sound effects, castersoundboard-gitAUR has been found to work quite well.It however needs to be closed and re-opened when PulseAudio is restarted.
Teardown
Loopback 2 0 0 – Route Audio Between Applications Across Multiple
The changes that the script makes to the running PulseAudio server are not permanent and will be lost when PulseAudio terminates.
Loopback 2 0 0 – Route Audio Between Applications Across Multiple
To ditch the custom configuration, just restart PulseAudio, e.g. with
systemctl --user stop pulseaudio.service
. (PulseAudio is socket-activated and will automatically start on demand.)Template script
Loopback 2 0 0 – Route Audio Between Applications Across The Country
This script has been inspired by https://askubuntu.com/a/915064 , for more in-depth information also see that post's author's pulseaudio-config GitHub repository.
Retrieved from 'https://wiki.archlinux.org/index.php?title=PulseAudio/Examples&oldid=639245'