You are not logged in.
Pages: 1
I want to know how to do this to use usb audio and without the following:
anything related to pulseaudio, pipewire, or other obnoxious linux frameworks.
alsa fine though.
Freedom is never more than one generation away from extinction. Feelings are not facts
If you wish to be humbled, try to exalt yourself long term If you wish to be exalted, try to humble yourself long term
Favourite operating systems: Hyperbola Devuan OpenBSD Gnuinos
Peace Be With us All!
Offline
I have 2 sound cards in my alsa only system:
The build-in analog out (used) and the digital HDMI audio (without any physical connection to make a sound).
cat /etc/asound.conf
defaults.pcm.card 1
defaults.ctl.card 1From time to time the index of the analog out sound card changes from 0 to 1 or back (e.g. after installing a linux distribution for testing purposes). If no sound is present, the index in "asound.conf" has to be adjusted.
A third (USB-)sound card might appear as card index "2" or even mix up the order.
Not sure whether this is helpful, but anyway.
Last edited by delgado (2026-05-14 22:38:00)
Offline
Here's a script to create or change the file delgado suggested. Run it without an argument and it will display the card names and numbers and let you choose the default card. Run it with the desired card number as an argument and it will set that card as default. e.g. set-default-card 1
Run it as root or with sudo.
$ cat set-default-card
#!/usr/bin/env bash
#set-default-card
choose_card () {
while true ; do
echo "Enter the card number to set as default."
read ans
cardnum="$ans"
break
done
}
if [ "$#" -eq 0 ] ; then
aplay -l
choose_card
else
cardnum="$1"
fi
echo "defaults.pcm.card $cardnum
defaults.ctl.card $cardnum" > /etc/asound.conf
/etc/init.d/alsa-utils restartOffline
@fsmithred does this let you swap out a card whenever and also what should I call file? And where should I put it.
Freedom is never more than one generation away from extinction. Feelings are not facts
If you wish to be humbled, try to exalt yourself long term If you wish to be exalted, try to humble yourself long term
Favourite operating systems: Hyperbola Devuan OpenBSD Gnuinos
Peace Be With us All!
Offline
I call it set-default-card. Put it in /usr/local/bin or somewhere else that's in root's path. Make it executable. Run it with or without the card number or with and without the usb audio device as many times as you want. It replaces the lines in asound.conf and restarts alsa so it takes effect.
Offline
Note that the alsa configuration for a program is loaded only once, at program start. So a configuration change like that will be in effect for the programs started after the change (only).
There is however a "refer" element that can be used in the configuration, to be expanded upon sink creation rather than just once initially. Your configuration must include such a "refer" element in order to have a configuration change take effect within an already started program.
Offline
Pages: 1