Remove the first .5 seconds from the Wav file

How can I remove the first .5 seconds from a wav file?

0
source share
3 answers

Here is the format . You need to open the file, find the header size, and then delete the required number of samples. You can find the number of bits in the sample in the header. A 16-bit WAV file with a sampling frequency of 44100 Hz will require deletion (16/8) * 44100 * 0.5 = 44100 bytes

+5
source

A quick Google search revealed a library that can do this.

+2
source

If you need to do this programmatically, you will need a parser for wav files. A 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. 
+1
source

Source: https://habr.com/ru/post/1411252/


All Articles