示例#1
0
        /* Set the SW Synth volume on Windows XP, by using the
         * Win32 API function mixerSetControlDetails().
         */
        public static void SetVolumeWindowsXP(int value)
        {
            /* The actual master volume range is 0 to 65536. Scale the value */
            value = (int)(value * 65536 / 100.0);

            int mixerHandle;
            int ret = mixerOpen(out mixerHandle, 0, 0, 0, 0);

            MIXERCONTROLDETAILS          details       = new MIXERCONTROLDETAILS();
            MIXERCONTROLDETAILS_UNSIGNED volumeDetails = new MIXERCONTROLDETAILS_UNSIGNED();

            details.item = 0;

            /* The ControlID is which volume to modify:
             *   Master    = 0
             *   Wave      = 2
             *   SW Synth  = 4
             *   CD Player = 6
             */
            details.dwControlID   = 4;
            details.cbStruct      = Marshal.SizeOf(details);
            details.cbDetails     = Marshal.SizeOf(volumeDetails);
            details.cChannels     = 1;
            volumeDetails.dwValue = value;

            details.paDetails = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(MIXERCONTROLDETAILS_UNSIGNED)));
            Marshal.StructureToPtr(volumeDetails, details.paDetails, false);
            ret = mixerSetControlDetails(mixerHandle, ref details, MIXER_SETCONTROLDETAILSF_VALUE);
            mixerClose(mixerHandle);
        }
示例#2
0
 private static extern int mixerSetControlDetails(int handle, ref MIXERCONTROLDETAILS details, int fdwDetails);
示例#3
0
 mixerSetControlDetails(int handle, ref MIXERCONTROLDETAILS details, int fdwDetails);
示例#4
0
        /* Set the SW Synth volume on Windows XP, by using the
         * Win32 API function mixerSetControlDetails().
         */
        public static void SetVolumeWindowsXP(int value)
        {
            /* The actual master volume range is 0 to 65536. Scale the value */
            value = (int)(value * 65536 / 100.0);

            int mixerHandle;
            int ret = mixerOpen(out mixerHandle, 0, 0, 0, 0);

            MIXERCONTROLDETAILS details = new MIXERCONTROLDETAILS();
            MIXERCONTROLDETAILS_UNSIGNED volumeDetails = new MIXERCONTROLDETAILS_UNSIGNED();
            details.item = 0;

            /* The ControlID is which volume to modify:
             *   Master    = 0
             *   Wave      = 2
             *   SW Synth  = 4
             *   CD Player = 6
             */
            details.dwControlID = 4;
            details.cbStruct = Marshal.SizeOf(details);
            details.cbDetails = Marshal.SizeOf(volumeDetails);
            details.cChannels = 1;
            volumeDetails.dwValue = value;

            details.paDetails = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(MIXERCONTROLDETAILS_UNSIGNED)));
            Marshal.StructureToPtr(volumeDetails, details.paDetails, false);
            ret = mixerSetControlDetails(mixerHandle, ref details, MIXER_SETCONTROLDETAILSF_VALUE);
            mixerClose(mixerHandle);
        }