Exemple #1
0
        public void Remove(MixerLine mixerLine)
        {
            if (this.InnerList.Contains(mixerLine))
            {
                this.InnerList.Remove(mixerLine);
                return;
            }

            MixerLine mixerLineToRemove = null;

            foreach (MixerLine mixerLineLoop in this.InnerList)
            {
                if (mixerLineLoop.ComponentType == mixerLine.ComponentType &&
                    mixerLineLoop.Destination == mixerLine.Destination &&
                    mixerLineLoop.Id == mixerLine.Id &&
                    mixerLineLoop.Source == mixerLine.Source &&
                    mixerLineLoop.Name == mixerLine.Name)
                {
                    mixerLineToRemove = mixerLineLoop;
                    break;
                }
            }

            if (mixerLineToRemove != null)
            {
                this.InnerList.Remove(mixerLineToRemove);
            }
        }
        public bool Contains(MixerLine line)
        {
            foreach(MixerLine mixerLine in this.InnerList)
                if (mixerLine == line)
                    return true;

            return false;
        }
Exemple #3
0
 private void PtrMixerLineChange(IntPtr hMixer, uint lineId)
 {
     if (hMixer != IntPtr.Zero && MixerLineChanged != null)
     {
         MixerLine line = mUserLines.GetMixerLineByLineId(lineId);
         if (line != null)
         {
             MixerLineChanged(this, line);
         }
     }
 }
Exemple #4
0
        public bool     Contains(MixerLine line)
        {
            foreach (MixerLine mixerLine in this.InnerList)
            {
                if (mixerLine == line)
                {
                    return(true);
                }
            }

            return(false);
        }
        private void RunCallback(Mixer mixer, MixerLine line)
        {
            int VolumeMin = Mixers.Playback.Lines[0].VolumeMin;
            int VolumeMax = Mixers.Playback.Lines[0].VolumeMax;
            int VolumeCurrent = Mixers.Playback.Lines[0].Volume;

            // Volume Min and Max are probably 0, and 100, but since I can't say that for sure adjust the values to be zero based
            VolumeMax = VolumeMax - VolumeMin;
            VolumeCurrent = VolumeCurrent - VolumeMin;
            VolumeMin = 0;

            double volume = ((double)VolumeCurrent)/((double) VolumeMax);
            bool muted = Mixers.Playback.Lines[0].Mute;

            if(_callback != null)
                _callback.Invoke(new DeviceInfo(volume, muted));
        }
Exemple #6
0
 private void PtrMixerControlChange(IntPtr hMixer, uint controlId)
 {
     if (hMixer != IntPtr.Zero && MixerLineChanged != null)
     {
         MixerLine line = mUserLines.GetMixerLineByControlId(controlId);
         if (line != null)
         {
             MixerLineChanged(this, line);
         }
         else
         {
             MixerLine lineOS = mLines.GetMixerLineByControlId(controlId);
             if (lineOS != null)
             {
                 foreach (MixerLine broadcastLine in mUserLines)
                 {
                     MixerLineChanged(this, broadcastLine);
                 }
             }
         }
     }
 }
Exemple #7
0
 private void mMixer_MixerLineChanged(Mixer mixer, MixerLine line)
 {
     try
     {
             int volume = 0;
                 volume = line.Volume;
         if ((MixerLine)chkMutein.Tag == line)
         {
             chkMutein.Checked = line.Volume == 0 ? true : false;
         }
         else if ((MixerLine)chkMuteOut.Tag == line)
         {
             chkMuteOut.Checked = line.Mute;
         }
     }
     finally
     {
     }
 }
 public void Add(MixerLine line)
 {
     this.InnerList.Add(line);
 }
        public void Remove(MixerLine mixerLine)
        {
            if (this.InnerList.Contains(mixerLine))
            {
                this.InnerList.Remove(mixerLine);
                return;
            }

            MixerLine mixerLineToRemove = null;
            foreach(MixerLine mixerLineLoop in this.InnerList)
            {
                if (mixerLineLoop.ComponentType	== mixerLine.ComponentType &&
                    mixerLineLoop.Destination	== mixerLine.Destination &&
                    mixerLineLoop.Id			== mixerLine.Id &&
                    mixerLineLoop.Source		== mixerLine.Source &&
                    mixerLineLoop.Name			== mixerLine.Name)
                {
                    mixerLineToRemove = mixerLineLoop;
                    break;
                }
            }

            if (mixerLineToRemove != null)
                this.InnerList.Remove(mixerLineToRemove);
        }
