I'm trying to resample the WasapiLoopbackCapture's output from my soundcards 44100Hz, 16bit, 2 channel
waveformat to a 16000Hz, 16bit, 1 channel
format for later use in a System.Net.Sockets.NetworkStream
(I want to write the converted bytes to the network stream)
But I have no idea how to start even! I'm really new to signal processing and I've tried searching for tutorials but I just can't wrap my head around how to do this.
Here's what I got so far:
void StartRecording()
{
capture = new WasapiLoopbackCapture(device); // device is an audiodevice picked from the user. speaker, headphones etc
capture.ShareMode = NAudio.CoreAudioApi.AudioClientShareMode.Shared;
capture.DataAvailable += capture_DataAvailable;
capture.RecordingStopped += capture_RecordingStopped;
capture.StartRecording();
}
void capture_DataAvailable(object sender, WaveInEventArgs e)
{
outputStream.Write(e.Buffer, 0, e.BytesRecorded); // here I want to output audio to the NetworkStream.
// But I have to resample it first, which brings me to my question.
}
What I basically want to know is how I can get a byte-array which has been resampled and ready to be shipped off to the other side of the networkstream! Any suggestions are really appreciated! Thank you in advance.