The officially official Devuan Forum!

You are not logged in.

#1 2025-09-22 12:14:33

kapqa
Member
Registered: 2019-01-02
Posts: 438  

(alsa) changin soundcard easily via terminal

Hello ,

i have installed devuanpi on pi4 and like how responsive the mpv player can get.

now i would like however to change the default @audio from alsa-headphones to alsa-vc4/hdmi1.
i am selecting in alsamixer F6 and select soundcard, but the sound would  not switch.

what is the proper procedure to switch the sound from the headphones to the HDMI on this raspberry easily, preferably via terminal, or via applet.

thanks.

https://imgur.com/87ZWEQx.png

PRETTY_NAME="Devuan GNU/Linux 5 (daedalus)"
NAME="Devuan GNU/Linux"
VERSION_ID="5"
VERSION="5 (daedalus)"
VERSION_CODENAME="daedalus"
ID=devuan
ID_LIKE=debian
HOME_URL="https://www.devuan.org/"
SUPPORT_URL="https://devuan.org/os/community"
BUG_REPORT_URL="https://bugs.devuan.org/"

Offline

#2 2025-09-22 12:29:36

igorzwx
Member
Registered: 2024-05-06
Posts: 314  

Re: (alsa) changin soundcard easily via terminal

If you have two ALSA configs with different default devices, you can toggle them with a mouse click. What is needed is a simple bash script and a Desktop launcher.
Example is here:
_https://dev1galaxy.org/viewtopic.php?pid=57177#p57177
It was designed for a Linux Mint user who wanted to switch from a Bluetooth headphones to Intel HDA codec (and other way round) with a mouse click.

The magic commans:

cp $HOME/.asoundrc-BT $HOME/.asoundrc 

cp $HOME/.asoundrc-HDA $HOME/.asoundrc 

cp means "copy".

$ alsamixer -h
Usage: alsamixer [options]
Useful options:
  -h, --help              this help
  -c, --card=NUMBER       sound card number or id
  -D, --device=NAME       mixer device name
  -m, --mouse             enable mouse
  -M, --no-mouse          disable mouse
  -f, --config=FILE       configuration file
  -F, --no-config         do not load configuration file
  -V, --view=MODE         starting view mode: playback/capture/all
Debugging options:
  -g, --no-color          toggle using of colors
  -a, --abstraction=NAME  mixer abstraction level: none/basic

Last edited by igorzwx (2025-09-22 12:43:39)

Online

#3 2025-09-22 13:18:54

ralph.ronnquist
Administrator
From: Battery Point, Tasmania, AUS
Registered: 2016-11-30
Posts: 1,473  

Re: (alsa) changin soundcard easily via terminal

Yes, and one thing that is confusing with ALSA is that programs typically loads the sound configuration only once, early during startup. Therefore such a change to the configuration only takes effect for programs that are started after the change.

There is a way to make a configuration have a dynamic part, to be automatically reloaded upon every sink (or source) creation instead, but then we are entering a deeper level of understanding of ALSA configuration structure and elements which most people rather wish to avoid.

Offline

#4 2025-09-22 13:49:19

igorzwx
Member
Registered: 2024-05-06
Posts: 314  

Re: (alsa) changin soundcard easily via terminal

Have you tested this method?

It works without problems.

If a problem occurs, the user can restart mpv player.

Last edited by igorzwx (2025-09-22 13:52:00)

Online

#5 2025-09-22 14:57:34

kapqa
Member
Registered: 2019-01-02
Posts: 438  

Re: (alsa) changin soundcard easily via terminal

have to admin that i am quite an ignoramus when it comes to (sound)architecture, and so , no , i havent tested it yet (if asked), as it seems to me quite @advanced magic.

was hoping for something foolproof_ that could also withstand a shuffling around of the devices e.g. when something new is added to the mix, without need for cp files<

like if the alsamixer can do so much finetuning, and actually adjust volumes, what prevents it from actually swtiching the output to the desired device?
maybe there is some @hidden?menu that lets it activate the device one wants to play and finally disable to ?bt_device sufficiently.

Offline

#6 2025-09-22 15:07:21

