void OnAudioCaptured(object sender, WaveInEventArgs e)
 {
     if (serverMute)
     {
     }
     else
     {
         byte[] encoded = codec.Encode(e.Buffer, 0, e.BytesRecorded);
         audioSender.Send(encoded);
     }
 }
        private void OnAudioCaptured(object sender, WaveInEventArgs e)
        {
            for (int i = 0; i < e.BytesRecorded; i += 2)
            {
                short sample = (short)((e.Buffer[i + 1] << 8) |
                                       e.Buffer[i + 0]);
                float sample32 = sample / 32768f;

                //Audio converted to db value.
                double sampleD = (double)sample32;
                sampleD = 20 * Math.Log10(Math.Abs(sampleD));
                temp    = (int)sampleD + 100;

                //Filter to remove nonsensical db outputs
                if (temp > 0 && temp < 100)
                {
                    inputVol = temp;
                }
                else
                {
                    //ignore
                }
            }

            //Microphone input sensitivty, controlled via scroll bar
            //500ms buffer using timer to stop choppy audio output
            if (inputVol > NetworkChatPanel.inputSens)
            {
                inputBuffer.Enabled = true;
                inputBuffer.Tick   += new EventHandler(BufferTimeout);
            }
            if (inputBuffer.Enabled)
            {
                byte[] encoded = codec.Encode(e.Buffer, 0, e.BytesRecorded);
                audioSender.Send(encoded);
            }
        }
Example #3
0
        private void OnAudioCaptured(object sender, WaveInEventArgs e)
        {
            for (var i = 0; i < e.BytesRecorded; i += 2)
            {
                var sample = (short)((e.Buffer[i + 1] << 8) |
                                     e.Buffer[i + 0]);
                var sample32 = sample / 32768f;

                //Audio converted to db value.
                var sampleD = (double)sample32;
                sampleD = 20 * Math.Log10(Math.Abs(sampleD));
                Temp    = (int)sampleD + 100;

                //Filter to remove nonsensical db outputs
                if (Temp > 0 && Temp < 100)
                {
                    InputVol = Temp;
                }
            }

            var encoded = Codec.Encode(e.Buffer, 0, e.BytesRecorded);

            AudioSender.Send(encoded);
        }
Example #4
0
        private void OnAudioCaptured(object sender, WaveInEventArgs e)
        {
            var encoded = codec.Encode(e.Buffer, 0, e.BytesRecorded);

            audioSender.Send(encoded);
        }