My next experiment was to use a USB sound card that I had gotten for cheap. Apparently, these are hit and miss and if I were to do it over again, I would get one from Adafruit where they sell ones that have been tested for the Pi. Everything worked out so I lucked out, but the path to success was not obvious. For your information, I used the CMedia HS100 from NRGtech. I also used the latest version of Raspbian (Debian Wheezy) and updated my pi firmware with "sudo rpi-update" before I even started since most guides mentioned to do this for latency.
Before I begin, I was repeatedly given the ALSA (Advanced Linux Sournd Architecture) document. There's a lot of information in there. I hope to spend sometime read it more thoroughly, but when you're trying to get something simple working, it's like drinking from a fire hose.
- Plugin the USB sound card.
- Navigate to the Menu>Preferences>Audio Device Settings.
- At the top of the dialog, there is a drop down for the sound card. Mine displayed "bcm2835 ALSA mixer) (Default)". Click it and you should see your new USB sound card. Again, mine displayed "USB PnP Sound Device (Alsa Mixer)".
- Select the USB sound card.
- Click "Make Default" button.
- You can click "Select Controls..." which brings up a dialog for you to be able to select things it can use to change settings on your sound card. I selected everything.
- Make sure volume is up and USB soundcard is connected to either headphones or speakers. To verify, my speaker setup, I used the built-in audio output first before connecting USB sound card.
- Edit /etc/modprobe.d/alsa-base.conf with your favorite editor (sudo vi /etc/modprobe.d/alsa-base.conf). I strongly recommend making a backup of this file. You can also follow this from an Adafruit article as well.
- Find the line "options snd-usb-audio index=-2" and change it to "options snd-usb-audio index=0".
- Add another line below the edited line: "options snd_bcm2835 index=1"
- Save the alsa-base.conf and reboot the pi (sudo reboot).
- speaker-test -c2 -D hw:0,0. This should work. You will hear white noise from left to right on your speakers.
- aplay -D hw:0,0 /usr/share/sounds/alsa/Front_Center.wav
- Success? Or did you get "Channels count non available". If success, you can stop now and celebrate. Have some fun with SonicPi!
- sudo aplay -D hw:0,0 /usr/share/sounds/alsa/Front_Center.wav
- This probably worked. If so, the answer is simple. Edit the $HOME/.asoundrc (vi $/.asoundrc). Back up the original is again strongly recommended.
- Clear the existing contents of the .asoundrc.
- Add "defaults.ctl.card 0"
- Add "defaults.pcm.card 0"
- Add "defaults.pcm.device 0"
- Save .asoundsrc. Try "aplay -D hw:0,0 /usr/share/sounds/alsa/Front_Center.wav" again.
- Success? Excellent. Glad this guide can help. If you are still having issues: this article and this one too helped me figure out what was going.
I wrote this guide up mainly for myself so I don't forget it and to use again. Hope it helps you as well.
Post a Comment