Example #1
0
        /// <summary>
        /// Gets all the mixer controls
        /// </summary>
        /// <param name="mixerHandle"></param>
        /// <param name="mixerLine"></param>
        /// <param name="mixerHandleType"></param>
        /// <returns></returns>
        public static IList<MixerControl> GetMixerControls(IntPtr mixerHandle, MixerLine mixerLine, MixerFlags mixerHandleType)
        {
            List<MixerControl> controls = new List<MixerControl>();
            if (mixerLine.ControlsCount > 0)
            {
                int mixerControlSize = Marshal.SizeOf(typeof(MixerInterop.MIXERCONTROL));
                MixerInterop.MIXERLINECONTROLS mlc = new MixerInterop.MIXERLINECONTROLS();
                IntPtr pmc = Marshal.AllocHGlobal(mixerControlSize * mixerLine.ControlsCount);
                mlc.cbStruct = Marshal.SizeOf(mlc);
                mlc.dwLineID = mixerLine.LineId;
                mlc.cControls = mixerLine.ControlsCount;
                mlc.pamxctrl = pmc;
                mlc.cbmxctrl = Marshal.SizeOf(typeof(MixerInterop.MIXERCONTROL));

                MmResult err = MixerInterop.mixerGetLineControls(mixerHandle, ref mlc, MixerFlags.All | mixerHandleType);
                if (err != MmResult.NoError)
                {
                    Marshal.FreeHGlobal(pmc);
                    throw new MmException(err, "mixerGetLineControls");
                }
                for (int i = 0; i < mlc.cControls; i++)
                {
                    Int64 address = pmc.ToInt64() + mixerControlSize * i;

                    MixerInterop.MIXERCONTROL mc = (MixerInterop.MIXERCONTROL)Marshal.PtrToStructure((IntPtr)address, typeof(MixerInterop.MIXERCONTROL));
                    MixerControl mixerControl = MixerControl.GetMixerControl(mixerHandle, mixerLine.LineId, mc.dwControlID, mixerLine.Channels, mixerHandleType);

                    controls.Add(mixerControl);
                }
            }
            return controls;
        }
 internal CustomMixerControl(MixerInterop.MIXERCONTROL mixerControl, IntPtr mixerHandle, MixerFlags mixerHandleType, int nChannels) 
 {
     this.mixerControl = mixerControl;
     this.mixerHandle = mixerHandle;
     this.mixerHandleType = mixerHandleType;
     this.nChannels = nChannels;
     this.mixerControlDetails = new MixerInterop.MIXERCONTROLDETAILS();            
     GetControlDetails();
 }
Example #3
0
 public MixerLine(IntPtr mixerHandle, int destinationIndex, MixerFlags mixerHandleType)
 {
     this.mixerHandle             = mixerHandle;
     this.mixerHandleType         = mixerHandleType;
     this.mixerLine               = default(MixerInterop.MIXERLINE);
     this.mixerLine.cbStruct      = Marshal.SizeOf(this.mixerLine);
     this.mixerLine.dwDestination = destinationIndex;
     MmException.Try(MixerInterop.mixerGetLineInfo(mixerHandle, ref this.mixerLine, mixerHandleType), "mixerGetLineInfo");
 }
