midi_receiver_example.scd 640 B

12345678910111213141516171819202122232425
  1. s.boot;
  2. // Make sure MIDI is initialized
  3. MIDIClient.init;
  4. // List available MIDI sources
  5. MIDIIn.connectAll;
  6. // Create a function to handle MIDI messages
  7. (
  8. MIDIdef.noteOn(\printNoteOn, { |vel, num, chan, src|
  9. "Note On - Channel: %, Note: %, Velocity: %, Source: %"
  10. .format(chan, num, vel, src).postln;
  11. });
  12. MIDIdef.noteOff(\printNoteOff, { |vel, num, chan, src|
  13. "Note Off - Channel: %, Note: %, Velocity: %, Source: %"
  14. .format(chan, num, vel, src).postln;
  15. });
  16. MIDIdef.cc(\printCC, { |val, num, chan, src|
  17. "Control Change - Channel: %, Controller: %, Value: %, Source: %"
  18. .format(chan, num, val, src).postln;
  19. });
  20. )