Created
May 30, 2022 21:09
-
-
Save tlubke/2bb2ea9ece4cbe1fddb8742b652cda97 to your computer and use it in GitHub Desktop.
OSCII-bot script for monome grid as MIDI controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@input monome OSC "*:8000" | |
@output loop MIDI "LoopBe Internal MIDI" | |
@init | |
// Map grid (16x8) keys to MIDI notes in memory. | |
mem_set_values(gmem[] + 0, 76, 76+1, 76+2, 76+3, 76+4, 76+5, 76+6, 76+7, 76+8, 76+9, 76+10, 76+11, 76+12, 76+13, 76+14, 76+15); | |
mem_set_values(gmem[] + 16, 69, 69+1, 69+2, 69+3, 69+4, 69+5, 69+6, 69+7, 69+8, 69+9, 69+10, 69+11, 69+12, 69+13, 69+14, 69+15); | |
mem_set_values(gmem[] + 32, 62, 62+1, 62+2, 62+3, 62+4, 62+5, 62+6, 62+7, 62+8, 62+9, 62+10, 62+11, 62+12, 62+13, 62+14, 62+15); | |
mem_set_values(gmem[] + 48, 55, 55+1, 55+2, 55+3, 55+4, 55+5, 55+6, 55+7, 55+8, 55+9, 55+10, 55+11, 55+12, 55+13, 55+14, 55+15); | |
mem_set_values(gmem[] + 64, 43, 43+1, 43+2, 43+3, 43+4, 43+5, 43+6, 43+7, 43+8, 43+9, 43+10, 43+11, 43+12, 43+13, 43+14, 43+15); | |
mem_set_values(gmem[] + 80, 38, 38+1, 38+2, 38+3, 38+4, 38+5, 38+6, 38+7, 38+8, 38+9, 38+10, 38+11, 38+12, 38+13, 38+14, 38+15); | |
mem_set_values(gmem[] + 96, 33, 33+1, 33+2, 33+3, 33+4, 33+5, 33+6, 33+7, 33+8, 33+9, 33+10, 33+11, 33+12, 33+13, 33+14, 33+15); | |
mem_set_values(gmem[] + 112, 28, 28+1, 28+2, 28+3, 28+4, 28+5, 28+6, 28+7, 28+8, 28+9, 28+10, 28+11, 28+12, 28+13, 28+14, 28+15); | |
// E5 .. | |
// A4 .. | |
// D4 .. | |
// G3 .. | |
// G2 .. | |
// D2 .. | |
// A1 .. | |
// E1 F1 .. | |
@timer | |
// Do nothing. (Every 10ms) | |
@oscmsg | |
strcmp(oscstr, "/monome/grid/key") == 0 ? ( | |
x = oscparm( 0, $'i' ); | |
y = oscparm( 1, $'i' ); | |
z = oscparm( 2, $'i' ); | |
note_change = (z == 1) ? 0x90 : 0x80; | |
note_number = 0; | |
note_velocity = 127; | |
mem_get_values(gmem[] + ((y * 16) + x), note_number); | |
msg1 = note_change; // BYTE-1 | |
msg2 = note_number; // BYTE-2 | |
msg3 = note_velocity; // BYTE-3 | |
midisend( loop ); | |
printf("x: %02d y: %02d z: %01d -> midi note: %d\n", x, y, z, note_number); | |
oscsend( -1 , "iii/monome/grid/led/level/set", x, y, ( z == 1 ) ? 15 : 0 ); | |
); | |
@midimsg | |
// Doesn't receive MIDI. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment