public XPAudioDeviceControl()
        {
            //audioDevices = new Microsoft.DirectX.DirectSound.CaptureDevicesCollection();

            mixers = new Mixers(true);
            captureMixer = mixers.Recording;
            renderMixer = mixers.Playback;

            if (captureMixer != null)
            {
                // Set the current default values:
                // For the Device interface
                CaptureDeviceInterface = captureMixer.DeviceDetail.MixerName;

                // For the Device line
                if (captureMixer.UserLines.Count > 0)
                {
                    _UnselectableMixerLineName = captureMixer.UserLines[0].Name;
                    MixerLine selectedCaptureMixerLine = getSelectedMixerLine(captureMixer);
                    CaptureDeviceLine = selectedCaptureMixerLine.Name;
                }
                else
                {
                    throw new DeviceInterfaceException(CaptureDeviceInterface, "No capture line detected for the " + CaptureDeviceInterface + " device interface.");
                }

            }

            // Not supported for now.
            // RenderDeviceInterface = renderMixer.DeviceDetail.MixerName;
            // MixerLine selectedRenderMixerLine = getSelectedMixerLine(renderMixer);
            // RenderDeviceLine = selectedRenderMixerLine.Name;
        }
Exemplo n.º 2
0
		public MixerForm()
		{
			InitializeComponent();
			tBarArray		= new TrackBar[2][];
			tBarBalanceArray= new TrackBar[2][];
			lblArray		= new Label[2][];
			chkBoxArray		= new CheckBox[2][];

			//Initialization
			mMixers = new Mixers();
			mMixers.Playback.MixerLineChanged += new WaveLib.AudioMixer.Mixer.MixerLineChangeHandler(mMixer_MixerLineChanged);
			mMixers.Recording.MixerLineChanged += new WaveLib.AudioMixer.Mixer.MixerLineChangeHandler(mMixer_MixerLineChanged);
		}
Exemplo n.º 3
0
        public PlaybackDevice()
        {
            devList = new List<string>();
            regKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Multimedia\Sound Mapper", true);
            if (regKey == null)
                regKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Multimedia", true).CreateSubKey("Sound Mapper");
            defaultPlayback = regKey.GetValue("Playback") as string;

            /*devColl = new DevicesCollection();
            foreach (DeviceInformation dev in devColl)
            {
                if (dev.ModuleName == "")
                    continue;

                devList.Insert(0, dev.Description);
            }*/

            mMixers = new Mixers();
            foreach (MixerDetail mixerDetail in mMixers.Playback.Devices)
                devList.Add(mixerDetail.MixerName);
        }
Exemplo n.º 4
0
 public VolumeDetectorXP()
 {
     Mixers = new Mixers(true);
 }
Exemplo n.º 5
0
        private void LoadAudioValues()
        {
            try
            {
                mMixers = new Mixers();
            }
            catch (Exception e)
            {
                ///report error
                MessageBox.Show(Properties.LocalizedStrings.Message_AudioMixerInitializeError, Properties.LocalizedStrings.Message_InitializeError + e.Message);
                return;
            }
            // set callback
            mMixers.Playback.MixerLineChanged += new WaveLib.AudioMixer.Mixer.MixerLineChangeHandler(mMixer_MixerLineChanged);
            mMixers.Recording.MixerLineChanged += new WaveLib.AudioMixer.Mixer.MixerLineChangeHandler(mMixer_MixerLineChanged);
            MixerLine pbline = mMixers.Playback.UserLines.GetMixerFirstLineByComponentType(MIXERLINE_COMPONENTTYPE.SRC_WAVEOUT);

            this.volumeTrackBar.Tag = pbline;
            this.muteButton.Tag = pbline;
            MixerLine recline = mMixers.Recording.UserLines.GetMixerFirstLineByComponentType(MIXERLINE_COMPONENTTYPE.SRC_MICROPHONE); ;
            micMuteButton.Tag = recline;

            //If it is 2 channels then ask both and set the volume to the bigger but keep relation between them (Balance)
            int volume = 0;
            float balance = 0;
            if (pbline.Channels != 2)
                volume = pbline.Volume;
            else
            {
                pbline.Channel = Channel.Left;
                int left = pbline.Volume;
                pbline.Channel = Channel.Right;
                int right = pbline.Volume;
                if (left > right)
                {
                    volume = left;
                    balance = (volume > 0) ? -(1 - (right / (float)left)) : 0;
                }
                else
                {
                    volume = right;
                    balance = (volume > 0) ? (1 - (left / (float)right)) : 0;
                }
            }

            if (volume >= 0)
                this.volumeTrackBar.Value = volume;
            else
                this.volumeTrackBar.Enabled = false;

            // toolstrip checkboxes
            this.muteButton.ButtonToggled = pbline.Mute;
            this.micMuteButton.ButtonToggled = recline.Volume == 0 ? true : false;
            _lastMicVol = recline.Volume;
        }
 public MasterVolumeControlLegacy()
 {
     _mixers = new Mixers();
     _mixers.Playback.DeviceId = -1;
 }
 public override void Dispose()
 {
     _mixers = null;
 }
