[PD] How to access audio files from disk randomly?

Roman Haefeli reduzierer at yahoo.de
Mon Dec 7 00:57:51 CET 2009

Hi all

Yeah, it's never too late for basic questions. Basically i would like to
create file player patch, that let's you pick a soundfile (be it a wav)
of any number of channels and a bit depth currently supported by
[readsf~] and it should be able to play from any position between the
start and the end of the file. 

Usually i used a kludge by using [soundfiler] in order to get the number
of sample frames of the file and then i calculated the number of bytes
to be skipped in order to be able to let [readsf~] play the file from a
random position. However, this only works when the actual header size of
the file is constant (i.e. known and the same for every file; ok, when
the header sizes would be known, they wouldn't need to be the same for
all files, but you get the point) and when you know beforehand the bit
depth of the file(s), since [readsf~] reads it correctly, but doesn't
tell you about it.

Now, i would like to be able to play wav files correctly with arbitrary
(unkown) bit depths and arbitrary (unkown) number of channels. Also, i
am looking for a way to be able to load both, simple RIFF WAV and so
called 'Broadcast WAV' files (the ones with a 'bext' header signature). 

I also tried [wavinfo] from ext13. However, this seems to work only with
the former (simple) format, but not with broadcast wav-files. Funny
enough, [readsf~] seems to have everything needed built-in, since it
reads both formats correctly, it just does not expose those functions to
the pd patch (as this unfortunately is often the problem with many
object classes). 

Any idea or pointers to other externals welcome!


More information about the Pd-list mailing list