Small microcontroller audio projects are designed to play very specific types of audio files. If your music sample is in MP3 format, or 44KHz .wav or if you have grabbed a sample from a source (or the Internet) and do not know how it was encoded, you'll want to convert it to the right format.

This way you will get the best sounding audio, and it'll make using audio with your code painless!

This page will show how to convert your sound file(s) into PCM 16-bit Mono WAV files at 22KHz sample rate, which is usually best for the current crop of microcontrollers which take WAV files and play them on a speaker.

Currently, we are recommending two ways to convert the files: via use of the program Audacity or via iTunes. Other software may do similar conversions, just remember the parameters above when you do the conversion.


The open-source software program Audacity is available for PC/Mac/Linux and is very easy to use to check files and convert the files if necessary. 

Audacity can also be used to trim audio files to just a small clip you might want as a phrase or sound effect. The Audacity online manual has information on doing the trimming and  more.

Download Audacity

Go to and click the Download button:

Select your operating system and download. For Windows, use the Windows Installer.

Run the downloaded installer program and then start Audacity.

(On macOS, double-click on the downloaded .dmg file, then drag the file to your Applications folder, then double-click the to launch.)

You should see a program window similar to the one below:

Step by Step Conversion

Step 1: Open the File

Select File -> Open to open your sound file. Audacity can open a wide range of files including MP3 and many obscure formats besides WAV (which is great!). 

Step 2: Check the File Properties

See the red circled text. That shows that the WAV file I chose is a 44.1 KHz, 32 bit stereo file which is above our microcontroller specifications noted (22 KHz, 16 bit, mono). We'll need to tell Audacity what parameters we want to convert the file.

Step 3: Split and Mix Stereo Sound (if necessary)

If Audacity reports that you have a stereo file, you will have two blue waveform files. If you only have one waveform and Audacity says you have a mono file, skip this step.

Combining a stereo track into a mono track will produce the original best on a mono speaker.

In Audacity 2.2, this is easier than in previous versions, it's one step instead of several:

Click on the menu item Tracks -> Mix -> Mix Stereo Down to Mono

Your file should now have one waveform and the text on the left says Mono. This is your combined track.

Step 4: Convert File to 16-bit Audio

If your audio rate is higher than 16-bit, you will want to downconvert it. The sample in the pictures above shows it is 32-bit.

Click on the track title and select Set Sample Format -> 16-bit

Your file bitrate should now show 16-bit PCM in the properties to the left.

Step 5: Convert to 22 KHz or Less

Finally, make sure the audio file will be saved as 22 kHz or less. If the the track label says 44100 Hz or some number higher than 22050 you will want to convert it.

At the bottom of the window there is a little button named Project Rate (Hz) - Make sure this is 22 kHz or less.

Then go to Tracks -> Resample and select the same rate. The rate in the info to the left of the waveform should show the new rate.

The lower the number the smaller the number of samples and the smaller your file will be when saved. BUT, you lose sound quality with lower sampling rates. Be careful about your choices. Upconverting a low bitrate (say 8 kHz to 16 to 22 kHz) will not make your file sound better.

Step 6: Export

The file you have now is ready to be written to disk. Select File -> Export -> Export as WAV

This will bring up the save dialog. Be sure to select WAV (Microsoft) signed 16-bit PCM as the file type.

Now you have your audio file! You can put it on an SD Card for a music player or on an Express flash drive for playback or whatever!

You can do the conversion easily with iTunes (available for Mac/Windows). If you have your music in iTunes already, this will be super fast to convert multiple files! 

You can download iTunes from the Apple website.

If you have Windows 10 or 10 S (for education), you can download a native Windows 10 version from the Microsoft App Store. For Windows 10 S this is the only version that may work. If you are having trouble downloading a Windows 10 version not from the Microsoft store, you might consider downloading this version from Apple, then upgrading.

Once you install and run the program, you'll have to set the preferences first, but you only have to do it once.

