The officially official Devuan Forum!

You are not logged in.

#26 2025-09-22 20:07:36

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

Re: (alsa) changin soundcard easily via terminal

For other devices the content of $HOME/.asoundrc should be like this:

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

or like this:

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

Run

speaker-test --channels 2

It should play "pink noise" to the current default device (set in $HOME/.asoundrc  )

To free all audio devices, run

fuser -kv $(find /dev/snd -type c 2>/dev/null)

NOTE: It may not work with pulseaudio

To verify, run

fuser -av $(find /dev/snd -type c 2>/dev/null)

Last edited by igorzwx (2025-09-22 20:23:35)

Online

#27 2025-09-22 20:35:58

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

Re: (alsa) changin soundcard easily via terminal

as before, it would continue to play on headphone-out (with both vc4hdmi0 or vc4hdmi1), so most probably pulseaudio is interfering or the config is not fully satisfactorly. will test some more 2morrow.

thank you and good night.

fuser -kv $(find /dev/snd -type c 2>/dev/null)
                     USER        PID ACCESS COMMAND
/dev/snd/controlC1:  test1      2251 F.... pulseaudio
/dev/snd/controlC0:  test1      2251 F.... pulseaudio
$ fuser -av $(find /dev/snd -type c 2>/dev/null)
                     USER        PID ACCESS COMMAND
/dev/snd/controlC2:
/dev/snd/pcmC2D0p:
/dev/snd/controlC1:  test1      2898 F.... pulseaudio
/dev/snd/pcmC1D0p:
/dev/snd/controlC0:  test1      2898 F.... pulseaudio
/dev/snd/pcmC0D0p:
/dev/snd/seq:
/dev/snd/timer:

Last edited by kapqa (2025-09-22 20:36:38)

Offline

#28 2025-09-22 21:08:58

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

Re: (alsa) changin soundcard easily via terminal

kapqa wrote:

so most probably pulseaudio is interfering

Yes. It should be removed.

Online

#29 2025-09-24 10:34:34

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

Re: (alsa) changin soundcard easily via terminal

thanks , it function after pulseaudio removed, however not on devuanpi
it seems devuanpi is missing alsa-base or similar, because after removing pulseaudio there is no more sound.

on raspios the c\hange is made, a little bit silly situation resulted however, to change the playback from one device now to copy .asoundrc , practically heeded your advice and made several copy for different devices i~d like to activate.

it is no issue at all for me since it cost next to nothing, however there is room for improvement<  if i  remember correctly , there was a similar situationn on debian wheezy since after removing pulseaudio, the alsa plugin would only function for regulating the volume and not much more else, but could be mistaken.

EDIT> checked on older version of debian, not sure if the alsa mixer there effectively allowed for selection of devices , but probably it did, and you can mute/unmute. picture is taken of debian 5.

https://ibb.co/PZ085nwg

Last edited by kapqa (2025-09-24 10:42:28)

Offline

#30 2025-09-24 12:51:10

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

Re: (alsa) changin soundcard easily via terminal

Can you separate your questions into different topics?

It should not be difficult to fix sound problems with "devuanpi". Start a new topic for it.

And a new topic for this:

the alsa plugin would only function for regulating the volume

If you are not a masochist, you may better try MATE Desktop.

To make a copy of "asoundrc", run

cp -v $HOME/.asoundrc $HOME/.asoundrc-copy1

"-v" means "verbose"

Check the result

ls -a ~/ | grep asound

To replace "asoundrc" with another one (named, for example, "asoundrc-copy2"), run

cp -v $HOME/.asoundrc-copy2 $HOME/.asoundrc

To read, edit, or create a text file, you may try commands like these:

mousepad $HOME/.asoundrc
mousepad $HOME/.asoundrc-copy2

alsamixer:

alsamixer -c <Name of the card (id)>

Try

alsamixer -c Headphones
alsamixer -c vc4hdmi0
alsamixer -c vc4hdmi1

speaker-test:

speaker-test -D hw:<Name of the card (id)>,0 --channels 2

Try

speaker-test -D hw:Headphones,0 --channels 2
speaker-test -D hw:vc4hdmi0,0 --channels 2
speaker-test -D hw:vc4hdmi1,0 --channels 2

