views:

48

answers:

1

Hello, I am trying to record the audio using AVAudioRecorder. My problem is i want to play the file while it is being recorded. Is there any way i can do this? I have set the category to PlayAndRecord. I have created the file for recording.

I have tried to initialize both the recorder and the player for the URL and tried to play the file after the record function. But it seems that only one chunk of the file gets played.

+1  A: 

I seriously doubt you can do this with AVAudioRecorder and AVAudioPlayer convenience classes.

The AVAudioPlayer assumes that the file it plays is static and complete. For example, it has no method to dynamically update the track length. It reads the track length once at startup and that is why only the initial chunk of the file gets played. Any modifications to the file made after the AVAudioPlayer instances opens the file are ignored.

You'll need to set up a custom audio queue if you want to get fancy.

As an aside, how do you plan on getting around feedback problem of caused by recording what you are playing? You have nothing but a shrieking squeal in very short order.

TechZen
Could you point me to some links where this can be done? I have tried to see the speak here code where audio queues are used but to no avail.
Nareshkumar
Audio programming is huge topic once you go beyond the convenience classes. Be prepared to spend a lot of time on it if your not familiar with audio programming already. I would start with http://developer.apple.com/iphone/library/referencelibrary/GettingStarted/GS_AudioVideo_iPhone/index.html
TechZen
I would advise concentrating on resolving the feedback issue before you do anything else. That is a show stopper problem. If both the mic and the speaker are active at the same time you will get feedback which will render the audio unusable. It even happens when you use speaker on the phone function proper.
TechZen