iPhone - 如果我用AVAudioRecorder录制,openAL将停止播放

时间:2010-04-09 09:51:41

标签: iphone openal avaudiorecorder

这是与iPhone相关的问题: 我使用openAL播放一些声音(我必须管理增益,音高等)。 我想记录我正在播放的内容并使用AVAudioRecorder但是当我“prepareToRecord”时,openAL停止播放音频。 有什么问题? 这是我使用的IBAction记录:

- (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];
}

由于

编辑:

我也试过了AudioQueue录音。 此代码后,此时间停止响起:

status = AudioQueueEnqueueBuffer(recordState.queue, recordState.buffers[i], 0, NULL);

因此可以记录iPhone何时播放openAL ???

再次感谢

1 个答案:

答案 0 :(得分:0)

FILEPATH与播放另一个文件的路径相同......? 如果从同一个地方调用recordprepareToRecord ...实际上您无需致电prepareToRecord ...... record将完成工作...... 见

http://developer.apple.com/iphone/library/documentation/AVFoundation/Reference/AVAudioRecorder_ClassReference/Reference/Reference.html#//apple_ref/occ/instm/AVAudioRecorder/prepareToRecord