The SoX command line program lists 85 sound formats. I need one that converts WAV files to a text format, listing the amplitude values in numerical form, preferably as integers.

Which format does that?

The Windows program GoldWave has the text format that does exactly that, but I need one that can be used in batch.


I think you want ".dat".

From the soxformat man page for Linux:

   .dat   Text Data files.  These  files  con‐
          tain a textual representation of the
          sample data.  There is one  line  at
          the beginning that contains the sam‐
          ple rate, and one line that contains
          the  number of channels.  Subsequent
          lines contain two  or  more  numeric
          data  intems:  the  time  since  the
          beginning of the  first  sample  and
          the sample value for each channel.

          Values  are  normalized  so that the
          maximum and minimum are  1  and -1.
          This file format can be used to cre‐
          ate data files for external programs
          such  as FFT analysers or graph rou‐
          tines.  SoX can also convert a  file
          in  this format back into one of the
          other file formats.

          Example  containing  only  2  stereo
          samples of silence:

              ; Sample Rate 8012
              ; Channels 2
                          0   0    0
              0.00012481278   0    0
  • @petoetje59 : Notice that the output .dat file might easily be ten times larger than the input file, which might be an issue with large input files. – audionuma Mar 20 '18 at 6:36
  • Thanks! A 05:40 FLAC mono audio file sampled at 5512 Hz using 16 bit signed integers resulted in 13,875,675 bytes using GoldWave's Numerical Text .txt format. SoX turned the same audio file into a whopping 67,512,010 bytes file. SoX's inefficient .dat uses floats for time and amplitude, and the time could have been deduced from just mentioning the number of samples in the header as GoldWave does. Anyway, it's easy to convert the .dat into .txt and vice-versa. – Petoetje59 Mar 20 '18 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.