s.boot;

// Make sure MIDI is initialized
MIDIClient.init;

// List available MIDI sources
MIDIIn.connectAll;

// Create a function to handle MIDI messages
(
MIDIdef.noteOn(\printNoteOn, { |vel, num, chan, src|
    "Note On - Channel: %, Note: %, Velocity: %, Source: %"
    .format(chan, num, vel, src).postln;
});

MIDIdef.noteOff(\printNoteOff, { |vel, num, chan, src|
    "Note Off - Channel: %, Note: %, Velocity: %, Source: %"
    .format(chan, num, vel, src).postln;
});

MIDIdef.cc(\printCC, { |val, num, chan, src|
    "Control Change - Channel: %, Controller: %, Value: %, Source: %"
    .format(chan, num, val, src).postln;
});
)