Example #4
0
		/// <summary>
		/// Creates a new mixer destination
		/// </summary>
        /// <param name="mixerHandle">Mixer Handle</param>
        /// <param name="destinationIndex">Destination Index</param>
        /// <param name="mixerHandleType">Mixer Handle Type</param>
        public MixerLine(IntPtr mixerHandle, int destinationIndex, MixerFlags mixerHandleType) 
		{
            this.mixerHandle = mixerHandle;
            this.mixerHandleType = mixerHandleType;
            mixerLine = new MixerInterop.MIXERLINE();			
			mixerLine.cbStruct = Marshal.SizeOf(mixerLine);
			mixerLine.dwDestination = destinationIndex;
            MmException.Try(MixerInterop.mixerGetLineInfo(mixerHandle, ref mixerLine, mixerHandleType | MixerFlags.GetLineInfoOfDestination), "mixerGetLineInfo");
		}
        /// <summary>
        /// Gets a specified Mixer Control
        /// </summary>
        /// <param name="mixerHandle">Mixer Handle</param>
        /// <param name="nLineId">Line ID</param>
        /// <param name="controlId">Control ID</param>
        /// <param name="nChannels">Number of Channels</param>
        /// <param name="mixerFlags">Flags to use (indicates the meaning of mixerHandle)</param>
        /// <returns></returns>
        public static MixerControl GetMixerControl(IntPtr mixerHandle, int nLineId, int controlId, int nChannels,
                                                   MixerFlags mixerFlags)
        {
            var mlc = new MixerInterop.MIXERLINECONTROLS();
            var mc  = new MixerInterop.MIXERCONTROL();

            // set up the pointer to a structure
            IntPtr pMixerControl = Marshal.AllocCoTaskMem(Marshal.SizeOf(mc));

            //Marshal.StructureToPtr(mc, pMixerControl, false);

            mlc.cbStruct    = Marshal.SizeOf(mlc);
            mlc.cControls   = 1;
            mlc.dwControlID = controlId;
            mlc.cbmxctrl    = Marshal.SizeOf(mc);
            mlc.pamxctrl    = pMixerControl;
            mlc.dwLineID    = nLineId;
            MmResult err = MixerInterop.mixerGetLineControls(mixerHandle, ref mlc, MixerFlags.OneById | mixerFlags);

            if (err != MmResult.NoError)
            {
                Marshal.FreeCoTaskMem(pMixerControl);
                throw new MmException(err, "mixerGetLineControls");
            }

            // retrieve the structure from the pointer
            mc = Marshal.PtrToStructure <MixerInterop.MIXERCONTROL>(mlc.pamxctrl);
            Marshal.FreeCoTaskMem(pMixerControl);

            if (IsControlBoolean(mc.dwControlType))
            {
                return(new BooleanMixerControl(mc, mixerHandle, mixerFlags, nChannels));
            }

            if (IsControlSigned(mc.dwControlType))
            {
                return(new SignedMixerControl(mc, mixerHandle, mixerFlags, nChannels));
            }

            if (IsControlUnsigned(mc.dwControlType))
            {
                return(new UnsignedMixerControl(mc, mixerHandle, mixerFlags, nChannels));
            }

            if (IsControlListText(mc.dwControlType))
            {
                return(new ListTextMixerControl(mc, mixerHandle, mixerFlags, nChannels));
            }

            if (IsControlCustom(mc.dwControlType))
            {
                return(new CustomMixerControl(mc, mixerHandle, mixerFlags, nChannels));
            }

            throw new InvalidOperationException($"Unknown mixer control type {mc.dwControlType}");
        }
Example #6
0
 /// <summary>
 /// Creates a new Mixer Source For a Specified Source
 /// </summary>
 /// <param name="mixerHandle">Mixer Handle</param>
 /// <param name="destinationIndex">Destination Index</param>
 /// <param name="sourceIndex">Source Index</param>
 /// <param name="mixerHandleType">Flag indicating the meaning of mixerHandle</param>
 public MixerLine(IntPtr mixerHandle, int destinationIndex, int sourceIndex, MixerFlags mixerHandleType)
 {
     this.mixerHandle        = mixerHandle;
     this.mixerHandleType    = mixerHandleType;
     mixerLine               = new MixerInterop.MIXERLINE();
     mixerLine.cbStruct      = Marshal.SizeOf(mixerLine);
     mixerLine.dwDestination = destinationIndex;
     mixerLine.dwSource      = sourceIndex;
     MmException.Try(MixerInterop.mixerGetLineInfo(mixerHandle, ref mixerLine, mixerHandleType | MixerFlags.GetLineInfoOfSource), "mixerGetLineInfo");
 }
