简体   繁体   English

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

[英]iPhone - openAL stops playing if I record with AVAudioRecorder

this is an iPhone-related question: I use openAL to play some sound (I have to manage gain, pitch, etc.). 这是一个与iPhone有关的问题:我使用openAL播放一些声音(必须管理增益,音高等)。 I want to record what I'm playing and I use AVAudioRecorder but when I "prepareToRecord" openAL stops to play audio. 我想记录正在播放的内容,并且使用AVAudioRecorder,但是当我“ prepareToRecord” openAL停止播放音频时。 What's the problem? 有什么问题? Here is the record IBAction I use: 这是我使用的记录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];
}

Thanks 谢谢

EDIT: 编辑:

I tried with AudioQueue recording too. 我也尝试了AudioQueue录音。 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??? 因此可以记录iPhone在何时使用openAL播放???

Thanks again 再次感谢

FILEPATH is same as path where another file is being played...? FILEPATH与正在播放另一个文件的路径相同吗? and if record and prepareToRecord are called from same place... actually you do not need to call prepareToRecord ... record will do the job... see 并且如果recordprepareToRecord是从同一位置调用的...实际上,您不需要调用prepareToRecord ... record将完成工作...请参阅

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM