Skip to content

Play raw files in Linux Ubuntu/Debian/CentOS/RedHat

RAW Audio format or just RAW Audio is a computer 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). So if you try to play RAW file, it will give you error. To play RAW file you have to manually add header information.

$ play -c 1 -s -r 8000 -t raw -2 filename.raw

Play all RAW files within a folder

$ for i in `ls *.raw`; do `play -c 1 -s -r 8000 -t raw -2 $i`; done

Don’t need to remember all these parameters, you can create a alias as a custom command to play the RAW file. Open you ~/.bashrc file.

$ vi ~/.bashrc

Add this line to your ~/.bashrc file.

alias playraw="play -c 1 -s -r 8000 -t raw -2"

Use source command to update your ~/.bashrc file

$ source ~/.bashrc

Now, you can use “playraw” as a command to play RAW files.

$ playraw filename.raw