RE: ExtAudioFileRead -- not reading enough frames
RE: ExtAudioFileRead -- not reading enough frames
- Subject: RE: ExtAudioFileRead -- not reading enough frames
- From: "Edwards, Waverly" <email@hidden>
- Date: Fri, 10 Sep 2010 19:33:11 -0500
- Acceptlanguage: en-US
- Thread-topic: ExtAudioFileRead -- not reading enough frames
Sorry, I need to add some clarification. I only learned this week through another list member's posting that upon completion of
result = ExtAudioFileRead(inExtAudFileRef, &framesToRead, bufList);
framesToRead will have stored the number of frames actually read versus the number of frames requested.
This is where I am getting a result of 440309 frames read, not 441000 as expected. I am perplexed as to why
there were only 440309 frames read.
W.
________________________________________
From: coreaudio-api-bounces+waverly.edwards=email@hidden [coreaudio-api-bounces+waverly.edwards=email@hidden] On Behalf Of Edwards, Waverly [email@hidden]
Sent: Friday, September 10, 2010 7:03 PM
To: 'email@hidden'
Subject: ExtAudioFileRead -- not reading enough frames
I have what an odd problem. For testing purposes, I have two files, ten seconds in length with a sample rate of 44100 Hz, which makes 441000 samples. The first file is a 16-bit WAV file and the second 32-bit. If I read file with the following code I get two different results for frames read upon completion of the read. I am typing this all out but hopefully there are not any errors.
propSize = sizeof( fileLenInFrames );
err = ExtAudioFileGetproperty( inExtAudFileRef, kExtAudioFileProperty_FileLenthFrames, &propSize, &fileLenInFrames );
// fileLenInFrames reports 441000 as expected on both files here
convRatio = outFormat.mSampleRate / inFormat.mSampleRate; //make room for conversion
framesToRead = fileLenInFrames * convRatio;// read samples according to conversion ratio when upsampling
dataSize = ( framesToRead * outFormat.mBytesPerFrame );
soundData = malloc( dataSize );
result = ExtAudioFileRead(inExtAudFileRef, &framesToRead, bufList);
When I read the 16-bit file, upon completion framesToRead returns a result of 440309, not 441000 as expected. If I read a 32-bit sample file, upon completion, I do get 441000 samples as expected. Now, if I ask for more frames than what are in the file when using the 16-bit sample test file, I do get the expected 441000 samples. The conversion factor is in place so that when I read a file that is of lower sampling rate, it automatically upsampled to 44100 Hz.
Is there something I am doing wrong?
Thank you,
W.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden