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

New Post: Detect which input device has audio

$
0
0

Hello,

I'm writing a program that reads from line-in device. However, some computers only have a mic port. Moreover, if there are two ports, a person may by mistake plug into the mic port instead of line-in port. I want my program to be resilient and read wave data from the device where there is music data coming in. How can I do that ?  I guess I need to do silence detection. How would I do that ? This is my sample code:

        
private void on_data(object sender, NAudio.Wave.WaveInEventArgs e) {
     if (waveWriter == null) return;
     waveWriter.WriteData(e.Buffer, 0, e.BytesRecorded);
     waveWriter.Flush();
}

Somewhere in this code I have to do silence detection.

Is there any other way to solve this, without doing silence detection? Does NAudio have some filters that I could use out of the box?


Viewing all articles
Browse latest Browse all 5831

Latest Images

Trending Articles



Latest Images