Step 1: Set Preferences

The settings depend on what version of iTunes you are running:

  • For older versions, Go to the Advanced -> Importing tab. Make sure it is set to 22KHz (or less), 16-bit (or less) and Mono channels. Click OK.
  • For newer versions like 12.1 and later, go to the tiny square in the upper left hand corner, left click with your mouse, and then click Preferences

Then click the Import Settings button under General:

Then click Import Using: WAV Encoder, Setting Custom. In the new popup window, select Sample Rate: 22,050 kHz, Sample Size: 16-bit, Channels: Mono.

Step 2: Convert

Older versions: Search for your file. then select Convert Selection to WAV from the menu.

For newer versions without a menu, right click the file you want and select Create WAV Version

Step 3: Copy Your Files

Simply drag the wav copy of the sound files onto an SD card, your hard drive, or desktop.

Audio and Video: Play and Record

Don't underestimate the low-tech way to capture any sound, be it from a home movie, a TV show, or from your cat.

The procedure is simple: Play the video or sound and record the audio. All modern computers have a microphone-in jack, headset mic or a webcam available for recording. Or, cue-up your sound and use your cell/mobile phone to record it.

Microsoft Windows Recording


Versions of Windows prior to Windows 10 have an program called Sound Recorder. This pops up a small window and the settings are fairly intuitive as far as record, stop, and play.

Windows 10, at least current editions, removes the Sound Recorder program and provides a Voice Recorder app. In the Cortana/Search bar type Voice Recorder. You'll get a big window with not much guidance.

If you do not have anything on your screen, click the three dots in the lower right and adjust the microphone settings. You may need to enable the microphone for this app and then run the app again.

Sound Recorder records WAV files directly. Voice Recorder records MPEG 4 audio files (no worries, read on). When you have a recording from Voice Recorder it will be listed to the right of the microphone button. Right click the file and select Open file location. You will then see your file - for example Recording.m4a. Note the directory, for example C:\Users\myusername\Documents\Sound recordings (where myusername is the user name you have in Windows  10).

Video Recording

You can also record a video in Windows 10 via the Camera app. It is suggested you use Voice Recorder to avoid having to split the video from the audio.

Follow the next page on Convert Audio from Videos to Sound Files to capture the sound from the video.

Mobile Phone Recordings

Many mobile phones offer audio and video recording capability. The methods vary depending on the model phone you have and its operating system. 

It is suggested you try to use a voice recorder app first to save steps in the file conversion if you were to take a video and want to then use the audio from the video.


There is no stock voice recorder but the phone manufacturer may have an equivalent application on your device. On Samsung, look for an app called Voice Recorder. If you have no such app, search the Internet for suggestions to try to find something simple, useful, and low cost. Lists such as "10 best voice recorder apps for Android" may help.

If you must record video, use your camera app, use the video record feature, and convert the file according to instructions on the next page on video to WAV conversion.


There is no Apple stock voice recorder app on iDevices. There are many third-party apps on the App Store if you wish to use one of those.

As with Android, it is suggested you try to use a voice recorder app first to save steps in the file conversion if you were to take a video and want to then use the audio from the video.

Other Methods

There are countless methods of recording a sound in the air to some recording device. If you have some hardware to do so, go ahead and use it!

Once That You Have a File with Sound

After you have recorded an audio or audio/video file, you probably will not know exactly what format the file is in. We need to ensure the file can be used in your electronics project.

Take the file you recorded and copy it to your computer. We will need to convert the file into a 22,050 kHz, 16-bit, mono WAV file for your project.

Use the guides below to get a digital sound file to use in your projects.

There are times where you have a video and would like the sound portion to use in your electronics project. The video can be from your own recordings or from videos on the Internet such as Youtube.

The process for extracting audio from video will be shown for a number of sources. Expect the complexity of this to be greater than just converting audio, as it helps to have some experience with video editing.