rolfie
Member
Registered: 2017-11-25
Posts: 1,303  

Re: (alsa) changin soundcard easily via terminal

If you use a desktop like Mate, Cinnamon, XFCE or like, install pipewire to switch between sources and sinks.

Alsa is not userfriendly and lacks everything required to easily control Audio hardware.

Offline

#7 2025-09-22 15:08:17

greenjeans
Member
Registered: 2017-04-07
Posts: 1,188  
Website

Re: (alsa) changin soundcard easily via terminal

Looks like from the screenshot that you are using the default (card 0) which is your headphones, when what you want is card 2, should be as simple as changing the card number in your ~/.asoundrc to 2 instead of 0. (Assuming you have that file, if not you may need to make one.)

I noticed it mentions "Broadcom Mixer", that I am unfamiliar with. If it's a genuine mixer, then it likely has control of alsa starting with boot-up, in which case the alsamixer will likely only be good for adjusting main volume. But perhaps that's just something local to the headphones.

Last edited by greenjeans (2025-09-22 15:10:52)


https://sourceforge.net/projects/vuu-do/ New Vuu-do isos uploaded August 2025!
Vuu-do GNU/Linux, minimal Devuan-based Openbox and Mate systems to build on. Also a max version for OB.
Devuan 5 mate-mini iso, pure Devuan, 100% no-vuu-do. wink Devuan 6 version also available for testing.
Please donate to support Devuan and init freedom! https://devuan.org/os/donate

Offline

#8 2025-09-22 15:18:04

igorzwx
Member
Registered: 2024-05-06
Posts: 314  

Re: (alsa) changin soundcard easily via terminal

If you do not like my solution, you may try something like this :
One united default PCM for two cards, or TwoCardsAsOne
_https://unix.stackexchange.com/a/295050
_https://unix.stackexchange.com/a/194631

Online

#9 2025-09-22 15:34:40

kapqa
Member
Registered: 2019-01-02
Posts: 438  

Re: (alsa) changin soundcard easily via terminal

there is unfortunately no .asoundrc as it seems ,
however i am @root account since the adduser did not create a user directory and hence startx would not start for sudo user.

maybe there is a switch in this configuration however that can easily be operated?

/usr/share/alsa/alsa.conf

#
#  ALSA library configuration file
#

# pre-load the configuration files

@hooks [
	{
		func load
		files [
			"/var/lib/alsa/conf.d"
			"/usr/etc/alsa/conf.d"
			"/etc/alsa/conf.d"
			"/etc/asound.conf|||/usr/etc/asound.conf"
			"~/.asoundrc"
			{
				@func concat
				strings [
					{
						@func getenv
						vars [
							XDG_CONFIG_HOME
						]
						default "~/.config"
					}
					"/alsa/asoundrc"
				]
			}
		]
		errors false
	}
]

# load card-specific configuration files (on request)

cards.@hooks [
	{
		func load
		files [
			{
				@func concat
				strings [
					{ @func datadir }
					"/cards/aliases.conf"
				]
			}
		]
	}
	{
		func load_for_all_cards
		files [
			{
				@func concat
				strings [
					{ @func datadir }
					"/cards/"
					{ @func private_string }
					".conf"
				]
			}
			{
				root {
					@func private_integer
				}
				file {
					@func concat
					strings [
						"/var/lib/alsa/card"
						{ @func private_integer }
						".conf.d"
					]
				}
			}
		]
		table {
			id {
				@func concat
				strings [
					{ @func private_integer }
				]
			}
			value {
				@func concat
				strings [
					"cards."
					{ @func private_string }
				]
			}
		}
		errors false
	}
]

#
# defaults
#

