Raw audio

From XPUB & Lens-Based wiki
Revision as of 17:18, 22 January 2018 by Andre Castro (talk | contribs)

RAW Audio is an audio file format for storing uncompressed audio in raw form. Comparable to WAV or AIFF in size, RAW Audio file does not include any header information (sampling rate, bit depth, endian, or number of channels)


cat img.png > audio.raw
aplay -f S8 -c 1 -r 4000 audio.raw 

-f sample format / bit rate:

  • 8bit: S8 U8
  • 16bit: S16_LE S16_BE U16_LE U16_BE
  • 24bit: S24_LE S24_BE U24_LE U24_BE
  • 32bit: S32_LE S32_BE U32_LE U32_BE

-c: channel number

-r: sample rate. 4000 Hz is the minimum allowed by aplay. 44100Hz is the default sample rate for CDs


If we want to write the result of playing the raw file into an audio file with a head, like a wav we can use Sox for the job

sox -r 4000 -b 8 -c 1 -e signed-integer pg_0018.raw pg_0018.wav

Notice that I have to indicate the same audio parameters:

-r 4000 sample sate

-b 8 bit rate

-e signed-integer encoding


Links