Converting Video Files You Have Downloaded to Audio

If you have a video file, in whatever format you recorded it in, you can convert the file to an audio-only version which can be feed into another program to encode it to the parameters needed for your electronics project.

If the video is on the Internet, like Youtube, first follow this guide to get a video file of that content.

There are several programs that can convert video files to audio-only formats. There are also websites that purport to do this although there may be ads or malicious content on such websites. 

First, we will demonstrate the open source available video and audio player VLC. VLC is available for every computer operating system (Mac, PC, Linux) and also for portable devices (Android and Apple iOS). 

You can also use Quicktime, that will also be shown below.

Use VLC to Convert Video to Audio

Go to the Audacity web site and follow the instructions to install and configure.

Open VLC and click the menu bar (upper left) on Media then Convert / Save...

This will pop up a window named Open Media. This is the correct window. You can capture from multiple sources - here I demonstrate with a file by clicking the + Add button and selecting a video file I have on my hard drive.

Click the Convert / Save button at the bottom and a new screen pops up:

Select "Convert" button, in Profile Select Audio CD then the wrench icon (the first one, spanner for UK). This will pull up another pop up screen to adjust the settings:

Click the Audio codec tab. Change the values to:

  • Audio box checked
  • Codec: WAV
  • Bitrate: you can leave this or lower it to save space but no lower than 44 kb/s
  • Channels: 1 (which is mono which we want)
  • Sample Rate: 22050 Hz

Click the Save button

You're back at the Convert screen. Add the Destination file name (you can click Browse to find a directory to save the file in if you want). Be sure the file ends in .wav and not another extension name. Click the Start Button to convert.

Let the computer process the file, in general wait the length of the audio clip but for a fast computer it may go quickly. 

Your WAV file is now available. Unfortunately the bit depth may not be perfect for our use. Go into Audacity or iTunes and check on the bit rate and convert if it is not 16-bit.

Audacity can also be used to trim an audio clip down to a manageable length, say part of a song or a specific word or sound effect.

Using Quicktime to Get an Audio File from a Video File

Quicktime can take a video file and export just the audio from the video. See the screenshot below:

The resulting m4a audio file can then be converted to a WAV file with the appropriate encoding for your microcontroller projects using Audacity or iTunes - click on one or the other program names for the respective step-by-step guide to convert your file.

Let's face it, sites like Youtube, Vimeo, and others have huge amounts of data we may wish to use for sound files on our microcontrollers. This page will discuss getting a video file from an online video.

Note that some video and audio content online is licensed or copyright protected. The laws vary from country to country. In some countries, like the U.S., using small clips as part of a review process may be acceptable if the whole file is not. Check your local laws on digital rights.

We'll demonstrate obtaining a video from Youtube that Adafruit put up as non-licensed.

Find the video on Youtube. The Adafruit video file is here - you can safely use this Adafruit video to practice without license issues.

First we will use a website called - Adafruit does not endorse this site, we have found it working for this purpose at the time the guide was written.

Copy the web address of the video into the video name box (circled in yellow) then click the blue link circled in red. You do NOT need to download their app.

The page will drop down a bit and allow you to save in several formats. MP4 is fine as long as it does not have the red no speaker icon next to it (as we do want the sound).

The site will then pop up a box asking where you want the video saved. Select a place on your computer hard drive or network storage, video files can be somewhat large.

You should now have a video MP4 file on your computer. You can split the audio from the video for your sound projects by using the Splitting the Audio from the Video guide.

Other Services

There are other websites that allow for getting videos from the web. The video sites tend to try to shut them down. Or, if they become heavily used, they are purchased and have malware on them. I have used with success, staying away from sites that say "warn". You can even save audio off a video and save an extra conversion step. But using 3rd party sites is risky and Adafruit does not endorse any of the sites.

This guide was first published on Jun 06, 2018. It was last updated on Jun 06, 2018.