Beispiel #1
0
        private void OnEventReceived(object sender, MidiEventReceivedEventArgs e)
        {
            var midiDevice = (MidiDevice)sender;

            Console.WriteLine($"Event received from '{midiDevice.Name}' at {DateTime.Now}: {e.Event}");

            if (e.Event.EventType.Equals(MidiEventType.NoteOn))
            {
                if (_serialPort.IsOpen)
                {
                    Melanchall.DryWetMidi.MusicTheory.Note note = Melanchall.DryWetMidi.MusicTheory.Note.Get(((NoteOnEvent)e.Event).NoteNumber);

                    Console.WriteLine("Arduino gets: " + processNote(note.NoteName, note.Octave));

                    _serialPort.Write(processNote(note.NoteName, note.Octave) + ";");
                }
            }
        }