Hi,
Is this generally true? ie. that you can set a property on an AudioUnit multiple times without it replacing itself?
In the context of an AudioGraph with a FilePlayer unit, I tried to set multiple start times for a single ScheduledFile Region but only get playback of one instance.
for (i = 0 ; i < 10 ; i ++) {
if ( i == 0 ) startTime.mSampleTime = -1; else startTime.mSampleTime = (22050 * i); result = AudioUnitSetProperty( filePlayerUnit, kAudioUnitProperty_ScheduleStartTimeStamp, kAudioUnitScope_Global, 0, &startTime, sizeof(startTime) );
if (noErr != result) {[self printErrorMessage: @"AudioUnitSetProperty[kAudioUnitProperty_ScheduleStartTimeStamp] failed" withStatus: result]; return;}
}
ScheduledAudioFileRegion rgn;
memset (&rgn.mTimeStamp, 0, sizeof(rgn.mTimeStamp));
rgn.mTimeStamp.mFlags = kAudioTimeStampSampleTimeValid;
rgn.mTimeStamp.mSampleTime = 0;
rgn.mCompletionProc = NULL;
rgn.mCompletionProcUserData = NULL;
rgn.mAudioFile = fileID;
rgn.mLoopCount = INT_MAX;
rgn.mStartFrame = 0;
rgn.mFramesToPlay = nPackets * fileAudioFormat.mFramesPerPacket;
CheckError(AudioUnitSetProperty(fileUnit,
kAudioUnitProperty_ScheduledFileRegion,
kAudioUnitScope_Global,
0,&rgn, sizeof(rgn)),
"AudioUnitSetProperty[kAudioUnitProperty_ScheduledFileRegion] for one
of the loops");
Note that, as I uncovered a couple of weeks ago, the latter use of
AudioUnitSetProperty isn't really "setting a property", at least not
in the sense that I consider a "property". You can call this several
times in sequence with different regions, and the first value doesn't
get replaced by the later. Rather than thinking of it as a property,
think of it as passing a command to the file player, telling to add
the scheduled region you're passing in to its own internal list of
scheduled regions that need to be played.
|