I got it! Still couldn't get it to work without threading, but it works like a charm like this. Now, I have to get it to stream over the network good enough so that there won't be noticeable lag as far away as India...
NAudio.Wave.WaveFormat frm = new NAudio.Wave.WaveFormat(2000, 16, 2);
BufferedWaveProvider bwProvider;
WaveOut waveOut;
public void Stream()
{
byte[] packet = new byte[128];
int offSet = 0;
int receivedPackets = 0;
byte[] stethoscopeAudioData = new byte[128 * 5000];
bwProvider = new BufferedWaveProvider(frm);
bwProvider.BufferLength = (128 * 5000);
new Thread(() =>
{
waveOut = new WaveOut();
waveOut.Init(bwProvider);
waveOut.Play();
}).Start();
stethoscope.StartAudioInput();
while (receivedPackets < 5000)
{
int bytesRead = stethoscope.AudioInputStream.Read(packet, 0, packet.Length);
if (bytesRead > 0)
{
// Data was bytesRead from the stream. Add the received packet to the audio data.
Array.Copy(packet, 0, stethoscopeAudioData, offSet, bytesRead);
bwProvider.AddSamples(stethoscopeAudioData, offSet, bytesRead);
receivedPackets++;
offSet += bytesRead;
}
}
stethoscope.StopAudioInput();
}