예제 #1
0
        private void Write(int deltaTicks, ShortMessage message)
        {
            #region Require

            if (IsDisposed)
            {
                throw new ObjectDisposedException("OutputStream");
            }

            #endregion

            // Delta time.
            events.AddRange(BitConverter.GetBytes(deltaTicks + offsetTicks));

            // Stream ID.
            events.AddRange(streamID);

            // Event code.
            byte[] eventCode = message.GetBytes();
            eventCode[eventCode.Length - 1] = MEVT_SHORTMSG;
            events.AddRange(eventCode);

            offsetTicks = 0;
        }
예제 #2
0
        private void HandleShortMessage(object state)
        {
            int message = (int)state;

            //first send RawMessage
            OnShortMessage(new ShortMessageEventArgs(message));

            int status = ShortMessage.UnpackStatus(message);

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

                OnMessageReceived(cmBuilder.Result);
                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();

                OnMessageReceived(scBuilder.Result);
                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;
                }

                OnMessageReceived(e.Message);
                OnSysRealtimeMessageReceived(e);
            }
        }
 public ShortMessageEventArgs(byte status, byte data1, byte data2)
 {
     this.message = new ShortMessage(status, data1, data2);
 }
 public ShortMessageEventArgs(int message)
 {
     this.message = new ShortMessage(message);
 }
 public ShortMessageEventArgs(ShortMessage message)
 {
     this.message = message;
 }
예제 #6
0
 private void Write(ShortMessage message)
 {
     trackData.AddRange(message.GetBytes());
 }