Thanks, this helped me making my TRAKTOR 2 working with Mixxx, which uses ALSA.
For other apps, which mainly use pulseaudio on top of ALSA, it used to work out of the box. But suddenly, after some ubuntu update it stopped working.
I could fix this problem by adding a configuration file to pulseaudio.
As root, go to /usr/share/pulseaudio/alsa-mixer/profile-sets.
You will see there are conf files for the audio6, audio8, etc, but nothing for the audio 2. THOUGH, surprisingly, a file named native-instruments-traktor-audio2.conf IS referenced in /lib/udev/rules.d/90-pulseaudio.rules . That's the source of the problem, maybe the file was omitted by the developpers, and pulseaudio complains about not finding it.
It's easy to create this file, i copied the audio6 file and stripped everything about inputs - as the audio2 has outputs only.
Then it has to be named exactly : native-instruments-traktor-audio2.conf
Now it works again, and as a bonus I can choose between channels A and B. Formerly i was restricted to channel A in pulseaudio.
Here is my file, hope it can help someone. I guess this omission will be fixed in a pulseaudio update to come.
[General]
auto-profiles = no
[Mapping analog-stereo-a]
description = Analog Stereo Channel A
device-strings = hw:%f,0,0
channel-map = left,right
[Mapping analog-stereo-b-output]
description = Analog Stereo Channel B (Headphones)
device-strings = hw:%f,0,1
channel-map = left,right
direction = output
[Profile output:analog-stereo-all]
description = Analog Stereo Duplex Channels A, B (Headphones)
output-mappings = analog-stereo-a analog-stereo-b-output
priority = 3
skip-probe = yes
[Profile output:analog-stereo-a]
description = Analog Stereo Output Channel A
output-mappings = analog-stereo-a
priority = 1
skip-probe = yes
[Profile output:analog-stereo-b]
description = Analog Stereo Output Channel B (Headphones)
output-mappings = analog-stereo-b-output
priority = 2
skip-probe = yes
Run:
$ pacmd list-cards
To display the index of your cards. For example, my pci sound card is at index 2. The sound profile for analogue output (again as an example) is called "output:analog-stereo".
Then:
$ pacmd set-card-profile 2 output:analog-stereo
To set this as the output (give it a try).
To make it permanent, edit /etc/pulse/default.pa and add:
set-card-profile 2 output:analog-stereo
set-default-sink 2
Restart pulseaudio or reboot to check persistence.
If you want to also set mic(input) defaults
set-card-profile 2 output:analog-stereo+input:analog-stereo
set-default-sink 2
Best Answer
This is a way set default sound output card dynamically using PulseAudio (not ALSA).
Check list of Sources and Sinks
Set defaults:
It is possible even to set ports too. See How to switch sound output with key shortcut
Reference:
man pactl