void onMidiMessageReceived(object sender, MidiMessageBroker.MessageReceivedEventArgs e) { if (!_isActive) { return; } int channel = e.Channel.Number; string note = String.Empty; switch (e.Message.Type) { case MidiMessageType.ControlChange: MidiControlChangeMessage ccMsg = e.Message as MidiControlChangeMessage; note = String.Format("CC.{0:000}", ccMsg.ControlId); break; case MidiMessageType.NoteOff: case MidiMessageType.NoteOn: MidiNoteMessage noteMsg = e.Message as MidiNoteMessage; note = "Note." + _keyConverter.GetKeyTextIPN(noteMsg.Key); break; case MidiMessageType.PitchBend: note = "PitchBend"; break; default: return; } _lastSignal = new MidiSignal(channel, note); notify(); }
private static Dictionary <string, AMidiDefinition> createGenericMidiDefinitions(MappingType type) { Dictionary <string, AMidiDefinition> result = new Dictionary <string, AMidiDefinition>(); KeyConverter keyConverter = new KeyConverter(); int numChannels = 16; int num = 128; for (int i = 1; i <= numChannels; i++) { for (int j = 0; j < num; j++) { var cc = new ControlChangeMidiDefinition(type, i, j); result.Add(cc.Note, cc); var note = new NoteMidiDefinition(type, i, keyConverter.GetKeyTextIPN(j)); result.Add(note.Note, note); } var pitch = new PitchBendMidiDefinition(type, i); result.Add(pitch.Note, pitch); } return(result); }