Elliot Woods
Elliot Woods

Reputation: 844

Reducing channel count when recording in NAudio

I'm recording in NAudio with a PS3Eye camera, using CLEye drivers. The camera has a 4 microphone array, and presents 4 channels of audio to the system.

By default, all of the channels are being recorded by NAudio. I'm recording to PCM wave, and getting a 4-channel WAV output file.

When I try to play the file in NAudio, I receive an MmException 'NoDriver' calling acmFormatSuggest. Stereo files play fine.

My sound card can only output 2 channels, which appears to cause the error. Setting my Windows audio settings to Quadraphonic does not resolve this issue.

Perhaps I can ask NAudio to record only 2 channels, or implement my own WaveStream somewhere?

Does anybody have any ideas for down-sampling the number of channels in NAudio? (preferably at record time). Big thanks!

Upvotes: 0

Views: 2220

Answers (1)

Lee Harrison
Lee Harrison

Reputation: 2453

isn't it as simple as declaring it in your WaveFormat? 12000 is the sample rate and "1" is the number of channels.

 waveInStream = new WaveIn(WaveCallbackInfo.FunctionCallback());
 waveInStream.WaveFormat = new WaveFormat(12000, 1);
 waveInStream.DeviceNumber = 2;

 AudioWriter = new WaveFileWriter("c:\\MyAudio.wav", waveInStream.WaveFormat);
 waveInStream.DataAvailable += waveInStream_DataAvailable;
 waveInStream.StartRecording();

thats how i setup my code for a basic webcam recorder and with stereo mics it outputs mono wav files.

Upvotes: 0

Related Questions