Exemple #10
0
		private void mMixer_MixerLineChanged(Mixer mixer, MixerLine line)
		{
			mAvoidEvents = true;

			try
			{
				float balance = -1;
				foreach(TrackBar tBar in tBarArray[(int) mixer.MixerType])
				{
					MixerLine frontEndLine = (MixerLine) tBar.Tag;
					if (frontEndLine == line)
					{
						int volume = 0;
						if (line.Channels != 2)
							volume = line.Volume;
						else
						{
							line.Channel = Channel.Left;
							int left	= line.Volume;
							line.Channel = Channel.Right;
							int right	= line.Volume;
							if (left > right)
							{
								volume = left;
								// TIP: Do not reset the balance if both left and right channel have 0 value
								if (left != 0 && right != 0)
									balance = (volume > 0) ? -(1 - (right / (float) left)) : 0;
							}
							else
							{
								volume = right;
								// TIP: Do not reset the balance if both left and right channel have 0 value
								if (left != 0 && right != 0)
									balance = (volume > 0) ? 1 - (left / (float) right) : 0;
							}
						}

						if (volume >= 0)
							tBar.Value = volume;
						break;
					}
				}
				//Set the balance
				if (balance != -1)
				{
					foreach(TrackBar tBar in tBarBalanceArray[(int) mixer.MixerType])
					{
						MixerLine frontEndLine = (MixerLine) tBar.Tag;
						if (frontEndLine == line)
						{
							tBar.Value = (int) (tBar.Maximum * balance);
							break;
						}
					}
				}

				foreach(CheckBox checkBox in chkBoxArray[(int) mixer.MixerType])
				{
					MixerLine frontEndLine = (MixerLine) checkBox.Tag;
					if (frontEndLine == line)
					{
						if (line.Direction == MixerType.Recording)
							checkBox.Checked = line.Selected;
						else
							checkBox.Checked = line.Mute;
						break;
					}
				}
			}
			finally
			{
				mAvoidEvents = false;
			}
		}
Exemple #11
0
 public void Add(MixerLine line)
 {
     this.InnerList.Add(line);
 }
        /// <summary>
        /// Callback from Windows Volume Control
        /// </summary>
        /// <param name="mixer"></param>
        /// <param name="line"></param>
        private void mMixer_MixerLineChanged(Mixer mixer, MixerLine line)
        {
            mAvoidEvents = true;

            try
            {
                float balance = -1;
                MixerLine frontEndLine = (MixerLine)volumeTrackBar.Tag;
                if (frontEndLine == line)
                {
                    int volume = 0;
                    if (line.Channels != 2)
                        volume = line.Volume;
                    else
                    {
                        line.Channel = Channel.Left;
                        int left = line.Volume;
                        line.Channel = Channel.Right;
                        int right = line.Volume;
                        if (left > right)
                        {
                            volume = left;
                            // TIP: Do not reset the balance if both left and right channel have 0 value
                            if (left != 0 && right != 0)
                                balance = (volume > 0) ? -(1 - (right / (float)left)) : 0;
                        }
                        else
                        {
                            volume = right;
                            // TIP: Do not reset the balance if both left and right channel have 0 value
                            if (left != 0 && right != 0)
                                balance = (volume > 0) ? 1 - (left / (float)right) : 0;
                        }
                    }

                    if (volume >= 0)
                        volumeTrackBar.Value = volume;

                }

                // adjust toolstrip checkboxes
                if ((MixerLine)micMuteButton.Tag == line)
                {
                    micMuteButton.ButtonToggled = line.Volume == 0 ? true : false;
                }
                else if ((MixerLine)muteButton.Tag == line)
                {
                    muteButton.ButtonToggled = line.Mute;
                }
            }
            finally
            {
                mAvoidEvents = false;
            }
        }
