Re: [LAU] Library for simple audio programming

From: James Harkins <jamshark70@email-addr-hidden>
Date: Wed Jan 16 2013 - 04:01:33 EET

Ivan K <ivan_521521@...> 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

_______________________________________________
Linux-audio-user mailing list
Linux-audio-user@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-user
Received on Wed Jan 16 04:15:02 2013

This archive was generated by hypermail 2.1.8 : Wed Jan 16 2013 - 04:15:02 EET