Hi, I am creating a preset to map some of the APC40 pads to a progression of notes. By the default the 8x5 pads grid on the APC40 send F2, F#2, G2, G#2, A2 on channels [1,2,…8]. I want to transform that to be like a midi keyboard, not repeating notes on a different channel.
Right now I am creating two rules for each pad (one for note on and one for note off), so it will result in 80 rules in total.
I use raw MIDI for incoming message and then rules to determine the note number and channel number.
I then use math rules to determine the outgoing note number to send.
In this case, one translator handles 3 notes, on and off.
Incoming: Raw MIDI oo pp qq
Outgoing: Raw MIDI oo tt qq
Here are the rules:
// look for note message
// mask status byte with 0xe0
rr=oo&224
// if it is note 128, then it is note a note message
if rr!=128 then exit rules, skip outgoing action
// mask lower nibble
rr=oo&15
// only look at ch 5-7
if rr<4 then exit rules, skip outgoing action
if rr>6 then exit rules, skip outgoing action
// Look for note 53 only
if pp!=53 then exit rules, skip outgoing action
//determine outgoing note
tt=rr+56
// set outgoing channel
rr=oo&15
oo=oo|14
// Get status using mask status byte with 0xe0
rr=oo&224
// If it is not 128, then it is not a note message
if rr!=128 then exit rules, skip outgoing action
// Get channel using mask lower nibble
rr=oo&15
// only look at channels 5-8
if rr<4 then exit rules, skip outgoing action
if rr>7 then exit rules, skip outgoing action
// Look for notes F2 to A2 only
if pp<53 then exit rules, skip outgoing action
if pp>57 then exit rules, skip outgoing action
// Channel offset [1, 4]
xx = rr % 4
xx = xx + 1
// Note offset [0, 4]
ww = pp % 53
// Compute output note
tt = ww * 4
tt = tt + xx
tt = tt + 59
// Channel output
oo = oo & 240
oo = oo + 14
From performance standpoint, should I prefer a single complex rule like this or multiple simple rules as I was doing initially? apc40-note-mapping.bmtp (1.5 KB)
You will find the performance difference is negligible. I prefer less translators and more rules for the purpose of making the code easier ot maintain. You sacrifice more complexity, however with more rules.
Steve Caldwell
Bome Customer Care
Also available for paid consulting services: bome@sniz.biz