Skip to content

Cønverting yøur audiø files

Møffenzeef Mødular edited this page Nov 6, 2016 · 10 revisions

Taken directly from TechnoBlogy Tutorial

Extract the raw audio data

The WAV file format contains a 44-byte header followed by the raw data. On a Mac or Unix computer you can dump the data in a C-friendly text format using the built-in xxd command in a Terminal window:

Copy the audio file into your home directory. Open the Terminal application. Type the following command, substituting the name of your WAV file: xxd -i -s +44 quack.wav The -i parameter tells xxd to output the data in C include format, and the -s parameter specifies an offset to omit the first 44 bytes of the file. The output will look something like:

unsigned char quack_wav[] = { 0x7d, 0x7c, 0x7e, 0x7e, 0x7d, 0x7b, 0x7b, 0x7c, 0x7c, 0x7e, 0x7f, 0x7f, 0x81, 0x83, 0x84, 0x86, 0x88, 0x8a, 0x8b, 0x8c, 0x88, 0x7f, 0x76, 0x6f, ... 0x82, 0x7f, 0x80 }; unsigned int quack_wav_len = 1467; It also gives you a variable containing the length of the data, which we will use to detect the end of the audio.