I want to copy a part of the audio file, given the starting and ending point(in terms of time which I'll convert to packets or frames-is the conversion 开发者_如何学Cright?), and create a new audio file for the copied snippet. How do I copy? Please advice.
Regards, Namratha
For what file format(s)?
For the simplest and common .WAV (RIFF) file format, you can just copy the canonical 44-byte header (after checking to make sure the file is using only this simple format), update with the target file length, and then copy a selected sub-range of bytes (multiply time by sample rate by frame size) from the source file, and append that PCM data to the copied header. Apple's codec does not complain about audio files patched together this way.
For other formats, you might be able to convert them either to a simple WAVE file, or to an array of raw PCM samples of suitable sample rate, data type and endianess, and then do the above.
精彩评论