[LAU] Library for simple audio programming

James Harkins jamshark70 at gmail.com
Wed Jan 16 02:01:33 UTC 2013


Ivan K <ivan_521521 at ...> writes:

> I want to write a simple application that can open a .wav file
> (stereo or mono), grab the header, and then read and dump
> the sample values from a portion of the .wav file to an ascii data
> file (I want to plot minute portions of the sound file with
> application such as gnuplot).

FWIW, this task is incredibly easy in SuperCollider:

// Open an existing sound file
// Automatically parses the header
f = SoundFile.openRead(Platform.resourceDir +/+ "sounds/a11wlk01.wav");

// Jump ahead to a given "sample frame"
// f.sampleRate "frames" always corresponds to 1 sec,
// no matter how many channels
f.seek(4410);  // 0.1 seconds in

// Allocate space for the samples, and get them
// Channels are interleaved
d = FloatArray.newClear(50);
f.readData(d);

f.close;


// Push them out to a text file
o = File("~/samples.txt", "w");
d.do { |sample| o << sample << Char.nl };
o.close;

It's also possible to rework this (fairly minor adjustments) to run it from the 
commandline. No time to do it at the moment -- maybe later, if anyone is 
curious.

hjh



More information about the Linux-audio-user mailing list