Multiple Application Sound Sharing on Ubuntu

It is assumed you are using Hardy Heron 8.04 amd64, i386, or Hardy UbuntuStudio8.04 i386 and amd64 or Intrepid. If you are testing Jaunty, it is somewhat different and subject to change so bear that in mind while you follow this guide.

It is very unlikely that anything you try here will put your sound into an unusable state that cannot be easily remedied by you after you read this.

This has been tested on i386 and amd64 Hardy8.04, UbuntuStudio8.04.1 i386 and amd64, Intrepid i386 and amd64 Gnome2.2.1 and KDE4 and Intrepid UbuntuStudio. Jaunty testing is underway.I have an HDA ALC883 sound chip, a C-Media 8768 7.1 PCI sound card, a Plantronics USB Headset and a Logitec webcam and they all work all the time. I have 21 devices in my volume control. I just got a bluetooth dongle and headset and as soon as I figure them out I will provide an update in the bluetooth section. Things I have used and tested: amarok, audacious, rythmbox, xmms, ardour, hydrogen, rosegarden, vlc, mplayer, totem, miro, streamtuner, tunapie, firefox, opera, ZynAddSubFx, Banshee, jackrack, soundrecorder, sound converter, timidity, beast, djplay, Qsynth, mixx, muse,…..and many many more.

Restore Default Configurations
Default sound configurations are of two types, system wide configurations and user configurations. . System wide configuration files are /etc/asoundrc and in /etc/pulse. The file etc/asoundrc is not normally necessary or included so it is OK if it is not there. It is used for setting up special configurations for system wide use. User configurations are hidden in the users home directory under ~ /.asoundrc and ~/.pulseThe files ~/.asound.rc and ~/.pulse/default.pa are used for the same thing but per user. In general you will have a ~/.asoundrc file but no ~/.pulse directory since there is generally no need for per user settings for pulseaudio.

If you edited asoundrc to get your surround sound working and were successful, leave that part. If you changed the sample size and/or rate to eliminate stuttering in /etc/pulse/daemon.conf and it worked, you can leave those changes. If you have edited your pulse/default.pa for multiple sound card devices or used combine and it works, you can leave those parts alone too. Otherwise, if you have an etc/asoundrc file, rename it to asoundrc.back so it won’t be used. If you have edited your ~/.asound.rc for any reason but those mentioned above, then you should reload the backup you saved. If you edited your etc/pulse/default.pa for equalizer support you should re-edit and comment those lines out for now, same thing if you have a ~./pulse/default.pa. You can try the other changes you made again once everything is working properly.

Keep the new libs and anything else you installed following this guide from psyke83 if you have already been there:
http://ubuntuforums.org/showthread.php?p=4928900

Packages
Check with Synaptic that these are all installed(You probably already have most of them. Some are specific to specific applications/servers, if you do not use these, they are not necessary. If you are not sure, get them anyway):

AlSA Packages (search alsa)

aconnectgui (ALSA MIDI connection utility)
alsa-oss (alsa wrapper for OSS apps)
alsaplayer-alsa (PCM player for alsa)
alsa-utils (command line utilities)
asoundconf-gtk (choose default alsa sound card)
gnome-alsamixer (GUI alsa mixer for Gnome)
gstreamer0.10-alsa (gstreamer plugin)
xmms2-plugin-alsa (xmms2 plugin)
libasound2 (alsa libs and plugins)
libasound2-plugins (jack, OSS, pulseaudio plugins for libasound2)
libesd-alsa0 Enlightened Sound Demon (allows multiple audio streams on one device, not really necessary)

PulseAudio Packages (search pulseaudio will find most of them)

audacious-plugins-extra (audacious plugin)
gstreamer0.10-pulseaudio (gstreamer plugin)
libao-pulse (libao plugin)
libpulse0 (client libraries)
libpulse-browse0 (client libraries)
libpulsecore5 (core services modules)
libpulse-mainloop-glib0 (client libraries)
padevchooser ( device chooser for setting up networking)
paman (PulseAudio Device Manager)
paprefs (Pulse Audio Preferences)
pavucontrol (Pulse Audio Volume Control)
pavumeter(Pulse Audio VU Meters)
pulseaudio( The Pulse Audio Daemon)
pulseaudio-esound-compat( Pulse Audio Esound drop in replacement for libesd for multiple audio streams)
pulseaudio-module-gconf (gconf module)
pulseaudio-module-hal (hal module, discover new sound devices via hal)
pulseadio-module-x11 (replace x11 bell/beep with PA sounds)
pulseaudio-module-zeroconf (Avahi, mdns, network help)
pulseaudio-utils (command line tools)
vlc-plugin-pulse (vlc plugin)
libsdl1.2debian-pulseaudio (plugin for sdl apps)

