iPhone - 如果我使用 AVAudioRecorder 录音,openAL 将停止播放
这是一个与 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);
So it's possible to record while iPhone is Playing with openAL???
再次感谢
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
EDIT:
I tried with AudioQueue recording too.
This time sounds stops after this code:
status = AudioQueueEnqueueBuffer(recordState.queue, recordState.buffers[i], 0, NULL);
So it's possible to record when iPhone is playing with openAL???
Thanks again
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
FILEPATH 与正在播放另一个文件的路径相同...?
如果
record
和prepareToRecord
从同一个地方调用...实际上你不需要调用prepareToRecord
...record< /code> 会完成这项工作...
请参阅
http://developer.apple.com/iphone/library/documentation/AVFoundation/Reference/AVAudioRecorder_ClassReference/Reference/Reference.html#//apple_ref/occ/instm/AVAudioRecorder/prepareToRecord
FILEPATH is same as path where another file is being played...?
and if
record
andprepareToRecord
are called from same place... actually you do not need to callprepareToRecord
...record
will do the job...see
http://developer.apple.com/iphone/library/documentation/AVFoundation/Reference/AVAudioRecorder_ClassReference/Reference/Reference.html#//apple_ref/occ/instm/AVAudioRecorder/prepareToRecord