# show all name hints also for definitions without hint {} section
defaults.namehint.showall on
# show just basic name hints
defaults.namehint.basic on
# show extended name hints
defaults.namehint.extended on
#
defaults.ctl.card 0
defaults.pcm.card 0
defaults.pcm.device 0
defaults.pcm.subdevice -1
defaults.pcm.nonblock 1
defaults.pcm.compat 0
defaults.pcm.minperiodtime 5000		# in us
defaults.pcm.ipc_key 5678293
defaults.pcm.ipc_gid audio
defaults.pcm.ipc_perm 0660
defaults.pcm.tstamp_type default
defaults.pcm.dmix.max_periods 0
defaults.pcm.dmix.channels 2
defaults.pcm.dmix.rate 48000
defaults.pcm.dmix.format unchanged
defaults.pcm.dmix.card defaults.pcm.card
defaults.pcm.dmix.device defaults.pcm.device
defaults.pcm.dsnoop.card defaults.pcm.card
defaults.pcm.dsnoop.device defaults.pcm.device
defaults.pcm.front.card defaults.pcm.card
defaults.pcm.front.device defaults.pcm.device
defaults.pcm.rear.card defaults.pcm.card
defaults.pcm.rear.device defaults.pcm.device
defaults.pcm.center_lfe.card defaults.pcm.card
defaults.pcm.center_lfe.device defaults.pcm.device
defaults.pcm.side.card defaults.pcm.card
defaults.pcm.side.device defaults.pcm.device
defaults.pcm.surround21.card defaults.pcm.card
defaults.pcm.surround21.device defaults.pcm.device
defaults.pcm.surround40.card defaults.pcm.card
defaults.pcm.surround40.device defaults.pcm.device
defaults.pcm.surround41.card defaults.pcm.card
defaults.pcm.surround41.device defaults.pcm.device
defaults.pcm.surround50.card defaults.pcm.card
defaults.pcm.surround50.device defaults.pcm.device
defaults.pcm.surround51.card defaults.pcm.card
defaults.pcm.surround51.device defaults.pcm.device
defaults.pcm.surround71.card defaults.pcm.card
defaults.pcm.surround71.device defaults.pcm.device
defaults.pcm.iec958.card defaults.pcm.card
defaults.pcm.iec958.device defaults.pcm.device
defaults.pcm.modem.card defaults.pcm.card
defaults.pcm.modem.device defaults.pcm.device
defaults.pcm.file_format raw
defaults.pcm.file_truncate true		# truncate files via file or tee PCM
defaults.rawmidi.card 0
defaults.rawmidi.device 0
defaults.rawmidi.subdevice -1
defaults.hwdep.card 0
defaults.hwdep.device 0
defaults.timer.class 2
defaults.timer.sclass 0
defaults.timer.card 0
defaults.timer.device 0
defaults.timer.subdevice 0

#
#  PCM interface
#

pcm.hw {
	@args [ CARD DEV SUBDEV ]
	@args.CARD {
		type string
		default {
			@func getenv
			vars [
				ALSA_PCM_CARD
				ALSA_CARD
			]
			default {
				@func refer
				name defaults.pcm.card
			}
		}
	}
	@args.DEV {
		type integer
		default {
			@func igetenv
			vars [
				ALSA_PCM_DEVICE
			]
			default {
				@func refer
				name defaults.pcm.device
			}
		}
	}
	@args.SUBDEV {
		type integer
		default {
			@func refer
			name defaults.pcm.subdevice
		}
	}		
	type hw
	card $CARD
	device $DEV
	subdevice $SUBDEV
	hint {
		show {
			@func refer
			name defaults.namehint.extended
		}
		description "Direct hardware device without any conversions"
	}
}

pcm.plughw {
	@args [ CARD DEV SUBDEV ]
	@args.CARD {
		type string
		default {
			@func getenv
			vars [
				ALSA_PCM_CARD
				ALSA_CARD
			]
			default {
				@func refer
				name defaults.pcm.card
			}
		}
	}
	@args.DEV {
		type integer
		default {
			@func igetenv
			vars [
				ALSA_PCM_DEVICE
			]
			default {
				@func refer
				name defaults.pcm.device
			}
		}
	}
	@args.SUBDEV {
		type integer
		default {
			@func refer
			name defaults.pcm.subdevice
		}
	}		
	type plug
	slave.pcm {
		type hw
		card $CARD
		device $DEV
		subdevice $SUBDEV
	}
	hint {
		show {
			@func refer
			name defaults.namehint.extended
		}
		description "Hardware device with all software conversions"
	}
}

pcm.plug {
	@args [ SLAVE ]
	@args.SLAVE {
		type string
	}
	type plug
	slave.pcm $SLAVE
}

pcm.shm {
	@args [ SOCKET PCM ]
	@args.SOCKET {
		type string
	}
	@args.PCM {
		type string
	}
	type shm
	server $SOCKET
	pcm $PCM
}

pcm.tee {
	@args [ SLAVE FILE FORMAT ]
	@args.SLAVE {
		type string
	}
	@args.FILE {
		type string
	}
	@args.FORMAT {
		type string
		default {
			@func refer
			name defaults.pcm.file_format
		}
	}
	type file
	slave.pcm $SLAVE
	file $FILE
	format $FORMAT
	truncate {
		@func refer
		name defaults.pcm.file_truncate
	}
}

pcm.file {
	@args [ FILE FORMAT ]
	@args.FILE {
		type string
	}
	@args.FORMAT {
		type string
		default {
			@func refer
			name defaults.pcm.file_format
		}
	}
	type file
	slave.pcm null
	file $FILE
	format $FORMAT
	truncate {
		@func refer
		name defaults.pcm.file_truncate
	}
}

pcm.null {
	type null
	hint {
		show {
			@func refer
			name defaults.namehint.basic
		}
		description "Discard all samples (playback) or generate zero samples (capture)"
	}
}

# redirect to load-on-demand extended pcm definitions
pcm.cards cards.pcm

pcm.default cards.pcm.default
pcm.sysdefault cards.pcm.default
pcm.front cards.pcm.front
pcm.rear cards.pcm.rear
pcm.center_lfe cards.pcm.center_lfe
pcm.side cards.pcm.side
pcm.surround21 cards.pcm.surround21
pcm.surround40 cards.pcm.surround40
pcm.surround41 cards.pcm.surround41
pcm.surround50 cards.pcm.surround50
pcm.surround51 cards.pcm.surround51
pcm.surround71 cards.pcm.surround71
pcm.iec958 cards.pcm.iec958
pcm.spdif iec958
pcm.hdmi cards.pcm.hdmi
pcm.dmix cards.pcm.dmix
pcm.dsnoop cards.pcm.dsnoop
pcm.modem cards.pcm.modem
pcm.phoneline cards.pcm.phoneline

#
#  Control interface
#
	
ctl.default cards.ctl.default
ctl.sysdefault cards.ctl.default

ctl.hw {
	@args [ CARD ]
	@args.CARD {
		type string
		default {
			@func getenv
			vars [
				ALSA_CTL_CARD
				ALSA_CARD
			]
			default {
				@func refer
				name defaults.ctl.card
			}
		}
	}
	type hw
	card $CARD
	hint.description "Direct control device"
}

ctl.shm {
	@args [ SOCKET CTL ]
	@args.SOCKET {
		type string
	}
	@args.CTL {
		type string
	}
	type shm
	server $SOCKET
	ctl $CTL
}

#
#  RawMidi interface
#

rawmidi.default {
	type hw
	card {
		@func getenv
		vars [
			ALSA_RAWMIDI_CARD
			ALSA_CARD
		]
		default {
			@func refer
			name defaults.rawmidi.card
		}
	}
	device {
		@func igetenv
		vars [
			ALSA_RAWMIDI_DEVICE
		]
		default {
			@func refer
			name defaults.rawmidi.device
		}
	}
	hint.description "Default raw MIDI device"
}

rawmidi.hw {
	@args [ CARD DEV SUBDEV ]
	@args.CARD {
		type string
		default {
			@func getenv
			vars [
				ALSA_RAWMIDI_CARD
				ALSA_CARD
			]
			default {
				@func refer
				name defaults.rawmidi.card
			}
		}
	}
	@args.DEV {
		type integer
		default {
			@func igetenv
			vars [
				ALSA_RAWMIDI_DEVICE
			]
			default {
				@func refer
				name defaults.rawmidi.device
			}
		}
	}
	@args.SUBDEV {
		type integer
		default -1
	}
	type hw
	card $CARD
	device $DEV
	subdevice $SUBDEV
	hint {
		description "Direct rawmidi driver device"
		device $DEV
	}
}