Example #7
0
 internal SignedMixerControl(MixerInterop.MIXERCONTROL mixerControl, IntPtr mixerHandle,
                             MixerFlags mixerHandleType, int nChannels)
 {
     this.mixerControl        = mixerControl;
     this.mixerHandle         = mixerHandle;
     this.mixerHandleType     = mixerHandleType;
     this.nChannels           = nChannels;
     this.mixerControlDetails = new MixerInterop.MIXERCONTROLDETAILS();
     GetControlDetails();
 }
Example #8
0
 public Mixer(int mixerIndex)
 {
     if (mixerIndex < 0 || mixerIndex >= Mixer.NumberOfDevices)
     {
         throw new ArgumentOutOfRangeException("mixerID");
     }
     this.caps = default(MixerInterop.MIXERCAPS);
     MmException.Try(MixerInterop.mixerGetDevCaps((IntPtr)mixerIndex, ref this.caps, Marshal.SizeOf(this.caps)), "mixerGetDevCaps");
     this.mixerHandle     = (IntPtr)mixerIndex;
     this.mixerHandleType = MixerFlags.Mixer;
 }
Example #9
0
        /// <summary>Connects to the specified mixer</summary>
        /// <param name="mixerIndex">The index of the mixer to use.
        /// This should be between zero and NumberOfDevices - 1</param>
        public Mixer(int mixerIndex)
        {
            if (mixerIndex < 0 || mixerIndex >= NumberOfDevices)
            {
                throw new ArgumentOutOfRangeException("mixerID");
            }
            caps = new MixerInterop.MIXERCAPS();
            MmException.Try(MixerInterop.mixerGetDevCaps((IntPtr)mixerIndex, ref caps, Marshal.SizeOf(caps)), "mixerGetDevCaps");
            this.mixerHandle     = (IntPtr)mixerIndex;
            this.mixerHandleType = MixerFlags.Mixer;

            //MmException.Try(MixerInterop.mixerOpen(out mixerHandle, mixerIndex, IntPtr.Zero, IntPtr.Zero, 0), "mixerOpen");
        }
Example #10
0
		/// <summary>
		/// Gets a specified Mixer Control
		/// </summary>
        /// <param name="mixerHandle">Mixer Handle</param>
		/// <param name="nLineID">Line ID</param>
		/// <param name="controlId">Control ID</param>
		/// <param name="nChannels">Number of Channels</param>
        /// <param name="mixerFlags">Flags to use (indicates the meaning of mixerHandle)</param>
		/// <returns></returns>
        public static MixerControl GetMixerControl(IntPtr mixerHandle, int nLineID, int controlId, int nChannels, MixerFlags mixerFlags) 
		{
			MixerInterop.MIXERLINECONTROLS mlc = new MixerInterop.MIXERLINECONTROLS();
			MixerInterop.MIXERCONTROL mc = new MixerInterop.MIXERCONTROL();
			
			// set up the pointer to a structure
			IntPtr pMixerControl = Marshal.AllocCoTaskMem(Marshal.SizeOf(mc));
			//Marshal.StructureToPtr(mc, pMixerControl, false);      
			
			mlc.cbStruct = Marshal.SizeOf(mlc);
			mlc.cControls = 1;
			mlc.dwControlID = controlId;
			mlc.cbmxctrl = Marshal.SizeOf(mc);
			mlc.pamxctrl = pMixerControl;
			mlc.dwLineID = nLineID;
            MmResult err = MixerInterop.mixerGetLineControls(mixerHandle, ref mlc, MixerFlags.OneById | mixerFlags);
			if(err != MmResult.NoError) {
				Marshal.FreeCoTaskMem(pMixerControl);
				throw new MmException(err,"mixerGetLineControls");
			}
			
			// retrieve the structure from the pointer
			mc = (MixerInterop.MIXERCONTROL) Marshal.PtrToStructure(mlc.pamxctrl, typeof(MixerInterop.MIXERCONTROL));
			Marshal.FreeCoTaskMem(pMixerControl);
			
			if(MixerControl.IsControlBoolean(mc.dwControlType)) 
			{
                return new BooleanMixerControl(mc, mixerHandle, mixerFlags, nChannels);
			}
			else if(MixerControl.IsControlSigned(mc.dwControlType)) 
			{
                return new SignedMixerControl(mc, mixerHandle, mixerFlags, nChannels);
			}
			else if(MixerControl.IsControlUnsigned(mc.dwControlType)) 
			{
                return new UnsignedMixerControl(mc, mixerHandle, mixerFlags, nChannels);
			}
			else if(MixerControl.IsControlListText(mc.dwControlType)) 
			{
                return new ListTextMixerControl(mc, mixerHandle, mixerFlags, nChannels);
			}
			else if(MixerControl.IsControlCustom(mc.dwControlType)) 
			{
                return new CustomMixerControl(mc, mixerHandle, mixerFlags, nChannels);
			}
			else 
			{
				throw new ApplicationException(String.Format("Unknown mixer control type {0}",mc.dwControlType));
			}					
		}
        /// <summary>Connects to the specified mixer</summary>
        /// <param name="mixerIndex">The index of the mixer to use. 
        /// This should be between zero and NumberOfDevices - 1</param>
        public Mixer(int mixerIndex)
        {
            if (mixerIndex < 0 || mixerIndex >= NumberOfDevices)
            {
                throw new ArgumentOutOfRangeException("mixerID");
            }
            caps = new MixerInterop.MIXERCAPS();
            MmException.Try(MixerInterop.mixerGetDevCaps((IntPtr)mixerIndex, ref caps, Marshal.SizeOf(caps)), "mixerGetDevCaps");
            this.mixerHandle = (IntPtr)mixerIndex;
            this.mixerHandleType = MixerFlags.Mixer;

            // TODO: optionally support really opening the mixer device
            //MmException.Try(MixerInterop.mixerOpen(out mixerHandle, mixerIndex, IntPtr.Zero, IntPtr.Zero, 0), "mixerOpen");
        }
