示例#1
0
 private static byte[] BuildByteMessage(int intMessage)
 {
     unchecked
     {
         return(new byte[] { (byte)ShortMessage.UnpackStatus(intMessage),
                             (byte)ShortMessage.UnpackData1(intMessage),
                             (byte)ShortMessage.UnpackData2(intMessage) });
     }
 }
 public RawMessageEventArgs(int message)
 {
     this.message = new byte[] { (byte)ShortMessage.UnpackStatus(message),
                                 (byte)ShortMessage.UnpackData1(message),
                                 (byte)ShortMessage.UnpackData2(message) };
 }
        private void HandleShortMessage(object state)
        {
            int message = (int)state;
            int status  = ShortMessage.UnpackStatus(message);

            if (status >= (int)ChannelCommand.NoteOff &&
                status <= (int)ChannelCommand.PitchWheel +
                ChannelMessage.MidiChannelMaxValue)
            {
                cmBuilder.Message = message;
                cmBuilder.Build();

                OnChannelMessageReceived(new ChannelMessageEventArgs(cmBuilder.Result));
            }
            else if (status == (int)SysCommonType.MidiTimeCode ||
                     status == (int)SysCommonType.SongPositionPointer ||
                     status == (int)SysCommonType.SongSelect ||
                     status == (int)SysCommonType.TuneRequest)
            {
                scBuilder.Message = message;
                scBuilder.Build();

                OnSysCommonMessageReceived(new SysCommonMessageEventArgs(scBuilder.Result));
            }
            else
            {
                SysRealtimeMessageEventArgs e = null;

                switch ((SysRealtimeType)status)
                {
                case SysRealtimeType.ActiveSense:
                    e = SysRealtimeMessageEventArgs.ActiveSense;
                    break;

                case SysRealtimeType.Clock:
                    e = SysRealtimeMessageEventArgs.Clock;
                    break;

                case SysRealtimeType.Continue:
                    e = SysRealtimeMessageEventArgs.Continue;
                    break;

                case SysRealtimeType.Reset:
                    e = SysRealtimeMessageEventArgs.Reset;
                    break;

                case SysRealtimeType.Start:
                    e = SysRealtimeMessageEventArgs.Start;
                    break;

                case SysRealtimeType.Stop:
                    e = SysRealtimeMessageEventArgs.Stop;
                    break;

                case SysRealtimeType.Tick:
                    e = SysRealtimeMessageEventArgs.Tick;
                    break;
                }

                OnSysRealtimeMessageReceived(e);
            }
        }