The very old versions of "alsamixer" did allow to select a card, but to start "alsamixer", you had to use the name of card (or number), for example:

alsamixer -c 0
alsamixer -c PCH

Last edited by igorzwx (2025-09-24 13:18:00)

Online

#31 2025-09-24 13:37:24

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

Re: (alsa) changin soundcard easily via terminal

@igorzwx for now it functions oso we could also lay it to rest<
had to install xfce4 anyway because otherwise would not get a desktopZ
devuanpi as i understand it is a work in progress and many thing still dont function as they could.

but for the alsamixer situation think some cannibalising has occured very sad that features being castrated dont like at all
so there is hope that a revival will bring some nice feature to this mixer that makes it easy to swtich sources.

https://ibb.co/27q44vQg

Last edited by kapqa (2025-09-24 13:43:13)

Offline

#32 2025-09-24 13:47:51

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

Re: (alsa) changin soundcard easily via terminal

kapqa wrote:

on raspios the c\hange is made, a little bit silly situation resulted however, to change the playback from one device now to copy .asoundrc , practically heeded your advice and made several copy for different devices i~d like to activate.

Do you want to know how to write a simple bash script to switch between two "devices" with a mouse click?

If you have XFCE, try this command

xfce4-terminal -e 'alsamixer -c Headphones'

It should open a new terminal with "alsamixer" for "Headphones'

Last edited by igorzwx (2025-09-24 13:59:03)

Online

#33 2025-09-24 14:22:14

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

Re: (alsa) changin soundcard easily via terminal

ok, yes, that would be very nice, one click or more.

now if alsamixer opens for Headphones, but it should also switch source, does it do it?

probably not.

https://ibb.co/9H3sFMZs

Offline

#34 2025-09-24 14:25:06

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

Re: (alsa) changin soundcard easily via terminal

It will change, if you want. It is 100% functioning ALSAMIXER

Let us try to make a simple script which can do the same.

mkdir ~/myscripts
cd ~/myscripts
mousepad script1.sh

Copy and past these 3 lines:

#!/bin/bash

xfce4-terminal -e 'alsamixer -c Headphones'

Save it.

Check

ls | grep script1.sh
cat script1.sh

Make it executable

chmod a+x -v script1.sh

Run

stat -c %a script1.sh

It shoud output "755"

$ stat -c %a script1.sh
755

See: _https://chmodcommand.com/chmod-755/

Run it:

./script1.sh

Run it with full path:

$HOME/myscripts/script1.sh

Last edited by igorzwx (2025-09-24 14:44:58)

Online

#35 2025-09-24 14:49:30

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

Re: (alsa) changin soundcard easily via terminal

alsamixer wont be of much use if there is no alsa functioning on devuanpi+
is that even possible?

but if i evoke

xfce4-terminal -e 'alsamixer -c vc4hdmi0' the sound does not magically change from headphone to vc4hmi0
clearly the alsamixer is lacking some beats nowadays.. o r i am getting deafer.

thanks, will have to uninstall pulseaudio first and then try your scipt, provided alsa/audio is still functioning.

Last edited by kapqa (2025-09-24 14:53:47)

Offline

#36 2025-09-24 14:54:26

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

Re: (alsa) changin soundcard easily via terminal

Does the script work?

If it works, we can try to modify it step by step until it does what you want.

Last edited by igorzwx (2025-09-24 14:57:26)

Online

#37 2025-09-24 15:19:45

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

Re: (alsa) changin soundcard easily via terminal

could not test the script yet,
after uninstall ing pulseaudio and reboot there is no longer sound

aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
lavrate
    Rate Converter Plugin Using Libav/FFmpeg Library
samplerate
    Rate Converter Plugin Using Samplerate Library
speexrate
    Rate Converter Plugin Using Speex Resampler
jack
    JACK Audio Connection Kit
oss
    Open Sound System
pulse
    PulseAudio Sound Server
speex
    Plugin using Speex DSP (resample, agc, denoise, echo, dereverb)
upmix
    Plugin for channel upmix (4,6,8)
vdownmix
    Plugin for channel downmix (stereo) with a simple spacialization
