iPhone - openAL stops playing if I record with AVAudioRecorder
- by Oscar Peli
Hi there, this is an iPhone-related question:
I use openAL to play some sound (I have to manage gain, pitch, etc.).
I want to record what I'm playing and I use AVAudioRecorder but when I "prepareToRecord" openAL stops to play audio.
What's the problem?
Here is the record IBAction I use:
- (IBAction) record: (id) sender
{
NSError *error;
NSMutableDictionary *settings = [NSMutableDictionary dictionary];
[settings setValue: [NSNumber numberWithInt:kAudioFormatLinearPCM] forKey:AVFormatIDKey];
[settings setValue: [NSNumber numberWithFloat:8000.0] forKey:AVSampleRateKey];
[settings setValue: [NSNumber numberWithInt: 1] forKey:AVNumberOfChannelsKey];
[settings setValue: [NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey];
[settings setValue: [NSNumber numberWithBool:NO] forKey:AVLinearPCMIsBigEndianKey];
[settings setValue: [NSNumber numberWithBool:NO] forKey:AVLinearPCMIsFloatKey];
NSURL *url = [NSURL fileURLWithPath:FILEPATH];
self.recorder = [[AVAudioRecorder alloc] initWithURL:url settings:settings error:&error];
self.recorder.delegate = self;
self.recorder.meteringEnabled = YES;
[self.recorder prepareToRecord];
[self.recorder record];
}
Thanks