Understanding midi paths

Each midi path includes thwo numbers, here marked as X and Y. What do they stand for? Sometimes X changes, when you change your midi setup, connecting or dis- or reconnecting devices. Any idea why they change and how to prevent this?


Xis a port number which is allocated (from 0 increasing) as midi devices are detected. It is linked to the name of the device, but you will find (as you state) that the actual number may change according to the order in which midi devices are plugged in or detected. The second number Y is the midi channel on which the messages are sent.

I expect that you are asking the question because you have set up something like

c,v = sync “/midi/photon_25_midi_1/X/Y/control_change”
and then you have changed channels or plugged in devices in a different order, and found that then numbers have changed and it no longer matches.

The solution is that you can use * as a wild card for any of these values IF you don’t care what the value is. You can even use it for the device name. So to detect a control change on ANY plugged in midi source on ANY channel you could use

live_loop :detect do
  c v, = sync "/midi/*/*/*/control_change"
  puts c,v

If you wanted to restrict to control changes on ONLY your photon_25_midi_1 you could use
sync "/midi/photon_25_midi_1/*/*/control_change"

The channel number is useful if you are receiving notes on several midi channels and you want to process them separately eg.

live_loop :midiC1 do
use_synth :tri
  n,v = sync "/midi/*/*/1/note_on" # process channel 1 only
  play n,release: 0.2
  sleep 0.2

live_loop :midiC2 do
use_synth ::pulse
  n,v = sync "/midi/*/*/2/note_on" # process channel 2 only
  play n,release: 0.2
  sleep 0.2

Hope this helps

Just to add a small point to this excellent explanation by @robin.newman

The MIDI port number is useful in the MIDI path for the cases where you have multiple identical MIDI devices connected simultaneously. In this case, it’s only the MIDI port number that will allow you to distinguish which MIDI event is coming from which hardware device :slight_smile:

Would be nice to own multiple mini-moogs etc so that this became an issue :smile:


Haha, for me, the issue was due to using a number of Korg nanoKontrols at the same time.

Yes, one or two would be more affordable. Nice device.

1 Like

Thank you so much Robin & Sam!