Exemplo n.º 1
0
        private MidiMessageType getMidiEventType(cmdr.MidiLib.Core.MidiIO.Data.MidiEvent ev)
        {
            MidiMessageType eventType;
            var             shortType = ev.Status & 0xF0;

            switch (shortType)
            {
            case 0x80:
                //Note Off
                eventType = MidiMessageType.NoteOff;
                break;

            case 0x90:
                // Note On
                eventType = MidiMessageType.NoteOn;
                break;

            case 0xA0:
                // Polyphonic Aftertouch
                eventType = MidiMessageType.PolyAftertouch;
                break;

            case 0xB0:
                // Control Message
                eventType = MidiMessageType.ControlChange;
                break;

            case 0xC0:
                // Program Change to general Midi Instrument Name
                eventType = MidiMessageType.ProgramChange;
                break;

            case 0xD0:
                // Channel Aftertouch
                eventType = MidiMessageType.ChannelAftertouch;
                break;

            case 0xE0:
                // Pitch Wheel / Pitch Bend
                eventType = MidiMessageType.PitchBend;
                break;

            default:
                eventType = MidiMessageType.Unknown;
                break;
            }

            return(eventType);
        }
Exemplo n.º 2
0
        private void onMidiEventHandle(cmdr.MidiLib.Core.MidiIO.Data.MidiEvent ev)
        {
            bool checkSysEx = false;

            var handleEvent = (ev.MidiEventType == cmdr.MidiLib.Core.MidiIO.Definitions.EMidiEventType.Short)
                ? _channelListeners[ev.Status & 0x0F]
                : checkSysEx;

            if (!handleEvent)
            {
                return;
            }

            MidiChannel channel = MidiManager.Channels[(ev.Status & 0x0F) + 1];

            MidiMessage message = null;
            var         type    = getMidiEventType(ev);

            switch (type)
            {
            case MidiMessageType.ControlChange:
                message = new MidiControlChangeMessage(ev, type);
                break;

            case MidiMessageType.NoteOff:
            case MidiMessageType.NoteOn:
                message = new MidiNoteMessage(ev, type);
                break;

            case MidiMessageType.ProgramChange:
                message = new MidiProgramChangeMessage(ev, type);
                break;

            case MidiMessageType.PitchBend:
                message = new MidiPitchBendMessage(ev, type);
                break;

            default:
                Console.WriteLine("MidiMessageType is unknown");
                break;
            }

            if (message != null && MessageReceived != null)
            {
                MessageReceived(_sender, new MessageReceivedEventArgs(channel, message));
            }
        }
Exemplo n.º 3
0
 internal MidiMessage(cmdr.MidiLib.Core.MidiIO.Data.MidiEvent ev, MidiMessageType type)
 {
     _coreMessage = ev;
     _type        = type;
 }