I have implemented two AVAudioPlayer in my iPad project. I am playing sound with one player object and also simultaneously recording with the other player.
First Scenario
1.Player1 is recording the words I am speaking. 2.Simultaneously player1 is also recording the music playing with player2.
*This scenario is working fine if I am not plugging in any headset with microphone to my iPad.
*But, if I plugged in the headset to my iPad & repeat the above scenario, the following points are observed:
i. I can hear the music being played by player2 in my headset.
ii. But after I stopped recording my voice through the microphone of the headset, there is no music sound when I playback the recorded track. I can only hear my voice which I recorded thru the microphone of headset.This is my problem. I want that with 'headset with microphone' my application should work same as with scenario1.
I am using the following settings for my AVAudioSession:
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
NSError *err = nil;
[audioSession setCategory :AVAudioSessionCategoryPlayAndRecord error:&err];
The following are the record settings for the recorder:
NSDictionary *recordSettings = [[NSDictionary alloc] initWithObjectsAndKeys:
[NSNumber numberWithFloat: 44100.0],AVSampleRateKey,
[NSNumber numberWithInt: kAudioFormatLinearPCM],AVFormatIDKey,
[NSNumber numberWithInt: 1], AVNumberOfChannelsKey,
[NSNumber numberWithInt: AVAudioQualityMax],AVEncoderAudioQualityKey,nil];
The track is saved in the .wav file format.
Also, the music played by player2 is of .wav or .mp3 format.
Please help me in resolving this issue.