[linux-audio-dev] libsndfile breakage

Erik de Castro Lopo erikd-lad at mega-nerd.com
Thu Feb 12 04:59:47 EST 2004


On Wed, 11 Feb 2004 21:32:03 +0000
james at dis-dot-dat.net wrote:

> Well, I've stopped the crashing.
> 
> It was my bad, but still a bit confusing.
> 
> Here's what I was doing
> 
> 
>        samples=info->frames*info->channels;
>        sound=(sample_t *) malloc (samples * sizeof(sample_t));
>        sf_readf_float(f,sound,samples);
> 
> Which (I now realise) isn't quite right because I'm trying to read
> twice as many frames as there are in the file (assuming a stereo
> file).

The cause of this is rather subtle. If you use the sndfile-info 
program in the file x_kick.wav that you posted, you will notice 
that there is non-audio data following the audio data. The 
problem is that using sf_readf_float() is attempting to read this
data as audio data.
  
> Changing to sf_read_float does the trick, but I still don't understand
> why some stereo files worked, while others didn't.  

The problem free files did not have the trailing non-audio data.

> Opening them in
> something wlse and saving them again in exactly the same format made
> them work!

Saving the file probably removed that trailing non-audio data. Use 
the sndfile-info program to verify this.

> Also, shouldn't sf_readf_float handle being asked to read too many
> frames?

Yes, thats a bug. Fix in progress.

Erik
-- 
+-----------------------------------------------------------+
  Erik de Castro Lopo  nospam at mega-nerd.com (Yes it's valid)
+-----------------------------------------------------------+
Java : A language from the C family of languages. It has all the bad
features of C++ but without the most powerful feature of C, pointers.
-- 
+-----------------------------------------------------------+
  Erik de Castro Lopo  nospam at mega-nerd.com (Yes it's valid)
+-----------------------------------------------------------+
" ... new TV ad for Microsoft's Internet Explorer e-mail program which
uses the musical theme of the "Confutatis Maledictis" from Mozart's
Requiem. "Where do you want to go today?" is the cheery line on the
screen, while the chorus sings "Confutatis maledictis, flammis acribus
addictis,". This translates to "The damned and accursed are convicted
to the flames of hell."


More information about the linux-audio-dev mailing list