public void Start(string inputDevice) { if (Started) { throw new Exception("Input already started"); } //waveIn = new WaveIn(WaveCallbackInfo.FunctionCallback()); waveIn = new WaveInEvent(); waveIn.BufferMilliseconds = 20; //Console.WriteLine("Input device: " + WaveIn.GetCapabilities(0).ProductName); waveIn.DeviceNumber = ClientAudioUtilities.MapInputDevice(inputDevice); waveIn.DataAvailable += _waveIn_DataAvailable; waveIn.WaveFormat = new WaveFormat(sampleRate, 16, 1); inputVolumeStreamArgs = new InputVolumeStreamEventArgs() { DeviceNumber = waveIn.DeviceNumber, PeakRaw = 0, PeakDB = float.NegativeInfinity, PeakVU = 0 }; opusDataAvailableArgs = new OpusDataAvailableEventArgs(); //inputControls = ClientAudioUtilities.GetWaveInMixerControls(waveIn.DeviceNumber); waveIn.StartRecording(); Started = true; }
private void Input_InputVolumeStream(object sender, InputVolumeStreamEventArgs e) { if (transmit) { //Gather AGC stats if (e.PeakDB > maxDbReadingInPTTInterval) { maxDbReadingInPTTInterval = e.PeakDB; } } }