简体   繁体   中英

iPhone SDK trimming audio file

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM