1

How can I decode a RAW/WAV file into a list of numbers ?

I need to do since I need to create a spectrogram/waveform from the audio file.

I thought I could use the list of numbers and create an image using a charting application (e.g. gnuplot)

Prakash Raman
  • 13,319
  • 27
  • 82
  • 132

1 Answers1

2

A raw files usually don't need any decoding, since it is already a list of numbers (hence 'raw').

Wav file is also a list of numbers, but with a header with extra information (number of channels, sampling rate, etc.). You don't mention what environment/programming language you use (which might help other people to help you), but if it is c/c++ you can use http://www.mega-nerd.com/libsndfile/

Itamar Katz
  • 9,544
  • 5
  • 42
  • 74
  • I am using ruby. I have looking at the contents of a wav file, I was not sure in which encoding the file was. it had words like \000 \az – Prakash Raman Dec 20 '10 at 06:15
  • 1
    I don't know ruby, but I guess a wav reader might already exist. If you want to parse the file yourself, you need to know the format of the header: https://ccrma.stanford.edu/courses/422/projects/WaveFormat/. After the header, the data is just a list of numbers, but you need to know the number of channels, sampling rate, bit depth, etc., which you get from the header. – Itamar Katz Dec 20 '10 at 06:45