Beispiel #1
0
        private void ParseMetaMessage(MetaMessage message, MidiEvent @event)
        {
            switch (message.MetaType)
            {
            case MetaType.Lyric:
                OnLyricParsed(Encoding.ASCII.GetString(message.GetBytes()));
                HandledMidiEvent?.Invoke(this, new MidiEventArgs(@event));
                break;

            case MetaType.Marker:
                OnMarkerParsed(Encoding.ASCII.GetString(message.GetBytes()));
                HandledMidiEvent?.Invoke(this, new MidiEventArgs(@event));
                break;

            case MetaType.Tempo:
                WhenTempoChanged(message);
                HandledMidiEvent?.Invoke(this, new MidiEventArgs(@event));
                break;

            case MetaType.TimeSignature:
                OnTimeSignatureParsed(message.GetBytes()[0], message.GetBytes()[1]);
                HandledMidiEvent?.Invoke(this, new MidiEventArgs(@event));
                break;

            case MetaType.KeySignature:
                KeySigParsed(message);
                HandledMidiEvent?.Invoke(this, new MidiEventArgs(@event));
                break;

            default:
                UnhandledMidiEvent?.Invoke(this, new MidiEventArgs(@event));
                break;
            }
        }
Beispiel #2
0
        private void ParseChannelMessage(ChannelMessage message, MidiEvent @event)
        {
            // For any message that isn't a NoteOn event, update the current time and channel.
            // (We don't do this for NoteOn events because NoteOn aren't written until the NoteOff event)
            if (!IsNoteOnEvent(message.Command, message.MidiChannel, @event))
            {
                CheckChannel(message.MidiChannel);
            }
            switch (message.Command)
            {
            case ChannelCommand.NoteOff:
                OnNoteOff(message.MidiChannel, @event);
                HandledMidiEvent?.Invoke(this, new MidiEventArgs(@event));
                break;

            case ChannelCommand.NoteOn:
                OnNoteOn(message.MidiChannel, @event);
                HandledMidiEvent?.Invoke(this, new MidiEventArgs(@event));
                break;

            case ChannelCommand.PolyPressure:
                OnPolyphonicPressureParsed(message.Data1, message.Data2);
                HandledMidiEvent?.Invoke(this, new MidiEventArgs(@event));
                break;

            case ChannelCommand.Controller:
                OnControllerEventParsed(message.Data1, message.Data2);
                HandledMidiEvent?.Invoke(this, new MidiEventArgs(@event));
                break;

            case ChannelCommand.ProgramChange:
                OnInstrumentParsed(message.Data1);
                HandledMidiEvent?.Invoke(this, new MidiEventArgs(@event));
                break;

            case ChannelCommand.ChannelPressure:
                OnChannelPressureParsed(message.Data1);
                HandledMidiEvent?.Invoke(this, new MidiEventArgs(@event));
                break;

            case ChannelCommand.PitchWheel:
                OnPitchWheelParsed(message.Data1, message.Data2);
                HandledMidiEvent?.Invoke(this, new MidiEventArgs(@event));
                break;

            default:
                UnhandledMidiEvent?.Invoke(this, new MidiEventArgs(@event));
                break;
            }
        }
Beispiel #3
0
 private void ParseSysExMessage(IMidiMessage message, MidiEvent @event)
 {
     OnSystemExclusiveParsed(message.GetBytes());
     HandledMidiEvent?.Invoke(this, new MidiEventArgs(@event));
 }