Esempio n. 1
0
        public void SetMute(MixerInfo mi, bool mute)
        {
            MIXERCONTROLDETAILS mcd = new MIXERCONTROLDETAILS();

            mcd.cbStruct       = (uint)Marshal.SizeOf(typeof(MIXERCONTROLDETAILS));
            mcd.dwControlID    = mi.muteCtl;
            mcd.cMultipleItems = 0;
            mcd.cChannels      = 1;
            mcd.cbDetails      = 4;
            mcd.paDetails      = Marshal.AllocHGlobal((int)mcd.cbDetails);

            Marshal.WriteInt32(mcd.paDetails, mute ? 1 : 0);

            WinMNWarpConstants.mixerSetControlDetails(IntPtr.Zero, ref mcd, MIXER.GETCONTROLDETAILSF_VALUE | MIXER.OBJECTF_MIXER);

            Marshal.FreeHGlobal(mcd.paDetails);
        }
Esempio n. 2
0
        public void SetVolume(MixerInfo mi, VOLUME volume)
        {
            MIXERCONTROLDETAILS mcd = new MIXERCONTROLDETAILS();

            mcd.cbStruct       = (uint)Marshal.SizeOf(typeof(MIXERCONTROLDETAILS));
            mcd.dwControlID    = mi.volumeCtl;
            mcd.cMultipleItems = 0;
            mcd.cChannels      = 2;
            mcd.cbDetails      = (uint)Marshal.SizeOf(typeof(int));
            mcd.paDetails      = Marshal.AllocHGlobal((int)mcd.cbDetails);

            Marshal.StructureToPtr(volume, mcd.paDetails, false);

            WinMNWarpConstants.mixerSetControlDetails(IntPtr.Zero, ref mcd, MIXER.GETCONTROLDETAILSF_VALUE | MIXER.OBJECTF_MIXER);

            Marshal.FreeHGlobal(mcd.paDetails);
        }
Esempio n. 3
0
        public void AdjustVolume(MixerInfo mi, int delta)
        {
            VOLUME volume = GetVolume(mi);

            if (delta > 0)
            {
                volume.left  = Math.Min(mi.maxVolume, volume.left + delta);
                volume.right = Math.Min(mi.maxVolume, volume.right + delta);
            }
            else
            {
                volume.left  = Math.Max(mi.minVolume, volume.left + delta);
                volume.right = Math.Max(mi.minVolume, volume.right + delta);
            }

            SetVolume(mi, volume);
        }
Esempio n. 4
0
        public bool IsMuted(MixerInfo mi)
        {
            MIXERCONTROLDETAILS mcd = new MIXERCONTROLDETAILS();

            mcd.cbStruct       = (uint)Marshal.SizeOf(typeof(MIXERCONTROLDETAILS));
            mcd.dwControlID    = mi.muteCtl;
            mcd.cMultipleItems = 0;
            mcd.cChannels      = 1;
            mcd.cbDetails      = 4;
            mcd.paDetails      = Marshal.AllocHGlobal((int)mcd.cbDetails);

            WinMNWarpConstants.mixerGetControlDetails(IntPtr.Zero, ref mcd, MIXER.GETCONTROLDETAILSF_VALUE | MIXER.OBJECTF_MIXER);

            int rtn = Marshal.ReadInt32(mcd.paDetails);

            Marshal.FreeHGlobal(mcd.paDetails);

            return(rtn != 0);
        }
Esempio n. 5
0
        public VOLUME GetVolume(MixerInfo mi)
        {
            MIXERCONTROLDETAILS mcd = new MIXERCONTROLDETAILS();

            mcd.cbStruct       = (uint)Marshal.SizeOf(typeof(MIXERCONTROLDETAILS));
            mcd.dwControlID    = mi.volumeCtl;
            mcd.cMultipleItems = 0;
            mcd.cChannels      = 2;
            mcd.cbDetails      = (uint)Marshal.SizeOf(typeof(int));
            mcd.paDetails      = Marshal.AllocHGlobal((int)mcd.cbDetails);

            WinMNWarpConstants.mixerGetControlDetails(IntPtr.Zero, ref mcd, MIXER.GETCONTROLDETAILSF_VALUE | MIXER.OBJECTF_MIXER);

            VOLUME rtn = (VOLUME)Marshal.PtrToStructure(mcd.paDetails, typeof(VOLUME));

            Marshal.FreeHGlobal(mcd.paDetails);

            return(rtn);
        }
Esempio n. 6
0
        public bool GetMixerControls(out MixerInfo data)
        {
            MIXERLINE         mxl = new MIXERLINE();
            MIXERLINECONTROLS mlc = new MIXERLINECONTROLS();

            mxl.cbStruct = (uint)Marshal.SizeOf(typeof(MIXERLINE));
            mlc.cbStruct = (uint)Marshal.SizeOf(typeof(MIXERLINECONTROLS));

            var errCode = WinMNWarpConstants.mixerGetLineInfo(IntPtr.Zero, ref mxl, MIXER.OBJECTF_MIXER | MIXER.GETLINEINFOF_DESTINATION);

            mlc.dwLineID  = mxl.dwLineID;
            mlc.cControls = mxl.cControls;
            //mlc.cbmxctrl = (uint)Marshal.SizeOf(typeof(MIXERCONTROL));
            //mlc.pamxctrl = Marshal.AllocHGlobal((int)(mlc.cbmxctrl * mlc.cControls));

            //WinMNWarpConstants.mixerGetLineControls(IntPtr.Zero, ref mlc, MIXER.OBJECTF_MIXER | MIXER.GETLINECONTROLSF_ALL);

            //MyMixerInfo rtn = new MyMixerInfo();
            data = new MixerInfo();

            //for (int i = 0; i < mlc.cControls; i++)
            //{
            //    MIXERCONTROL mxc = (MIXERCONTROL)Marshal.PtrToStructure((IntPtr)((int)mlc.pamxctrl + (int)mlc.cbmxctrl * i), typeof(MIXERCONTROL));
            //    switch (mxc.dwControlType)
            //    {
            //        case MIXERCONTROL_CONTROLTYPE.VOLUME:
            //            data.volumeCtl = mxc.dwControlID;
            //            data.minVolume = mxc.Bounds.lMinimum;
            //            data.maxVolume = mxc.Bounds.lMaximum;
            //            break;
            //        case MIXERCONTROL_CONTROLTYPE.MUTE:
            //            data.muteCtl = mxc.dwControlID;
            //            break;
            //    }
            //}

            //Marshal.FreeHGlobal(mlc.pamxctrl);

            return(true);
        }