I’m trying to get the PCM data from an MP3. I’m using AVAssetReaderOutput and it seems to reading the data fine.
while(true)
{
nextBuffer = [assetReaderOutput copyNextSampleBuffer];
if(nextBuffer)
{
countsample = CMSampleBufferGetNumSamples(nextBuffer);
NSLog(@"%i", countsample);
}
}
I noticed that if I add up countsample, it equates to the number of seconds in the song (assuming 44100hz sample rate). For this reason, I’m sure the reading is being handled perfectly. What I’d like to do, however, is perform various DSP filters on this data but I need to do it on the sample information itself. How can I access the sample data? Also, I noticed that the CMSampleBufferGetNumSamples always returned 8192 except at the end of the song. Is there a way to increase/decrease this read rate?
Thank you
Append the data to a
NSMutableDataobject.countsampleandnextBufferare assumed to already exist in your code.