Exemplo n.º 8
0
 void BtnMuteClick(object sender, EventArgs e)
 {
     Mixers mMixers = new Mixers();
     //MixerLine pbline = mMixers.Playback.UserLines.GetMixerFirstLineByComponentType(MIXERLINE_COMPONENTTYPE.SRC_WAVEOUT);
     MixerLine recline = mMixers.Recording.UserLines.GetMixerFirstLineByComponentType(MIXERLINE_COMPONENTTYPE.SRC_MICROPHONE);
     foreach (MixerLine line in mMixers.Recording.UserLines) {
         MessageBox.Show(line.ToString() + " " + line.Selected + " " + line.Id);
     }
 }
Exemplo n.º 9
0
        private void ReloadLines()
        {
            MMErrors errorCode = 0;

            mLines.Clear();
            mUserLines.Clear();

            MIXERLINE         mxl = new MIXERLINE();
            MIXERLINECONTROLS mlc = new MIXERLINECONTROLS();
            MIXERCONTROL      mc  = new MIXERCONTROL();
            uint dwDestination;

            unchecked
            {
                dwDestination = (uint)-1;
            }

            mxl.cbStruct = (uint)Marshal.SizeOf(mxl);

            if (mMixerType == MixerType.Recording)
            {
                mxl.dwComponentType = MIXERLINE_COMPONENTTYPE.DST_WAVEIN;
                errorCode           = (MMErrors)MixerNative.mixerGetLineInfo(mHMixer, ref mxl, MIXER_GETLINEINFOF.COMPONENTTYPE);
                if (errorCode != MMErrors.MMSYSERR_NOERROR)
                {
                    throw new MixerException(errorCode, Mixers.GetErrorDescription(FuncName.fnMixerGetLineInfo, errorCode));
                }
            }
            else if (mMixerType == MixerType.Playback)
            {
                mxl.dwComponentType = MIXERLINE_COMPONENTTYPE.DST_SPEAKERS;
                errorCode           = (MMErrors)MixerNative.mixerGetLineInfo(mHMixer, ref mxl, MIXER_GETLINEINFOF.COMPONENTTYPE);
                if (errorCode != MMErrors.MMSYSERR_NOERROR)
                {
                    mxl.dwComponentType = MIXERLINE_COMPONENTTYPE.DST_UNDEFINED;
                    errorCode           = (MMErrors)MixerNative.mixerGetLineInfo(mHMixer, ref mxl, MIXER_GETLINEINFOF.COMPONENTTYPE);
                    if (errorCode != MMErrors.MMSYSERR_NOERROR)
                    {
                        throw new MixerException(errorCode, Mixers.GetErrorDescription(FuncName.fnMixerGetLineInfo, errorCode));
                    }
                }
            }

            dwDestination = mxl.dwDestination;

            MixerLine mixLine = new MixerLine();

            if (mMixerType == MixerType.Recording)
            {
                mixLine.Direction = MixerType.Recording;
            }
            else if (mMixerType == MixerType.Playback)
            {
                mixLine.Direction = MixerType.Playback;
            }

            mixLine.Mixer         = this;
            mixLine.Channels      = mxl.cChannels;
            mixLine.CControls     = mxl.cControls;
            mixLine.Connections   = mxl.cConnections;
            mixLine.Flag          = mxl.fdwLine;
            mixLine.Destination   = dwDestination;
            mixLine.Name          = mxl.szName;
            mixLine.Id            = mxl.dwLineID;
            mixLine.ComponentType = mxl.dwComponentType;
            mixLine.Source        = mxl.dwSource;
            mixLine.HMixer        = mHMixer;

            if (mixLine.CControls != 0 && !(mixLine.CControls == 1 && mixLine.Controls[0].Type == MIXERCONTROL_CONTROLTYPE.MUX))
            {
                mUserLines.Add(mixLine);
            }
            mLines.Add(mixLine);

            int cConnections = (int)mxl.cConnections;

            for (int i = 0; i < cConnections; i++)
            {
                mxl.cbStruct      = (uint)Marshal.SizeOf(mxl);
                mxl.dwDestination = dwDestination;
                mxl.dwSource      = (uint)i;

                errorCode = (MMErrors)MixerNative.mixerGetLineInfo(mHMixer, ref mxl, MIXER_GETLINEINFOF.SOURCE);
                if (errorCode != MMErrors.MMSYSERR_NOERROR)
                {
                    throw new MixerException(errorCode, Mixers.GetErrorDescription(FuncName.fnMixerGetLineInfo, errorCode));
                }

                MixerLine mixLineNew = new MixerLine();

                if (mMixerType == MixerType.Recording)
                {
                    mixLineNew.Direction = MixerType.Recording;
                }
                else if (mMixerType == MixerType.Playback)
                {
                    mixLineNew.Direction = MixerType.Playback;
                }

                mixLineNew.Mixer         = this;
                mixLineNew.Channels      = mxl.cChannels;
                mixLineNew.CControls     = mxl.cControls;
                mixLineNew.Connections   = mxl.cConnections;
                mixLineNew.Flag          = mxl.fdwLine;
                mixLineNew.Destination   = dwDestination;
                mixLineNew.Name          = mxl.szName;
                mixLineNew.Id            = mxl.dwLineID;
                mixLineNew.ComponentType = mxl.dwComponentType;
                mixLineNew.Source        = mxl.dwSource;
                mixLineNew.HMixer        = mHMixer;

                if (mixLineNew.CControls != 0)
                {
                    mUserLines.Add(mixLineNew);
                }
                mLines.Add(mixLineNew);
            }
        }
