msilvestri
Posts: 1
Joined: Sat Apr 06, 2013 9:55 pm

Force audio output to 3.5mm output jack

Sat Apr 06, 2013 11:04 pm

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.

JeZxLee
Posts: 18
Joined: Wed Apr 17, 2013 2:37 pm

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

Wed Apr 17, 2013 2:43 pm

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

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

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

Wed Apr 17, 2013 3:42 pm

[Mod Edit] merged two similar posts
Dear forum: Play nice ;-)

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

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

Wed Apr 17, 2013 3:50 pm

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
Dear forum: Play nice ;-)

JeZxLee
Posts: 18
Joined: Wed Apr 17, 2013 2:37 pm

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

Wed Apr 17, 2013 4:12 pm

Works, many thanks!

JeZ+Lee

pete_l
Posts: 15
Joined: Thu May 17, 2012 7:08 am

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

Sun Jul 14, 2013 5:51 pm

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

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

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

Mon Jul 15, 2013 7:25 pm

can you post *exactly* how you are executing the command?
Dear forum: Play nice ;-)

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

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

Mon Jul 29, 2013 12:53 am

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?
Dear forum: Play nice ;-)

windy54
Posts: 99
Joined: Sat Dec 29, 2012 3:37 pm

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

Sun Aug 04, 2013 4:43 pm

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

PJOttCan
Posts: 1
Joined: Thu Nov 29, 2012 2:19 am

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

Sun Sep 15, 2013 7:06 pm

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

ska1ix
Posts: 1
Joined: Wed Mar 18, 2015 8:38 am

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

Wed Mar 18, 2015 8:54 am

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 60952 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

313Alf
Posts: 23
Joined: Sun Jul 07, 2019 12:55 am

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

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.

dominic03
Posts: 111
Joined: Fri Dec 21, 2018 1:50 am
Location: Indiana, USA

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

Fri Aug 09, 2019 11:36 am

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
Raspberry Pi 4B 4gb dual-booting ARM32/ARM64 Pi OS (PINN)
Kingston 32 GB C10 (U1) microSD
Sceptre E225W 22" 75hz 1080p monitor
Overclocked to 2.147ghz

100 posts! Woo!

Return to “Beginners”