How to use the AEAudioFileWriter?

I have an audio and I added filter,I want save this new audio, I found this class 'AEAudioFileWriter' from The Amazing Audio Engine,but I do not konw how to use it. :'( :'(
I hope someone can help me :D
Thank you in advance :#


  • I use this code ,but not work!! :s
    NSArray documentsFolders = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *path = [documentsFolders[0] stringByAppendingPathComponent:@Recording.m4a];
    error = nil;

    const int kBufferLength = 4096;
    NSTimeInterval renderDuration = self.audioPlayer.duration;
    Float64 sampleRate = self.audioControler.audioDescription.mSampleRate;
    UInt32 lengthInFrames = (UInt32) (renderDuration * sampleRate);
    AudioTimeStamp timeStamp;
    memset (&timeStamp, 0, sizeof(timeStamp));
    timeStamp.mFlags = kAudioTimeStampSampleTimeValid;
    _audioFileWriter = [[AEAudioFileWriter alloc] initWithAudioDescription:self.audioControler.audioDescription];
    AudioBufferList *buf = AEAllocateAndInitAudioBufferList(self.audioControler.audioDescription, kBufferLength);
    [_audioFileWriter beginWritingToFileAtPath:path fileType:kAudioFileM4AType error:&error];
    for (UInt64 i = 0; i < lengthInFrames; i += kBufferLength)
       AEAudioControllerRenderMainOutput(self.audioControler, timeStamp, kBufferLength, buf);
        timeStamp.mSampleTime += kBufferLength;
        OSStatus status = AEAudioFileWriterAddAudioSynchronously(_audioFileWriter, buf, kBufferLength);
        if (status != noErr) {
            NSLog(@"ERROR: %d", (int) status);
    [_audioFileWriter finishWriting];
    [self.audioControler start:nil];
  • Solved?I have the same demand.

Sign In or Register to comment.