Linux default audio device

plembo / SetDefAudioInUbuntu1804.md

The problem: When you log in, Gnome picks whatever it damn pleases to make the active audio device(s). In my situation this was a little used but electrically problematic (bad grounding caused it to introduce an annoying hum) Dell Sound Bar. I fiddled with the gui interfaces (both Gnome’s built-in and the add-on pavucontrol), with no success.

NOTE: No longer using this as I’ve moved on to Ubuntu 22.04 with pipewire. I’m back to working with pavucontrol to try keeping things under control.

Some brief notes to bring together what I’ve personally found to work.

The definitive thread on askubuntu is here:

This contains the answer(s), but in a disjointed way.

  1. Get the names of your audio devices loading by running pactl list short sinks (for me this would include alsa_output.pci-0000_00_1f.3.analog-stereo , my built-in audio).
  2. Create a new command with Startup Applications called «Set Default Audio Output» and enter this as the Command: pactl set-default-sink . In my case:
pactl set-default-sink alsa_output.pci-0000_00_1f.3.analog-stereo 
  1. Save and exit Startup Applications and log out.
  2. Log back in and verify that your desired audio device is now active (Gnome settings sound applet or pavucontrol will show this).

While normally I’d prefer to run something like this from .bashrc or .profile, I opted for a Startup Applications command because it launches with Gnome, and so won’t get bigfooted by whatever settings the damned gui decides to impose.

As I was going through this exercise, I couldn’t help but think I’d been through this kind of struggle with an operating environment before. Then I remembered. Right. Windows 95 (and every Windows since).

NOTE: The favoritism shown by PulseAudio to USB audio devices is no mystery. That’s driven, among other things, by line 37 in the default /etc/pulse/default.pa (the whole section in context):

35 ### Use hot-plugged devices like Bluetooth or USB automatically (LP: #1702794) 36 .ifexists module-switch-on-connect.so 37 load-module module-switch-on-connect 38 .endif

Anyone trying to control Pulse’s behavior at the system, rather than user, level should comment that line out. For user level fixes like the one above it can be left in place (which is a relief because changes there could be overwritten by future updates).

NOTE: If you’re thinking about doing PCI passthrough with an Intel CPU having onboard graphics (e.g. HD530 on a 6th generation i5 or i7) you’ll most likely have to blacklist the i915 module. Doing that may also make the onboard audio inaccessible on boot, mooting the above trick. You’ll probably be able to switch to onboard audio after logging in, but that might compromise your ability to passthrough GPU. As always, YMMV. The results I observered were on a 3 year-old i5-6500 in an Asus PRIME B250M-C/CSM. And no, I ultimately wasn’t able to get passthrough to work for. reasons.

Читайте также:  Adding modules to linux

Источник

Setting Default Audio Device in Ubuntu 18.04

After upgrading to Ubuntu 18.04, I ran into an issue (or possibly a feature) causing the active audio input / output devices to revert to a device of the system’s choosing after a power cycle.

Installing the Sound Input & Output Device Chooser GNOME shell extension mitigated this to an extent, but was adding the need to manually change devices after every reboot still; which quickly became tedious.

Thankfully, the pactl application provides a way to script the changing of devices. The first thing to understand about this application, are the two terminologies used to describe devices. A sink is an output device (i.e. your speakers), and a source is an input device (i.e. your microphone).

Using pactl to Switch Devices

To get a list of all the output devices, open a terminal and run pactl list short sinks ; this should provide you with a list of output devices.

0 alsa_output.pci-0000_02_00.1.hdmi-stereo module-alsa-card.c s16le 2ch 44100Hz SUSPENDED 1 alsa_output.usb-Blue_Microphones_Yeti_Stereo_Microphone_REV8-00.analog-stereo module-alsa-card.c s16le 2ch 44100Hz SUSPENDED 2 alsa_output.usb-FiiO_DigiHug_USB_Audio-01.analog-stereo module-alsa-card.c s16le 2ch 44100Hz SUSPENDED 3 alsa_output.pci-0000_00_1f.3.analog-stereo module-alsa-card.c s16le 2ch 48000Hz RUNNING 

For reference, the devices listed in the above output relate to the devices that can be seen in the settings screen below:

For my setup, the device I want to be the default output is the one that can be seen highlighted in the above screenshot — Line Out — Built-in Audio .

To switch to this device, using pactl , the device must first be identified from the list of device names previously acquired. In this case, the device name is alsa_output.pci-0000_00_1f.3.analog-stereo .

With the name known, pactl can be executed using the set-default-sink option, to switch the output device. In the above example, the command that would be executed is:

pactl set-default-sink 'alsa_output.pci-0000_00_1f.3.analog-stereo' 

Switching the input device consists of the same process, but replacing any instance of sink with source . For example, instead of running pactl list short sinks , one would run pactl list short sources .

Below are the steps taken to set the default input device to the Yeti microphone.