Exemplo n.º 10
0
        private void InitializeMixer()
        {
            try
            {
                mMixers = new Mixers();
                mMixers.Playback.MixerLineChanged += new WaveLib.AudioMixer.Mixer.MixerLineChangeHandler(mMixer_MixerLineChanged);
                mMixers.Recording.MixerLineChanged += new WaveLib.AudioMixer.Mixer.MixerLineChangeHandler(mMixer_MixerLineChanged);
                LoadDeviceCombos(mMixers);
            }
            catch (Exception ex)
            {

            }
        }
Exemplo n.º 11
0
        private void LoadDeviceCombos(Mixers mixers)
        {
            //Load Output Combo
            MixerDetail mixerDetailDefault = new MixerDetail();
            mixerDetailDefault.DeviceId = -1;
            mixerDetailDefault.MixerName = "Default";
            mixerDetailDefault.SupportWaveOut = true;
            comboBoxPlaybackDevices.Items.Add(mixerDetailDefault);
            foreach (MixerDetail mixerDetail in mixers.Playback.Devices)
            {
                comboBoxPlaybackDevices.Items.Add(mixerDetail);
            }
            comboBoxPlaybackDevices.SelectedIndex = Settings.Default.SelectedPlaybackDevice;

            //Load Ring Combo
            mixerDetailDefault = new MixerDetail();
            mixerDetailDefault.DeviceId = -1;
            mixerDetailDefault.MixerName = "Default";
            mixerDetailDefault.SupportWaveOut = true;
            comboBoxRingDevices.Items.Add(mixerDetailDefault);
            foreach (MixerDetail mixerDetail in mixers.Playback.Devices)
            {
                comboBoxRingDevices.Items.Add(mixerDetail);
            }
            comboBoxRingDevices.SelectedIndex = Settings.Default.SelectedRingDevice;

            //Load Input Combo
            mixerDetailDefault = new MixerDetail();
            mixerDetailDefault.DeviceId = -1;
            mixerDetailDefault.MixerName = "Default";
            mixerDetailDefault.SupportWaveIn = true;
            comboBoxRecordingDevices.Items.Add(mixerDetailDefault);
            foreach (MixerDetail mixerDetail in mixers.Recording.Devices)
            {
                comboBoxRecordingDevices.Items.Add(mixerDetail);
            }
            comboBoxRecordingDevices.SelectedIndex = Settings.Default.SelectedRecordingDevice;
        }
        public KeyValuePair<string, string> GetWindowsSelectedCaptureDeviceInfo()
        {
            KeyValuePair<string, string> kvp;

            // Retrieve the device selected by default in windows sound configuration
            Mixers mixers = new Mixers(true);
            Mixer captureMixer = mixers.Recording;

            if (captureMixer != null)
            {
                MixerLine selectedCaptureMixerLine = getSelectedMixerLine(captureMixer);

                // Create the key value pair that will contain the device interface name as a key and the line name as a value.
                kvp = new KeyValuePair<string, string>(captureMixer.DeviceDetail.MixerName, selectedCaptureMixerLine.Name);
            }
            else
            {
                kvp = new KeyValuePair<string, string>("", "");
            }

            return kvp;
        }
