void WaveIn_DataAvailable(object sender, WaveInEventArgs e)
 {
     if (micOn)
     {
         byte[] encoded = codec.Encode(e.Buffer, 0, e.BytesRecorded);
         udpSender.Send(encoded, encoded.Length);
     }
 }
Example #2
0
 protected virtual byte[] ProcessRecordedData(byte[] recorded, int offset, int count)
 {
     lock (lockObject)
     {
         if (saveToFile && fileWriter != null)
         {
             fileWriter.Write(recorded, offset, count);
         }
         return(codec.Encode(recorded, offset, count));
     }
 }
 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 #5
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 #6
0
 private void _waveIn_DataAvailable(object sender, WaveInEventArgs e)
 {
     OnAudioCaptured?.Invoke(this, _speexCodec.Encode(e.Buffer, 0, e.BytesRecorded));
 }
Example #7
0
        private void OnAudioCaptured(object sender, WaveInEventArgs e)
        {
            var encoded = codec.Encode(e.Buffer, 0, e.BytesRecorded);

            audioSender.Send(encoded);
        }
Example #8
0
 void waveIn_DataAvailable(object sender, WaveInEventArgs e)
 {
     byte[] encoded = codec.Encode(e.Buffer, 0, e.BytesRecorded);
     udpAudioSender.Send(encoded, encoded.Length);
     // Console.WriteLine("Send audio size {0}", encoded.Length);
 }
Example #9
0
 static void waveIn_DataAvailable(object sender, WaveInEventArgs e)
 {
     byte[] encoded = selectedCodec.Encode(e.Buffer, 0, e.BytesRecorded);
     udpSender.Send(encoded, encoded.Length);
 }