Eradicatore
Posts: 23
Joined: Sun Jul 29, 2012 1:21 am

Setting the volume for 3.5mm jack

Sun Aug 19, 2012 6:41 am

Hi,
So I got audio playing just fine, but I can't seem to change the volume. I'm trying to find a way to use amixer to change this, but I need some help. To play audio, I just type "aplay xyz.wav" and I get audio on headsets plugged into the 3.5mm jack. So I tried this to set volume, but I don't see any change in the listed values:



[email protected]:/home/jdeltoft# amixer cset numid=1 -- 90%
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
[email protected]:/home/jdeltoft# amixer cset numid=1 -- 10%
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
[email protected]:/home/jdeltoft# sudo amixer cset numid=1 -- 10%
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

Eradicatore
Posts: 23
Joined: Sun Jul 29, 2012 1:21 am

Re: Setting the volume for 3.5mm jack

Sun Aug 19, 2012 6:43 am

Oh, and one other question that may be quick for someone that can answer the volume question is how to change it from Mono to stereo? This is my output of "amixer":



[email protected]:/home/jdeltoft# amixer
Simple mixer control 'PCM',0
Capabilities: pvolume pvolume-joined pswitch pswitch-joined penum
Playback channels: Mono
Limits: Playback -10239 - 400
Mono: Playback -10239 [0%] [-99999.99dB] [off]

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5282
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: Setting the volume for 3.5mm jack

Sun Aug 19, 2012 10:04 am

Can you try updating firmware. There's been some improvements with ALSA volume/muting.
http://elinux.org/R-Pi_Troubleshooting# ... g_firmware

User avatar
Jim JKla
Posts: 2218
Joined: Sun Jan 29, 2012 11:15 pm
Location: Newcastle upon Tyne UK

Re: Setting the volume for 3.5mm jack

Sun Aug 19, 2012 10:11 am

I've added a link to the troubleshooting page to the Noob Image guide page might solve some issues. ;)
Noob is not derogatory the noob is just the lower end of the noob--geek spectrum being a noob is just your first step towards being an uber-geek ;)

If you find a solution please post it in the wiki the forum dies too quick

jgearing
Posts: 51
Joined: Sat Mar 03, 2012 6:33 pm

Re: Setting the volume for 3.5mm jack

Sun Aug 19, 2012 10:38 am

you could buy a cheap inline volume control from amazon
mine works fine
http://www.amazon.co.uk/gp/offer-listin ... dition=all
cheers

JG

Eradicatore
Posts: 23
Joined: Sun Jul 29, 2012 1:21 am

Re: Setting the volume for 3.5mm jack

Sun Aug 19, 2012 8:36 pm

Dom, thanks, I updated my firmware (and then had to get wifi working again :) ) But no help.

