First, let’s choose which device to use. Enter the command cat /proc/asound/modules
to list all available sound devices whether it’s a PWM audio or USB sound device.
The command you just entered should output something like:
0 snd_bcm2835
<< this is the PWM audio I configured on GPIO18 & GPIO13.
1 snd_usb_audio
<< this is my USB sound device.
Enter the command sudo nano /etc/asound.conf
and paste the following code:
# convert stereo to mono LEFT output pcm.monocard{ slave.pcm "hw:N" slave.channels 2 type route ttable { # Copy both input channels to output channel 0 (Left). 0.0 1 1.0 1 # Send nothing to output channel 1 (Right). 0.1 0 1.1 0 } } pcm.!default monocard
Change the N
on the line slave.pcm "hw:N"
to the number that corresponds to the audio device you want to use. I will be using my USB audio device so mine should read slave.pcm "hw:1"
.
The above code uses both left and right audio input to output to LEFT channel. If you want the output to the RIGHT then you can just edit the line 8 – 14 to:
# Copy both input channels to output channel 1 (Right).
0.1 1
1.1 1
# Send nothing to output channel 0 (Left).
0.0 0
1.0 0
Restart ALSA by sudo /etc/init.d/alsa-utils restart
or you can reboot your Raspberry Pi using sudo reboot
.
Thank you for this guide. Will it work on hdmi audio as well?