问题
How can I remove the first .5 of a second from Wav file?
回答1:
Here is the format. You need to open up the file, find the size of the header, then remove the required number of samples. You can find the number of bits per sample in the header. A 16-bit WAV file at a sampling rate of 44100 Hz would require you to remove (16/8) * 44100 * 0.5 = 44100 bytes
回答2:
A quick Google search turned up a library that may be able to do this.
回答3:
If you need to do it programatically, you need a wav file parser. The general algorithm would be
A) open the file
b) find the fmt chunk
c) parse to calculate X = bytes per sample * samples per second.
d) find the data chunk
e) remove the first X bytes
f) adjust the size of the data chunk
g) adjust the size of the initial RIFF chunk.
h) write the new file.
来源:https://stackoverflow.com/questions/4786660/remove-the-first-5-of-a-second-from-wav-file