GetMixerLine() public method

Microphone Level
public GetMixerLine ( ) : NAudio.Mixer.MixerLine
return NAudio.Mixer.MixerLine
        public VolumeControl(int deviceNumber)
        {
            waveIn = new WaveIn();
            waveIn.DeviceNumber = deviceNumber;
            //           waveIn.DataAvailable += waveIn_DataAvailable;
            //           waveIn.StartRecording();

            int waveInDeviceNumber = waveIn.DeviceNumber;
            if (Environment.OSVersion.Version.Major >= 6) // Vista and over
            {
                var mixerLine = waveIn.GetMixerLine();
                //new MixerLine((IntPtr)waveInDeviceNumber, 0, MixerFlags.WaveIn);
                foreach (var control in mixerLine.Controls.Where(control => control.ControlType == MixerControlType.Volume))
                {
                    this.volumeControl = control as UnsignedMixerControl;
                    //Level = desiredVolume;
                    break;
                }
            }
            else
            {
                var mixer = new Mixer(waveInDeviceNumber);
                foreach (var source in from destination in mixer.Destinations
                                       where destination.ComponentType == MixerLineComponentType.DestinationWaveIn
                                       from source in destination.Sources
                                       where source.ComponentType == MixerLineComponentType.SourceMicrophone
                                       select source)
                {
                    foreach (var control in source.Controls.Where(control => control.ControlType == MixerControlType.Volume))
                    {
                        volumeControl = control as UnsignedMixerControl;
                        //Level = desiredVolume;
                        break;
                    }
                }
            }
        }
Beispiel #2
0
 public void CanGetWaveInMixerLine()
 {
     using (WaveIn waveIn = new WaveIn())
     {
         MixerLine line = waveIn.GetMixerLine();                
         //Debug.WriteLine(String.Format("Mic Level {0}", level));
     }
 }
        public void Record(string fileName, int volume = 100)
        {
            _waveIn = new WaveIn { WaveFormat = new WaveFormat() };
            _writer = new WaveFileWriter(fileName, _waveIn.WaveFormat);

            TrySetVolumeControl(_waveIn.GetMixerLine(), volume);

            _waveIn.DataAvailable += new_dataAvailable;
            _waveIn.StartRecording();
        }
 protected AudioLevelManager(WaveIn waveDevice)
     : this(GetVolumeMixerControlForInputLine(waveDevice.GetMixerLine()))
 {
 }