hw:CARD=Headphones,DEV=0
    bcm2835 Headphones, bcm2835 Headphones
    Direct hardware device without any conversions
plughw:CARD=Headphones,DEV=0
    bcm2835 Headphones, bcm2835 Headphones
    Hardware device with all software conversions
default:CARD=Headphones
    bcm2835 Headphones, bcm2835 Headphones
    Default Audio Device
sysdefault:CARD=Headphones
    bcm2835 Headphones, bcm2835 Headphones
    Default Audio Device
dmix:CARD=Headphones,DEV=0
    bcm2835 Headphones, bcm2835 Headphones
    Direct sample mixing device
usbstream:CARD=Headphones
    bcm2835 Headphones
    USB Stream Output
hw:CARD=vc4hdmi0,DEV=0
    vc4-hdmi-0, MAI PCM i2s-hifi-0
    Direct hardware device without any conversions
plughw:CARD=vc4hdmi0,DEV=0
    vc4-hdmi-0, MAI PCM i2s-hifi-0
    Hardware device with all software conversions
default:CARD=vc4hdmi0
    vc4-hdmi-0, MAI PCM i2s-hifi-0
    Default Audio Device
sysdefault:CARD=vc4hdmi0
    vc4-hdmi-0, MAI PCM i2s-hifi-0
    Default Audio Device
hdmi:CARD=vc4hdmi0,DEV=0
    vc4-hdmi-0, MAI PCM i2s-hifi-0
    HDMI Audio Output
dmix:CARD=vc4hdmi0,DEV=0
    vc4-hdmi-0, MAI PCM i2s-hifi-0
    Direct sample mixing device
usbstream:CARD=vc4hdmi0
    vc4-hdmi-0
    USB Stream Output
hw:CARD=vc4hdmi1,DEV=0
    vc4-hdmi-1, MAI PCM i2s-hifi-0
    Direct hardware device without any conversions
plughw:CARD=vc4hdmi1,DEV=0
    vc4-hdmi-1, MAI PCM i2s-hifi-0
    Hardware device with all software conversions
default:CARD=vc4hdmi1
    vc4-hdmi-1, MAI PCM i2s-hifi-0
    Default Audio Device
sysdefault:CARD=vc4hdmi1
    vc4-hdmi-1, MAI PCM i2s-hifi-0
    Default Audio Device
hdmi:CARD=vc4hdmi1,DEV=0
    vc4-hdmi-1, MAI PCM i2s-hifi-0
    HDMI Audio Output
dmix:CARD=vc4hdmi1,DEV=0
    vc4-hdmi-1, MAI PCM i2s-hifi-0
    Direct sample mixing device
usbstream:CARD=vc4hdmi1
    vc4-hdmi-1
    USB Stream Output
$ 

i think it is because alsa-base is missing?

Offline

#38 2025-09-24 15:35:01

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

Re: (alsa) changin soundcard easily via terminal

Reload ALSA:

sudo /etc/init.d/alsa-utils force-reload

or

sudo service alsa-utils force-reload

If you have systemd, you may need enother command to reload ALSA

sudo systemctl restart alsa

Post the output of these commands:

fuser -av $(find /dev/snd -type c 2>/dev/null)
inxi -A
cat /proc/asound/cards
lsmod | grep snd
aplay -l
kapqa wrote:

i think it is because alsa-base is missing?

Do you mean:

alsa-base conf file missing

Perhaps, you have to create ALSA config

Post the ouput of these commands:

cat $HOME/.asoundrc
ls -1 /usr/share/alsa
cat /usr/share/alsa/alsa.conf

Last edited by igorzwx (2025-09-24 16:15:01)

Online

#39 2025-09-24 16:07:14

golinux
Administrator
Registered: 2016-11-25
Posts: 3,546  

Re: (alsa) changin soundcard easily via terminal

Do you have apulse installed? That was the magic - at least 10 years ago - to get rid of pulseaudio. Seems it is still in the repos:

https://pkginfo.devuan.org/cgi-bin/poli … e&x=submit

Offline

#40 2025-09-24 16:20:32

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

Re: (alsa) changin soundcard easily via terminal

apulse is very useful, but he has another problem.

Something like this:

