Hi rbj,

I think he's wanting to use the libsndfile library but in the C case don't
u have to decode the samples from the PCM data i.e. bits?  I've done this
before as well and I think there's a good web reference here

http://soundfile.sapp.org/doc/WaveFormat/


-ez



On Sun, Dec 6, 2020, 11:27 PM robert bristow-johnson <
[email protected]> wrote:

> > On 12/06/2020 5:02 PM Kevin Dixon <[email protected]> wrote:
> >
> ...
> >
> > Honestly, building from scratch with static libraries will probably be
> easier
> >
>
> especially if there is only one format, like a plain-old 16-bit WAV file.
> in C, you would have to fopen() the file as binary, not text, and using
> fread() and fseek(), ftell(), and maybe rewind(), scan for maybe 4
> different RIFF chunks.  In the olden days, when a soundfile might be longer
> than the space you get in RAM, you would use ftell() and fseek() and maybe
> rewind() to navigate around the file before moving in specific data and
> then finally the audio in blocks of audio (assuming the file was not read
> from beginning to end at first) and finally end with fclose().
>
> long ago i wrote C code to do this for straight, linear, uncompressed WAV
> files.  doing it in general for a variety of file formats would indeed be a
> big job, but the labor is more about researching and understanding the
> different file formats.  the only code that i own is long ago from my Mac
> days, i have an AIFF file I/O function that is pretty straight forward.  i
> dunno if i can find it.
>
> in doing this, my recommendation is first scan the entire file for every
> RIFF chunk, one after another.  from the chunk type, determine if it's a
> chunk you care about or not.  if it's the chunk that contains the audio
> sample data, don't read it at first but just the header information and
> note the position in the file where the sample data begins.  get all the
> information you need first, then read in the sample data into memory all at
> once if you have enough memory or in blocks if you don't.
>
> --
>
> r b-j                  [email protected]
>
> "Imagination is more important than knowledge."
>

Reply via email to