Record/Playback with AudioQueue on iPhone
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
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.
精彩评论