Exemplo n.º 13
0
    private void LoadAudioValues()
    {
			try {
      mMixers = new Mixers();
			} catch (Exception e)
      {
        ///report error
        (new ErrorDialog("Initialize Error " + e.Message, "Audio Mixer cannot initialize! \r\nCheck audio configuration and start again!")).ShowDialog();
        return;
      }
      // set callback
      mMixers.Playback.MixerLineChanged += new WaveLib.AudioMixer.Mixer.MixerLineChangeHandler(mMixer_MixerLineChanged);
      mMixers.Recording.MixerLineChanged += new WaveLib.AudioMixer.Mixer.MixerLineChangeHandler(mMixer_MixerLineChanged);

      MixerLine pbline = mMixers.Playback.UserLines.GetMixerFirstLineByComponentType(MIXERLINE_COMPONENTTYPE.SRC_WAVEOUT);

      toolStripTrackBar1.Tag = pbline;
      toolStripMuteButton.Tag = pbline;
      MixerLine recline = mMixers.Recording.UserLines.GetMixerFirstLineByComponentType(MIXERLINE_COMPONENTTYPE.SRC_MICROPHONE); ;
      toolStripMicMuteButton.Tag = recline;

      //If it is 2 channels then ask both and set the volume to the bigger but keep relation between them (Balance)
      int volume = 0;
      float balance = 0;
      if (pbline.Channels != 2)
        volume = pbline.Volume;
      else
      {
        pbline.Channel = Channel.Left;
        int left = pbline.Volume;
        pbline.Channel = Channel.Right;
        int right = pbline.Volume;
        if (left > right)
        {
          volume = left;
          balance = (volume > 0) ? -(1 - (right / (float)left)) : 0;
        }
        else
        {
          volume = right;
          balance = (volume > 0) ? (1 - (left / (float)right)) : 0;
        }
      }

      if (volume >= 0)
        this.toolStripTrackBar1.Value = volume;
      else
        this.toolStripTrackBar1.Enabled = false;

      // toolstrip checkboxes
      this.toolStripMuteButton.Checked = pbline.Mute;
      this.toolStripMicMuteButton.Checked = recline.Volume == 0 ? true : false;
      _lastMicVol = recline.Volume;
    }
        public Dictionary<string, List<AudioLineInfo>> getDeviceNames(Mixer mixer, Dictionary<string, List<AudioLineInfo>> deviceDictionary)
        {
            // Clear dictionary of previously added data (in case some devices have been unplugged or new ones have been plugged in)
            deviceDictionary.Clear();

            foreach (MixerDetail mixerDetail in mixer.Devices)
            {
                // Get the device's interface name
                string deviceInterfaceFriendlyName = mixerDetail.MixerName;

                // Which is set as a dictionary key if a different line already exists for it...
                if (!deviceDictionary.ContainsKey(deviceInterfaceFriendlyName))
                {
                    // If this device interface name hasn't already set as a dictionary key, then create a new entry for it.
                    deviceDictionary[deviceInterfaceFriendlyName] = new List<AudioLineInfo>();
                }

                // Create a mixer object based on the current deviceId so that we can retrieve the lines.
                mixers = new Mixers(true);
                Mixer mixer2 = null;

                // Get proper mixer type
                if (mixer.MixerType == MixerType.Playback){
                    mixer2 = mixers.Playback;
                }

                else if(mixer.MixerType == MixerType.Recording){
                    mixer2 = mixers.Recording;
                }

                // Set the device id
                mixer2.DeviceId = mixerDetail.DeviceId;

                // Retrieve the mixer lines and set them in the dictionar
                foreach (MixerLine mixerLine in mixer2.UserLines)
                {
                    /**
                     * Create the line name and interface friendly name (mixer name) pair to associate with the mixer name.
                     *
                     * But what? We are associating the mixer name with the mixer name? Isn't this unecessary redundancy?
                     * We have too because these two values are only identical under XP. In Vista and Windows7 The will be different so this
                     * is why we structure the response this way.
                     * Check out the Vista implementation for further details.
                     */
                    //KeyValuePair<string, string> lineNameAndFriendlyNamePair = new KeyValuePair<string, string>(mixerLine.Name, mixerDetail.MixerName);

                    // Gather device line properties to associate with the device's interface name.
                    AudioLineInfo audioLineInfo = new AudioLineInfo();

                    // Line name is confusingly known as the device friendly name.
                    audioLineInfo.LineName = mixerLine.Name;

                    // The device's friendly name (the REAL friendly name).
                    audioLineInfo.FriendlyName = mixerDetail.MixerName;

                    // Is the device line mutable
                    audioLineInfo.Mutable = mixerLine.ContainsMute;

                    deviceDictionary[mixerDetail.MixerName].Add(audioLineInfo);

                }

            }

            return deviceDictionary;
        }
