Please note: These are just examples, and not related to the config presented in README.md
Before installing this module you need to make sure your speakers and microphone are working correctly. Note that this setup was tested on Raspbian Linux distribution but it should work with many others.
In this case, my (sound)card# is 0 and my device(microphone)# is also zero.
So, in my config entry I have, microphone: "0,0",
You should try this first for your own setup. If it works, which it should, you can stop right here.
If it doesn't work, you must continue through the rest of this guide
Let's first test your speakers:
- Make sure speakers are plugged in and they are turned on
- Move some audio file (I used mp3 file) to your Raspberry
- Try to play your audio file with
aplay myAudioFile.mp3
- If you hear your audio file then speakers are working correctly and you can move to microphone testing
- If you can't hear your audio file playing move to audio troubleshooting
Let's test your microphone next:
- Make sure microphone is plugged in and it is not muted (some microphones has mute switch)
- Try to record yourself with
arecord --format cd --duration 15 --channels 1 test.wav
- This will record you for 15 seconds so please talk continuously for 15 seconds
- If you get error like
arecord: main:788: audio open error: No such file or directory
you know right away that your mic is not setup properly so you can move to audio troubleshooting - If it did record without problems play the file with
aplay test.wav
- If you can hear yourself then everything is setup correctly!
- If you can't hear yourself move to audio troubleshooting
First thing to do is to run alsamixer
on command line and view like this pops up:
Here you can check your configured playback and capture devices. If you press F4 you can see that I don't have any default microphones setup
This is because I am using USB sound card on my Raspberry. Your setup may be different of course but the process is the same.
Run aplay -l
which lists all your sound cards and audio devices.
Here I want to make my USB sound card as default device. As you can see the card 1 is my USB sound card.
Also run arecord -l
to list your recording devices
Here is the same thing that my USB sound card is number one. Next we need to change those.
Create ALSA config file to your home directory like this touch ~/.asoundrc
Open that file for example with nano nano ~/.asoundrc
Add the following contents to it
pcm.!default {
type hw
card 1
}
ctl.!default {
type hw
card 1
}
Let's break this down:
- in
pmc
thep
stands for playback. So were configuring playback settings inside this block - all you need to know that we are setting default card to 1 for playback
- this number has to match your desired card that we looked up previous. For my case it is 1
- in
ctl
thec
stands for capture. So were configuring capture settings inside this block - same here that change the card number to right one. In my case it was 1 like we checked previously
- also note that if you want to configure some other device inside the card you can specify that too
- we did not define device number in these block so then default 0 is used
- with the above setting we are saying "by default playback uses card 1 and device 0 to play audio files"
- and also we are saying "by default use card 1 and device 0 to record audio"
More info on configuring asoundrc
can be found here
After these steps your audio setup is done! If you still have problems play around with the setting and check the documentation on asoundrc