3

how do I get a list of amplitudes from a audio file using a linux command line tool ?

Prakash Raman
  • 13,319
  • 27
  • 82
  • 132
  • something like http://linux.die.net/man/1/harminv ? – bobah Dec 20 '10 at 08:50
  • Looks like it might help, but according to the harmniv doc, it requires an input. What input must I provide ? – Prakash Raman Dec 20 '10 at 10:17
  • possible duplicate of [How can I decode a RAW/WAV file into a list of numbers ?](http://stackoverflow.com/questions/4482221/how-can-i-decode-a-raw-wav-file-into-a-list-of-numbers) – Paul R Dec 22 '10 at 16:50

1 Answers1

4

Do you mean getting all the individual samples as text? SoX can do that.

$ sox file.wav file.dat

will take an audio file file.wav, and generate a text file file.dat with a column for the timebase in seconds, and a column for each audio channel scaled by the maximum possible value.

mtrw
  • 34,200
  • 7
  • 63
  • 71
  • I wanted to know what is the value for each time of each channel ? Is it a frequency or is it an amplitude ? – Prakash Raman Dec 20 '10 at 09:35
  • So would it be right to plot a sound waveform (e.g the one in http://soundcloud.com/dawnbrian5/photograph-katie-by-brian-clayton) using the values from the .dat file ? – Prakash Raman Dec 20 '10 at 10:19
  • Also, why does it lie between a range of -1 to +1 ? (according to SoX docs) ? – Prakash Raman Dec 20 '10 at 10:20
  • 3
    1. Yes, you can plot the sound waveform with those vales. 2. Because the samples are scaled by their maximum possible value. In the case of 16-bit samples, that would be 2^15, in the case of 24-bit samples, 2^23. – mtrw Dec 20 '10 at 10:53
  • Ah thanks. Make more sense now. – Prakash Raman Dec 21 '10 at 05:41