public void SendNoteOff(Channel channel, Pitch pitch, int velocity) { var cmd = (int)ShortMsg.EncodeNoteOff(channel, pitch, velocity); Debug.LogFormat("EncodeNoteOff:{0},{1},{2}={3}", channel, pitch, velocity, cmd); m_jc.CallStatic("SendMsg", cmd); }
/// <summary> /// Send a MIDI note-off message. /// </summary> /// <param name="channel">MIDI channel.</param> /// <param name="noteId">Note ID / pitch.</param> /// <param name="velocity">Note velocity.</param> /// <exception cref="ArgumentOutOfRangeException">Channel, pitch, 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, int noteId, int velocity) { lock (_lockObj) { CheckOpen(); CheckReturnCode(Win32API.midiOutShortMsg(_handle, ShortMsg.EncodeNoteOff(channel, noteId, velocity))); } }
public void SendProgramChange(Channel channel, Instrument instrument) { var cmd = (int)ShortMsg.EncodeProgramChange(channel, instrument); Debug.LogFormat("EncodeNoteOff:{0},{1}={2}", channel, instrument, cmd); m_jc.CallStatic("SendMsg", cmd); }
/// <summary> /// Sends a Program Change message. /// </summary> /// <param name="channel">MIDI 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 (_lockObj) { CheckOpen(); CheckReturnCode(Win32API.midiOutShortMsg(_handle, ShortMsg.EncodeProgramChange( channel, instrument))); } }
/// <summary> /// Sends a Pitch Bend message. /// </summary> /// <param name="channel">MIDI channel.</param> /// <param name="value">The pitch bend value, 0..16383; Central value is 8192.</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 (_lockObj) { CheckOpen(); CheckReturnCode(Win32API.midiOutShortMsg(_handle, ShortMsg.EncodePitchBend(channel, value))); } }
/// <summary> /// Sends a Control Change message. /// </summary> /// <param name="channel">MIDI channel.</param> /// <param name="control">Control type.</param> /// <param name="value">Control value.</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 (_lockObj) { CheckOpen(); CheckReturnCode(Win32API.midiOutShortMsg(_handle, ShortMsg.EncodeControlChange( channel, control, value))); } }
private void ModifyMsg(ShortMsg msgEntity) { _msgRepository.Modify(msgEntity); }
private void AddMsg(ShortMsg msgEntity) { msgEntity.CreateTime = DateTime.Now; _msgRepository.Add(msgEntity); }
private void InputCallback_MidiInMessage_Data(UIntPtr dwParam1, UIntPtr dwParam2) { Channel channel; int noteId; int velocity; int value; uint win32Timestamp; if (ShortMsg.IsNoteOn(dwParam1, dwParam2)) { if (null != this.NoteOn) { ShortMsg.DecodeNoteOn(dwParam1, dwParam2, out channel, out noteId, out velocity, out win32Timestamp); NoteOn(new NoteMessage(channel, true, noteId, velocity)); } } else if (ShortMsg.IsNoteOff(dwParam1, dwParam2)) { if (null != this.NoteOff) { ShortMsg.DecodeNoteOff(dwParam1, dwParam2, out channel, out noteId, out velocity, out win32Timestamp); NoteOff(new NoteMessage(channel, false, noteId, velocity)); } } else if (ShortMsg.IsControlChange(dwParam1, dwParam2)) { if (null != this.ControlChange) { ShortMsg.DecodeControlChange(dwParam1, dwParam2, out channel, out Control control, out value, out win32Timestamp); ControlChange(new ControlChangeMessage(channel, control, value)); } } else if (ShortMsg.IsProgramChange(dwParam1, dwParam2)) { if (null != this.ProgramChange) { ShortMsg.DecodeProgramChange(dwParam1, dwParam2, out channel, out Instrument instrument, out win32Timestamp); ProgramChange(new ProgramChangeMessage(channel, instrument)); } } else if (ShortMsg.IsPitchBend(dwParam1, dwParam2)) { if (null != this.PitchBend) { ShortMsg.DecodePitchBend(dwParam1, dwParam2, out channel, out value, out win32Timestamp); PitchBend(new PitchBendMessage(channel, value)); } } else if (ShortMsg.IsRealTime(dwParam1, dwParam2)) { if (null != this.RealTime) { RealTimeMessageType msgType; ShortMsg.DecodeRealTime(dwParam1, dwParam2, out msgType, out win32Timestamp); RealTime(new RealTimeMessage(msgType)); } } else { // Unsupported messages are ignored. //Debug.WriteLine($"{dwParam1:X4} | {dwParam2:X4}"); } }