Esempio n. 1
0
 private void ednw_EventHandler(ref Message m, ref bool handled)
 {
     if (!CreateEvents)
     {
         return;
     }
     if (m.Msg == MM_MIXM_CONTROL_CHANGE && m.WParam == hMixer)
     {
         int          ctrlID = m.LParam.ToInt32();
         MixerControl c      = FindControl(ctrlID);
         if (c != null)
         {
             ControlChanged?.Invoke(this, new MixerEventArgs(this, c.Line, c));
             c.OnChanged();
         }
     }
     else if (m.Msg == MM_MIXM_LINE_CHANGE && m.WParam == hMixer)
     {
         int       lineID = m.LParam.ToInt32();
         MixerLine l      = FindLine(lineID);
         if (l != null)
         {
             if (ControlChanged != null)
             {
                 LineChanged(this, new MixerEventArgs(this, l, null));
             }
             l.OnChanged();
         }
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Find a control of this mixer by ID.
 /// </summary>
 /// <param name="ctrlId">ID of the control to find.</param>
 /// <returns>The control, or <code>null</code> if no control was found.</returns>
 public MixerControl FindControl(int ctrlId)
 {
     foreach (DestinationLine dl in DestinationLines)
     {
         MixerControl found = dl.findControl(ctrlId);
         if (found != null)
         {
             return(found);
         }
     }
     return(null);
 }
Esempio n. 3
0
        private static MixerControl GetControl(Mixer mx, MixerLine ml, MIXERCONTROL mc)
        {
            MixerControl result = new MixerControl(mx, ml, mc);

            if (result.Class == MixerControlClass.FADER && ((uint)result.ControlType & MIXERCONTROL_CT_UNITS_MASK) == (uint)MixerControlType.MIXERCONTROL_CT_UNITS_UNSIGNED)
            {
                result = new FaderMixerControl(mx, ml, mc);
            }
            else if (result.Class == MixerControlClass.SWITCH && ((uint)result.ControlType & MIXERCONTROL_CT_SUBCLASS_MASK) == (uint)MixerControlType.MIXERCONTROL_CT_SC_SWITCH_BOOLEAN && ((uint)result.ControlType & MIXERCONTROL_CT_UNITS_MASK) == (uint)MixerControlType.MIXERCONTROL_CT_UNITS_BOOLEAN)
            {
                result = new BooleanMixerControl(mx, ml, mc);
            }
            return(result);
        }
Esempio n. 4
0
        internal static MixerControl[] GetControls(Mixer mx, MixerLine line, int controlCount)
        {
            if (controlCount == 0)
            {
                return(new MixerControl[0]);
            }
            MIXERCONTROL[] mc     = new MIXERCONTROL[controlCount];
            int            mxsize = Marshal.SizeOf(mc[0]);

            if (mxsize != 148)
            {
                throw new Exception("" + mxsize);
            }
            //mxsize = 148;

            MIXERLINECONTROLS mlc = new MIXERLINECONTROLS();

            mlc.cbStruct  = Marshal.SizeOf(mlc);
            mlc.cControls = controlCount;
            mlc.dwLineID  = line.Id;

            mlc.pamxctrl = Marshal.AllocCoTaskMem(mxsize * controlCount);
            mlc.cbmxctrl = mxsize;

            int err;

            if ((err = mixerGetLineControlsA(mx.Handle, ref mlc, MIXER_GETLINECONTROLSF_ALL)) != 0)
            {
                throw new Win32Exception("Error #" + err + " calling mixerGetLineControls()\n");
            }

            for (int i = 0; i < controlCount; i++)
            {
                mc[i] = (MIXERCONTROL)Marshal.PtrToStructure(new IntPtr(mlc.pamxctrl.ToInt64() + mxsize * i),
                                                             typeof(MIXERCONTROL));
            }

            Marshal.FreeCoTaskMem(mlc.pamxctrl);
            MixerControl[] result = new MixerControl[controlCount];
            for (int i = 0; i < controlCount; i++)
            {
                result[i] = GetControl(mx, line, mc[i]);
            }

            return(result);
        }
 internal MixerControl findControl(int ctrlId)
 {
     foreach (MixerControl c in Controls)
     {
         if (c.Id == ctrlId)
         {
             return(c);
         }
     }
     foreach (MixerLine l in ChildLines)
     {
         MixerControl found = l.findControl(ctrlId);
         if (found != null)
         {
             return(found);
         }
     }
     return(null);
 }
Esempio n. 6
0
 internal BooleanMixerControl(Mixer mx, MixerLine ml, MixerControl.MIXERCONTROL mc) : base(mx, ml, mc) { }
Esempio n. 7
0
 internal FaderMixerControl(Mixer mx, MixerLine ml, MixerControl.MIXERCONTROL mc) : base(mx, ml, mc) { }
Esempio n. 8
0
 private static MixerControl GetControl(Mixer mx, MixerLine ml, MIXERCONTROL mc)
 {
     MixerControl result = new MixerControl(mx, ml, mc);
     if (result.Class == MixerControlClass.FADER && ((uint)result.ControlType & MIXERCONTROL_CT_UNITS_MASK) == (uint)MixerControlType.MIXERCONTROL_CT_UNITS_UNSIGNED)
     {
         result = new FaderMixerControl(mx, ml, mc);
     }
     else if (result.Class == MixerControlClass.SWITCH && ((uint)result.ControlType & MIXERCONTROL_CT_SUBCLASS_MASK) == (uint)MixerControlType.MIXERCONTROL_CT_SC_SWITCH_BOOLEAN && ((uint)result.ControlType & MIXERCONTROL_CT_UNITS_MASK) == (uint)MixerControlType.MIXERCONTROL_CT_UNITS_BOOLEAN)
     {
         result = new BooleanMixerControl(mx, ml, mc);
     }
     return result;
 }
Esempio n. 9
0
        internal static MixerControl[] GetControls(Mixer mx, MixerLine line, int controlCount)
        {
            if (controlCount == 0) return new MixerControl[0];
            MIXERCONTROL[] mc = new MIXERCONTROL[controlCount];
            int mxsize = Marshal.SizeOf(mc[0]);
            if (mxsize != 148) throw new Exception("" + mxsize);
            //mxsize = 148;

            MIXERLINECONTROLS mlc = new MIXERLINECONTROLS();
            mlc.cbStruct = Marshal.SizeOf(mlc);
            mlc.cControls = controlCount;
            mlc.dwLineID = line.Id;

            mlc.pamxctrl = Marshal.AllocCoTaskMem(mxsize * controlCount);
            mlc.cbmxctrl = mxsize;

            int err;
            if ((err = mixerGetLineControlsA(mx.Handle, ref mlc, MIXER_GETLINECONTROLSF_ALL)) != 0)
            {
                throw new Win32Exception("Error #" + err + " calling mixerGetLineControls()\n");
            }
            for (int i = 0; i < controlCount; i++)
            {
                mc[i] = (MIXERCONTROL)Marshal.PtrToStructure(new IntPtr(mlc.pamxctrl.ToInt64() + mxsize * i), typeof(MIXERCONTROL));
            }
            Marshal.FreeCoTaskMem(mlc.pamxctrl);
            MixerControl[] result = new MixerControl[controlCount];
            for (int i = 0; i < controlCount; i++)
            {
                result[i] = GetControl(mx, line, mc[i]);
            }
            return result;
        }
Esempio n. 10
0
 /// <summary>
 /// Initializes a new instance of the 
 /// <see cref="MixerEventArgs">MixerEventArgs</see> class.
 /// </summary>
 /// <param name="mixer">The affected mixer</param>
 /// <param name="line">The affected line</param>
 /// <param name="control">The affected control, or <code>null</code>
 /// if this is a LineChanged event.</param>
 public MixerEventArgs(Mixer mixer, MixerLine line, MixerControl control)
 {
     this.mixer = mixer;
     this.line = line;
     this.control = control;
 }
Esempio n. 11
0
 /// <summary>
 ///     Initializes a new instance of the
 ///     <see cref="MixerEventArgs">MixerEventArgs</see> class.
 /// </summary>
 /// <param name="mixer">The affected mixer</param>
 /// <param name="line">The affected line</param>
 /// <param name="control">
 ///     The affected control, or <code>null</code>
 ///     if this is a LineChanged event.
 /// </param>
 public MixerEventArgs(Mixer mixer, MixerLine line, MixerControl control)
 {
     Mixer   = mixer;
     Line    = line;
     Control = control;
 }
Esempio n. 12
0
 /// <summary>
 /// Initializes a new instance of the
 /// <see cref="MixerEventArgs">MixerEventArgs</see> class.
 /// </summary>
 /// <param name="mixer">The affected mixer</param>
 /// <param name="line">The affected line</param>
 /// <param name="control">The affected control, or <code>null</code>
 /// if this is a LineChanged event.</param>
 public MixerEventArgs(Mixer mixer, MixerLine line, MixerControl control)
 {
     this.mixer   = mixer;
     this.line    = line;
     this.control = control;
 }