Linux Audio

= Linux Audio with Pulse Audio =

Pulse Audio is a popular audio system for Linux.

Its basic command line app is "pacmd"

Terminology:

Sink: an audio output, typically an Analog audio output such as a sound card.

Source: an audio input, typically an Analog audio from a sound card such as a microphone. Can also can be a loop back / monitor of an audio output (Sink)

A very nice audio mixer with graphical options for setting up and choosing inputs / outputs (as below) is pavucontrol

List Default Devices
You can use `pactl info` to list the default devices / settings Pulse Audio is using. ... Default Sink: alsa_output.pci-0000_00_1b.0.analog-stereo Default Source: alsa_input.usb-Behringer_BCD3000-00-BCD3000.analog-4-channel-input
 * 1) pactl info

List available sound outouts
Welcome to PulseAudio! Use "help" for usage information. >>> 2 sink(s) available. index: 0 name:  flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY FLAT_VOLUME DYNAMIC_LATENCY state: RUNNING ...    * index: 14 name:  driver:  	flags: HARDWARE DECIBEL_VOLUME LATENCY FLAT_VOLUME DYNAMIC_LATENCY state: RUNNING ...
 * 1) pacmd list-sinks

Change Default Output Device
or
 * 1) pacmd "set-default-sink ${Device Index}"
 * 1) pacmd "set-default-sink ${Device Name}"

E.G. Welcome to PulseAudio! Use "help" for usage information. >>> >>>
 * 1) pacmd "set-default-sink 14"

or

Welcome to PulseAudio! Use "help" for usage information. >>> >>>
 * 1) pacmd set-default-sink alsa_output.usb-Behringer_BCD3000-00-BCD3000.analog-surround-40

List Apps using sound outputs
Welcome to PulseAudio! Use "help" for usage information. >>> 2 sink input(s) available. index: 1994 driver:  		flags: state: RUNNING sink: 0  ... 			application.process.id = "12170" application.process.binary = "java" ... 	index: 2106 driver:  		flags: START_CORKED state: RUNNING sink: 14  ...		 			application.process.id = "22083" application.icon_name = "media-player-banshee" ...
 * 1) pacmd list-sink-inputs

Move App to another output device
Welcome to PulseAudio! Use "help" for usage information. >>> >>>
 * 1) pacmd "move-sink-input ${App Index}  ${Device Index}"
 * 1) pacmd "move-sink-input 1994 0"

List available sound inputs
# pacmd list-sources Welcome to PulseAudio! Use "help" for usage information. >>> 4 source(s) available. index: 0 name:  ...	 	properties: device.description = "Monitor of Built-in Audio Analog Stereo" device.class = "monitor" ...  * index: 1 name:  ... 	used by: 0 linked by: 0 module: 4 properties: alsa.name = "VT1708S Analog" alsa.id = "VT1708S Analog" alsa.card_name = "HDA Intel PCH" device.profile.name = "analog-stereo" device.profile.description = "Analog Stereo" device.description = "Built-in Audio Analog Stereo" ports: analog-input-microphone-front: Front Microphone (priority 8500, available: unknown) analog-input-microphone-rear: Rear Microphone (priority 8200, available: unknown) analog-input-linein: Line In (priority 8100, available: unknown) active port:  ...    index: 28 name:  properties: device.description = "Monitor of BCD3000 Analog Surround 4.0" device.class = "monitor" ...    index: 29 name:  ... 	used by: 0 linked by: 0 alsa.name = "USB Audio" alsa.id = "USB Audio" alsa.card_name = "BCD3000" device.profile.name = "analog-4-channel-input" device.profile.description = "Analog 4-channel Input" device.description = "BCD3000 Analog 4-channel Input" alsa.mixer_name = "USB Mixer" ...
 * 1) pacmd list-sources

Managing Card Profiles
Audio device will often have multiple usage Profiles. Profiles such as "Input", "output" or "Input and Output"

Having your card set in the "wrong" profile will prevent its sink or source showing up and there for pulseaudio will not show the device as you may expect.

Listing a Cards Profile
We can see what profile our sound card is currently running in by listing the cards current settings.

Card #1 Name: alsa_card.usb-Behringer_BCD3000-00-BCD3000 Driver: module-alsa-card.c 	Owner Module: 26 Properties: alsa.card_name = "BCD3000" alsa.long_card_name = "Behringer BCD3000 at usb-0000:00:1d.0-1.7, full speed" alsa.driver_name = "snd_usb_audio" ... 		udev.id = "usb-Behringer_BCD3000-00-BCD3000" ... 		device.description = "BCD3000" module-udev-detect.discovered = "1" device.icon_name = "audio-card-usb" Profiles: output:analog-surround-40: Analog Surround 4.0 Output (sinks: 1, sources: 0, priority. 700) output:analog-surround-40+input:analog-4-channel-input: Analog Surround 4.0 Output + Analog 4-channel Input Input (sinks: 1, sources: 1, priority. 701) input:analog-4-channel-input: Analog 4-channel Input Input (sinks: 0, sources: 1, priority. 1) off: Off (sinks: 0, sources: 0, priority. 0) Active Profile: output:analog-surround-40+input:analog-4-channel-input ...
 * 1) pactl list cards

