Hello everyone,
Before I start, I am excited to know you about that the expected idea which is written in my roadtest application is almost done with few bugs. I am still working to fix the issues. I’ll post my about that in next post. But before that it is important to setup microphone in order to make a karaoke machine. So I’ve decided to post explaining “how I setup the microphone?”.
At first I buy a USB Sound Card from local market it works fine only for output audio but while using it as input through the microphone it works horrible. It works somehow fine in my laptop.
I’ve searched for the solution and also asked about the problem with some of my friend. They said that it might be an issue because of low output current capabilities of the raspberry pi.
So I’ve bought a new USB power hub. But the problem was still not gone. At last at very frustrated moment I bought a new USB sound card again from local market but from different shop. After using that I got to know that the old USB sound card is faulty. And wasted my money on that and buying extra power USB hub. So I have decided to post my story so that you will not waste your money.
Now come to the technical things.
How to use USB sound card
Step1. Plug USB sound card to the Raspberry Pi USB port.
Step2. Plug the microphone to the USB Sound card microphone jack. ( I’ve cut the 3.5mm jack from the old spare earphone and soldered the condenser microphone to it.)
Step3. (Optional) Plug the speaker USB sound card output or to the Raspberry Pi audio output jack.
Now, In the Raspberry Pi’s terminal
cat /proc/asound/cards
cat /proc/asound/modules
This is my output before and after plugging USB sound card
Recording and Playback
As in the image previously my device 0 (default sound device) is ALSA and the device 1 is USB-Audio
Recording Sound
arecord -d 3 -D plughw:1,0 testsound.wav
This will record your audio for 3 second to the file name testsound.wav.
You can change plughw:0,0 if your default device is USB-Audio
Playing sound
aplay testsound.wav
This will play sound to the default audio output. In mine case the default audio output is ALSA.
In order to play sound over the USB-Audio
aplay –D plughw:1,0 testsound.wav
Combining all things together
Lets create a shell script
sudo nano testsound.sh
Enter following to the file and save changes
echo “Say something within 5 Second”
arecord -d 5 -D plughw:1,0 testsound.wav
echo “Playing Recording”
aplay -D plughw:1,0 testsound.wav
Make the file executable
sudo chmod +x testsound.sh
Execute the script
./testsound.sh
This is all for now.
If you have any problem and query regarding this don’t hesitate to ask. If you have any suggestion’ please comment below.
Regards,