Example #12
0
        /// <summary>
        /// Gets all the mixer controls
        /// </summary>
        /// <param name="mixerHandle">Mixer Handle</param>
        /// <param name="mixerLine">Mixer Line</param>
        /// <param name="mixerHandleType">Mixer Handle Type</param>
        /// <returns></returns>
        public static IList <MixerControl> GetMixerControls(IntPtr mixerHandle, MixerLine mixerLine,
                                                            MixerFlags mixerHandleType)
        {
            var controls = new List <MixerControl>();

            if (mixerLine.ControlsCount > 0)
            {
                int    mixerControlSize = Marshal.SizeOf(typeof(MixerInterop.MIXERCONTROL));
                var    mlc = new MixerInterop.MIXERLINECONTROLS();
                IntPtr pmc = Marshal.AllocHGlobal(mixerControlSize * mixerLine.ControlsCount);
                mlc.cbStruct  = Marshal.SizeOf(mlc);
                mlc.dwLineID  = mixerLine.LineId;
                mlc.cControls = mixerLine.ControlsCount;
                mlc.pamxctrl  = pmc;
                mlc.cbmxctrl  = Marshal.SizeOf(typeof(MixerInterop.MIXERCONTROL));
                try
                {
                    MmResult err =
                        MixerInterop.mixerGetLineControls(mixerHandle, ref mlc, MixerFlags.All | mixerHandleType);
                    if (err != MmResult.NoError)
                    {
                        throw new MmException(err, "mixerGetLineControls");
                    }
                    for (int i = 0; i < mlc.cControls; i++)
                    {
                        Int64 address = pmc.ToInt64() + mixerControlSize * i;

                        var mc = (MixerInterop.MIXERCONTROL)
                                 Marshal.PtrToStructure((IntPtr)address, typeof(MixerInterop.MIXERCONTROL));
                        var mixerControl = GetMixerControl(mixerHandle, mixerLine.LineId, mc.dwControlID,
                                                           mixerLine.Channels,
                                                           mixerHandleType);

                        controls.Add(mixerControl);
                    }
                }
                finally
                {
                    Marshal.FreeHGlobal(pmc);
                }
            }
            return(controls);
        }
