On Thu, 12 Feb, 2004 at 08:59PM +1100, Erik de Castro Lopo spake thus: > On Wed, 11 Feb 2004 21:32:03 +0000 > [EMAIL PROTECTED] 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.
Ahhh. > > 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. Thanks, that's great. > > Also, shouldn't sf_readf_float handle being asked to read too many > > frames? > > Yes, thats a bug. Fix in progress. Heh! I didn't realise I was talking to the author. Sorry if that last line sounded whiney and/or ungrateful - what I should have said was : thanks so much for libsndfile. James > Erik