Changing Profile
Changing the cards profile is simple we simple need the name of the card and profile we want to use. These names can be found in the output of the list command (above)


 * 1) pacmd set-card-profile ${Card Name} ${Profile Name}

Welcome to PulseAudio! Use "help" for usage information.
 * 1) pacmd set-card-profile alsa_card.usb-Behringer_BCD3000-00-BCD3000 output:analog-surround-40+input:analog-4-channel-input

pacmd help
Welcome to PulseAudio! Use "help" for usage information. >>> Available commands: help                     Show this help list-modules             List loaded modules list-cards               List cards list-sinks               List loaded sinks list-sources             List loaded sources list-clients             List loaded clients list-sink-inputs         List sink inputs list-source-outputs      List source outputs stat                     Show memory block statistics info                     Show comprehensive status load-module              Load a module (args: name, arguments) unload-module            Unload a module (args: index) describe-module          Describe a module (arg: name) set-sink-volume          Set the volume of a sink (args: index|name, volume) set-source-volume        Set the volume of a source (args: index|name, volume) set-sink-mute            Set the mute switch of a sink (args: index|name, bool) set-source-mute          Set the mute switch of a source (args: index|name, bool) set-sink-input-volume    Set the volume of a sink input (args: index, volume) set-source-output-volume Set the volume of a source output (args: index, volume) set-sink-input-mute      Set the mute switch of a sink input (args: index, bool) set-source-output-mute   Set the mute switch of a source output (args: index, bool) set-default-sink         Set the default sink (args: index|name) set-default-source       Set the default source (args: index|name) set-card-profile         Change the profile of a card (args: index|name, profile-name) set-sink-port            Change the port of a sink (args: index|name, port-name) set-source-port          Change the port of a source (args: index|name, port-name) suspend-sink             Suspend sink (args: index|name, bool) suspend-source           Suspend source (args: index|name, bool) suspend                  Suspend all sinks and all sources (args: bool) move-sink-input          Move sink input to another sink (args: index, sink) move-source-output       Move source output to another source (args: index, source) update-sink-proplist     Update the properties of a sink (args: index|name, properties) update-source-proplist   Update the properties of a source (args: index|name, properties) update-sink-input-proplist Update the properties of a sink input (args: index, properties) update-source-output-proplist Update the properties of a source output (args: index, properties) list-samples             List all entries in the sample cache play-sample              Play a sample from the sample cache (args: name, sink|index) remove-sample            Remove a sample from the sample cache (args: name) load-sample              Load a sound file into the sample cache (args: name, filename) load-sample-lazy         Lazily load a sound file into the sample cache (args: name, filename) load-sample-dir-lazy     Lazily load all files in a directory into the sample cache (args: pathname) kill-client              Kill a client (args: index) kill-sink-input          Kill a sink input (args: index) kill-source-output       Kill a source output (args: index) set-log-level            Change the log level (args: numeric level) set-log-meta             Show source code location in log messages (args: bool) set-log-time             Show timestamps in log messages (args: bool) set-log-backtrace        Show backtrace in log messages (args: frames) play-file                Play a sound file (args: filename, sink|index) dump                     Dump daemon configuration dump-volumes             Debug: Show the state of all volumes shared                   Debug: Show shared properties exit                     Terminate the daemon
 * 1) pacmd help

pactl help
pactl [options] stat [short] pactl [options] info pactl [options] list [short] [TYPE] pactl [options] exit pactl [options] upload-sample FILENAME [NAME] pactl [options] play-sample NAME [SINK] pactl [options] remove-sample NAME pactl [options] load-module NAME [ARGS ...] pactl [options] unload-module #N pactl [options] move-(sink-input|source-output) #N SINK|SOURCE pactl [options] suspend-(sink|source) NAME|#N 1|0 pactl [options] set-card-profile CARD PROFILE pactl [options] set-(sink|source)-port NAME|#N PORT pactl [options] set-(sink|source)-volume NAME|#N VOLUME pactl [options] set-(sink-input|source-output)-volume #N VOLUME pactl [options] set-(sink|source)-mute NAME|#N 1|0 pactl [options] set-(sink-input|source-output)-mute #N 1|0 pactl [options] set-sink-formats #N FORMATS pactl [options] subscribe -h, --help                           Show this help --version                        Show version -s, --server=SERVER                  The name of the server to connect to  -n, --client-name=NAME                How to call this client on the server
 * 1) pactl --help

Linux Pulseaudio USB Audio