Many of the above user applications can be found in Applications/Sound and Video after they are installed, others are in System/Preferences. Others are command line programs that need to be run in a terminal or libs that you do not need to access or plugins available in or to applications.

Default Sound Card
What we are doing here is routing the ALSA plugins and players through Pulse Audio so it can manage them. Some applications have an ALSA plugin but no Pulse Audio support so they go through ALSA to Pulse Audio and on to the ALSA low level sound device drivers. Contrary to popular belief this does not increase latency since pulseaudio adds zero latency but actually reduces it since applications sharing sound no longer need to go through dmix.

System/Preferences/Default Sound Card, ( this is asoundconf-gtk) choose Pulse Audio.

System/Preferences/Multimedia Systems Selector/Audio set Plugin to Pulse Audio.

System/Preferences/Sound, set all to Pulse Audio except Default mixer tracks which should be set to “your sound card” (i.e. ATI IXP (ALSA )mixer) probably the first choice 0. If you have more than one hardware device, choose the one you want to use/control. If you set your defaults to automatic some applications will bypass Pulse Audio and grab exclusive control of the sound card. We want to avoid this.

Reboot. If you are having trouble changing settings in Multimedia Systems Selector or Sound, reboot and then make the changes and reboot again. You need to reboot because some configuration files are only read at boot.

Volume Control
The Volume control is the little speaker on your top panel. If you left click on it you can adjust the volume. This can get a little tricky if you have more than one device. To choose the device to control right click on it and choose Preferences. This will open a little window where you can choose which device to control. You can also choose what sliders you want to control. You should select Master but you can play around with it to see what it can do.If you hold down the sift key you can select more than one control. If you want to control the volume with your multimedia keys you need to select the device in System/Preferences/Sound.

For now though, right click on the Volume Control on the Panel and choose Open Volume Control/File/Change Device and make sure it is set to the same device as in System/Preferences/Sound. Go to Recording if that section is available and put the capture slider up about 1/3 to 1/2 and make sure the icons on the bottom are not x-ed out. If available, go to to Switches and check mix. If you have an Options section, check to make sure they are set to the proper configuration for where your speakers and mic are attached. If you get feedback, mute the microphone, it is working just fine. If you do not have these sections, do not worry, they are not available for all devices. If you only have one hardware device to choose, that is also OK.

Sound Mixer
Open any alsa mixer, I use gnome-alsamixer. Turn stuff on and put up the sliders. check mix, capture, cd, mic, etc, unmute, mute, blah blah blah… If you have a usb mic or headphones tab over to that section and turn them on and set the levels etc. Some of this is redundant but it doesn’t hurt and gets you familiar with your mixer. This is the same controls as the volume control in your panel. If you adjust the sliders and switches they will adjust in every other volume control.

Pulse Audio Device Chooser padevchooser
The Pulse Audio Device Chooser is a small applet that lives on your panel. From it you can open all the Pulse Audio interfaces, the Pulse Audio Manager and Pulse Audio Volume Control, the Pulse Audio Meters, and also Configure Local Sound Server and PulseAudio Preferences. You can put this in your panel by opening it from the Applications/Sound and Video menu and then clicking on Preferences/Start applet on session login. You can tell it to start up automatically when you login by choosing Preferences and selecting Start Applet on session login.

Pulse Audio Volume Control, pavucontrol
This is the control center for Pulse Audio. It has tabs as follows. You can find it in Applications/Sound and Video or open it from the Pulse Audio Device Chooser.
Playback
You can adjust the volume of the individual streams by moving the sliders, You can change which output device they use by right clicking on the stream and choosing move stream,
Output Devices
You can set the default output device in the Output Device section by right clicking on it. This section also lists any Virtual Output Devices you have if you set Show: ALL Output Devices, like one for Simultaneous Output and one for RTP Multicast for network streaming or one for jack. You can select these in Playback just like any of your hardware devices.
Input Device
You can set the default input device in the Input Device Section by right clicking on it. You can set the Default Input Device to a monitor of one of the Output Devices so you can record what you are playing. You can set Show to All Input Devices of Show: Monitors to see the monitors.
Recording
This is new in Intrepid. It operates the same as Playback but for recording.

