User avatar
NormanDunbar
Posts: 111
Joined: Wed Nov 23, 2011 12:13 pm
Location: Leeds, West Yorkshire, England.
Contact: Website

sudo amixer troubles - started recently

Fri Dec 07, 2012 4:03 pm

I've got a Model 2 Pi with 256 MB RAM. I'm running headless with the latest Rasbian (upgraded yesterday) and a Python GUI utility to choose the sound output device, test sound and set the volume or mute has ceased working. I've been looking into this and the following has been noted:

1. In an ssh session, not running a GUI:

Code: Select all

$ sudo amixer cset numid=3 1
numid=3,iface=MIXER,name='PCM Playback Route'
  ; type=INTEGER,access=rw------,values=1,min=0,max=2,step=0
  : values=1
Regardless of the parameter value (0=auto, 1=3.5mm socket or 2=HDMI output) the sound is always coming from the speakers attached to the 3.5mm socket. It used to stop making a noise when I redirected it to HDMI with parameter 2. Now it just always goes to the speakers.

Code: Select all

$ sudo amixer cset numid=3 2 
numid=3,iface=MIXER,name='PCM Playback Route'
  ; type=INTEGER,access=rw------,values=1,min=0,max=2,step=0
  : values=2
The final line shows that the parameter has been changed to 2 as requested, but still sound comes form the speakers. Checking the parameter with cget shows that it h as been changed:

Code: Select all

$ sudo amixer cget numid=3
numid=3,iface=MIXER,name='PCM Playback Route'
  ; type=INTEGER,access=rw------,values=1,min=0,max=2,step=0
  : values=2
So, it's definitely set to HDMI for sound output and still I can hear it load as anything, from the speakers on the socket.

Mute/unmute works ok with numid=2 1 or 0. So that hasn't changed.

Volume control is broken now as well.

Code: Select all

$ sudo amixer cset numid=1 -- -400
numid=1,iface=MIXER,name='PCM Playback Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=-10239,max=400,step=0
  : values=-10239
  | dBscale-min=-102.39dB,step=0.01dB,mute=1
You can see the valu of -400 has been ignored, it remains at -10239 which should actually be minimum volume.

Code: Select all

$ sudo amixer cset numid=1 -- 100
numid=1,iface=MIXER,name='PCM Playback Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=-10239,max=400,step=0
  : values=-10239
  | dBscale-min=-102.39dB,step=0.01dB,mute=1
Again, volume setting remains unchanged. Testing with cget to retrieve the volumn setting shows that it is indeed at the minimum, and still I get sound!

Code: Select all

$ sudo amixer cget numid=1
numid=1,iface=MIXER,name='PCM Playback Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=-10239,max=400,step=0
  : values=-10239
  | dBscale-min=-102.39dB,step=0.01dB,mute=1
I'm a little puzzled as to why this should be suddenly happening now. It worked before. Amixer is version 1.0.25 if that makes a difference?

Code: Select all

$ sudo amixer -v
amixer version 1.0.25
My GUI runs as a normal user and simply calls the various sudo amixer commands shown above to do whatever is required.


2. Running in LXDE in a VNC session.

So far so good, when I start a VNC session and use the GUI over VNC, opening up LXTerminal and typing exactly the same commands in gies me something different:

Code: Select all

$ sudo amixer cset numid=3 1
Clinet is not authorized to connect to Serverxcb_connection_has_error() returned true
numid=3,iface=MIXER,name='PCM Playback Route'
  ; type=INTEGER,access=rw------,values=1,min=0,max=2,step=0
  : values=1
The other cset or cget commands all give the same error at the start. Getting the version of amixer (sudo amixer -v) works fine.

/dev/snd is root:root but the contents are root:audio. My user, pi, is a member of the audio group, and has been able to run these commands previously.

Sorry it's so long, better to have too much info than not enough? Appreciate any help.

Thanks.


Cheers,
Norm.
Why do they put lightning conductors on churches?
Why did Tarzan never have a beard?