Exemple #13
0
        private void mMixer_MixerLineChanged(Mixer mixer, MixerLine line)
        {
            //mAvoidEvents = true;

            try
            {
                float balance = -1;
                TrackBar tBar =trackBarVolume;

                    MixerLine frontEndLine = (MixerLine)tBar.Tag;
                    if (frontEndLine == line)
                    {
                        int volume = 0;
                        if (line.Channels != 2)
                            volume = line.Volume;
                        else
                        {
                            line.Channel = Channel.Left;
                            int left = line.Volume;
                            line.Channel = Channel.Right;
                            int right = line.Volume;
                            if (left > right)
                            {
                                volume = left;
                                // TIP: Do not reset the balance if both left and right channel have 0 value
                                if (left != 0 && right != 0)
                                    balance = (volume > 0) ? -(1 - (right / (float)left)) : 0;
                            }
                            else
                            {
                                volume = right;
                                // TIP: Do not reset the balance if both left and right channel have 0 value
                                if (left != 0 && right != 0)
                                    balance = (volume > 0) ? 1 - (left / (float)right) : 0;
                            }
                        }

                        if (volume >= 0)
                            tBar.Value = volume;

                    }

                //Set the balance
                if (balance != -1)
                {

                        MixerLine frontEndLine2 = (MixerLine)tBar.Tag;
                        if (frontEndLine2 == line)
                        {
                            tBar.Value = (int)(tBar.Maximum * balance);

                        }

                }

            }
            finally
            {
                //mAvoidEvents = false;
            }
        }
Exemple #14
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);
            }
        }
Exemple #15
0
 private void mMixer_MixerLineChanged(Mixer mixer, MixerLine line)
 {
     //mAvoidEvents = true;
 }
Exemple #16
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);
			}
		}
Exemple #17
0
    private float adjustValues(MixerLine line, TrackBar tBar)
    {
      float balance = -1;
      MixerLine frontEndLine = (MixerLine)tBar.Tag;
      if (frontEndLine == line)
      {
        int volume = 0;
        if (line.Channels != 2)
          volume = line.Volume;
        else
        {
          line.Channel = Channel.Left;
          int left = line.Volume;
          line.Channel = Channel.Right;
          int right = line.Volume;
          if (left > right)
          {
            volume = left;
            // TIP: Do not reset the balance if both left and right channel have 0 value
            if (left != 0 && right != 0)
              balance = (volume > 0) ? -(1 - (right / (float)left)) : 0;
          }
          else
          {
            volume = right;
            // TIP: Do not reset the balance if both left and right channel have 0 value
            if (left != 0 && right != 0)
              balance = (volume > 0) ? 1 - (left / (float)right) : 0;
          }
        }

        if (volume >= 0)
          tBar.Value = volume;

      }
      return balance;
    }
Exemple #18
0
    private void mMixer_MixerLineChanged(Mixer mixer, MixerLine line)
    {
      mAvoidEvents = true;

      try
      {
        if (line.Direction == MixerType.Playback)
        {
          float balance = adjustValues(line, trackBarPlaybackVolume);

          //Set the balance
          if (balance != -1)
          {
            if ((MixerLine)trackBarPlaybackBalance.Tag == line)
            {
              trackBarPlaybackBalance.Value = (int)(trackBarPlaybackBalance.Maximum * balance);
            }
          }

          // adjust checkboxes
          checkBoxPlaybackMute.Checked = line.Mute;
        }
        else if (line.Direction == MixerType.Recording)
        {
          line.Channel = Channel.Uniform;
          // adjust recording 
          float balance = adjustValues(line, trackBarRecordingVolume);
          //Set the balance
          //if (balance != -1)
          //{
          //  if ((MixerLine)trackBarRecordingBalance.Tag == line)
          //  {
          //    trackBarRecordingBalance.Value = (int)(trackBarRecordingBalance.Maximum * balance);
          //  }
          //}
          // adjust checkboxes
          checkBoxRecordingMute.Checked = (line.Volume == 0 ? true : false);

        }
      }
      finally
      {
        mAvoidEvents = false;
      }
    }