Exemplo n.º 15
0
    private void SettingsForm_Load(object sender, EventArgs e)
    {
      // Continued
      updateAccountList();

      comboBoxAccounts.SelectedIndex = SipekResources.Configurator.DefaultAccountIndex;

      /////
      checkBoxDND.Checked = SipekResources.Configurator.DNDFlag;
      checkBoxAA.Checked = SipekResources.Configurator.AAFlag;
      checkBoxCFU.Checked = SipekResources.Configurator.CFUFlag;
      checkBoxCFNR.Checked = SipekResources.Configurator.CFNRFlag;
      checkBoxCFB.Checked = SipekResources.Configurator.CFBFlag;

      textBoxCFU.Text = SipekResources.Configurator.CFUNumber;
      textBoxCFNR.Text = SipekResources.Configurator.CFNRNumber;
      textBoxCFB.Text = SipekResources.Configurator.CFBNumber;

      textBoxListenPort.Text = SipekResources.Configurator.SIPPort.ToString();

      textBoxStunServerAddress.Text = SipekResources.Configurator.StunServerAddress;
      comboBoxDtmfMode.SelectedIndex = (int)SipekResources.Configurator.DtmfMode;
      checkBoxPublish.Checked = SipekResources.Configurator.PublishEnabled;
      textBoxExpires.Text = SipekResources.Configurator.Expires.ToString();
      checkBoxVAD.Checked = SipekResources.Configurator.VADEnabled;
      textBoxECTail.Text = SipekResources.Configurator.ECTail.ToString();
      textBoxNameServer.Text = SipekResources.Configurator.NameServer;

      // init audio
			try {
        mMixers = new Mixers();

				mMixers.Playback.MixerLineChanged += new WaveLib.AudioMixer.Mixer.MixerLineChangeHandler(mMixer_MixerLineChanged);
        mMixers.Recording.MixerLineChanged += new WaveLib.AudioMixer.Mixer.MixerLineChangeHandler(mMixer_MixerLineChanged);
			
        LoadDeviceCombos(mMixers);			
			} 
      catch (Exception ex)
			{
			  ///report error
        (new ErrorDialog("Initialize Error " + ex.Message, "Audio Mixer cannot initialize! \r\nCheck audio configuration and start again!")).ShowDialog();
      }		

      // load codecs from system 
      if (SipekResources.StackProxy.IsInitialized)
      {
        int noofcodecs = SipekResources.StackProxy.getNoOfCodecs();
        for (int i = 0; i < noofcodecs; i++)
        {
          string name = SipekResources.StackProxy.getCodec(i);
          listBoxDisCodecs.Items.Add(name);
        }
        // load enabled codecs from settings
        List<string> codeclist = SipekResources.Configurator.CodecList;
        foreach (string item in codeclist)
        {
          // item match with disabled list (all supported codec)
          if (listBoxDisCodecs.Items.Contains(item))
          {
            // move item from disabled list to enabled
            listBoxDisCodecs.Items.Remove(item);
            listBoxEnCodecs.Items.Add(item);
          }
        }
      }
      
      // set stack flags
      ReregisterRequired = false;
      RestartRequired = false;
    }
