开发者

Drawing a waveform in C#

I want to be able to display a WaveForm in C#, along with some simple features such as zooming and selection. I already have the data as a short[] of amplitude values.

However开发者_运维知识库, I am an amateur when it comes to hardcoding GUI. I have already found a possible helper class WaveFormClass that may help me achieve this but as a backup, I want to learn how to manually do it.

So may I ask for some methods and possibly some links that will help? Thanks!


NAudio has a WPF sample app that displays waveforms - you can get the source code from codeplex, the author also has an article about the topic here.


As with any chart, you'll have to iterate through X values and draw appropriate Y value taken from the sample array that you have.

If you will want to pan left and right through the audio, you'll have to offset getting the data from the array. If you will ad zoom out capability - so one pixel on the screen corresponds to some samples (try with integer numbers for start), you'll have to average some values and then draw appropriate value.

If word PIXEL and SAMPLE isn't yet in your vocabulary, before drawing the waveform you should get familiar with them, because no amount of others' people code will teach you how to do it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