Example #13
0
 public static extern MmResult mixerSetControlDetails(IntPtr hMixer, ref MIXERCONTROLDETAILS mixerControlDetails, MixerFlags dwDetailsFlags);
 public static extern MixerError mixerOpen(ref IntPtr handle, int index, MixerCallback callback, int dwInstance,
                                           MixerFlags flags);
Example #15
0
 public static extern MmResult mixerGetLineInfo(IntPtr hMixer, ref MIXERLINE mixerLine, MixerFlags dwInfoFlags);
Example #16
0
 public static extern MmResult mixerGetID(IntPtr hMixer, out Int32 mixerID, MixerFlags dwMixerIDFlags);
Example #17
0
 internal CustomMixerControl(MixerInterop.MIXERCONTROL mixerControl, IntPtr mixerHandle, MixerFlags mixerHandleType, int nChannels)
 {
     this.mixerControl        = mixerControl;
     this.mixerHandle         = mixerHandle;
     this.mixerHandleType     = mixerHandleType;
     this.nChannels           = nChannels;
     this.mixerControlDetails = default(MixerInterop.MIXERCONTROLDETAILS);
     base.GetControlDetails();
 }
Example #18
0
        /// <summary>
        /// Gets all the mixer controls
        /// </summary>
        /// <param name="mixerHandle">Mixer Handle</param>
        /// <param name="mixerLine">Mixer Line</param>
        /// <param name="mixerHandleType">Mixer Handle Type</param>
        /// <returns></returns>
        // Token: 0x060005CB RID: 1483 RVA: 0x00012C9C File Offset: 0x00010E9C
        public static IList <MixerControl> GetMixerControls(IntPtr mixerHandle, MixerLine mixerLine, MixerFlags mixerHandleType)
        {
            List <MixerControl> list = new List <MixerControl>();

            if (mixerLine.ControlsCount > 0)
            {
                int num = Marshal.SizeOf(typeof(MixerInterop.MIXERCONTROL));
                MixerInterop.MIXERLINECONTROLS mixerlinecontrols = default(MixerInterop.MIXERLINECONTROLS);
                IntPtr intPtr = Marshal.AllocHGlobal(num * mixerLine.ControlsCount);
                mixerlinecontrols.cbStruct  = Marshal.SizeOf(mixerlinecontrols);
                mixerlinecontrols.dwLineID  = mixerLine.LineId;
                mixerlinecontrols.cControls = mixerLine.ControlsCount;
                mixerlinecontrols.pamxctrl  = intPtr;
                mixerlinecontrols.cbmxctrl  = Marshal.SizeOf(typeof(MixerInterop.MIXERCONTROL));
                try
                {
                    MmResult mmResult = MixerInterop.mixerGetLineControls(mixerHandle, ref mixerlinecontrols, mixerHandleType);
                    if (mmResult != MmResult.NoError)
                    {
                        throw new MmException(mmResult, "mixerGetLineControls");
                    }
                    for (int i = 0; i < mixerlinecontrols.cControls; i++)
                    {
                        long value = intPtr.ToInt64() + (long)(num * i);
                        MixerInterop.MIXERCONTROL mixercontrol = (MixerInterop.MIXERCONTROL)Marshal.PtrToStructure((IntPtr)value, typeof(MixerInterop.MIXERCONTROL));
                        MixerControl item = MixerControl.GetMixerControl(mixerHandle, mixerLine.LineId, mixercontrol.dwControlID, mixerLine.Channels, mixerHandleType);
                        list.Add(item);
                    }
                }
                finally
                {
                    Marshal.FreeHGlobal(intPtr);
                }
            }
            return(list);
        }
