hey hey!
if you’re executing this from the REPL (or if you haven’t yet assigned a variable as midi.connect(x)
, where x is the port you want to address), you’ll need to address the specific port where your device is located.
ports
you can navigate to DEVICES > MIDI and see which port your MIDI device is connected to:
(here, my AKM320
MIDI device is connected to port 1)
knowing the device’s port is super important – norns needs to be told where to direct midi messages, so we’ll use a device’s port assignment to help specify.
you can also query the ports from maiden's REPL
tab.print(midi.vports) -- execute this, which returns:
1 table: 0x3cbb78
2 table: 0x3bf688
3 table: 0x3c0678
4 table: 0x3c0650
tab.print(midi.vports[1]) -- execute this, which returns:
note_off function: 0x3a79c0
key_pressure function: 0x3a78c8
start function: 0x3a73c8
channel_pressure function: 0x3a77a8
pitchbend function: 0x3a75e0
note_on function: 0x3a7ae0
send function: 0x3a77f8
cc function: 0x3a7760
clock function: 0x3a7330
stop function: 0x3a76b0
program_change function: 0x3a7548
name AKM320
song_select function: 0x3a7498
song_position function: 0x3a71b0
continue function: 0x3a7590
the easiest way to keep track of the little boxes is to assign the destination port to a variable in your script, eg. device1 = midi.connect(1)
, to alias the device connected to port 1 as device1
. this is a little more readable than midi.vports[1]
either way, once we know which port the device is connected to, we can…
send midi cc
you were spot on, you need to use :cc(cc,val,ch)
to send a cc message, but the first part needs to be more specific since we need to provide a port destination for that cc message.
if you don’t assign the device port to a variable, you’ll address devices using the raw port assignment:
midi.vports[1]:cc(103,127,5)
if you do assign the device port to a variable, then you can just use that variable:
device1:cc(103,127,5)
hope this helps! please lmk if there’s any ambiguity! i just posted a video walkthrough of some midi hacking, which covers these setup steps. cc
is a function of the midi
library, same as note_on
, so the same approach applies: *norns walkthrough*: hacking a script to add MIDI output