User avatar
SteveDee
Posts: 343
Joined: Thu Dec 29, 2011 2:18 pm
Location: Sunny Southern England
Contact: Website

Re: sudo amixer troubles - started recently

Sun Dec 09, 2012 12:09 pm

I wish I had your problem.

I'm trying to get analogue sound (out of the jack socket) so I do:-
sudo amixer cset numid=3 0 80%

...then I test with:-
sudo aplay /usr/share/sounds/alsa/Front_Center.wav

...but just get a "pop", a pause, and a second "pop"

So it sounds like the channel is being opened & closed, but nothing is being sent.

Again, this seemed to work on earlier versions.

User avatar
NormanDunbar
Posts: 111
Joined: Wed Nov 23, 2011 12:13 pm
Location: Leeds, West Yorkshire, England.
Contact: Website

Re: sudo amixer troubles - started recently

Mon Dec 10, 2012 12:45 pm

Morning Steve,

I've never seen the command used with the 80% thingy on the end. Are you sure it works?

if your sound is working find, and not having my problems, try the following:

Code: Select all

$ sudo amixer cset numid=3 1
$ sudo amixer cset numid=1 400
That should set the output to the hedphone socket and set the volume to maximum.

You can check the settings worked by running these 'cget' commands:

Code: Select all

$ sudo amixer cget numid=3
$ sudo amixer cget numid=1
You should see "values=1" and "values=400" in the output.

It's also possible that mute is on, run a sget on numid=2 and you should see "values=on" for sound and "values=off" for mute.

Have fun.

Cheers,
Norm.
Why do they put lightning conductors on churches?
Why did Tarzan never have a beard?

User avatar
SteveDee
Posts: 343
Joined: Thu Dec 29, 2011 2:18 pm
Location: Sunny Southern England
Contact: Website

Re: sudo amixer troubles - started recently

Mon Dec 10, 2012 8:50 pm

Thanks Norm, I actually cheated and ran good old alsamixer. Un-muting fixed it.

User avatar
NormanDunbar
Posts: 111
Joined: Wed Nov 23, 2011 12:13 pm
Location: Leeds, West Yorkshire, England.
Contact: Website

Re: sudo amixer troubles - started recently

Mon Dec 10, 2012 9:24 pm

Evening Steve,

ok, at least your problem is solved. Mine, alas, remains.

Cheers,
Norm.
Why do they put lightning conductors on churches?
Why did Tarzan never have a beard?

Mambono5
Posts: 1
Joined: Wed Jan 16, 2013 11:38 pm

Re: sudo amixer troubles - started recently

Wed Jan 16, 2013 11:47 pm

Hi I am also having problems with sound I have set up the air play set up and can get the network I'm the iPod joins the network and kills the sound on the iPod but nothing out of the speakers.

The raspberry is brand new with all the software updated to latest versions! Any ideas ?

Tony

User avatar
NormanDunbar
Posts: 111
Joined: Wed Nov 23, 2011 12:13 pm
Location: Leeds, West Yorkshire, England.
Contact: Website

Re: sudo amixer troubles - started recently

Thu Jan 17, 2013 7:10 am

Hi Mambono5,

as your Pi is new, I suspect you might need to run the

Code: Select all

sudo alsamixer
command and use the up arrow to set
the master volume and/or unmute.

HTH.

Cheers,
Norm
Why do they put lightning conductors on churches?
Why did Tarzan never have a beard?

User avatar
NormanDunbar
Posts: 111
Joined: Wed Nov 23, 2011 12:13 pm
Location: Leeds, West Yorkshire, England.
Contact: Website

Re: sudo amixer troubles - started recently

Wed Jan 30, 2013 12:33 pm

This is getting weird now! Going back to my first post here on this very thread, you will see this code:

Code: Select all

 
$ sudo amixer cset numid=3 1

numid=3,iface=MIXER,name='PCM Playback Route'
   ; type=INTEGER,access=rw------,values=1,min=0,max=2,step=0
   : values=1
However, today when I execute the exact same code, I get this instead:

