This project has moved and is read-only. For the latest updates, please go here.

Cutting wave

Feb 1, 2012 at 11:49 AM

Hi. I want to be able to cut some part of wave file and save the rest of it. I'm using WaveViewer control to show waveform of loaded wav file. I have even found a code showing how to trim the wave file(but not cut it in the middle). But I don't have an idea how to obtain position of wavefile. I mean, when I click on the waveform(in WaveViewer control), how can I get the time of the file?

Or maybe there is some other method?
(I'm using windows forms, not WPF)

Feb 1, 2012 at 6:34 PM

You would have to do the calculation yourself, based on the number of pixels along the mouse-click was, and how many milliseconds of audio are represented by one pixel. Also, the WaveForm viewer I made for NAudioDemo scrolls off to the left, so you would also need to know what position in the file the left-most sample represented.

Mark

Feb 2, 2012 at 11:05 AM

Can you give me some more pieces of advice? How to obtain how many miliseconds are represented by pixel? And what is the issue with left-most sample?

Feb 2, 2012 at 10:44 PM

you dont have to calc ms. you have to calculate the bytes because you just have to copy a part of the stream.

Feb 3, 2012 at 10:27 AM

The code that I found shows trimming using timespan. What's more, I can zoom in and zoom out the waveform. So now, I don't know how to do the cut.