views:

379

answers:

5

Hi there, 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

A: 

FILEPATH is same as path where another file is being played...? and if record and prepareToRecord are called from same place... actually you do not need to call prepareToRecord... 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

mihirpmehta
Thanks for your answer.No FILEPATH points to Documents folder and the played file is in the Bundle. I tried to comment prepareToRecord but it still stops.I found that when I run record, alGetSourcei(source, AL_SOURCE_STATE, returns always AL_PLAYING for state.So for openAL the file is still playing.
Oscar Peli
A: 

I answer to myself to add more info. 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

Oscar Peli
A: 

i have the problem using OpenAL and AVAudio Functions together.

i don't think OpenAL get along with AVAudioRecorder and AVAudioPlayer.

But i absolutely know There are apps that play and record in app store.for example "Beat maker" or "Sampletoy" and so on.

there definitely is solution. I want to know the solution....

Pawe
A: 

I am recording Audio From AVAudioRecorder and play it back using OpenGL to gain pitching ...but when playing it back i am not getting any sound ... but wen i play it using AVAudioplayer i can get the audio... what might be the problem...please help me...

Ramkumar
A: 

Can anyone tell me why the volume in openal becomes lower and lower if I change the pitch higher and higher? Thanks in advance.

alSourcef(source, AL_PITCH, 1.2f); alSourcef(source, AL_GAIN, 1.0f);

with this setting, the volume is still very very low. is there a way to cheat it to make the gain above 1?

Xiu