This project has moved. For the latest updates, please go here.

Mixing Audio, "Too many mixer inputs"

May 29, 2014 at 1:09 AM
Edited Jun 3, 2014 at 1:14 PM
Im having an issue using MixingSampleProvider inside a chat client application. After the chat client has been up and receiving audio for about 30 seconds, the MixingSampleProvider class throws an InvalidOperationException claiming "Too many mixer inputs". Its very possible I flooded the classes' maxInputs = 1024 limit as I set the recording buffer to 10 ms before that data is sent away. However, I tried 50 ms and 200 ms and still no luck.

When the form loads...
        private void Messenger_Load(object sender, EventArgs e)
            comboBoxCodecs.SelectedIndex = 2;
            comboBoxCodecs.Enabled = false;
            selectedCodec = ((CodecComboItem)comboBoxCodecs.SelectedItem).Codec;
            mixingProvider = new MixingSampleProviderOverride(WaveFormat.CreateIeeeFloatWaveFormat(selectedCodec.RecordFormat.SampleRate, selectedCodec.RecordFormat.Channels));
            mixingProvider.ReadFully = true;                                                //allows for the stream to send silence, waveOut will not stop automatically
            sampleProvider = new SampleToWaveProvider(mixingProvider);
            waveOut = new WaveOut();
            ThreadPool.QueueUserWorkItem(StartRecieve, null);
The code to recreate the audio signal is as follows; I removed the other cases for simplicity
private void ProcessBytes(object state)
            var senderThreadState = (SenderThreadState)state;

            Data msgReceived = new Data(senderThreadState.EncodedBytes);

            switch (msgReceived.cmdCommand)
                case Command.Audio:
                    if (msgReceived.messageContents != null)
                        waveProvider = new BufferedWaveProvider(selectedCodec.RecordFormat);
                        byte[] decoded = new byte[1024];
                        decoded = selectedCodec.Decode(msgReceived.messageContents, 0, msgReceived.messageContents.Length);
                        waveProvider.AddSamples(decoded, 0, decoded.Length);
Any Sugestions?
Jul 17, 2014 at 3:56 PM
don't keep making new BufferedWaveProviders. Just have one for each person you receive audio for.