This project has moved. For the latest updates, please go here.

Triming A wav file

Feb 3, 2013 at 1:29 PM
Hi mark
I used this method. And I passed the Argument to trim-
Double xpos1 = Math.Ceiling(Convert.ToDouble(startPos1.X * (Convert.ToDouble(waveStream.TotalTime.Milliseconds) / Convert.ToDouble(this.Width))));

WavFileUtils.TrimWavFile(Program.openedFileName, outPath, new TimeSpan(0, 0, Convert.ToInt32(xpos1)), new TimeSpan(0, 0, Convert.ToInt32(Convert.ToDouble(waveStream.TotalTime.Milliseconds))));
But I did not get desired output.The Trimmed(Output) File is being too large than i expect.Suppose I expect it will be 2-3 min long but it's length being almost same as input file length. What should I do to fix it ?
Feb 4, 2013 at 10:01 AM
you can look at the WaveFileFormat's AverageBytesPerSecond value, and use that to calculate the offsets needed. That's what I do in the blog post. Your xPos1 does not take this into account at all.