Esempio n. 1
0
        private void SetValue(MixerComponentType componentType, MixerControlType controlType, int controlValue)
        {
            MixerNativeMethods.MixerLine mixerLine = new MixerNativeMethods.MixerLine(componentType);

            if (MixerNativeMethods.mixerGetLineInfoA(_handle, ref mixerLine, MixerLineFlags.ComponentType) != MixerError.None)
            {
                throw new InvalidOperationException("Mixer.SetValue.1");
            }

            using (
                MixerNativeMethods.MixerLineControls mixerLineControls =
                    new MixerNativeMethods.MixerLineControls(mixerLine.LineId, controlType))
            {
                if (MixerNativeMethods.mixerGetLineControlsA(_handle, mixerLineControls, MixerLineControlFlags.OneByType) !=
                    MixerError.None)
                {
                    throw new InvalidOperationException("Mixer.SetValue.2");
                }

                MixerNativeMethods.MixerControl mixerControl =
                    (MixerNativeMethods.MixerControl)
                    Marshal.PtrToStructure(mixerLineControls.Data, typeof(MixerNativeMethods.MixerControl));

                using (
                    MixerNativeMethods.MixerControlDetails mixerControlDetails =
                        new MixerNativeMethods.MixerControlDetails(mixerControl.ControlId))
                {
                    Marshal.WriteInt32(mixerControlDetails.Data, controlValue);
                    MixerNativeMethods.mixerSetControlDetails(_handle, mixerControlDetails, 0);
                }
            }
        }
Esempio n. 2
0
    private void SetValue(MixerNativeMethods.MixerControlDetails control, int value)
    {
      if (control == null)
      {
        return;
      }

      Marshal.WriteInt32(control.Data, value);
      MixerNativeMethods.mixerSetControlDetails(_handle, control, 0);
    }