Page 1 of 1

Force audio output to 3.5mm output jack

Posted: Sat Apr 06, 2013 11:04 pm
by msilvestri
I am trying to force audio output to the 3.5mm output jack, but I have been unsuccessful. I am using Raspbian.

Many sources suggest using this line to force the Pi to use 3.5mm jack for audio output:
$ amixer cset numid=3 1

I don't think this works. Given these two commands:
$ amixer -h
cset cID P set control contents for one control

$ 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 think the line I initially referenced sets the Master Playback Volume to nearly zero. The line does not seem to control whether the Pi outputs audio to the 3.5mm jack or the HDMI port.

The only way I was able to get any audio out of the 3.5mm jack was by running the test code below.
$ cd /opt/vc/src/hello_pi/
$ ./rebuild.sh
$ cd hello_audio
$ ./hello_audio.bin

But this does not allow me to play the WAV files I have put on my Pi.

Disable HDMI Audio & Force 1/8" Jack Audio?

Posted: Wed Apr 17, 2013 2:43 pm
by JeZxLee
Disable HDMI Audio & Force 1/8" Jack Audio?

Hi,

I am running my Pi display
though the HDMI port with an HDMI to VGA adapter wire
to an old LCD monitor.

I need to permanently disable HDMI audio
and permanently force the 1/8" stereo jack audio.

I currently have no audio and want to fix it with my current setup.
How can I do the above?
Thanks!

EDIT: I am using a Model B Pi with current Raspbian Wheezy O.S.

JeZ+Lee

Re: Disable HDMI Audio & Force 1/8" Jack Audio?

Posted: Wed Apr 17, 2013 3:42 pm
by abishur
[Mod Edit] merged two similar posts

Re: Disable HDMI Audio & Force 1/8" Jack Audio?

Posted: Wed Apr 17, 2013 3:50 pm
by abishur
The following commands work on Raspbian Wheezy image 2013-02-09

sudo amixer cset numid=3 <output>

0=auto
1=headphones
2=hdmi

I use them in a script to automatically change which sound source I'm using when I want to listen to internet radio without leaving my TV on all the time (so I can absolutely attest to the fact that yes, these commands do work). You have to excute it as sudo though

Example for outputting sound through the 3.5mm jack

Code: Select all

sudo amixer cset numid=3 1
Example for outputting sound through HDMI

Code: Select all

sudo amixer cset numid=3 2

Re: Disable HDMI Audio & Force 1/8" Jack Audio?

Posted: Wed Apr 17, 2013 4:12 pm
by JeZxLee
Works, many thanks!

JeZ+Lee

Re: Disable HDMI Audio & Force 1/8" Jack Audio?

Posted: Sun Jul 14, 2013 5:51 pm
by pete_l
I agree with msilvestri in his OP.
I'm running 2013-05-25-wheezy-raspbian.img and the amixer command does nothing like what other people claim. Maybe it did with early versions, but with the 25-May cut of Raspbian the functions have changed completely. The last parameter (the "1" in most examples) sets the output volume to a very low level, ranging from 0 .. 65535 - so inaudible. It seems to have no effect at all on switching the sound output.
The "documentation" even says that it's a volume control. Run
amixer cget numid=3
and you get output like this:
numid=3,iface=MIXER,name='Master Playback Volume'
; type=INTEGER,access=rw------,values=2,min=0,max=65536,step=1
: values=1,1

Re: Disable HDMI Audio & Force 1/8" Jack Audio?

Posted: Mon Jul 15, 2013 7:25 pm
by abishur
can you post *exactly* how you are executing the command?

Re: Disable HDMI Audio & Force 1/8" Jack Audio?

Posted: Mon Jul 29, 2013 12:53 am
by abishur
Just to follow up, using the latest image from the site, I run my commands and it outputs audio to my 1/8" audio jack no problems. Could you please provide the exact command you used that is result in abnormal behavior?

Re: Disable HDMI Audio & Force 1/8" Jack Audio?

Posted: Sun Aug 04, 2013 4:43 pm
by windy54
I am having similar problems.

Default is set to HDMI.

I have got a lxteminal window open and another one open running alsamixer

If I use aplay to play back a sound it comes out of the TV via HDMI.
I enter
sudo amixer cset numid=3 1

the volume is set to 0 and no sound is heard.

