hello
i'm trying to do a visualizer using Naudio wasapi loop back capture feature, but i have a problem using samples.
NAudio.Wave.WasapiLoopbackCapture wasapi = new NAudio.Wave.WasapiLoopbackCapture();
wasapi.StartRecording();
wasapi.DataAvailable += InputBufferToFileCallback;
Now i use the event InputBufferToFileCallback to get the e.buffer and then extracting from the byte array the samples
thanks
i'm trying to do a visualizer using Naudio wasapi loop back capture feature, but i have a problem using samples.
NAudio.Wave.WasapiLoopbackCapture wasapi = new NAudio.Wave.WasapiLoopbackCapture();
wasapi.StartRecording();
wasapi.DataAvailable += InputBufferToFileCallback;
Now i use the event InputBufferToFileCallback to get the e.buffer and then extracting from the byte array the samples
byte[] buffer = e.Buffer;
int bytesRecorded = e.BytesRecorded;
int bufferIncrement = (int)(wasapi.WaveFormat.BlockAlign / wasapi.WaveFormat.Channels);
int bitsPerSample = wasapi.WaveFormat.BitsPerSample;
for (int index = 0; index < e.BytesRecorded; index += bufferIncrement)
{
float sample32left = 0;
float sample32right = 0;
sample32right = BitConverter.ToSingle(buffer, index);
sample32left = BitConverter.ToSingle(buffer, index + 4);
sampleAggregator.Add(sample32left, sample32right);
}
My question is if the samples for the right and left channels are right or if is it possible to use the wavechannel32 class to get the left and right samples in relation to the wasapiloopbackCapture.thanks