If you do not see an application playing in the Pulse Audio Volume Control then it is using the sound device directly. and is most likely an OSS or Jack or other type application. If you can, change their audio output to alsa or pulseaudio. OSS applications may need to be launched with aoss which is the alsa wrapper for oss . You can also try launching them with padsp which is the pulseaudio wrapper for OSS. Edit the launchers as necessary by putting either aoss or padsp before the application name. If it is a jack application, see the jack section below. If the application uses Portaudio or some other sound server then you may need to use the pasuspender command.

Pulse Audio Manager, paman
Go to Applications/Sound and Video/Pulse Audio Manager or use the padevchooser and you should see in Server Information:

Default Sink: alsa_output.pci_1002_4370_sound_card_0_alsa_playba ck_0
Defalt Source: alsa_input.pci_1002_4370_sound_card_0_alsa_capture _0

or something like that or completely not like that but with alsa as the first word.

All of your applications are listed in the Devices section of Pulse Audio Device Manager as #1, #2, #18 etc, under the line for what sink it is using. You can highlight one of them and click on properties to see what client/plugin it is using and other useful information.

The PulseAudio Manager is being deprecated and will not appear in future versions of PulseAudio. It is not recommended to use the PA Manager for controlling PulseAudio. The padevchoser is also being deprecated so the Configure Local Sound Server will be found in PulseAudio Preferences along with the rtp network controls.

Testing
Test with Rythmbox, vlc, totem, firefox flash, firefox mplayer, and other plugins, etc. configure preferences to ALSA or Pulseaudio if available/possible. Play a cd or dvd or both. Run them all at once, or as many as you want/can. You should hear them all, together and see them in Pulseaudio Volume Control/Playback.

Testing, Recording
To control your input for recording you can set your System/Preferences/Sound/Audio Conferencing/Sound capture to PulseAudio Sound Server and use PulseAudio Volume Control/Input Devices to choose which device to record from. This is very handy as you can quickly switch between your sound card pcm stream or microphone to your webcam mic or usb headset. All you need to do is open the PulseAudio Volume Control/Input Devices and right click on any available device to make it the default then open the application. You can choose any (ALSA) hardware device available or one of the “monitor” virtual devices. So, if you are listening to some music in your speakers you can choose the monitor for your Output Device to record. Just make sure that “capture” is enabled and turned up in the panel volume control or your alsa based mixer if you are trying to use a hardware input device.

If you are using Intrepid you can move the recording application to another Input device in the recording tab of the Pulseaudio Volume Control and adjust the levels, mute etc.

PulseAudio Volume Meters
You should now have a PulseAudio Volume Meter (capture) you can use to test your microphone or other capture inputs available in your sound mixer or volume control. Once you have chosen your default device, you can open sound recorder and record it. If you choose a monitor device, you can record whatever is going through the comparable Output Device.
You can use the PulseAudio Volume Meter (Playback) for monitoring playback streams. The volume meters work on the default streams.

If you are using a microphone for recording and wish to not hear the microphone input to prevent feedback, you can just mute the microphone playback in the panel volume control or ALSA sound mixer. It is the Capture settings that are the only important ones for recording.

If you are using jack this will not work for you. As far as I can tell you can only change jack inputs in jack control setup/input device and then restart jack. For using jack with PulseAudio, see the Ubuntu Studio and jack section below.

Starting and Stopping Pulse Audio
To start Pulseaudio from a terminal.

Code:
pulseaudio -D

The -D option starts pulseaudio as a daemon so it is OK to close the terminal after using it to start Pulseaudio.
If you want to kill the pulseaudio daemon:

Code:
killall pulseaudio

Troubleshooting Pulseaudio
If you are having weird problems using pulseaudio then you can kill pulseaudio and restart it from a terminal with

Code:
pulseaudio -vvv

This will run pulseaudio in the terminal in verbose mode so all the messages about what pulseaudio is doing will be written to the terminal. When you close the terminal Pulseaudio will exit. These messages can pinpoint problems with ALSA drivers or application plugins or network streaming issues etc along with problems with pulseaudio itself.
Bugs in pulseaudio can be reported by opening new ticket. Make sure you search the tickets before filing a new bug. You can also talk to the devs at the mailing list or with IRC which have links from the home page:

http://www.pulseaudio.org/

Wagiman Wiryosukiro

Petani Sistem Informasi, tukang las plugin & themes Wordpress. Co-Founder SistemInformasi.biz. Saat ini aktif sebagai Developer & kontributor di OpenMandriva Linux.

You may also like...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: