Thanks @AnonymousPi but I try both config and I get cutting whit noise on hdmi while analogue outline working well.
what did i do wrong?
can it be a bad configuration on alsamixer ?
lqqqqqqqqqqqqqqqqqqqqqqqqqqqqq AlsaMixer v1.0.28 qqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
x Card: audiocodec F1: Help x
x Chip: F2: System information x
x View: F3:[Playback] F4: Capture F5: All F6: Select sound card x
x Item: Lineout volume control Esc: Exit x
x x
x lqqk lqqk lqqk lqqk x
x xaax xaax xaax xaax x
x xaax xaax xaax xaax x
x xaax xaax xaax xaax →
x xaax xaax xaax xaax →
x xaax xaax xaax xaax →
x xaax xaax xaax xaax →
x xaax xaax xaax xaax →
x xaax xaax xaax xaax →
x xaax xaax xaax xaax →
x xaax xaax xaax xaax x
x xaax xaax xaax xaax x
x mqqj mqqj lqqk lqqk lqqk lqqk mqqj mqqj x
x xOOx xOOx xOOx xOOx x
x mqqj mqqj mqqj mqqj x
x 100 100 100 100 x
x <Lineout >ADC inpu Audio ad Audio ad Audio li Audio li LINEIN_G MIC1 boo x
mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
And dmesg will tell you the reason: Filesystem corrupted due to using faulty or counterfeit SD card and kernel trying to save your FS by setting it to read-only
Call dmesg and watch for ext4/corruption, then follow the checking procedure on another system as outlined in our documentation: http://docs.armbian.com/User-Guide_Getting-Started/#how-to-prepare-a-sd-card or throw the card away.
After I accomplished my IR Red Key Rick Rolling experiment the other day with much success, and from general end-luser use with Armbian, there were two things which irritated me, which are namely due to the default ALSA configuration that comes with stock Debian and that Armbian inherits. These were:
Update: 11 September 2017. This guide will not work for newer Armbiam (Debian) installations which comes with Pulseaudio by default. If you really want what this tutorial provides, you will need to uninstall pulseaudio first: sudo apt-get remove pulseaudio
1) You can't have simultaneous applications using an Audio device. So, how about if I want to stream Internet Radio with 'Radio Tray' but also get system alert sounds, or anything else? Out of luck, you'll get (for example):
[ao/alsa] Playback open error: Device or resource busy
2) I want to actually have audio going out of the 3.5mm jack (don't really care about video out), better still if it's the same/simultaneous to what is going out via. HDMI. That means if I have a HDMI TV connected then I can get the sound from the TV, if I don't, then I can just use the 3.5mm jack (i.e. If I'm using my Pi to play Rick Astley headless/without a TV). No need to keep editing /etc/asound.conf every time.
Solution?
Step 1) Fix the mute on the analog Line-Out in alsamixer (for a start)
There's a lot of noise out there about people not being able to get any sound our of the analog Line-Out jack even when having changed /etc/asound.conf. The reason for this is likely due to a mute by default on the analog audio line-out (i.e. the 3.5mm headphone jack) in alsa that you would unlikely to be aware of. I only found this out thanks to a comment here, otherwise I would have thrown by Pi PC out the window today.
So to fix, you need to type in the console:
sudo alsamixer
Then F6 select the 'audiocodec', then tap the right arrow key to select the 'Audio lineout [Off]' item.
Press 'm' and you'll get the green 'OO', which means it's now active.
Exit alsamixer, and when you're back at the console type:
sudo alsactl store 0
... to store you mixer settings.
For your information, the mixer settings are stored to the file:
/var/lib/alsa/asound.state
... and if you do a diff of this file after having made the changes in alsamixer, this is what is changed in the alsa asound.state file:
control.9 { control.9 {
iface MIXER iface MIXER
name 'Audio lineout' name 'Audio lineout'
value false | value true
comment { comment {
access 'read write' access 'read write'
type BOOLEAN type BOOLEAN
count 1 count 1
} }
} }
Step 2) Change the /etc/asound.conf file
As you might or might not be aware, the default /etc/asound.conf file looks something like this:
pcm.!default {
type hw
card 1
}
ctl.!default {
type hw
card 1
}
All it is configured to do is give applications direct access to the hardware audio device, and pump the sound either out to the analogue line-out ('card 0') or via HDMI ('card 1'). Pretty basic, but does the job.
However, what I wanted was two things:
Software mixing before the resulting PCM/Sound is sent to the hardware audio device - This enables me to listen to Internet Radio and Youtube at the same time...
Simultaneous Output to both HDMI and analog line-out.
If you want only (1) above, and only via HDMI, then the /etc/asound.conf file is this:
pcm.!default {
type plug
slave.pcm "dmixer"
}
pcm.dmixer {
type dmix
ipc_key 1024
slave {
pcm "hw:1,0" # "hw:1,0" means HDMI change to "hw:0,0" for analog lineout jack output
period_time 0
period_size 1024
buffer_size 4096
rate 44100
}
bindings {
0 0
1 1
}
}
ctl.dmixer {
type hw
card 0
}
ctl.!default {
type hw
card 0
}
If you want (1) and (2) (which of course you do), then the /etc/asound.conf file is this:
# Thanks to: http://alsa.opensrc.org/Asoundrc#Dupe_output_to_multiple_cards
# https://sourceforge.net/p/alsa/mailman/message/33476395/
# Check that a MUTE doesn't exist on the Audio Line Out for Orange PI PC
# or you'll get no sound other than via HDMI
pcm.!default {
type plug
slave.pcm "duplicate"
}
ctl.!default {
type hw
card 0
}
# Create the Software Mixer for HDMI and then link to hardware
pcm.hdmi-dmixer {
type dmix
ipc_key 1024
slave {
#pcm "hw:0,0"
# pcm "duplicate"
pcm "hdmi-hw"
# pcm "analog-hw"
period_time 0
period_size 1024
buffer_size 4096
rate 44100
}
bindings {
0 0
1 1
}
}
ctl.hdmi-dmixer {
type hw
card 0
}
# Create the Software Mixer for Analogue Out and then link to hardware
pcm.analog-dmixer {
type dmix
ipc_key 2048
slave {
#pcm "hw:0,0"
# pcm "duplicate"
# pcm "hdmi-hw"
pcm "analog-hw"
period_time 0
period_size 1024
buffer_size 4096
rate 44100
}
bindings {
0 0
1 1
}
}
ctl.analog-dmixer {
type hw
card 0
}
# Route the audio requests to both hardware devices via the mixer.
# For some reason we can't have one mixer and then route to two hardware
# devices (would be more efficient).
pcm.duplicate {
type route
slave.pcm {
type multi
slaves {
a { pcm "analog-dmixer" channels 2 }
h { pcm "hdmi-dmixer" channels 2 }
}
bindings [
{ slave a channel 0 }
{ slave a channel 1 }
{ slave h channel 0 }
{ slave h channel 1 }
]
}
ttable [
[ 1 0 1 0 ]
[ 0 1 0 1 ]
]
}
ctl.duplicate {
type hw;
card 0;
}
# Physical Output Device Mappings - Analogue and HDMI for Orange PI PC
pcm.analog-hw {
type hw
card 0
}
pcm.hdmi-hw {
type hw
card 1
}
There you have it. The only downside is that CPU usage for playing music will increase a bit as ALSA will essentially route inputs from applications to two Software Mixers, which are connected to the HDMI and Analog Line-Out hardware devices separately. For some reason you can't have a single Software Mixer route to two hardware devices (or I couldn't get it to work), but whatever. We're talking 20% CPU usage vs. 10% on one core, to play music.