I have not been able to change volume from amixer, have to go into alsamixer and increase it. Sound still comes from hdmi.

I am using raspbian wheezy.

Time to go and read up on amixer etc

Re: Disable HDMI Audio & Force 1/8" Jack Audio?

Posted: Sun Sep 15, 2013 7:06 pm
by PJOttCan
Simple script to change/display audio-out settings. I called it "audioout.sh" and placed it in my home directory (make sure permissions are set to 755 for the file). To run, type: cd ~, and then: ./audioout.sh

Code: Select all

#!/bin/bash

while true; do
	echo "Audio Output Selection for the Raspberry PI (in Raspbian only?):"
	echo "  H - HDMI"
	echo "  L - Line-Out (3.5-inch jack)"
	echo "  R - Read current settings (or D for Display or G for Get)"
	echo "  X - Exit"
    read -p "Which audio output do you want to use now? " answer
    case $answer in
        [Hh]* ) sudo amixer cset numid=3 2; break;;
        [Ll]* ) sudo amixer cset numid=3 1; break;;
        [GgRrDd]* ) amixer cget numid=3; break;;
        [Xx]* ) exit;;
        * ) echo "Please answer H,L,R or X.";;
    esac
done

Re: Disable HDMI Audio & Force 1/8" Jack Audio?

Posted: Wed Mar 18, 2015 8:54 am
by ska1ix
Found the solution: it seems that in my case the problem was due to attached webcams, which don't work as speakers but they do as microphones.

Open alsamixer (sudo alsamixer). Push F6 to select sound card. Check which number bcm2835 ALSA has (xn where n is the number).
alsa.png
alsa.png (53.37 KiB) Viewed 60604 times
Write "sudo amixer -c n cset numid=3 x" where n is the number your sound card has as seen in alsamixer, and x the desired output (0 for auto, 1 for jack and 2 for HDMI). Worked for me. It should say something like:

pi@raspberrypi:~/FFMPEG$ sudo amixer -c 3 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

Re: Disable HDMI Audio & Force 1/8" Jack Audio?

Posted: Thu Aug 08, 2019 8:52 pm
by 313Alf
ska1ix wrote:
Wed Mar 18, 2015 8:54 am
Write "sudo amixer -c n cset numid=3 x" where n is the number your sound card has as seen in alsamixer, and x the desired output (0 for auto, 1 for jack and 2 for HDMI). Worked for me.
Worked for me too. I realise I'm resurrecting an old thread but I wanted to thank you for your advice.
I have tried many methods to get the audio jack on my Pi4B outputting sound, and this is the only method I have found which worked.

HDMI has always worked, but when I tried to select Analog (audio jack) the setting would not persist and/or the volume would drop close to zero then Analog would be deselected when I tried to raise the volume. Perhaps my issues are due to the software I have installed (emulators, RTL-SDR radio - there may be conflicting settings), but its working now. I may try a clean install and see if indeed I caused the issue in the first place.

Edit: I think it has something to do with my SDR install. I can hear Youtube videos fine using the audio jack, but when I start the SDR I lose audio again. Something for me to work out.

Re: Disable HDMI Audio & Force 1/8" Jack Audio?

Posted: Fri Aug 09, 2019 11:36 am
by dominic03
313Alf wrote:
Thu Aug 08, 2019 8:52 pm
ska1ix wrote:
Wed Mar 18, 2015 8:54 am
Write "sudo amixer -c n cset numid=3 x" where n is the number your sound card has as seen in alsamixer, and x the desired output (0 for auto, 1 for jack and 2 for HDMI). Worked for me.
Worked for me too. I realise I'm resurrecting an old thread but I wanted to thank you for your advice.
I have tried many methods to get the audio jack on my Pi4B outputting sound, and this is the only method I have found which worked.

HDMI has always worked, but when I tried to select Analog (audio jack) the setting would not persist and/or the volume would drop close to zero then Analog would be deselected when I tried to raise the volume. Perhaps my issues are due to the software I have installed (emulators, RTL-SDR radio - there may be conflicting settings), but its working now. I may try a clean install and see if indeed I caused the issue in the first place.

Edit: I think it has something to do with my SDR install. I can hear Youtube videos fine using the audio jack, but when I start the SDR I lose audio again. Something for me to work out.
Please don't 'resurrect' old posts