Dup Ver Goto 📝

AKAI MidiMix

To
55 lines, 433 words, 1984 chars Page 'MidiMix' does not exist.

AKAI MidiMix

The Akai Midi Mix is a simple MIDI controller with 3*8 knobs, 8+1 faders and 16+3 buttons. (I use the n+3 type notation since 16 buttons are horizontal between the faders and knobs, and 3 are on the side; and 8 of the faders are below the 8 columns of 3 knobs each, with one extra knob to the right; and there are 3 rows of 8 knobs.)

knobs and faders -- cc numbers 16..47
16 20 24 28 32 36 40 44 rotary 1        
17 21 25 29 33 37 41 45 rotary 2 (n+1)
18 22 26 30 34 38 42 46 rotary 3 (n+2)
19 23 27 31 35 39 43 47 fader    (n+3)

buttons -- note numbers vel=127 for on vel=0 for off,
           send note on with vel !=0 or =0 to set led on or off
 1  4  7 10 13 16 19 22 buttons row 1   
 3  6  9 12 15 18 21 24 buttons row 2
62                      master fader

top side button sends all values
25 side buttons notes
26
27

so mapping button number to index is

def note_number_to_button_index(x):
  return (8 + (x-3)//3 if x % 3 == 0 else x//3) 

We have two cases depending on x % 3. The upper row has x % 3 == 1 and the lower row x % 3 == 0. The lower row starts at 3, so we subtract 3 before integer dividing by 3 for the lower row; and simply integer divide by 3 for the upper row (the remainder 1 is discarded).

Buttons workings

The main purposes of this is to illustrate using comprehensions and ternary expressions.

>>> a = [ 3*x+1 for x in range(8) ]
>>> b = [ 3*x+3 for x in range(8) ]
>>> a
[1, 4, 7, 10, 13, 16, 19, 22]
>>> b
[3, 6, 9, 12, 15, 18, 21, 24]
>>> [ (x-1)//3 for x in a ]
[0, 1, 2, 3, 4, 5, 6, 7]
>>> [ (x-3)//3 for x in b ]
[0, 1, 2, 3, 4, 5, 6, 7]
>>> [ 8 + (x-3)//3 for x in b ]
[8, 9, 10, 11, 12, 13, 14, 15]
>>> c = a + b
>>> c
[1, 4, 7, 10, 13, 16, 19, 22, 3, 6, 9, 12, 15, 18, 21, 24]
>>> [ (8 + (x-3)//3 if x % 3 == 0 else (x-1)//3) for x in c ]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
>>>