0

这是一个与 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 的时候进行记录???

再次感谢

4

1 回答 1

0

FILEPATH 与正在播放另一个文件的路径相同...?如果recordandprepareToRecord是从同一个地方被调用的......实际上你不需要打电话prepareToRecord......record会做这项工作......看

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

于 2010-04-09T10:21:35.527 回答