rawmidi.virtual {
	@args [ MERGE ]
	@args.MERGE {
		type string
		default 1
	}
	type virtual
	merge $MERGE
}

#
#  Sequencer interface
#

seq.default {
	type hw
	hint.description "Default sequencer device"
}

seq.hw {
	type hw
}

#
#  HwDep interface
#

hwdep.default {
	type hw
	card {
		@func getenv
		vars [
			ALSA_HWDEP_CARD
			ALSA_CARD
		]
		default {
			@func refer
			name defaults.hwdep.card
		}
	}
	device {
		@func igetenv
		vars [
			ALSA_HWDEP_DEVICE
		]
		default {
			@func refer
			name defaults.hwdep.device
		}
	}
	hint.description "Default hardware dependent device"
}

hwdep.hw {
	@args [ CARD DEV ]
	@args.CARD {
		type string
		default {
			@func getenv
			vars [
				ALSA_HWDEP_CARD
				ALSA_CARD
			]
			default {
				@func refer
				name defaults.hwdep.card
			}
		}
	}
	@args.DEV {
		type integer
		default {
			@func igetenv
			vars [
				ALSA_HWDEP_DEVICE
			]
			default {
				@func refer
				name defaults.hwdep.device
			}
		}
	}
	type hw
	card $CARD
	device $DEV
	hint {
		description "Direct hardware dependent device"
		device $DEV
	}
}

#
#  Timer interface
#

timer_query.default {
	type hw
}

timer_query.hw {
	type hw
}

timer.default {
	type hw
	class {
		@func refer
		name defaults.timer.class
	}
	sclass {
		@func refer
		name defaults.timer.sclass
	}
	card {
		@func refer
		name defaults.timer.card
	}
	device {
		@func refer
		name defaults.timer.device
	}
	subdevice {
		@func refer
		name defaults.timer.subdevice
	}
	hint.description "Default timer device"
}

timer.hw {
	@args [ CLASS SCLASS CARD DEV SUBDEV ]
	@args.CLASS {
		type integer
		default {
			@func refer
			name defaults.timer.class
		}
	}
	@args.SCLASS {
		type integer
		default {
			@func refer
			name defaults.timer.sclass
		}
	}
	@args.CARD {
		type string
		default {
			@func refer
			name defaults.timer.card
		}
	}
	@args.DEV {
		type integer
		default {
			@func refer
			name defaults.timer.device
		}
	}
	@args.SUBDEV {
		type integer
		default {
			@func refer
			name defaults.timer.subdevice
		}
	}
	type hw
	class $CLASS
	sclass $SCLASS
	card $CARD
	device $DEV
	subdevice $SUBDEV
	hint {
		description "Direct timer device"
		device $DEV
	}
}

EDIT> i am now at user @test1 , but there is still no .asoundrc present.

Last edited by kapqa (2025-09-22 15:43:35)

Offline

#10 2025-09-22 15:45:58

igorzwx
Member
Registered: 2024-05-06
Posts: 314  

Re: (alsa) changin soundcard easily via terminal

Can you create two ALSA configs (with different default devices) with arateconf?

For example:
1. Create a config with arateconf and save it.
2. Open it with a text editor a save a copy of it, for example:

pluma $HOME/.asoundrc 
mousepad $HOME/.asoundrc 
echo $HOME

3. Create another config and save a copy of it.

Last edited by igorzwx (2025-09-22 15:47:29)

Online

#11 2025-09-22 15:51:04

greenjeans
Member
Registered: 2017-04-07
Posts: 1,188  
Website

Re: (alsa) changin soundcard easily via terminal

Well I don't know much about Devuanpi, is it using XFCE or something else? Some DE's have their own built-in mixer.

I think I would start by making a super simple .asoundrc and going from there.

pcm.!default {
	type hw
	card 0
}

ctl.!default {
	type hw           
	card 0
}

Of course that leaves you with the default card 0, so try changing the 0's to 2's for the card you want.

If that works, a simple script that offers a dialog where you choose either 0, 1, or 2, and it seds the change and re-starts alsa, would allow you to change during session.

