public void SendNrpn(Channel channel, int parameter, int value)
        {
            lock (this)
            {
                CheckOpen();

                var parameter14 = new Int14(parameter);
                var value14     = new Int14(value);

                // Parameter, MSB
                CheckReturnCode(Win32API.midiOutShortMsg(_handle, ShortMsg.EncodeControlChange(
                                                             channel, Control.NonRegisteredParameterMSB, parameter14.MSB)));

                // Parameter, LSB
                CheckReturnCode(Win32API.midiOutShortMsg(_handle, ShortMsg.EncodeControlChange(
                                                             channel, Control.NonRegisteredParameterLSB, parameter14.LSB)));

                // Value, MSB
                CheckReturnCode(Win32API.midiOutShortMsg(_handle, ShortMsg.EncodeControlChange(
                                                             channel, Control.DataEntryMSB, value14.MSB)));

                // Value, LSB
                CheckReturnCode(Win32API.midiOutShortMsg(_handle, ShortMsg.EncodeControlChange(
                                                             channel, Control.DataEntryLSB, value14.LSB)));
            }
        }
Beispiel #2
0
        private void HandleInputMimData(UIntPtr dwParam1, UIntPtr dwParam2)
        {
            Channel channel;
            Pitch   pitch;
            int     velocity;
            int     value;
            uint    win32Timestamp;

            if (ShortMsg.IsNoteOn(dwParam1, dwParam2))
            {
                if (NoteOn == null)
                {
                    return;
                }

                ShortMsg.DecodeNoteOn(dwParam1, dwParam2, out channel, out pitch, out velocity, out win32Timestamp);
                NoteOn(new NoteOnMessage(this, channel, pitch, velocity, _clock?.Time ?? win32Timestamp / 1000f));
            }
            else if (ShortMsg.IsNoteOff(dwParam1, dwParam2))
            {
                if (NoteOff == null)
                {
                    return;
                }

                ShortMsg.DecodeNoteOff(dwParam1, dwParam2, out channel, out pitch, out velocity, out win32Timestamp);
                NoteOff(new NoteOffMessage(this, channel, pitch, velocity, _clock?.Time ?? win32Timestamp / 1000f));
            }
            else if (ShortMsg.IsControlChange(dwParam1, dwParam2))
            {
                Control control;
                ShortMsg.DecodeControlChange(dwParam1, dwParam2, out channel, out control, out value, out win32Timestamp);

                var msg = new ControlChangeMessage(this, channel, control, value, _clock?.Time ?? win32Timestamp / 1000f);
                _nrpnWatcher.ReceivedControlChange(msg);
            }
            else if (ShortMsg.IsProgramChange(dwParam1, dwParam2))
            {
                if (ProgramChange == null)
                {
                    return;
                }

                Instrument instrument;
                ShortMsg.DecodeProgramChange(dwParam1, dwParam2, out channel, out instrument, out win32Timestamp);
                ProgramChange(new ProgramChangeMessage(this, channel, instrument, _clock?.Time ?? win32Timestamp / 1000f));
            }
            else if (ShortMsg.IsPitchBend(dwParam1, dwParam2))
            {
                if (PitchBend == null)
                {
                    return;
                }

                ShortMsg.DecodePitchBend(dwParam1, dwParam2, out channel, out value, out win32Timestamp);
                PitchBend(new PitchBendMessage(this, channel, value, _clock?.Time ?? win32Timestamp / 1000f));
            }
        }
 public void SendNoteOn(Channel channel, Pitch pitch, int velocity)
 {
     lock (this)
     {
         CheckOpen();
         CheckReturnCode(Win32API.midiOutShortMsg(_handle, ShortMsg.EncodeNoteOn(channel,
                                                                                 pitch, velocity)));
     }
 }
 public void SendProgramChange(Channel channel, Instrument instrument)
 {
     lock (this)
     {
         CheckOpen();
         CheckReturnCode(Win32API.midiOutShortMsg(_handle, ShortMsg.EncodeProgramChange(
                                                      channel, instrument)));
     }
 }
 public void SendPitchBend(Channel channel, int value)
 {
     lock (this)
     {
         CheckOpen();
         CheckReturnCode(Win32API.midiOutShortMsg(_handle, ShortMsg.EncodePitchBend(channel,
                                                                                    value)));
     }
 }
 public void SendControlChange(Channel channel, Control control, int value)
 {
     lock (this)
     {
         CheckOpen();
         CheckReturnCode(Win32API.midiOutShortMsg(_handle, ShortMsg.EncodeControlChange(
                                                      channel, control, value)));
     }
 }
 public void SendPercussion(Percussion percussion, int velocity)
 {
     lock (this)
     {
         CheckOpen();
         CheckReturnCode(Win32API.midiOutShortMsg(_handle, ShortMsg.EncodeNoteOn(
                                                      Channel.Channel10, (Pitch)percussion,
                                                      velocity)));
     }
 }