Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NAudio WaveStream and multiple channels

Tags:

c#

.net

naudio

I have a WaveStream, and I can read WaveFormat to obtain number of channels. When I read from that WaveStream am I reading the first channel or data from all the channels mixed?

I want to do a user control to display WaveForm, but I'm not sure if my control displays it properly.

like image 476
apocalypse Avatar asked Jul 10 '12 07:07

apocalypse


1 Answers

When you are reading from WaveStream, you are reading all channel samples, one by one. First you are reading the first channel, and the second sample is the first sample of the second channel.

If you put them in an array, then the first index is the first channel, the second index is the second channel, the third index is the third channel. So if you are displaying the left channel in your waveform, you should display indexes 0, 2, 4, and 6 and if you are displaying the right channel indexes 1, 3, 5, and 7 (if you have a stereo wave file of course).

like image 54
Legoless Avatar answered Nov 05 '22 08:11

Legoless