https://www.alsa-project.org/main/index.php/Asoundrc

Last edited by greenjeans (2025-09-22 15:52:38)


https://sourceforge.net/projects/vuu-do/ New Vuu-do isos uploaded August 2025!
Vuu-do GNU/Linux, minimal Devuan-based Openbox and Mate systems to build on. Also a max version for OB.
Devuan 5 mate-mini iso, pure Devuan, 100% no-vuu-do. wink Devuan 6 version also available for testing.
Please donate to support Devuan and init freedom! https://devuan.org/os/donate

Offline

#12 2025-09-22 16:31:21

igorzwx
Member
Registered: 2024-05-06
Posts: 314  

Re: (alsa) changin soundcard easily via terminal

No need to re-start ALSA, if you change (or create) ~/.asoundrc

If sound quality does not matter, a simple config might be a solution.

You may need to reload ALSA, if you remove pulseaudio or pipewire.

Last edited by igorzwx (2025-09-22 17:34:56)

Online

#13 2025-09-22 16:33:43

kapqa
Member
Registered: 2019-01-02
Posts: 438  

Re: (alsa) changin soundcard easily via terminal

@greenjeans, yes, have installed xfce4 and start with "startx" for user now test1.
thanks, will look into it and test abit all your solutions that may reach.

EDIT> have not yet removed pulse or pipe, would like to see if this can be handled at "pristine" state right out of devuanpi. pulse audio is a bit handy as it allows via pavucontrol socalled "fallback" reallive-switching of sources. but the task should be handled by alsa via alsamixer or any other feature easily activabble even for a fairly inexperienced user.

Last edited by kapqa (2025-09-22 16:37:57)

Offline

#14 2025-09-22 16:56:06

kapqa
Member
Registered: 2019-01-02
Posts: 438  

Re: (alsa) changin soundcard easily via terminal

I think I would start by making a super simple .asoundrc and going from there.

pcm.!default {
    type hw
    card 0
}

ctl.!default {
    type hw           
    card 0
}

unfortunately this would not switch the audio to device 0 if in pulseaudio hdmi0 is selected as active fallback.
maybe there is some additional info needed to effectuate the change.

https://imgur.com/vUjyq7t.png
https://imgur.com/ccaTY5j.png
https://imgur.com/kDYeQSx.png
https://imgur.com/MR6ptML.png
https://imgur.com/UXc7DAy.png

Offline

#15 2025-09-22 17:04:52

g4sra
Member
Registered: 2018-12-12
Posts: 37  

Re: (alsa) changin soundcard easily via terminal

Do not use indexes, use the designated device names consistently and totally...

# PlayStation®VR USB Streaming used in 3D Mode Only (HDMI used in 2D Cine Mode)
pcm.psvr_hw {
  type hw
  card 'PlayStation®VR'
  device 0
  channels 2
}

This is an example from my config of a sound device which comes and goes without breaking anything.

Offline

#16 2025-09-22 17:19:40

igorzwx
Member
Registered: 2024-05-06
Posts: 314  

Re: (alsa) changin soundcard easily via terminal

Yes. To avoid troubles, one has to use the names.

$ cat /proc/asound/cards
 0 [system         ]: USB-Audio - iMic USB audio system
                      Griffin Technology, Inc iMic USB audio system at usb-0000:00:1a.0-1.3.4, full s
$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: system [iMic USB audio system], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
Card number: 0   Name: "system"

This is config generated by arateconf:

$ cat $HOME/.asoundrc
# ALSA library configuration file managed by arateconf.
#
# MANUAL CHANGES TO THIS FILE WILL BE OVERWRITTEN!
#
# Manual changes to the ALSA library configuration should be implemented
# by editing the ~/.asoundrc file, not by editing this file.

#=====================================================
# Configuration for system
#-----------------------------------------------------

# Perform dmixer
pcm.dmixer
{
	type			dmix
	ipc_key			1024
	ipc_perm		0666

	hint
	{
		show		off
		description	"Direct mixing of multiple audio streams"
	}

	slave
	{
		pcm		"hw:system,0"

		rate		48000
		channels	2
		format		S16_LE

		period_size	1920
		buffer_size	7680
	}
}

