Example #1
0
 /// <summary>
 ///     Returns the human-readable name of a MIDI control.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <exception cref="ArgumentOutOfRangeException">The control is out-of-range.</exception>
 public static string Name(this Control control)
 {
     control.Validate();
     if (ControlNames.ContainsKey((int)control))
     {
         return(ControlNames[(int)control]);
     }
     return("Other Control (see MIDI spec for details).");
 }
Example #2
0
 /// <summary>
 /// Encodes a Control Change short message.
 /// </summary>
 /// <param name="channel">The channel.</param>
 /// <param name="control">The control.</param>
 /// <param name="value">The new value 0..127.</param>
 /// <returns>A value that can be passed to midiOutShortMsg.</returns>
 public static UInt32 EncodeControlChange(Channel channel, Control control, int value)
 {
     channel.Validate();
     control.Validate();
     if (value < 0 || value > 127)
     {
         throw new ArgumentOutOfRangeException("Value is out of range.");
     }
     return((UInt32)(0xB0 | (int)(channel) | ((int)control << 8) | (value << 16)));
 }
Example #3
0
 /// <summary>
 ///     Encodes a Control Change short message.
 /// </summary>
 /// <param name="channel">The channel.</param>
 /// <param name="control">The control.</param>
 /// <param name="value">The new value 0..127.</param>
 /// <returns>A value that can be passed to midiOutShortMsg.</returns>
 public static uint EncodeControlChange(Channel channel, Control control, int value)
 {
     channel.Validate();
     control.Validate();
     if (value < 0 || value > 127)
     {
         throw new ArgumentOutOfRangeException(nameof(value));
     }
     return((uint)(0xB0 | (int)channel | ((int)control << 8) | (value << 16)));
 }
 /// <summary>
 /// Constructs a Control Change message.
 /// </summary>
 /// <param name="channel">MIDI channel.</param>
 /// <param name="control">Control type.</param>
 /// <param name="value">Control value.</param>
 public ControlChangeMessage(Channel channel, Control control, int value)
     : base(channel)
 {
     control.Validate();
     if (value < 0 || value > 127)
     {
         throw new ArgumentOutOfRangeException("control");
     }
     this.Control = control;
     this.Value   = value;
 }
Example #5
0
 /// <summary>
 /// Construts a Control Change message.
 /// </summary>
 /// <param name="device">The device associated with this message.</param>
 /// <param name="channel">Channel, 0..15, 10 reserved for percussion.</param>
 /// <param name="control">Control, 0..119</param>
 /// <param name="value">Value, 0..127.</param>
 /// <param name="time">The timestamp for this message.</param>
 public ControlChangeMessage(DeviceBase device, Channel channel, Control control, int value,
                             float time)
     : base(device, channel, time)
 {
     control.Validate();
     if (value < 0 || value > 127)
     {
         throw new ArgumentOutOfRangeException("control");
     }
     this.control = control;
     this.value   = value;
 }
Example #6
0
 /// <summary>
 /// Returns the control (CC) number as an integer.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <exception cref="ArgumentOutOfRangeException">The control is out-of-range.</exception>
 public static int Number(this Control control)
 {
     control.Validate();
     return((int)control);
 }
Example #7
0
 /// <summary>
 /// Encodes a Control Change short message.
 /// </summary>
 /// <param name="channel">The channel.</param>
 /// <param name="control">The control.</param>
 /// <param name="value">The new value 0..127.</param>
 /// <returns>A value that can be passed to midiOutShortMsg.</returns>
 public static UInt32 EncodeControlChange(Channel channel, Control control, int value)
 {
     channel.Validate();
     control.Validate();
     if (value < 0 || value > 127)
     {
         throw new ArgumentOutOfRangeException("Value is out of range.");
     }
     return (UInt32)(0xB0 | (int)(channel) | ((int)control << 8) | (value << 16));
 }
Example #8
0
 public override bool Validate()
 {
     return(Control.Validate());
 }
Example #9
0
 /// <summary>
 /// Construts a Control Change message.
 /// </summary>
 /// <param name="device">The device associated with this message.</param>
 /// <param name="channel">Channel, 0..15, 10 reserved for percussion.</param>
 /// <param name="control">Control, 0..119</param>
 /// <param name="value">Value, 0..127.</param>
 /// <param name="time">The timestamp for this message.</param>
 public ControlChangeMessage(DeviceBase device, Channel channel, Control control, int value,
     float time)
     : base(device, channel, time)
 {
     control.Validate();
     if (value < 0 || value > 127)
     {
         throw new ArgumentOutOfRangeException("control");
     }
     this.control = control;
     this.value = value;
 }
Example #10
0
 public void Validate()
 {
     Header.Validate();
     Control.Validate();
 }