How to use Midi note_on messages from drum pads

# My midi controller (Arturia MiniLab Mk II) sends drum pad messages such as "/midi:arturia_minilab_mkii:0:10/note_on"
# but the below code doesn't work. sync blocks forever even though I can see the messages arriving in the
# "cues" window with the same name.

# it *does* work if I use "0:1" and play the keys
# it does work if I use "0:*" and play the keys *or* the pads

# what am I doing wrong?


live_loop :drum do
  use_real_time
  
  note,vel = sync "/midi:arturia_minilab_mkii:0:10/note_on"   # 0:10 doesn't work here
  
  puts note.to_s + "::" + vel.to_s
  
  sample :bd_haus, amp: vel/127.0
  
end

Hi there @mjg123,

apologies but there is a bug in v3.2.2 of Sonic Pi with MIDi devices containing multiple : in their description such as yours. This has been fixed and is part of the upcoming v3.3 (a BETA is currently available to Patreon supporters here: https://www.patreon.com/posts/43441419). I hope to see v3.3 released freely in a few weeks.

For the meantime you can bypass this bug by using a * wildcard character in your description such as:

sync "/midi:arturia_minilab_mkii*/note_on"

This matches all MIDI devices starting with arturia_minilab_mkii and avoids the use of : in the name which is what is causing the issue here.

Apologies again for the problem and I hope this helps you out.

1 Like

Thank you Sam, that is helpful. Although I haven’t had any problem with the double - colon if I use the keys, which map to :0:1.

If I use the wildcard form in sync is there any way to determine which channel the event came from? I would ideally be able to use the keys in a synth and the pads for a sample.

Hi,
did you try match on
note, velocity = sync “/midi*10/note_on”
This works for me on v4 beta version

I also found out how to get the channel name from another post by @robin.newman:
puts get_event("/midi:*/*").to_s.split(",")[6]