Example #19
0
        /// <summary>
        /// Gets a specified Mixer Control
        /// </summary>
        /// <param name="mixerHandle">Mixer Handle</param>
        /// <param name="nLineID">Line ID</param>
        /// <param name="controlId">Control ID</param>
        /// <param name="nChannels">Number of Channels</param>
        /// <param name="mixerFlags">Flags to use (indicates the meaning of mixerHandle)</param>
        /// <returns></returns>
        // Token: 0x060005CC RID: 1484 RVA: 0x00012DC8 File Offset: 0x00010FC8
        public static MixerControl GetMixerControl(IntPtr mixerHandle, int nLineID, int controlId, int nChannels, MixerFlags mixerFlags)
        {
            MixerInterop.MIXERLINECONTROLS mixerlinecontrols = default(MixerInterop.MIXERLINECONTROLS);
            MixerInterop.MIXERCONTROL      mixercontrol      = default(MixerInterop.MIXERCONTROL);
            IntPtr intPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(mixercontrol));

            mixerlinecontrols.cbStruct    = Marshal.SizeOf(mixerlinecontrols);
            mixerlinecontrols.cControls   = 1;
            mixerlinecontrols.dwControlID = controlId;
            mixerlinecontrols.cbmxctrl    = Marshal.SizeOf(mixercontrol);
            mixerlinecontrols.pamxctrl    = intPtr;
            mixerlinecontrols.dwLineID    = nLineID;
            MmResult mmResult = MixerInterop.mixerGetLineControls(mixerHandle, ref mixerlinecontrols, MixerFlags.ListText | mixerFlags);

            if (mmResult != MmResult.NoError)
            {
                Marshal.FreeCoTaskMem(intPtr);
                throw new MmException(mmResult, "mixerGetLineControls");
            }
            mixercontrol = (MixerInterop.MIXERCONTROL)Marshal.PtrToStructure(mixerlinecontrols.pamxctrl, typeof(MixerInterop.MIXERCONTROL));
            Marshal.FreeCoTaskMem(intPtr);
            if (MixerControl.IsControlBoolean(mixercontrol.dwControlType))
            {
                return(new BooleanMixerControl(mixercontrol, mixerHandle, mixerFlags, nChannels));
            }
            if (MixerControl.IsControlSigned(mixercontrol.dwControlType))
            {
                return(new SignedMixerControl(mixercontrol, mixerHandle, mixerFlags, nChannels));
            }
            if (MixerControl.IsControlUnsigned(mixercontrol.dwControlType))
            {
                return(new UnsignedMixerControl(mixercontrol, mixerHandle, mixerFlags, nChannels));
            }
            if (MixerControl.IsControlListText(mixercontrol.dwControlType))
            {
                return(new ListTextMixerControl(mixercontrol, mixerHandle, mixerFlags, nChannels));
            }
            if (MixerControl.IsControlCustom(mixercontrol.dwControlType))
            {
                return(new CustomMixerControl(mixercontrol, mixerHandle, mixerFlags, nChannels));
            }
            throw new InvalidOperationException(string.Format("Unknown mixer control type {0}", mixercontrol.dwControlType));
        }
Example #20
0
 public static void InitMixer(MixerFlags flags) => Mix_Init(flags);
Example #21
0
 public static extern MmResult mixerOpen(out IntPtr hMixer, int uMxId, IntPtr dwCallback, IntPtr dwInstance, MixerFlags dwOpenFlags);
Example #22
0
 public static extern MmResult mixerGetID(IntPtr hMixer, out Int32 mixerID, MixerFlags dwMixerIDFlags);
Example #23
0
 public static extern MmResult mixerOpen(out IntPtr hMixer, int uMxId, IntPtr dwCallback, IntPtr dwInstance, MixerFlags dwOpenFlags);
Example #24
0
 public static extern MmResult mixerGetLineControls(IntPtr hMixer, ref MIXERLINECONTROLS mixerLineControls, MixerFlags dwControlFlags);
Example #25
0
 public static extern MmResult mixerGetLineControls(IntPtr hMixer, ref MIXERLINECONTROLS mixerLineControls, MixerFlags dwControlFlags);
Example #26
0
 public static extern MmResult mixerGetLineInfo(IntPtr hMixer, ref MIXERLINE mixerLine, MixerFlags dwInfoFlags);
Example #27
0
 public static extern MmResult mixerSetControlDetails(IntPtr hMixer, ref MIXERCONTROLDETAILS mixerControlDetails, MixerFlags dwDetailsFlags);
 public static extern MixerError mixerOpen(ref IntPtr handle, int index, MixerCallback callback, int dwInstance,
                                           MixerFlags flags);