views:

356

answers:

2

Hi,

I am currently using Audio Queues on the iPhone to record and playback audio.

What I would like to be able to do is to record some audio, allow the user to pause the record queue, and to seek back and forward through the audio to select a position from where they can start recording from again.

I have got over the seeking issue by making the playback AudioQueueBuffer sizes small enough so that the play audio queue callback happens at a rate that allows the user to use a slider control to hear the audio as they adjust the slider back and forth.

I think I can achieve the recording at a new position by setting the inStartingPacket parameter of the AudioFileWritePackets function that I call from the Audio Recording Queue callback.

The trouble is this only inserts audio over the previously recorded audio. The file length obviously doesn't change so if the user were to go backwards and record less audio than before, the old audio still remains after the end of the newly recorded audio.

Is there a way I can get the AudioFile to truncate at the point the user starts to insert the new audio, is there some other way I can remove the old audio starting at the insert position or is there a better way about going about this task?

Thanks

+1  A: 

I have the same question. My current approach is to record the new audio into a separate file, and then when that's done concatenate the first part of the first file with the second file, writing the result to a third file, then renaming the third file onto the first file and deleting the second file. The concatenate operation requires writing a custom but fairly straightforward function using the AudioFile API.

I'd also love to hear any more enlightened ideas, or see an AudioFileTruncate() function.

Archie
A: 

hi Biranchi,

I also want to do the same of seeking audio file to play forward / backward. i want to know , how i can do that? i am using "SpeakHere" sample code for Audio recording and playback. I am also getting position of slider which user has dragged, but i don't know how to set Audio properties.

please help.

thanks in advance,

Mitul Shah

mitul shah
You're asking question in the answer here. Ask as a separate question.
Sagar