Code: Select all

    
$ sudo amixer cset numid=3 1

numid=3,iface=MIXER,name='Master Playback Volume'
   ; type=INTEGER,access=rw------,values=2,min=0,max=65536,step=1
   : values=1,1
This implies that my ability to use numid=3 has "gone away" as that used to adjust the 'PCM Playback Route' whereas now, it updates the 'Master Playback Volume' instead. WTF?

Code: Select all

$ sudo amixer controls

numid=4,iface=MIXER,name='Master Playback Switch'
numid=3,iface=MIXER,name='Master Playback Volume'
numid=2,iface=MIXER,name='Capture Switch'
numid=1,iface=MIXER,name='Capture Volume'
I assume I can no longer redirect sound from HDMI to the jask sockets?

Anyone have any clues as to what is going on in Rasbian and the sound system?

Cheers,
Norm.
Why do they put lightning conductors on churches?
Why did Tarzan never have a beard?

KenT
Posts: 758
Joined: Tue Jan 24, 2012 9:30 am
Location: Hertfordshire, UK
Contact: Website

Re: sudo amixer troubles - started recently

Wed Jan 30, 2013 1:33 pm

See here, asb is looking at it

https://github.com/raspberrypi/firmware/issues/139

workaround is to unistall pulseaudio
Pi Presents - A toolkit to produce multi-media interactive display applications for museums, visitor centres, and more
Download from http://pipresents.wordpress.com

User avatar
NormanDunbar
Posts: 111
Joined: Wed Nov 23, 2011 12:13 pm
Location: Leeds, West Yorkshire, England.
Contact: Website

Re: sudo amixer troubles - started recently

Wed Jan 30, 2013 2:21 pm

Thanks KenT, removing pulseaudio did indeed solve the problem. I can redirect sound again.

I've not played with mute or volume yet, too busy, but for now, I'm happy.

Cheers,
Norm.
Why do they put lightning conductors on churches?
Why did Tarzan never have a beard?

User avatar
NormanDunbar
Posts: 111
Joined: Wed Nov 23, 2011 12:13 pm
Location: Leeds, West Yorkshire, England.
Contact: Website

[SOLVED] sudo amixer troubles - started recently

Wed Jan 30, 2013 4:02 pm

Yippee! It's fixed.

Once more, I have sound that comes out of the headphone socket or HDMI as I choose, I can adjust the volume and mute the sound to my heart's content. The simple solution, as hinted at by KenT above, was to remove pulseaudio and reboot.

Code: Select all

sudo apt-get purge --yes pulseaudio
sudo reboot
You may need to set the sound to go to your desired device after the reboot:

Code: Select all

sudo amixer cset numid=3 1 ## For headphones.
or

Code: Select all

sudo amixer cset numid=3 2 ## for HDMI.
However, I'm a happy bunny again now. Back to writing my Python GUI.

I've also done a wee write up on my blog, for my own future reference. http://qdosmsq.dunbar-it.co.uk/blog/201 ... -pi-sound/

Cheers,
Norm
Why do they put lightning conductors on churches?
Why did Tarzan never have a beard?

gsenna
Posts: 6
Joined: Tue Feb 05, 2013 6:48 pm

Re: sudo amixer troubles - started recently

Wed Feb 06, 2013 11:12 am

Hello,
Although you can choose whether to keep or not Pulseaudio. This isn't really Pulseaudio's fault.
The thing is when you have it installed, it becomes the default device. So if you want to change some soundcard control, you have to specify it with the -c argument like: amixer -c 0 cset numid=3 'n'.
Cheers.

ski522
Posts: 394
Joined: Sun Sep 30, 2012 2:22 pm

Re: sudo amixer troubles - started recently

Wed Feb 06, 2013 12:13 pm

Didn't read through all the threads so can't provide comment in that regard, but noticed that people are using "sudo". You shouldn't need to use sudo with alsa. If you do then you need to make sure that your user name is part of the audio group.

User avatar
NormanDunbar
Posts: 111
Joined: Wed Nov 23, 2011 12:13 pm
Location: Leeds, West Yorkshire, England.
Contact: Website