# Perform dsnooper
pcm.dsnooper
{
	type			dsnoop
	ipc_key			1025
	ipc_perm		0666

	hint
	{
		show		off
		description	"Recording from the same device for several applications simultaneously"
	}

	slave
	{
		pcm		"hw:system,0"

		rate		48000
		format		S16_LE

		period_size	1920
		buffer_size	7680
	}
}

# Perform duplex
pcm.duplex
{
	type			asym
	playback.pcm		"dmixer"
	capture.pcm		"dsnooper"

	hint
	{
		show		off
		description	"Full duplex for simultaneous playback and recording"
	}
}

# Perform convert
pcm.convert
{
	type			rate
	converter		fftrate

	hint
	{
		show		off
		description	"Sample rate converter"
	}

	slave
	{
		pcm	"duplex"
		rate	48000
		format	S16_LE
	}
}

#=====================================================
# Configuration for default audio device
#-----------------------------------------------------

# Perform plug device
pcm.!default
{
	type			plug
	slave.pcm		"convert"
	hint.description	"Default device"
}

Last edited by igorzwx (2025-09-22 17:41:14)

Online

#17 2025-09-22 17:41:54

kapqa
Member
Registered: 2019-01-02
Posts: 438  

Re: (alsa) changin soundcard easily via terminal

@igor to get arateconf one has to geo go the extra mile first, so it should be feasible also without?

have just checcked on "raspios" which is favored by raspberry pi foundation, and there is also no .asoundrc,
but i presume the plugin which is function beautifully is handled via pulseaudio<
it functions, but there is alot of stuttering involved, which is probably abit feature of pulse as already experienced in the past.

https://ibb.co/wZ9p1zWp

Offline

#18 2025-09-22 17:50:24

igorzwx
Member
Registered: 2024-05-06
Posts: 314  

Re: (alsa) changin soundcard easily via terminal

Post the output of these commands:

fuser -av $(find /dev/snd -type c 2>/dev/null)
inxi -A
cat /proc/asound/cards

Online

#19 2025-09-22 18:30:19

kapqa
Member
Registered: 2019-01-02
Posts: 438  

Re: (alsa) changin soundcard easily via terminal

For RaspiOS

fuser -av $(find /dev/snd -type c 2>/dev/null)
                     USER        PID ACCESS COMMAND
/dev/snd/controlC2:  rich        733 F.... wireplumber
/dev/snd/pcmC2D0p:
/dev/snd/controlC1:
/dev/snd/pcmC1D0p:
/dev/snd/controlC0:  rich        733 F.... wireplumber
/dev/snd/pcmC0D0p:
/dev/snd/seq:        rich        729 F.... pipewire
/dev/snd/timer:
inxi -A
Audio:
  Device-1: bcm2711-hdmi0 driver: vc4_hdmi
  Device-2: bcm2711-hdmi1 driver: vc4_hdmi
  API: ALSA v: k6.12.34+rpt-rpi-v8 status: kernel-api
  Server-1: PipeWire v: 1.2.7 status: active
cat /proc/asound/cards
 0 [vc4hdmi0       ]: vc4-hdmi - vc4-hdmi-0
                      vc4-hdmi-0
 1 [vc4hdmi1       ]: vc4-hdmi - vc4-hdmi-1
                      vc4-hdmi-1
 2 [Headphones     ]: bcm2835_headpho - bcm2835 Headphones
                      bcm2835 Headphones

for Devuanpi

fuser -av $(find /dev/snd -type c 2>/dev/null)
                     USER        PID ACCESS COMMAND
/dev/snd/controlC2:
/dev/snd/pcmC2D0p:
/dev/snd/controlC1:  test1      2167 F.... pulseaudio
/dev/snd/pcmC1D0p:
/dev/snd/controlC0:  test1      2167 F.... pulseaudio
/dev/snd/pcmC0D0p:
/dev/snd/seq:
/dev/snd/timer:
inxi -A 
Audio:
  Device-1: bcm2711-hdmi0 driver: vc4_hdmi
  Device-2: bcm2711-hdmi1 driver: vc4_hdmi
  API: ALSA v: k6.1.93 status: kernel-api
  Server-1: PulseAudio v: 16.1 status: active
