I'm actually making an app which has to play and record streaming audio from internet on ipad. The streaming of the audio is done, I will have to come to the recording part very soon and I don't have any idea on how to proceed.
Could you give me a hint??? Idea? It will have to play while simultaneously recording into AAC or MP3.
Thanks.
You'll need to use the lower-level AudioQueue API, and use the AudioSession API to set up the audio session.
Then you'll need to fill out an AudioStreamBasicDescription
struct and create a new input queue with AudioQueueNewInput()
and include your callback function for handling input buffers.
And then you'll need to create 3 buffers using AudioQueueAllocateBuffer()
and AudioQueueEnqueueBuffer()
. And only then will you be ready to call AudioQueueStart()
. You should also handle audio session interruptions, and handle stopping the audio queue.
That will just get you a stream of buffers containing uncompressed 16-bit integer PCM audio data. You still need to compress the data, which is another can of worms that involves using the AudioConverter
API, which I haven't done on the iPhone OS so I don't know what will work there.
Please Look at this Framework. It provide data for recording while recording Streaming Kit
Play an MP3 over HTTP
STKAudioPlayer* audioPlayer = [[STKAudioPlayer alloc] init];
[audioPlayer play:@"http://www.abstractpath.com/files/audiosamples/sample.mp3"];
And append its data to NSMutabledata to play offline by using this delegate.
Intercept PCM data just before its played
[audioPlayer appendFrameFilterWithName:@"MyCustomFilter" block:^(UInt32 channelsPerFrame, UInt32 bytesPerFrame, UInt32 frameCount, void* frames)
{
...
}];