question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mixing two microphone inputs to one wav file

See original GitHub issue

Hi,

I am trying to mix two microphone inputs and save them to one wav file. To this end I have been experimenting with the RecordingPanel from the NAudio demo trying to get the microphone input in and out of a MixingWaveProvider32.

I think I am missing a step to write the MixingWaveProvider into the WaveFileWriter I have open. Could someone give me a hand please.

Please see the code snippets below.

Regards,

Darren

` private void CreateWaveInDevice() { if (radioButtonWaveIn.Checked) { waveIn = new WaveIn(); waveIn.WaveFormat = new WaveFormat(8000, 1); } else if (radioButtonWaveInEvent.Checked) { waveIn = new WaveInEvent(); waveIn.WaveFormat = new WaveFormat(8000, 1); } else if (radioButtonWasapi.Checked) { // can’t set WaveFormat as WASAPI doesn’t support SRC var device = (MMDevice) comboWasapiDevices.SelectedItem; waveIn = new WasapiCapture(device); } else { // can’t set WaveFormat as WASAPI doesn’t support SRC waveIn = new WasapiLoopbackCapture(); }

        WaveFormat OutputFormat = new WaveFormat(8000, 16, 1);


        bufferedWaveProvider = new BufferedWaveProvider(OutputFormat);

        MediaFoundationResampler MFR = new MediaFoundationResampler(bufferedWaveProvider, WaveFormat.CreateIeeeFloatWaveFormat(8000, 1));

        mixer = new MixingWaveProvider32();
        mixer.AddInputStream(MFR);


        WFW = new WaveFileWriter("D:\\a\\DJS.wav", waveIn.WaveFormat);

        waveIn.DataAvailable += OnDataAvailable;
        waveIn.RecordingStopped += OnRecordingStopped;
    }

`

` void OnDataAvailable(object sender, WaveInEventArgs e) { if (this.InvokeRequired) { //Debug.WriteLine(“Data Available”); this.BeginInvoke(new EventHandler<WaveInEventArgs>(OnDataAvailable), sender, e); } else { //Debug.WriteLine(“Flushing Data Available”); //writer.Write(e.Buffer, 0, e.BytesRecorded);

            bufferedWaveProvider.AddSamples(e.Buffer, 0, e.BytesRecorded);

            int secondsRecorded = (int)(writer.Length / writer.WaveFormat.AverageBytesPerSecond);
            if (secondsRecorded >= 30)
            {
                StopRecording();
            }
            else
            {
                progressBar1.Value = secondsRecorded;
            }
        }
    }

`

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
GxCreationscommented, Sep 30, 2021

we are a few years later. Is there a way now?

0reactions
mkRustamcommented, Aug 13, 2023

Still waiting))

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I connect two microphones to one input?
Basicly, you need either audio card with two mic inputs, or audio mixer. Both can be expensive. But you will be able to...
Read more >
How to Connect Multiple Microphones to a Computer for ...
The good news is connecting multiple microphones is a whole lot easier than you might think with solutions ranging from using an audio...
Read more >
Can You Record With 2 USB Microphones or More?
Can you record with 2 USB microphones at the same time? Yes! Should you record with 2 USB microphones at the same time?...
Read more >
2 mics, but only one xlr input?????
I am trying to put two mics into my Behringer K1800fx, one is xlr to xlr, sounds ... Sounds like your plugging a...
Read more >
How to connect multiple microphones to a computer
As a general rule, the best way to connect multiple microphones to a computer is to use multiple XLR inputs on an audio...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found