add gridkbd, tidy up grid

This commit is contained in:
Nico 2021-08-20 23:02:15 +01:00
parent 769b8277f4
commit ea7b29c993
4 changed files with 158 additions and 15 deletions

View File

@ -3,3 +3,4 @@
This is a repo where I keep pd abstractions/externals I built and use regularly that will hopefully also be useful to other people. Currently it contains:
* [grid] - an I/O abstraction for monome and compatible grid controllers
* [gridkbd] - a 4ths string isomorphic keyboard for the grid

28
grid.pd
View File

@ -1,11 +1,11 @@
#N canvas 114 86 1518 875 12;
#N canvas 116 89 1518 875 12;
#X obj 435 446 netsend -b -u;
#X msg 743 296 listen 9999;
#X obj 743 365 oscparse;
#X obj 743 340 netreceive -b -u;
#X obj 435 413 oscformat sys info;
#X msg 435 382 list localhost 9999;
#X msg 577 415 connect localhost \$1;
#X msg 606 426 connect localhost \$1;
#X obj 743 390 list split 1;
#X msg 361 360 disconnect;
#X obj 783 422 list trim;
@ -16,8 +16,8 @@
#X text 809 369 list sys [whatever] \, see monome osc docs;
#X text 732 549 if the message specifies the port;
#X text 778 574 connect to recieve messages;
#X obj 211 533 oscformat;
#X obj 211 558 netsend -b -u;
#X obj 197 534 oscformat;
#X obj 197 559 netsend -b -u;
#X obj 551 239 t f b b f b;
#X msg 197 400 connect localhost \$1;
#X obj 655 637 unpack s s s f f f;
@ -29,13 +29,13 @@
#X obj 633 159 send disconnect;
#X msg 633 132 disconnect;
#X obj 551 100 t b b;
#X obj 477 357 receive disconnect;
#X obj 477 355 receive disconnect;
#X obj 839 269 receive disconnect;
#X msg 839 294 listen 0;
#X obj 589 488 receive disconnect;
#X msg 589 513 listen 0;
#X obj 783 458 route port prefix;
#X obj 58 509 receive disconnect;
#X obj 44 510 receive disconnect;
#X text 856 422 get rid of the "list" prefix;
#X obj 1003 557 list fromsymbol;
#X obj 1043 625 list tosymbol;
@ -89,12 +89,12 @@ message \, 4 parse contents of message \, 5 disconnect from serialosc.
#X connect 20 0 2 0;
#X restore 551 193 pd get-device-port;
#X obj 551 72 route connect disconnect;
#X text 220 462 Sender for OSC messages;
#X obj 232 482 r grid-message;
#X text 206 463 Sender for OSC messages;
#X obj 218 483 r grid-message;
#X obj 804 187 s grid-message;
#X obj 1043 693 symbol;
#X obj 1043 732 s grid-osc-prefix;
#N canvas 182 243 407 675 create-osc-messages 1;
#N canvas 171 251 407 675 create-osc-messages 0;
#X obj 139 53 inlet;
#X msg 47 280 set \$1 grid led set;
#X obj 83 244 symbol monome;
@ -200,8 +200,6 @@ message \, 4 parse contents of message \, 5 disconnect from serialosc.
#X connect 41 0 5 0;
#X connect 42 0 5 0;
#X restore 804 156 pd create-osc-messages;
#X text 133 125 TODO clean up more \, put things into subpatches;
#X text 133 153 TODO make create-osc-messages not be stupid;
#X msg 720 129 all 0;
#X obj 633 102 t b b;
#X connect 1 0 3 0;
@ -244,12 +242,12 @@ message \, 4 parse contents of message \, 5 disconnect from serialosc.
#X connect 41 1 39 0;
#X connect 43 0 19 0;
#X connect 44 0 29 0;
#X connect 44 1 54 0;
#X connect 44 1 52 0;
#X connect 44 2 50 0;
#X connect 46 0 17 0;
#X connect 48 0 49 0;
#X connect 50 0 47 0;
#X connect 53 0 50 0;
#X connect 54 0 28 0;
#X connect 54 1 53 0;
#X connect 51 0 50 0;
#X connect 52 0 28 0;
#X connect 52 1 51 0;
#X coords 0 875 1 874 85 60 0;

19
gridkbd-help.pd Normal file
View File

@ -0,0 +1,19 @@
#N canvas 334 503 611 419 12;
#X obj 10 11 gridkbd;
#X text 68 11 - do a 4ths string keyboard on a monome grid;
#X obj 223 63 grid;
#X msg 296 63 connect;
#X msg 37 77 disconnect;
#X text 8 32 gridkbd is a device that controls a grid to draw and decode
a 4ths-string (bass guitar like) layout on the grid. The inlet recieves
the messages as (like and ). The left outlet is midi notes and the
right outlet is note on (1) or off (0).;
#X msg 49 155 connect;
#X msg 54 178 disconnect;
#X obj 49 226 gridkbd;
#X floatatom 49 274 5 0 0 0 - - -;
#X floatatom 95 256 5 0 0 0 - - -;
#X connect 6 0 8 0;
#X connect 7 0 8 0;
#X connect 8 0 9 0;
#X connect 8 1 10 0;

