IPhone SDK trimming audio file

I implemented an audio recording function using AVAudioRecorder with AVSampleRateKey as 44100.0 and saved it as .caf. After recording audio, I want the user to be able to trim the audio from both ends, if necessary. Can someone please help me implement this?

In my case, since the AVSampleRateKey is 44100.0, 44100 bytes represent 1 second of recording. Right? Therefore, 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 be skipped to keep the header intact?

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

Thank you very much in advance

+4
source share
2 answers

The CAF file header usually contains information about how long a piece of data should be, as well as other data that needs to be consistent for file integrity. If you just trim the bytes from the end of the file, it will look like a damaged file for other applications. If you use ExtAudioFile to access files, you should be able to read the audio file and receive sample data, and then record a new audio file with the ends completed.

+1
source

You can use advanced audio file services. look at the link for ExtAudioFileRead and ExtAudioFileWrite (they have sample code), then you can open one audio file, read it, trim it, and then write a new one.go here http://developer.apple.com/library/ios/# documentation / MusicAudio / Reference / ExtendedAudioFileServicesReference / Reference / reference.html

0
source

All Articles