_https://raspberrypi.stackexchange.com/questions/39187/alsa-base-conf-file-missing

kapqa wrote:

it seems devuanpi is missing alsa-base or similar, because after removing pulseaudio there is no more sound.

"devuanpi" or "raspberry pi"? He is testing them both.

This topic is now very confusing.

You may better close it and let him start new topics for each problems separately, and clearly define each problem.

Systemd can start services in parallel, significantly reducing boot times.

In a similar way, he is trying to solve all problems "in parallel" to minimize time and efforts.

EDIT:

_https://tracker.debian.org/pkg/alsa-base

alsa-base

package is gone
This package is not part of any Debian distribution. Thus you won't find much information here. The package is either very new and hasn't appeared on mirrors yet, or it's an old package that eventually got removed. The old news are kept for historic purpose only.

alsa-base was gone some years ago, but the myth of alsa-base is still alive.

Last edited by igorzwx (2025-09-24 19:49:01)

Online

#41 2025-09-24 16:41:39

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

Re: (alsa) changin soundcard easily via terminal

thank you guys, the sound was only muted.

it is not so easy to figure out also with alsamixer in terminal, since it says @00 or @mm

but sound is back.
will check the script asaw.

Offline

#42 2025-09-24 16:49:08

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

Re: (alsa) changin soundcard easily via terminal

OK. Let us make the script. It is very simple. And scripts are very useful.

In Ubuntu, hidden files are any file or folder whose name begins with a period (.). These files are not displayed by default in file managers or the ls command but are still present on the system. They typically serve as configuration files for user applications and system services, helping to keep the directory clutter-free and preventing accidental modification by normal users. You can view hidden files by pressing Ctrl + H or using the "Show Hidden Files" option in the file manager's menu, and you can hide a file or folder by renaming it to start with a dot

The command ls -a displays all files.

ls --help | grep '\-\-a'
  -a, --all                  do not ignore entries starting with .
  -A, --almost-all           do not list implied . and ..
      --author               with -l, print the author of each file
ls -al --author -1
ls -al -1

Last edited by igorzwx (2025-09-24 17:23:26)

Online

#43 2025-09-24 19:11:12

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

Re: (alsa) changin soundcard easily via terminal

1. First, make a dir

mkdir ~/myscripts

The folder "myscripts" should be in your home directory.
You can open it with your file manager (file browser).

2. Then write the script and make it executable, as described here:
_https://dev1galaxy.org/viewtopic.php?pid=58214#p58214

And test it.

#!/bin/bash

xfce4-terminal -e 'alsamixer -c Headphones' &

xfce4-terminal -e 'alsamixer -c vc4hdmi1' &

It should open two terminals with alsamixer

3. Then create two different text files in the folder ~/myscripts
with content like this:

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

For example, the second text file might be like this:

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

4. Then post here the output of these commands:

echo "$HOME/myscripts"
ls -a -1 $HOME/myscripts

Then we will add other commands to the script.

For bash terminal and bash script, commands are the same.
First, test commands on terminal.
If they work, you can add them to the script.

Try this website:
Explain Shell
_https://explainshell.com/#
_https://explainshell.com/explain?cmd=ls+-a+-1+%24HOME%2Fmyscripts#
_https://explainshell.com/explain?cmd=xfce4-terminal+-e+%27alsamixer+-c+vc4hdmi1%27+%26#

Bash scripting tutorial for Ubuntu newbies
_https://help.ubuntu.com/community/Beginners/BashScripting

Bash scripting is one of the easiest types of scripting to learn...
if you are a 'non-computer-savvy' person that won't mean a thing to you. Bash is the language that you will learn to love as much of everyday Ubuntu life is done/can be done using the Terminal.

Scripting

NOTE: The commands given in the scripting section are to be put into the text editor and not in the terminal unless instructed otherwise.

Bash is primarily a scripting language, so it would be a crime not to talk about scripting. Let's dive straight in with a bash script... You can create a bash script by opening your favorite text editor to edit your script and then saving it (typically the .sh file extension is used for your reference, but is not necessary.
_https://help.ubuntu.com/community/Beginners/BashScripting#Scripting

Last edited by igorzwx (Yesterday 18:53:45)

Online

Board footer