Re: [linux-audio-dev] Reading a wave file in blocks

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] Reading a wave file in blocks
From: Paul Davis (pbd_AT_Op.Net)
Date: Wed May 30 2001 - 19:23:47 EEST


>Is it possible to make an array of structures with two fields (short l,r)
>and read in a huge part of the wavefile at once? This to speed up reading?

Its not really clear to me what you're asking. First of all, I'm
guessing that when you "wave file" you mean a file containing audio
data with a header defined by the RIFF/WAV standard from
Microsoft. Secondly, the data in this file is a continuous series of
sample values, but they are not always 16 bit, nor are there always
2 channels.

You can quite easily read in as much data as you wish; there's no need
for specific data structures to do so. If you mean making it simpler
to do:

   struct { short l, r } *frameptr;

   for (frameptr = buf; frameptr != end; frameptr++) {
       do_something_with_left_value (frameptr->l);
       do_something_with_right_value (frameptr->r);
   }

then sure, but this will break the moment you encounter a non-16-bit,
non-stereo file, just like way to many other Linux audio applications
that read WAV format files.

Use libsndfile instead, and stop worrying about it :)

--p


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Wed May 30 2001 - 19:46:13 EEST