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(); } } }
/// <summary> /// Find a line of this mixer by ID. /// </summary> /// <param name="lineId">ID of the line to find</param> /// <returns>The line, or <code>null</code> if no line was found.</returns> public MixerLine FindLine(int lineId) { foreach (DestinationLine dl in DestinationLines) { MixerLine found = dl.findLine(lineId); if (found != null) { return(found); } } return(null); }
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); }
internal MixerLine findLine(int lineId) { if (Id == lineId) { return(this); } foreach (MixerLine ml in ChildLines) { MixerLine found = ml.findLine(lineId); if (found != null) { return(found); } } return(null); }
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(Mixer mx, MixerLine ml, MIXERCONTROL ctrl) { this.mx = mx; this.ml = ml; this.ctrl = ctrl; }
internal BooleanMixerControl(Mixer mx, MixerLine ml, MixerControl.MIXERCONTROL mc) : base(mx, ml, mc) { }
internal FaderMixerControl(Mixer mx, MixerLine ml, MixerControl.MIXERCONTROL mc) : base(mx, ml, mc) { }
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; }
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; }
/// <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; }
internal FaderMixerControl(Mixer mx, MixerLine ml, MIXERCONTROL mc) : base(mx, ml, mc) { }
/// <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; }