Skip to content
Advertisement

File information of .raw audio files using terminal in linux

How to get file information like sampling rate, bit rate etc of .raw audio files using terminal in linux? Soxi works for .wav files but it isn’t working for .raw.

Advertisement

Answer

If your life depended on discovering an answer you could make some assumption to tease apart the unknowns … however there is no automated way since the missing header would give you the easy answers …

The audio analysis tool called audacity allows you to open up a RAW file, make some guesses and play the track http://www.audacityteam.org

In audacity goto File -> Import -> Raw Data…

Above settings are typical for audio ripped from a CD … toy with trying stereo vs mono for starters.

Those picklist widgets give you wiggle room to discover the format of your PCM audio given that the source audio is something when properly rendered is recognizable … would be harder if the actual audio was noise

However if you need a programmatic method then rolling your own solution to ask those same questions which appear in above window is possible … is that what you need or will audacity work for you ? We can go down the road of writing code to play off the unknowns mentioned in @Frank Lauterwald’s comment

To kick start discovering this information programmatically, if the binary raw audio is 16 bit then each audio sample (point on the audio curve) will consume two bytes of your PCM file. For mono audio then the following two bytes would be your next sample, however if its stereo then these two following bytes would be the sample from the other channel. If more than two channels then just repeat. Typical audio is little endian. Sampling rate is important when rendering the audio, not when programmatically parsing raw bytes. One approach would be to create an output file with a WAV header followed by your source PCM data. Populate the header with answers from your guesswork. This way you could listen to this output file to help confirm your guesses.

Here is a sample 500k mono PCM audio file signed 16 bit which can be imported into audacity or used as input to rolling your own identification code

The_Constructus_Corporation_Long_Street-ycexQvMy03k_excerpt_mono.pcm

Advertisement