Quantcast
Channel: NAudio
Viewing all articles
Browse latest Browse all 5831

New Post: Using NAudio.GUI.WaveViewer

$
0
0

Hi, can someone tell me how to use WaveViewer? I don't think I'm using it properly.

I want to record voice and show its waveform while recording. Now I am using waveFormPainter, but this control "erases" waveform while scrolling.
So I want to use waveViewer which I think shows all the wave and scrollbar if needed(?).

So far I'm doing something like VoiceRecorder. While recording, I'm showing the waveform using WaveFormPainter. When recording is finished I want to show all the wave in WaveViewer. Unfortunately VoiceRecorder is WPF application(and my is windows form) and it doesn't use WaveViewer.

So now I'm adding every read buffer to memory stream:

private void input_DataAvailable(object sender, WaveInEventArgs e)
{   
    //some code here

    memStream.Write(e.Buffer, 0, e.BytesRecorded);
}

 

and then after the recording is stopped I do something like that:

rawSource = new RawSourceWaveStream(memStream, input.WaveFormat);
waveViewer.WaveStream = rawSource;

 

The wave is showed, but... I noticed some things. This waveform was completely different than this one in waveFormPainter. I noticed that this is connected with SamplesPerPixel property of WaveViewer. So I tried some values and it occured that 2048 gives me rather the same waveform(why?). BUT. When this wave form is longer than control width it is being scaled I thing, so it looks completely different again ;)
I expected WaveViever to give me the same waveform as waveFormPainter and scrollbar if needed. So am I doing something wrong, or just this control works like that?

 


Viewing all articles
Browse latest Browse all 5831

Trending Articles