views:

369

answers:

2

Hi

I have implemented a audio recording feature using AVAudioRecorder with AVSampleRateKey as 44100.0 and its saved as .caf. Once the audio is recorded, I want the user to be able to trim the audio from both the ends if required. Can some one please help me implement this?

In my case since the AVSampleRateKey is 44100.0, 44100 bytes represent 1 sec of recording. Right? So if I remove these many bytes from the end the audio will be trimmed at the end. But from trimming from the beginning, how many bytes should I skip so that the header remain intact?

It will be great if you can point me to some tutorial/document.

Thanks a lot in advance

A: 

The header of a CAF file usually contains information on how long the data chunk should be, along with other data that must be consistent for the integrity of the file. If you just trim bytes off the end of the file, it'll look like a corrupted file to other apps. If you use ExtAudioFile to access the files, you should be able to read the audio file and get the sample data, and then write a new audio file with the ends trimmed off.

lucius
A: 

See example 6, it does exactly what you want.

http://www.modejong.com/iPhone/

MoDJ