@angrycrow hi!
i prefer coding in a separate text editor (like Sublime Text) and running chuck from the command line. miniaudicle is weird because you have to do this “add shred” then “remove shred” dance every time you want to run something. from command line, it’s just “chuck yourprogram.ck” and then ctrl+c+c to quit.
i taught myself by reading the language specification over and over and over and looking at other people’s programs…
chili
and life
are two examples.
via the old forum, here’s a chunk of stuff to copy+paste at the top of a program to have it ready to recognize, then receive/send commands to monome.
//osc
“/charmeleon” => string prefix;
15 => int brightness;
//initial send and receive
OscSend xmit;
xmit.setHost(“localhost”, 12002);
OscRecv recv;
8000 => recv.port;
recv.listen ();
//list devices
xmit.startMsg("/serialosc/list", “si”);
“localhost” => xmit.addString;
8000 => xmit.addInt;
;
recv.event("/serialosc/device", “ssi”) @=> OscEvent discover;
discover => now;
string serial; string devicetype; int port;
while(discover.nextMsg() != 0){
discover.getString() => serial;
discover.getString() => devicetype;
discover.getInt() => port;
;
}
//connect to device
xmit.setHost(“localhost”, port);
xmit.startMsg("/sys/port", “i”);
8000 => xmit.addInt;
//get size
recv.event("/sys/size", “ii”) @=> OscEvent getsize;
xmit.startMsg("/sys/info", “si”);
“localhost” => xmit.addString;
8000 => xmit.addInt;
getsize => now;
int width; int height;
while(getsize.nextMsg() != 0){
getsize.getInt() => width;
getsize.getInt() => height;
;
//reports twice for me – need to look into this
}
//set prefix, brightness
xmit.startMsg("/sys/prefix", “s”);
prefix => xmit.addString;
xmit.startMsg( prefix+"/grid/led/intensity", “i”);
brightness => xmit.addInt;
;
recv.event( prefix+"/grid/key", “iii”) @=> OscEvent oe;
then for tilt:
//tilt business
xmit.startMsg( prefix+"/tilt/set", “ii”);
0 => xmit.addInt;
255 => xmit.addInt;
recv.event( prefix+"/tilt", “iiii”) @=> OscEvent te;
int tilt[2];
// i set it up with an array, where tilt[0] is the current tilt position for x and tilt[1] is y. from there, the code for handling changes in tilt is much like button presses:
while (te.nextMsg() != 0){
te.getInt() => int n;
te.getInt() => int x;
te.getInt() => int y;
te.getInt() => int z;
(127-x) / (75 / (width)) => int changex;
(y-127) / (75 / (height)) => int changey;
if (tilt[0] != changex || tilt[1] != changey){
changex => tilt[0];
changey => tilt[1];
move(changex, changey);
//;
}
}
you’ll see all this stuff in triangles.ck if u poke around. happy to explain parts of the code if u have questions!