Exemplo n.º 16
0
        private void trackBarVolume_ValueChanged2(object sender, EventArgs e)
        {
            Mixers	mMixers;
            mMixers = new Mixers();
            mMixers.Playback.MixerLineChanged += new WaveLib.AudioMixer.Mixer.MixerLineChangeHandler(mMixer_MixerLineChanged);

            foreach (MixerDetail mixerDetail in mMixers.Playback.Devices)
                cboOutputDevices.Items.Add(mixerDetail);
            cboOutputDevices.SelectedIndex = 0;

            MixerLines lines;
            mMixers.Playback.DeviceId = ((MixerDetail)cboOutputDevices.SelectedItem).DeviceId;
            lines = mMixers.Playback.UserLines;

            TrackBar tBar = (TrackBar)sender;
            MixerLine line = (MixerLine)tBar.Tag;
            if (line.Channels != 2)
            {
                // One channel or more than two let set the volume uniform
                line.Channel = Channel.Uniform;
                line.Volume = tBar.Value;
            }
        }
Exemplo n.º 17
0
        private void LoadDeviceCombos(Mixers mixers)
        {
            //Load Output Combo
            MixerDetail mixerDetailDefault = new MixerDetail();
            mixerDetailDefault.DeviceId = -1;
            mixerDetailDefault.MixerName = "Default";
            mixerDetailDefault.SupportWaveOut = true;
            comboBoxPlaybackDevices.Items.Add(mixerDetailDefault);
            foreach (MixerDetail mixerDetail in mixers.Playback.Devices)
            {
                comboBoxPlaybackDevices.Items.Add(mixerDetail);
            }
            //comboBoxPlaybackDevices.SelectedIndex = 0;
            comboBoxPlaybackDevices.Text = Globals.Cnf.audioPlay;

            //Load Input Combo
            mixerDetailDefault = new MixerDetail();
            mixerDetailDefault.DeviceId = -1;
            mixerDetailDefault.MixerName = "Default";
            mixerDetailDefault.SupportWaveIn = true;
            comboBoxRecordingDevices.Items.Add(mixerDetailDefault);
            foreach (MixerDetail mixerDetail in mixers.Recording.Devices)
            {
                comboBoxRecordingDevices.Items.Add(mixerDetail);
            }
            //comboBoxRecordingDevices.SelectedIndex = 0;
            comboBoxRecordingDevices.Text = Globals.Cnf.audioRec;
        }
Exemplo n.º 18
0
        bool InicializaAudio()
        {
            try
            {
                mMixers = new Mixers();
                //mMixers.Playback.MixerLineChanged += new WaveLib.AudioMixer.Mixer.MixerLineChangeHandler(mMixer_MixerLineChanged);
                //mMixers.Recording.MixerLineChanged += new WaveLib.AudioMixer.Mixer.MixerLineChangeHandler(mMixer_MixerLineChanged);
                LoadDeviceCombos(mMixers);

                return true;
            }
            catch (Exception ex)
            {
                ///report error
                MessageBox.Show("Error de inicialización de audio" + ex.Message, "Audio Mixer");
                return false;
            }
        }