Re: sudo amixer troubles - started recently

Wed Feb 06, 2013 12:20 pm

ski522 wrote:You shouldn't need to use sudo with alsa. If you do then you need to make sure that your user name is part of the audio group.
This is true. If you are not in the audio group, you must use sudo. If you are in the group, you don;t have to.

Cheers,
Norm
Why do they put lightning conductors on churches?
Why did Tarzan never have a beard?

User avatar
NormanDunbar
Posts: 111
Joined: Wed Nov 23, 2011 12:13 pm
Location: Leeds, West Yorkshire, England.
Contact: Website

Re: sudo amixer troubles - started recently

Wed Feb 06, 2013 12:25 pm

gsenna wrote:...So if you want to change some soundcard control, you have to specify it with the -c argument like: amixer -c 0 cset numid=3 'n'.
Useful, thanks. On my Pi, card 0 was the PCM one, and PulseAudio was card 1. (I'm 99% sure of that) But either way, your suggestion is excellent. I might even reinstall pulseaudio and test it out.

Thanks.

Cheers,
Norm.
Why do they put lightning conductors on churches?
Why did Tarzan never have a beard?

User avatar
SteveDee
Posts: 343
Joined: Thu Dec 29, 2011 2:18 pm
Location: Sunny Southern England
Contact: Website

Re: sudo amixer troubles - started recently

Fri Feb 22, 2013 1:16 pm

Up till now I've only used analogue audio, but I spent a couple of hours this morning trying to get sound from my TV via HDMI.

I uninstalled PulseAudio and initially thought it was still not working, but then discovered that I get sound from VLC, mpg123, and via the Music.Play method in Gambas.

What does not seem to work is aplay (as in: aplay /usr/share/sounds/alsa/Front_Left.wav).
These test wav files play OK in VLC. I also created a longer wav file (about 10 second) but still nothing.

My Pi is up to date (updated/graded, not a fresh download) so I don't know if there is a new issue or I've just broken something. This is not currently a problem for me, just thought I'd mention it.

User avatar
NormanDunbar
Posts: 111
Joined: Wed Nov 23, 2011 12:13 pm
Location: Leeds, West Yorkshire, England.
Contact: Website

Re: sudo amixer troubles - started recently

Fri Feb 22, 2013 1:30 pm

Hi Steve,

I'm not a sound guru but what do you get for the command:

Code: Select all

aplay -L
I get the following:

Code: Select all

aplay -L
null
      Discard all samples (playback) or generate zero samples (capture)
pulse
      PulseAudio Sound Server
sysdefault:CARD=ALSA
      bcm2835 ALSA, bcm2835 ALSA
      Default Audio Device
You can try playing through the bcm2835, in my case, with:

Code: Select all

aplay -D sysdeafult /usr/share/sounds/alsa/Front_Left.wav
Or choose to play via pulse with:

Code: Select all

aplay -D pulse /usr/share/sounds/alsa/Front_Left.wav
I think PulseAudio sets itself up as the default device, how? I have no idea! You may find when you list your devices as above, that pulse is set as the default - in that case, use the name it gives for the built in device instead. I've tried bcm2835, ALSA, "bcm2835 ALSA" etc, and the only one that worked for me, was sysdefault. (or default - which isn't listed!)

You have tried to set the sound output to the HDMI haven't you?

By the way, have a look at my "PiSound" utility over on github, if you wish. It's command line at the moment, but easier to type "sound hdmi" than remembering which ID to use and all that stuff! GUI coming soon.

https://github.com/NormanDunbar/PiSound

Cheers,
Norm.
Why do they put lightning conductors on churches?
Why did Tarzan never have a beard?

User avatar
SteveDee
Posts: 343
Joined: Thu Dec 29, 2011 2:18 pm
Location: Sunny Southern England
Contact: Website

Re: sudo amixer troubles - started recently

Fri Feb 22, 2013 4:08 pm

NormanDunbar wrote:Hi Steve,

