This project has moved and is read-only. For the latest updates, please go here.

Recording from headset

Oct 7, 2011 at 9:24 AM

Hi
I have been using the code in http://opensebj.blogspot.com/2009/04/naudio-tutorial-5-recording-audio.html to record audio. Basically this code:

	WaveIn waveInStream;
	WaveFileWriter writer;
	waveInStream = new WaveIn(44100,2);
	writer = new WaveFileWriter(outputFilename, waveInStream.WaveFormat);
	waveInStream.DataAvailable += new EventHandler<WaveInEventArgs>(waveInStream_DataAvailable);
	waveInStream.StartRecording();

It works perfectly and record every sound on the system. The problem arises when I pluck in a headset (not usb, just directly into the headset jack on the built in soundcard on my laptop). This has the effect that any sound I can hear in the headset is not recorded. I think it has something to do with which device i am recording from, but I can't quite figure it out.

I am trying to record a conversation, which means I would like to record the sound that comes from the mic and the sound I can hear in the headset at the same time.
Can someone point me in the right direction for this? Thanks.

Btw, this is a cross post from stackoverflow (http://stackoverflow.com/questions/7670463/naudio-recording-from-headset) where no one seems able to answer...

Oct 13, 2011 at 6:25 AM

I have the same problem. My code used to work fine even for conference calls and I was using it on the laptop with built-in mic and speakers. Now I switched to the desktop where I am using a headset. I record "something" but then unable to hear anything not only in my app but also using WMP. 

                    waveInStream = new WaveIn();
                    waveInStream.DeviceNumber = 0;
                    waveInStream.NumberOfBuffers = 2;
                    waveInStream.BufferMilliseconds = 100;

                    writer = new WaveFileWriter(RecordedFileName, waveInStream.WaveFormat);

                    waveInStream.DataAvailable += new EventHandler(waveInStream_DataAvailable);
                    waveInStream.StartRecording();

May be it has to do with DeviceNumber = 0 ?? How would I know what DeviceNumber to use?

Oct 17, 2011 at 10:39 AM

DeviceNumber 0 means use the default recording device

Jun 10, 2014 at 8:03 PM
Markheath@ I have the same problem. Please giving explanation shortly how to record sound from headset. Thanks.
Jun 12, 2014 at 12:38 PM
Well you either assume that the headset is device 0, or else you have to iterate through the WaveIn devices and examine the name to see which one is your headset. Usually, if it is a USB headset, Windows will automatically make it the default device when you plug it in.