Products for USB Sensing and Control Canada flag
Products for USB Sensing and Control

sales inquiries

quotes, distributor information, purchase orders
sales@phidgets.com

technical inquiries

support, advice, warranty, returns, misshipment
support@phidgets.com

website inquiries

corrections or suggestions
web@phidgets.com

Address

Unit 1 - 6115 4 St SE
Calgary AB  T2H 2H9
Canada

Play an MP3 from your Phidget SBC

Learn how to play an MP3 using your Phidget SBC


by Lucas

Introduction

After reading this article, you will be able to play an MP3 from your Phidget SBC. Before we get started, you will need a USB to Audio Adapter. These are widely available online. A simple Amazon search yields many suitable results.

Instructions

Step 1: Install MPG321

The first step to playing audio from your SBC is to install mpg321. You can do this from the terminal by entering the following command:

Step 2: Plug in Adapter

Next, plug your USB adapter. You can enter the following command in order to confirm your adapter has been recognized:

dmesg | tail -n 5

You should see something similar to this:

Step 3: Confirm your Sound Card Index

Start by entering the following command in the terminal:

cat /proc/asound/cards

Note that our sound card index is currently set to 1, if we were to try to play an MP3 file, we would get the following error: As you can see, we have no sound card with an index of 0, so our command fails. In order to fix this, we need to change the index of our USB sound card.

Step 3: Modify your Sound Card Index

In order to modify our sound card index, navigate to the following location:

/etc/modprobe.d/

Here you can add a file named alsa-base.conf that has the following content:

Step 4: Final Steps

The last thing to do is reboot your SBC so that the changes can be applied: Finally, you can play your MP3 file by entering the following command:

mpg321 your_file.mp3

Conclusion

If you have any questions, let us know!