A WAV File to C Code Converter

A freeware application for generating sound data in C code format from WAV files.


This application enables you to read WAV audio files and convert them into C code for inclusion in embedded systems projects. I wrote it for an embedded processor project of mine where I wanted to get sound data from my PC, but in a data format suitable for an embedded processor to send to a DAC, that could be included in a C compiler. Having failed to find an existing application suitable for my requirement, I decided to write my own.

Supported WAVE file formats:

Number of input channels: 1-8

Bits per sample: 8, 16, 24

Mix output: 1 or 2 channels, 8 or 16 bit

C format:
Interleaved / Separate arrays
Signed / unsigned


Download and unpack setup.zip and run the setup.exe file. Always check downloads with anti-virus and anti-spyware tools, you can never be entirely sure what happens to files in transit!!

Target platform: Windows XP, Windows 7 or later, 32 bit. Should run OK on 64 bit Windows.

Download: setup.zip, Version, 27 ‎February ‎2011, 156kB

Note: If you are using a standard user account, and want the option to install for everyone who uses the computer, the setup.exe file must be "Run as Administrator".


To open a WAV file, go to the main menu and select "File / Open a WAV file". The waveform of the loaded file will be displayed in the middle pane, and information about the file format in the top panel.

The bottom panel contains several fader controls. There will be one fader enabled for each channel in the original WAV file. A spin control at the top selects which channel is input to the mix, and a spin control at the bottom of the fader selects which channel is the output. Thus if the top spin controls are set to 0, 1, and the bottom spin controls are set to 0, 0, then channel 0 of the mix will be taken from channels 0 and 1 of the original file, in proportion according to the slider setting.

To the right of the faders is a spinner to select the number of channels in the mix (output) - either 1 (mono) or 2 (stereo) are available. The resolution may be selected by the radio buttons as either 8 bit or 16 bit. If the original file is 8 bit, the 16 bit option is not available.

The "MIX" button in the bottom panel will generate the output mix waveform. Alternatively, the menu options "Tools / Mix to Mono" or "Tools / Mix to Stereo" may be used without needing to select the number of channels spinner.

When you have generated the mix output, you can compare the sound quality by using "Tools / Play original" and "Tools / Play mix".

The mix output can be saved as a WAV file by "File / Save Mix as WAV file". You might want to use that to save the mix for future reference. The "File / Save Marked Section as C code" will save the part of the mix between the markers as C code. You set the markers by left clicking on the mix waveform for the start, and right clicking for the end of the selected section. When the markers are set, the "Tools / Play mix" command will play the selection.

The "File / Save Marked Section as C code" command brings up a dialog box with options for the embedded code output. If the mix is stereo, you have the option of generating arrays in either interleaved format, where alternate elements of the array contain the two channels in pairs, or in separate arrays, where one array contains one channel's data and the second array contains the second channel data. "Interleaved" has no meaning for mono output, as there is only one array containing sample elements for one channel. The data format can be selected to suit the embedded project, as either signed or unsigned data. The range of the data will correspond to whether 8 bit or 16 bit data was selected. The C code generated has a comment header with information about the sound format, and each row of array data has a comment indicating the array indices, to assist in editing the arrays if necessary.

Example of C code Output

* Written by WAVToCode
* Date:             Mon Feb 28 07:47:30 PM
* FileName:         full8bitmono.C
* Interleaved:      Yes
* Signed:           No
* No. of channels:  1
* No. of samples:   253040
* Bits/Sample:      8

#define NUM_ELEMENTS 253040

127, 127, 128, 127, 127, 128, 128, 127, // 0-7
128, 127, 127, 127, 127, 127, 127, 127, // 8-15

Known Issues

The data type of the arrays is currently always BYTE. This needs to suit the format, i.e. normally BYTE is an unsigned 8 bit type which is unsuitable for 16 bit or signed formats. You can easily change this to a suitable type in your embedded code.

If you use this program, please let me know of any issues you find using the contact form via the "About me" button at the top of the page.


This application is made freely available under the terms of a license based on the new BSD license. This is displayed in the setup program and stored in the License.txt file in the installation folder.

Created: February 28th, 2011