TheAmazingAudioEngine / TheAmazingAudioEngine2

The Amazing Audio Engine is a sophisticated framework for iOS audio applications, built so you don't have to.
http://theamazingaudioengine.com/doc2
Other
543 stars 87 forks source link

Not recording #57

Open acsarraf opened 7 years ago

acsarraf commented 7 years ago

Hi,

I've been trying to set up TAAE1/2 in different apps in an attempt to record the screen output essentially. In this case, I am using TAAE2 and I have an app where I am loading 2 sounds locally, and I want to be able to start a recording, play and pause the 2 sounds at varying times along with some effects at random times, stop recording and then save the file.

I have linked up Record and PlayRecording buttons to snippets of code similar to what is available in the TAAE2 Sample, but can't seem to get any actual output recorded. When i check through iExplorer, I always have an AppOutput.m4a file on display, but it is always 557 Bytes in size, so i'm guessing it doesn't actually contain any audio.

Before pasting my code in, does recording not work when playing sounds through AVAudioPlayer? I'm not particularly sure about this. Though I did try to start playing the Drums sound that comes with the sample app when i click record and to stop it when i stop recording, but that sound never comes up when i run the app, though my code does enter the if audio.drums.playing section that'll be included below.

Anyway, I will paste snippets of my record and play record functions. Any help would be greatly appreciated.

- (IBAction)recordPressed:(id)sender {
    if (_audioController.recording) {
        if (_audioController.drums.playing) {
            [_audioController.drums stop];
        }
        NSLog(@"stop recording");
        [_audioController stopRecordingAtTime:0 completionBlock:^{
            [self.recordButton setSelected:false];
        }];
    } else {
        @try {
            NSLog(@"Start recording");
            NSError *error;
            [_audioController.drums playAtTime:AETimeStampNone];
            [_audioController beginRecordingAtTime:0 error:&error];
        } @catch (NSException *exception) {
            [_recordButton setEnabled:NO];
        }
    }
}

- (IBAction)playRecorded:(id)sender {
    if (_audioController.playingRecording) {
        NSLog(@"Stop Playing recording");
        [_audioController stopPlayingRecording];
        [_playRecordingButton setSelected:NO];
    } else {
        NSLog(@"Start playing recording");
        [_playRecordingButton setSelected:YES];

        [_audioController playRecordingWithCompletionBlock:^{
            [_playRecordingButton setSelected:NO];
        }];
    }
}

Thanks a lot, Alan