cat /proc/asound/cards
 0 [Headphones     ]: bcm2835_headpho - bcm2835 Headphones
                      bcm2835 Headphones
 1 [vc4hdmi0       ]: vc4-hdmi - vc4-hdmi-0
                      vc4-hdmi-0
 2 [vc4hdmi1       ]: vc4-hdmi - vc4-hdmi-1
                      vc4-hdmi-1

i am primarily interested in sorting it for Devuanpi atm.

Last edited by kapqa (2025-09-22 18:35:52)

Offline

#20 2025-09-22 18:39:40

igorzwx
Member
Registered: 2024-05-06
Posts: 314  

Re: (alsa) changin soundcard easily via terminal

Can you create a text file (two lines) with a text editor such mousepad, pluma, and the like?

If you can, it should not be a problem to create a simple ALSA config.

Do you want to use pulseaudio, or it can be removed?

Last edited by igorzwx (2025-09-22 18:47:26)

Online

#21 2025-09-22 18:53:46

kapqa
Member
Registered: 2019-01-02
Posts: 438  

Re: (alsa) changin soundcard easily via terminal

no, want to remove it.
but first want to see how to effectuate change with it present.

maybe pulseuadio interferes with .asoundrc?
it seems whatever i put in there, it is overriden by pavucontrol?

aplay -D hw:0,0 test.wav
Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
^CAborted by signal Interrupt...
$ aplay -D hw:1,1 test.wav
aplay: main:831: audio open error: No such file or directory
$ aplay -D hw:2,2 test.wav
aplay: main:831: audio open error: No such file or directory
$ cat /proc/asound/cards
 0 [Headphones     ]: bcm2835_headpho - bcm2835 Headphones
                      bcm2835 Headphones
 1 [vc4hdmi0       ]: vc4-hdmi - vc4-hdmi-0
                      vc4-hdmi-0
 2 [vc4hdmi1       ]: vc4-hdmi - vc4-hdmi-1
                      vc4-hdmi-1
$ aplay -D hw:1 test.wav 
aplay: main:831: audio open error: Device or resource busy
$ aplay -D hw:2 test.wav
aplay: main:831: audio open error: Unknown error 524

Last edited by kapqa (2025-09-22 18:58:34)

Offline

#22 2025-09-22 19:20:06

igorzwx
Member
Registered: 2024-05-06
Posts: 314  

Re: (alsa) changin soundcard easily via terminal

Do you want to know how to create $HOME/.asoundrc with a text editor?

Do you have a text editor?

sudo apt install mousepad

Last edited by igorzwx (2025-09-22 19:26:27)

Online

#23 2025-09-22 19:34:20

kapqa
Member
Registered: 2019-01-02
Posts: 438  

Re: (alsa) changin soundcard easily via terminal

feel .asoundrc could be useful in this usecase<

mousepad, installed

Last edited by kapqa (2025-09-22 19:36:52)

Offline

#24 2025-09-22 19:48:28

igorzwx
Member
Registered: 2024-05-06
Posts: 314  

Re: (alsa) changin soundcard easily via terminal

Run

mousepad $HOME/.asoundrc

Copy and past 4 lines:

defaults.pcm.!card Headphones
defaults.ctl.!card Headphones
defaults.pcm.!device 0
defaults.ctl.!device 0

Save it.

Run

cat $HOME/.asoundrc

It should look like this:

$ cat $HOME/.asoundrc
defaults.pcm.!card Headphones
defaults.ctl.!card Headphones
defaults.pcm.!device 0
defaults.ctl.!device 0

Run

speaker-test --channels 2

It should play "pink noise" to the default device (Headphones)

Online

#25 2025-09-22 19:58:34

kapqa
Member
Registered: 2019-01-02
Posts: 438  

Re: (alsa) changin soundcard easily via terminal

thank you very much, it plays,
would not have found out. (that easily)

now there are other devices, i have cable on hdmi0.

Offline

Board footer