Re: ExtAudioFileOpenURL and associated functions...
Re: ExtAudioFileOpenURL and associated functions...
- Subject: Re: ExtAudioFileOpenURL and associated functions...
- From: Richard Burnett <email@hidden>
- Date: Fri, 17 Apr 2009 16:28:08 -0400
Thanks for this code, it certainly helped give me a lot more details into what I was trying to accomplish.
The last issue I noticed was this, and let me just throw it out there and see if anything rings a bell.
Inside my buffer filling routine, I was taking an NSMutableArray that had some array of numbers in it, in the test case ONLY one number. I'd iterate through the NSMutableArray with a for statement pulling out an NSNumber value that was an indicator how far into the buffer to start. Once I hit the length of samples the callback was asked to process, I'd add the next number onto a new NSMutableArray and at the end of the whole process, assign it back to the original array so next time through, there would be a new array of samples to play at whatever start time was stored. Note, this is always playing the same sample, but you can start it multiple times and it gets put on a list to process.
For some reason, with this method, I get lots of random glitching in the sound. It is NOT consistent. I am sure I have leaking memory in my code, and I am allocating and deallocating things in this loop. Would this cause the problems I was seeing?
If I switch to a UInt32 in my class as a member variable and just say focus on playing once, it has no problem and no glitches. Essentially, I am just ripping out the NSMutableArray code and NSNumber stuff.
Are there certain operations I should NOT be doing in a buffer filling routine?
Here is a bit of the code I was using for reference:
NSMutableArray *newQueueAfterPass = [[[NSMutableArray alloc] init]retain];
NSInteger passCounter = 0;
//dataSize is the bytes size of sampleData and sampleData2 which contain all the loaded samples.
for( NSNumber *number in keySampleTriggerTable )
{ //if pass 0 we set, if greater we add (mix) the values
int i;
if( passCounter == 0 )
{ for( i=0; i<samples && (i + [number intValue])<(dataSize/3);i++)
{ data[i] = sampleData[i + [number intValue]];
data2[i] = sampleData2[i + [number intValue]];
}
if( i<samples)
{ while( i<samples)
{ data[i]=0;
data2[i]=0;
//exhausted note, no need to put back in queue
i++;
}
}
else
{ [newQueueAfterPass addObject: [NSNumber numberWithInt:i+[number intValue]]];
}
}
else
{ //Deleted this code, but if more than one note was in the queue, I'd add to data[i] and data2[i] at this point and all additional entries
}
[number release];
passCounter++;
}
[keySampleTriggerTable release];
keySampleTriggerTable = [[[NSMutableArray alloc] initWithArray:newQueueAfterPass]retain];
[newQueueAfterPass release];
Thanks,
Rick
>Hi guys
>
>I ran into these same issues not long ago and created an example of using
>the Ext audio file API. See Example #3
>for some working code, I suggest you start with some working code and then
>modify it to do what you need.
>
>http://www.modejong.com/iPhone/
>
>cheers
>Mo DeJong
>
_______________________________________________
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