$ pactl list short sources 0 alsa_output.pci-0000_02_00.1.hdmi-stereo.monitor module-alsa-card.c s16le 2ch 44100Hz SUSPENDED 1 alsa_input.usb-AVerMedia_Technologies__Inc._Live_Gamer_Portable_2_5202050100060-03.analog-stereo module-alsa-card.c s16le 2ch 48000Hz SUSPENDED 2 alsa_output.usb-Blue_Microphones_Yeti_Stereo_Microphone_REV8-00.analog-stereo.monitor module-alsa-card.c s16le 2ch 44100Hz SUSPENDED 3 alsa_input.usb-Blue_Microphones_Yeti_Stereo_Microphone_REV8-00.analog-stereo module-alsa-card.c s16le 2ch 44100Hz RUNNING 4 alsa_output.usb-FiiO_DigiHug_USB_Audio-01.analog-stereo.monitor module-alsa-card.c s16le 2ch 44100Hz SUSPENDED 5 alsa_input.usb-FiiO_DigiHug_USB_Audio-01.analog-stereo module-alsa-card.c s16le 2ch 44100Hz SUSPENDED 6 alsa_output.pci-0000_00_1f.3.analog-stereo.monitor module-alsa-card.c s16le 2ch 48000Hz SUSPENDED 7 alsa_input.pci-0000_00_1f.3.analog-stereo module-alsa-card.c s16le 2ch 44100Hz SUSPENDED $ pactl set-default-source 'alsa_input.usb-Blue_Microphones_Yeti_Stereo_Microphone_REV8-00.analog-stereo' 

Automating The Switch

Now that the device names are known, and they have been verified to work by using the pactl application. They can be used in conjunction with the default Pulse configuration file.

Читайте также:  Linux professional institute certification study guide

Open /etc/pulse/default.pa and scroll to the bottom of the file, where two lines starting with set- will be commented out.

Uncomment these lines and replace the words input and output with the number of the sink / source that you want to be the default.

In my case, the alsa_input.usb-Blue_Microphones_Yeti_Stereo_Microphone_REV8-00.analog-stereo and alsa_output.pci-0000_00_1f.3.analog-stereo devices were both 3 , so the settings I used were:

### Make some devices default set-default-sink 3 set-default-source 3 

After doing this, delete the ~/.config/pulse directory, and then reboot the system. Once the system comes back up, the appropriate devices should now be set as the defaults.

The downside to this approach, will be that if the device list changes, the indexes of the devices may also change, meaning this process may need to be repeated; but it resolves the immediate issue, when there are multiple audio devices connected on a permanent basis.

Источник

Change default sound device

After upgrading to Ubuntu 13.10 my sound stopped working. I eventually figured out that Ubuntu had selected the HDMI sound device instead of my analogue speakers. I switched to the correct device and everything worked fine until I rebooted. I now have to select the correct device every time I boot Ubuntu. How do I set my speakers as the default device? Edit: Since i upgraded to Ubuntu 14.04 Ubuntu now selects the onboard sound device by default so I no longer have this problem.

This question is not a duplication of that post. Maybe it would be more appropriate for the title to be «Change default default sound device» (the word default is intentionally used twice). Hope that clears things up a bit.

7 Answers 7

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».

$ 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 

Thanks! That was the only way to solve my problem, having every sound muted after ALSA & JACKD installation.

Читайте также:  Mpv player linux настройка

Still works on Ubuntu 17.10. I was first confused because pacmd list-cards only listed one card so I thought I could not switch. I want to switch from my laptop speakers to hdmi. This is the same card for me, just another output ( analog-stereo vs. hdmi-stereo ).

On the Dash, search for Multimedia Systems Selector.

Open it and in its Audio tab you can select the default audio Input and Output devices.

enter image description here

This application is installed by default in Ubuntu Installation. But if you haven`t this somehow can install by

sudo apt-get install gnome-media 

If it is not shown in the Dash, run:

gksudo gedit /usr/share/applications/gstreamer-properties.desktop 

In the resulting text file, go to the line starts with NoDisplay= . Change the NoDisplay=true to NoDisplay=false

Thanks for the thourough response, unfortunately this didn’t work. It would seem like this is the perfect solution but Ubuntu seems to ignore these preferences and continues to select the HDMI sound device on startup.

The easiest solution for Ubuntu 16.04 was to create a script that listens when screen unlocks instead of script that listens to when system wakeups because it seems not all services are available at the instant that system wakes up. I couldn’t get pulseaudio to switch to HDMI sound with a wakeup script but have successfully fixed it using the unlock listening script:

dbus-monitor --session "type='signal',interface='com.ubuntu.Upstart0_6'" | \ ( while true; do read X if echo $X | grep "desktop-lock" &> /dev/null; then echo "screen locked" elif echo $X | grep "desktop-unlock" &> /dev/null; then /usr/bin/pacmd set-card-profile 0 output:hdmi-surround+input:analog-stereo fi done ) 

If you’re using a newer 3.x gnome, show your launcher (default windows key) type settings -> sound. Select a different default, close the window.

Picture of the select sound window

There’s also an Audio Output Switcher GNOME extension, which provides quick access:

enter image description here

You can set the default by ordering the sound cards in ALSA with slots= .

Find the driver module names for the sound cards you want to use by inspecting lsmod ‘s output with: lsmod | grep -P ‘^snd[_]?[A-z]*’ or just lsmod . For e.g. my Creative X-FI Xtreme Gamer is snd_ctxfi , my on-board is snd_hda_intel and my USB webcam is snd_usb_audio .

Now open up in a text editor or nano your corresponding ALSA config file e.g. sudo nano /etc/modprobe.d/alsa-base.conf and at the bottom add something of the following in order of precedence (the first declaration becomes default):

options snd slots=snd_ctxfi,snd_hda_audio,snd_usb_audio then to save just CTRL+o+enter & CTRL+x . Restart and you may be sorted.

Источник

Оцените статью
Adblock
detector