JG, thanks for the suggestion. I do want to have s/w control though and this seems to me to be something that should be totally trivial to get working. :-(

I did try the troubleshooting link here also: http://elinux.org/R-Pi_Troubleshooting
It doesn't have anything about volume. It would help get sound if I didn't already have that working, but as I said I have that already.

So then I tried alsamixer. Interestingly, when you run that and type any of the number keys, it "tries" to go to a higher volume, but then jumps back to zero right away. Odd since my issue is that I can't seem to lower the volume. But anyway, I'll keep playing around. I'm so confused why this is hard but hey, what fun would it be if it just worked. :-)

Eradicatore
Posts: 23
Joined: Sun Jul 29, 2012 1:21 am

Re: Setting the volume for 3.5mm jack

Sun Aug 19, 2012 9:21 pm

Ok, I stumbled on it. I type to following (logged in a root for now):

amixer set PCM -- -XYY

Which will set the volume to -X.YYdB

So for example:


[email protected]:/home/jdeltoft# amixer set PCM -- -2200
Simple mixer control 'PCM',0
Capabilities: pvolume pvolume-joined pswitch pswitch-joined penum
Playback channels: Mono
Limits: Playback -10239 - 400
Mono: Playback -2200 [76%] [-22.00dB] [on]


I would still like to know how to change from mono. Let me play around there now.

spitecho
Posts: 24
Joined: Tue Jul 10, 2012 12:03 am
Location: internet

Re: Setting the volume for 3.5mm jack

Wed Aug 22, 2012 11:59 pm

Thanks, Eradicatore. Been wondering how to set the analog volume.
Here are some aliases to put in ~/.bashrc to simplify the commands.

Code: Select all

# Increase volume by 5%
alias volu='sudo amixer set PCM -- $[$(amixer get PCM|grep -o [0-9]*%|sed 's/%//')+5]%'
# Decrease volume by 5%
alias vold='sudo amixer set PCM -- $[$(amixer get PCM|grep -o [0-9]*%|sed 's/%//')-5]%'

crsskynet
Posts: 4
Joined: Sat Oct 20, 2012 8:55 pm
Location: Stirling, Scotland, UK

Re: Setting the volume for 3.5mm jack

Tue Jan 01, 2013 12:13 pm

Can I just say a massive thank you to spitecho this issue of the Raspberry Volume being so low was driving me up the wall. This little script you posted has been my salvation! Massive thanks!

:D
spitecho wrote:Thanks, Eradicatore. Been wondering how to set the analog volume.
Here are some aliases to put in ~/.bashrc to simplify the commands.

Code: Select all

# Increase volume by 5%
alias volu='sudo amixer set PCM -- $[$(amixer get PCM|grep -o [0-9]*%|sed 's/%//')+5]%'
# Decrease volume by 5%
alias vold='sudo amixer set PCM -- $[$(amixer get PCM|grep -o [0-9]*%|sed 's/%//')-5]%'

Raspberrypiglitch
Posts: 4
Joined: Sat Mar 23, 2013 1:47 am

Re: Setting the volume for 3.5mm jack

Mon Apr 29, 2013 3:16 am

Dear Raspberry pi users

I'm running a test with aplay and I want to put the volume down does anyone how to
Thanks,
Raspberrypiglitch! :D

mkgbian
Posts: 1
Joined: Fri Nov 08, 2013 6:27 pm

Re: Setting the volume for 3.5mm jack

Fri Nov 08, 2013 6:30 pm

Hi Raspbians,
I have tried many codes but when i checked amixer doc ,i found this

Code: Select all

amixer  sset PCM,0 90%
this sets the volume to desired percentage

Happy pie-ing :D

chaddha
Posts: 1
Joined: Sat Nov 09, 2013 3:58 pm

Re: Setting the volume for 3.5mm jack

Sat Nov 09, 2013 4:01 pm

Hi, I have tested my speakers with a iphone and the sound is quite loud, when I connect the speakers to the audiojack in the pi and play music from my iphone via shareport sound is very low. I have tried to increase sound to 100% via the great instructions on this page, but it does not increase volume. Any advice?

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 11993
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Setting the volume for 3.5mm jack

Sat Nov 09, 2013 4:06 pm

chaddha wrote:Hi, I have tested my speakers with a iphone and the sound is quite loud, when I connect the speakers to the audiojack in the pi and play music from my iphone via shareport sound is very low. I have tried to increase sound to 100% via the great instructions on this page, but it does not increase volume. Any advice?
You are hijacking a thread, you should ask non identical questions in a new thread, but I assume you did not realize it has nothing to do with loudness control.

The PI's stereo output are only for amplifiers, they do not output enough energy even for headsets, let alone to directly drive speakers.


Also, as a general remark, the PMW signal used to drive the 3.5mm port is an 11-bit signal, and decreasing the volume will simply scale the signal down to less than 11 bits, which will have effect on the quality, so you should use an external volume control, and leave the PWM output at 100%.

zSprawl
Posts: 6
Joined: Sun Jun 22, 2014 3:36 pm

Re: Setting the volume for 3.5mm jack

Wed Jun 25, 2014 2:56 am

spitecho wrote:Thanks, Eradicatore. Been wondering how to set the analog volume.
Here are some aliases to put in ~/.bashrc to simplify the commands.

Code: Select all

# Increase volume by 5%
alias volu='sudo amixer set PCM -- $[$(amixer get PCM|grep -o [0-9]*%|sed 's/%//')+5]%'
# Decrease volume by 5%
alias vold='sudo amixer set PCM -- $[$(amixer get PCM|grep -o [0-9]*%|sed 's/%//')-5]%'
Thank you so much for this. It has helped a lot!!

ajan
Posts: 12
Joined: Tue Apr 01, 2014 2:49 pm
Location: Greater London, UK

Re: Setting the volume for 3.5mm jack

Sun Jul 06, 2014 3:36 am

mkgbian wrote:Hi Raspbians,
I have tried many codes but when i checked amixer doc ,i found this

Code: Select all

amixer  sset PCM,0 90%
this sets the volume to desired percentage

Happy pie-ing :D
This worked for me. :D
Connected my Headphones to the Pi and increased increased upto 200% :twisted:

Moderator comment: Warning Any attempt of reducing or increasing the volume of the analog output this way will lead to loss of audio fidelity, the only correct way to set audio volume on analog output is to do it externally! Now locking this thread!

Return to “Beginners”