Open enamodeka opened 8 years ago
same Issue. Ended up heavily optimising EZAudio.
Things i have done..
writing setDelegate:(id<accordingProtocols>)delegate
methods in all classes to take away the [delegate respondsToSelector:sel]
in the real time threads. Each delegate method to call got its own BOOL to store if they respond when the delegate is setup or back to nil. Looks stupid, but is less cpu stress while the callbacks work with the backside it needs some more bytes in memory. I mean bytes not megabytes.. LoL, i can handle that. Its audio anyway
changed EZAudioPlot redraw
so it applies the gain as transform instead to calculate it into data via setSampleData..
kicked all CAAnimations out, really all! With dedicated Actions reset to NSNull for each possible property. That way CoreGraphics is working as intended - faster. This makes only sense because in a real time application you want to see what is going on in real time and not animate heavy graphics without expression in data.
changed all possible Objective-C calls to pure C calls. Leads to significant less object messaging holding up the realtime thread.
and most important after lots testing.. changed
- (void)appendDataFromBufferList:(AudioBufferList *)bufferList withBufferSize:(UInt32)bufferSize
{
//
// Make sure the audio file is not closed
if (self.info->closed) return; //no NSAssert here, return is enoug
//would be even better without *self*, so it could become an argument.
//
// Perform the write
// ExtAudioFileWrite() not used here, instead Asynchron writing without Objective-C ErrorHandling Wrapper. I take the risk.
ExtAudioFileWriteAsync(self.info->extAudioFileRef, bufferSize, bufferList);
//
// Notify delegate <-- NOT, we call the delegate!
//
//if ([self.delegate respondsToSelector:@selector(recorderUpdatedCurrentTime:)])
if (delegatedRecorderUpdatedCurrentTimeToString) //ugly name from the delegate optimisation.
{
// see the C function naming? and not *self* here, what is not in the block can not be locked!
[_delegate recorderUpdatedCurrentTimeToString:EZAudioUtilities_displayTimeStringFromSeconds([self currentTime])];
}
}
this basically made EZAudio work for me..
After hours of hickups, little glitches or skipps, listening for errors in recordings in different formats,
it writes much cleaner cause the ExtAudioFileWriteAsync()
seems to fit better for EZAudio
Ah and not to forget, EZAudioDisplayLink protocol has a delegate method that takes the displaylink as message, which you never need.
- (void)displayLinkNeedsDisplay;
cheers
Hi there,
has anybody got the problem of skipped frames now and then? At times the recording plot freezes for the split second and the frames at that time are missing in the recorded file. I'm recording to AIFF format (with modified flags:
asbd.mFormatFlags = kLinearPCMFormatFlagIsBigEndian | kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked; such that the recorded file can open in Ableton Live.)
I'm recording using Soundflower device. The same setup with AudioQueues (instead of EZAudio engine) from the Learning Core Audio book example works fine. Even if the system stutters the recording is unaffected.
Any idea on what could be happening?