private midiOutShortMsg ( HMIDIOUT hmo, |
||
hmo | HMIDIOUT | |
dwMsg | ||
return | MMRESULT |
public void SendShortMsg(byte[] message) { lock (this) { CheckOpen(); const int StatusMask = 16776960; const int Data1Mask = 16711935; const int Data2Mask = 65535; int m = 0; m &= StatusMask; m |= message[0]; m &= Data1Mask; m |= message[1] << 8; m &= Data2Mask; m |= message[2] << 16; //UInt32 m = (UInt32)(message[0] | message[1] >> 8 | message[2] >> 16); CheckReturnCode(Win32API.midiOutShortMsg(handle, (UInt32)m)); } }
/// <summary> /// Sends a raw 3 byte message, encoded as an integer (Most significant byte not used) /// </summary> /// <param name="data">3 bytes encoded as an int, use 3 least significant bytes</param> public void SendRaw(int data) { lock (this) { CheckOpen(); CheckReturnCode(Win32API.midiOutShortMsg(handle, (uint)data)); } }
/// <summary> /// Sends a Program Change message to this MIDI output device. /// </summary> /// <param name="channel">The channel.</param> /// <param name="instrument">The instrument.</param> /// <exception cref="ArgumentOutOfRangeException">channel or instrument is out-of-range. /// </exception> /// <exception cref="InvalidOperationException">The device is not open.</exception> /// <exception cref="DeviceException">The message cannot be sent.</exception> /// <remarks> /// A Program Change message is used to switch among instrument settings, generally /// instrument voices. An instrument conforming to General Midi 1 will have the /// instruments described in the <see cref="Instrument"/> enum; other instruments /// may have different instrument sets. /// </remarks> public void SendProgramChange(Channel channel, Instrument instrument) { lock (this) { CheckOpen(); CheckReturnCode(Win32API.midiOutShortMsg(handle, ShortMsg.EncodeProgramChange( channel, instrument))); } }
/// <summary> /// Sends a Pitch Bend message to this MIDI output device. /// </summary> /// <param name="channel">The channel.</param> /// <param name="value">The pitch bend value, 0..16383, 8192 is centered.</param> /// <exception cref="ArgumentOutOfRangeException">channel or value is out-of-range. /// </exception> /// <exception cref="InvalidOperationException">The device is not open.</exception> /// <exception cref="DeviceException">The message cannot be sent.</exception> public void SendPitchBend(Channel channel, int value) { lock (this) { CheckOpen(); CheckReturnCode(Win32API.midiOutShortMsg(handle, ShortMsg.EncodePitchBend(channel, value))); } }
/// <summary> /// Sends a Control Change message to this MIDI output device. /// </summary> /// <param name="channel">The channel.</param> /// <param name="control">The control.</param> /// <param name="value">The new value 0..127.</param> /// <exception cref="ArgumentOutOfRangeException">channel, control, or value is /// out-of-range.</exception> /// <exception cref="InvalidOperationException">The device is not open.</exception> /// <exception cref="DeviceException">The message cannot be sent.</exception> public void SendControlChange(Channel channel, Control control, int value) { lock (this) { CheckOpen(); CheckReturnCode(Win32API.midiOutShortMsg(handle, ShortMsg.EncodeControlChange( channel, control, value))); } }
/// <summary> /// Sends a Note Off message to this MIDI output device. /// </summary> /// <param name="channel">The channel.</param> /// <param name="pitch">The pitch.</param> /// <param name="velocity">The velocity 0..127.</param> /// <exception cref="ArgumentOutOfRangeException">channel, note, or velocity is /// out-of-range.</exception> /// <exception cref="InvalidOperationException">The device is not open.</exception> /// <exception cref="DeviceException">The message cannot be sent.</exception> public void SendNoteOff(Channel channel, Pitch pitch, int velocity) { lock (this) { CheckOpen(); CheckReturnCode(Win32API.midiOutShortMsg(handle, ShortMsg.EncodeNoteOff(channel, pitch, velocity))); } }
/// <summary> /// Sends a Note On message to this MIDI output device. /// </summary> /// <param name="channel">The channel.</param> /// <param name="note">The note.</param> /// <param name="velocity">The velocity 0..127.</param> /// <exception cref="ArgumentOutOfRangeException">channel, note, or velocity is /// out-of-range.</exception> /// <exception cref="InvalidOperationException">The device is not open.</exception> /// <exception cref="DeviceException">The message cannot be sent.</exception> public void SendNoteOn(Channel channel, Note note, int velocity) { lock (this) { CheckOpen(); CheckReturnCode(Win32API.midiOutShortMsg(handle, ShortMsg.EncodeNoteOn(channel, note, velocity))); } }
/// <summary> /// Sends a Note On message to Channel10 of this MIDI output device. /// </summary> /// <param name="percussion">The percussion.</param> /// <param name="velocity">The velocity 0..127.</param> /// <remarks>This is simply shorthand for a Note On message on Channel10 with a /// percussion-specific note, so there is no corresponding message to receive from an input /// device.</remarks> /// <exception cref="ArgumentOutOfRangeException">percussion or velocity is out-of-range. /// </exception> /// <exception cref="InvalidOperationException">The device is not open.</exception> /// <exception cref="DeviceException">The message cannot be sent.</exception> public void SendPercussion(Percussion percussion, int velocity) { lock (this) { CheckOpen(); CheckReturnCode(Win32API.midiOutShortMsg(handle, ShortMsg.EncodeNoteOn( Channel.Channel10, (Pitch)percussion, velocity))); } }