【问题标题】:iPhone - openAL stops playing if I record with AVAudioRecorderiPhone - 如果我使用 AVAudioRecorder 录制,openAL 会停止播放
【发布时间】:2011-02-06 01:52:09
【问题描述】:

这是一个与 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 播放时进行录制???

再次感谢

【问题讨论】:

    标签: iphone openal avaudiorecorder


    【解决方案1】:

    FILEPATH 与正在播放另一个文件的路径相同...? 如果recordprepareToRecord 是从同一个地方调用的……实际上你不需要调用prepareToRecord……record 就可以完成这项工作…… 见

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

    【讨论】:

    • 感谢您的回答。没有 FILEPATH 指向 Documents 文件夹,并且播放的文件在 Bundle 中。我试图评论 prepareToRecord 但它仍然停止。我发现当我运行记录时, alGetSourcei(source, AL_SOURCE_STATE, &state);始终返回 AL_PLAYING 状态。所以对于 openAL,文件仍在播放。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-24
    • 2011-11-06
    • 1970-01-01
    • 1970-01-01
    • 2011-03-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多