Skip to content

Allows to track only one (default) microphone volume meter. #291

Open
@srhtbynkln

Description

Hello,
I am trying to track multiple microphone input volume level, but I am able to track only default microphone level if not open (Sound--> Recording Devices ) settings. When this settings open two or more microphone level possible to track, but if not it is allows only default microphone level to track.
And also it gives buffer full exception,

Here is code:

public Form1()
       {
           InitializeComponent();
           initMethods();
           sourceStrem = new NAudio.Wave.WaveIn();
           sourceStrem.WaveFormat = new NAudio.Wave.WaveFormat(44100, NAudio.Wave.WaveIn.GetCapabilities(0).Channels); //44100 khz 
           sourceStrem.StartRecording();
           sourceStrem.DataAvailable += new EventHandler<NAudio.Wave.WaveInEventArgs>(sourceStream_DataAvailableForCecking);

           sourceStrem2 = new NAudio.Wave.WaveIn();
           sourceStrem2.WaveFormat = new NAudio.Wave.WaveFormat(44100, NAudio.Wave.WaveIn.GetCapabilities(1).Channels); //44100 khz 
           sourceStrem2.StartRecording();
           sourceStrem2.DataAvailable += new EventHandler<NAudio.Wave.WaveInEventArgs>(sourceStream_DataAvailableForCecking);

           MMDeviceEnumerator enumerator = new MMDeviceEnumerator();
           var devices = enumerator.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.Active); //DeviceState.Active
           for (int i = 0; i < devices.Count; i++)
           {
               if (i == 0)
               {
                   firstMic = devices.ElementAt(i);
               }
               else if (i == 1)
               {
                   firstMic = devices.ElementAt(i-1);
                   secondMic = devices.ElementAt(i);
               }

           }
       }
       private void sourceStream_DataAvailableForCecking(object sender, WaveInEventArgs e)
       {
           progressBar1.Value = (int)(Math.Round(firstMic.AudioMeterInformation.MasterPeakValue * 100)); //PC_VolumeControl.VolumeControl.GetVolume(); 
           labelVolumeLevel1.Text = ((int)(Math.Round(firstMic.AudioMeterInformation.MasterPeakValue * 100))).ToString();
           progressBar2.Value = (int)(Math.Round(secondMic.AudioMeterInformation.MasterPeakValue * 100));
           labelVolumeLevel2.Text = ((int)(Math.Round(secondMic.AudioMeterInformation.MasterPeakValue * 100))).ToString();
       }


Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions