Skip to main content

Topic: GNU Octave audio package hacked for buffered reads (Read 3893 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • Axon
  • [*][*][*][*][*]
  • Members (Donating)
GNU Octave audio package hacked for buffered reads
Two zips attached.

"" contains "auopen.m", "auread.m", and "auclose.m", derived from "auload.m" in the audio-1.1.4 package bundled with Octave 3.2.4 (installed via Octave-Forge windows installer). The purpose of these three files is to implement a minimal API to read WAVs in a buffered (piecemeal) way as opposed to the all-at-once method that auload uses.

You're entirely on your own on how to "properly" install this thing, I just hacked files in-place at Octave\3.2.4_gcc-4.4.0\share\octave\packages\audio-1.1.4, which is a pretty naughty thing to do.

Note, the name here is kind of a misnomer, "" contains ONLY new .m files. (So don't delete your old "audio" package.)

My changes/API definition should be pretty brutally self-explanatory: I hold a "handle" data structure, returned by auopen(), which holds the file handle and all of the file header info necessary to actually read data. auread() returns a [buffer, handle] tuple (I am a total Octave noob so this is the brutally functional way I chose to update handle state through auread() calls). auclose() just closes the file.

File seeking is wholly unimplemented, and I never attempted to test or get working file reads through EOF (eg when the returned sample array is smaller than the requested sample array). I did fix the two's complement crap, and anything else that might have leered at me, but caveat emptor on all of this -- I got sufficiently fed up with Octave immediately after getting this working that I haven't made much of an attempt to maintain this, besides ensuring that it still runs.

"" contains the little ditty I wrote to test and validate the loader above, which is a barebones implementation of Welch's Method with 50% overlap and a Vorbis window. To test, unzip, make sure the unzip dir is on your octave path, run "ptest", and you should get a very believable spectrum plot of a sine wave, along with a numeric verification of Parsival's Theorem (comparing avg power as measured both in time domain and frequency domain to make sure the math checks out).

For any GNU homies, I'll attribute all of these changes to the same license that goes for the rest of Octave (GPL2 or latest GPL, right?)

  • Last Edit: 29 May, 2011, 09:06:44 PM by Axon