125
gridkbd.pd Normal file
View File

@ -0,0 +1,125 @@
#N canvas 313 218 1296 948 12;
#X obj 547 228 grid;
#X obj 209 279 pack f f f;
#X msg 209 304 set \$1 \$2 \$3;
#X obj 241 368 s grid;
#X obj 547 170 r grid;
#X obj 209 242 r x;
#X obj 242 242 r y;
#X obj 276 241 r s;
#X obj 520 279 s x;
#X obj 559 280 s y;
#X obj 220 492 r s;
#X obj 587 280 s s;
#X text 464 469 when a key is pressed \, get the column \, subtract
7 and abs (so that the columns run bottom-top) \, multiply by 5 (to
create stacked 4ths) and add 40 (for a root note of E like a bass).
Then add the x position to that as a semitone.;
#X obj 364 222 until;
#X obj 364 279 f;
#X obj 364 304 + 1;
#X obj 388 330 div 16;
#X obj 364 199 t f b;
#X msg 500 171 all 0;
#X msg 408 222 -1;
#X obj 330 331 mod 16;
#X obj 380 495 mod 12;
#X obj 380 520 == 0;
#X obj 341 554 spigot;
#X obj 341 607 s grid;
#X obj 209 399 s draw-scale;
#X obj 364 128 r draw-scale;
#X msg 341 582 lset \$1 \$2 2;
#X obj 209 338 t b a;
#X msg 364 175 127;
#N canvas 135 140 631 431 get-note 0;
#X text 51 26 for an x and y value \, gets the note at that position
;
#X obj 113 94 inlet y;
#X obj 113 228 + 40;
#X obj 95 258 +;
#X obj 113 195 * 5;
#X obj 113 169 abs;
#X obj 95 283 outlet;
#X obj 95 70 inlet x;
#X obj 113 169;
#X obj 113 169;
#X obj 113 140 - 7;
#X connect 1 0 10 0;
#X connect 2 0 3 1;
#X connect 3 0 6 0;
#X connect 4 0 2 0;
#X connect 5 0 4 0;
#X connect 7 0 3 0;
#X connect 10 0 5 0;
#X restore 210 469 pd get-note;
#X obj 210 429 r x;
#X obj 284 429 r y;
#N canvas 132 141 631 431 get-note 0;
#X text 51 26 for an x and y value \, gets the note at that position
;
#X obj 113 94 inlet y;
#X obj 113 228 + 40;
#X obj 95 258 +;
#X obj 113 195 * 5;
#X obj 113 169 abs;
#X obj 95 283 outlet;
#X obj 95 70 inlet x;
#X obj 113 169;
#X obj 113 169;
#X obj 113 140 - 7;
#X connect 1 0 10 0;
#X connect 2 0 3 1;
#X connect 3 0 6 0;
#X connect 4 0 2 0;
#X connect 5 0 4 0;
#X connect 7 0 3 0;
#X connect 10 0 5 0;
#X restore 380 465 pd get-note;
#X obj 348 377 pack f f;
#X obj 348 402 t a a;
#X obj 380 433 unpack f f;
#X text 638 264 keyboard on the grid using the 4th string layout (like
a bass guitar).;
#X obj 467 208 inlet;
#X obj 210 553 outlet pitch;
#X obj 220 527 outlet velocity;
#X connect 0 0 8 0;
#X connect 0 1 9 0;
#X connect 0 2 11 0;
#X connect 1 0 2 0;
#X connect 2 0 28 0;
#X connect 4 0 0 0;
#X connect 5 0 1 0;
#X connect 6 0 1 1;
#X connect 7 0 1 2;
#X connect 10 0 40 0;
#X connect 13 0 14 0;
#X connect 14 0 15 0;
#X connect 15 0 14 1;
#X connect 15 0 16 0;
#X connect 15 0 20 0;
#X connect 16 0 34 1;
#X connect 17 0 13 0;
#X connect 17 1 19 0;
#X connect 18 0 0 0;
#X connect 19 0 14 0;
#X connect 20 0 34 0;
#X connect 21 0 22 0;
#X connect 22 0 23 1;
#X connect 23 0 27 0;
#X connect 26 0 29 0;
#X connect 27 0 24 0;
#X connect 28 0 25 0;
#X connect 28 1 3 0;
#X connect 29 0 17 0;
#X connect 30 0 39 0;
#X connect 31 0 30 0;
#X connect 32 0 30 1;
#X connect 33 0 21 0;
#X connect 34 0 35 0;
#X connect 35 0 23 0;
#X connect 35 1 36 0;
#X connect 36 0 33 0;
#X connect 36 1 33 1;
#X connect 38 0 0 0;