I'm not a sound guru but what do you get for the command:

Code: Select all

aplay -L
I get the following:

Code: Select all

aplay -L
null
      Discard all samples (playback) or generate zero samples (capture)
pulse
      PulseAudio Sound Server
sysdefault:CARD=ALSA
      bcm2835 ALSA, bcm2835 ALSA
      Default Audio Device
You can try playing through the bcm2835, in my case, with:

Code: Select all

aplay -D sysdeafult /usr/share/sounds/alsa/Front_Left.wav
...
Hi Norm, I get the same as you up to this point, and I hear "front left" the first time I use the command above.

The 2nd time I run that command I just hear "front". The 3rd time I run it I hear "fff", and after that I hear nothing.

If I then try to play a music track (say via VLC) I get something very strange. I get a 200ms (approx) burst of music followed by 3 seconds of nothing, then 200ms burst of music...and this cycle continues until I reboot.

User avatar
NormanDunbar
Posts: 111
Joined: Wed Nov 23, 2011 12:13 pm
Location: Leeds, West Yorkshire, England.
Contact: Website

Re: sudo amixer troubles - started recently

Fri Feb 22, 2013 4:20 pm

Hi Steve,
SteveDee wrote:Hi Norm, I get the same as you up to this point, and I hear "front left" the first time I use the command above.

The 2nd time I run that command I just hear "front". The 3rd time I run it I hear "fff", and after that I hear nothing.

If I then try to play a music track (say via VLC) I get something very strange. I get a 200ms (approx) burst of music followed by 3 seconds of nothing, then 200ms burst of music...and this cycle continues until I reboot.
Interesting ..... for certain values of interesting!

I'm not sure what's happening there I'm afraid. Maybe someone with a better brain than me will jump in and offer a solution. Mine plays the wav file happily as many times as I like. I get bored before my Pi does.

Sorry, I don't have any answers to your problem. :-( Maybe PulseAudio is stealing the output back for some reason? I honestly don't have a clue.


Cheers,
Norm.
Why do they put lightning conductors on churches?
Why did Tarzan never have a beard?

User avatar
SteveDee
Posts: 343
Joined: Thu Dec 29, 2011 2:18 pm
Location: Sunny Southern England
Contact: Website

Re: sudo amixer troubles - started recently

Fri Feb 22, 2013 10:54 pm

NormanDunbar wrote:...Interesting ..... for certain values of interesting!...
I've put a fresh download onto another SD, and I see it does not include PulseAudio.

It looks like just adding:-
hdmi_drive=2
...to the Config.txt file has enabled hdmi audio. But I'll do some further testing over the weekend.

This looks like an example where its better to start again, than keep updating an old installation.

User avatar
NormanDunbar
Posts: 111
Joined: Wed Nov 23, 2011 12:13 pm
Location: Leeds, West Yorkshire, England.
Contact: Website

Re: sudo amixer troubles - started recently

Sun Feb 24, 2013 12:57 pm

Morning Steve,
SteveDee wrote:I've put a fresh download onto another SD, and I see it does not include PulseAudio.
Watch out for

Code: Select all

sudo apt-get update && sudo apt-get upgrade
because I think that puts PulseAudio back in!
SteveDee wrote:It looks like just adding "hdmi_drive=2" to the Config.txt file has enabled hdmi audio. But I'll do some further testing over the weekend.
Have fun. This option does indeed turn on HDMI audio output. And indeed, HDMI video output voltages. HDMI_DRIVE 1 turns audio off and sets DVI output voltages. And DVI has no audio signal.
SteveDee wrote:This looks like an example where its better to start again, than keep updating an old installation.
Yes, been there before myself. I had a set up that booted headless for ages, and after an upgrade, it would only boot with a monitor attached. Most strange.

I reflashed (same base edition of Rasbian) and reinstalled all my programs and settings, and it still carried on allowing me to boot headless. Strange.

Cheers,
Norm.
Why do they put lightning conductors on churches?
Why did Tarzan never have a beard?

Return to “Raspberry Pi OS”