Javascripting with Monome: js, node.js, grid studies, apps, etc

A simple question, since I’m not able to check it at the moment, but can at least lay out my thoughts on paper:

Is it possible to assign a variable to a single button press of the monome? That is, only that button should perform the function. I’m assuming yes, but I’m not sure how:

what would the code for this be?

I’m looking to do an if function - so if button122 is pressed, then run this… etc.

Any help would be appreciated!

http://monome.org/docs/grid-studies

there are tutorials in processing (js) and nodejs

Thank you! But unfortunately, I cannot for the life of me get nodejs to run on my laptop, while it’s good, it’s not complete in java.

all the concepts carry. that’s more the point.

1 Like

not sure what sort of roadbumps you hit trying to install nodejs, but the installer from https://nodejs.org/ should ‘just work’. though to get the monome libraries installed require some knowledge of the node package manager.

if you’re a bit new to the language there’s a free book eloquent javascript that might be helpful, though it’s pretty light on node specific practices. it will at least allow you to get a basic understanding of functions and the core features the language.

…though the code school prerequisites on the grid studies page will probably be more indepth.

1 Like

I’ve returned to working in processing seeing as artistically it does what I’m looking for. However, I’m still having problems with this little thing.

The grid-studies for processing has been helpful, as have the many tutorials I’ve ran through by this point. But I’m still having difficulties having a single button having its own functionality. That is, I can get the led to turn on for any corresponding button, but I can’t assign just one button a specific function (of its own).

Can any advice be given on breaking this down further?

how about:

void GridKeyCallback(byte x, byte y, byte z) { 
  if(x == 2 && y == 3 && z == 1)
     party();
}

when key 2,3 is pressed down, function PARTY will be called. yeah?

3 Likes

Aha! That makes sense - thank you!

I shall have a look at that book, thank you! I’ve been working through all different online/offline tutorials, so a bit of reading et al might be a nice change.

Hi, thought that I’d write it here.

I recently got a 40h and trying to integrate it within a nodejs based system. I have it up and running on Supercollider so driver/serial stuff are good.

Importing the library into the nodejs doesn’t seem to work. Maybe It’s not compatible with the latest version - or somehow outdated?

Mostly curious if the problem is on my end or not.

Thanks!

How are you running the code? Any error output from when trying to connect to your JS program?

possibly needs some updates for later node versions. i’ll run some tests and get back to you.

looks like node-serialosc is working fine. node-monome-grid, the module the grid studies are based on, is no longer working on the latest version. culprit is this module i believe:

i included it to avoid a callback and make things simpler, in hindsight probably not a good idea. if you use node v0.12 it should work. i’ll work on updating it for newer versions.

node-monome-grid is just a simple wrapper around node-serialosc anyway, and you may just want to skip it and get right into node-serialosc. link:

1 Like

I ran into this issue recently with node 8.9; in the end, I just removed uvrun-12 entirely and everything seems OK, although I appreciate I’ve opened myself up to race conditions:

so maybe there’s a better way to go about thinks. In the meantime: I appear to be javascripting with a grid, which is nice.

2 Likes

that’s great! i still need to redo node-monome-grid, but happy to hear this is working for you nonetheless.

edit: added a callback

oh, nice. a bit of me wonders if a promise might be more idiomatic than a callback… but maybe we’re all good.

i like it… maybe even a little async/await. i’ll make a few updates.

1 Like

i’m currently in a web dev bootcamp and thought i’d try my hand at programming for the monome. i tried all the steps in https://monome.org/docs/grid-studies/nodejs/ and when i get to the following part:

npm install --save easymidi

i’m given an error that i’ve pasted below

gyp ERR! configure error 
gyp ERR! stack Error: Command failed: /anaconda3/bin/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                                ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack 
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:289:12)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at maybeClose (internal/child_process.js:962:16)
gyp ERR! stack     at Socket.stream.socket.on (internal/child_process.js:381:11)
gyp ERR! stack     at Socket.emit (events.js:182:13)
gyp ERR! stack     at Pipe._handle.close (net.js:606:12)
gyp ERR! System Darwin 18.0.0
gyp ERR! command "/Users/home/.nvm/versions/node/v10.11.0/bin/node" "/Users/home/.nvm/versions/node/v10.11.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/home/Desktop/code/projects/grid-studies/node_modules/midi
gyp ERR! node -v v10.11.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm WARN grid-studies@1.0.0 No description
npm WARN grid-studies@1.0.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! midi@0.9.5 install: `node-gyp rebuild`
npm ERR! Exit status 1

npm ERR! 
npm ERR! Failed at the midi@0.9.5 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

any idea why this happens?

I personally haven’t run into this issue but after doing a little digging it seems like gyp isn’t compatible with Python 3+. Take a look at this issue: https://github.com/nodejs/node-gyp/issues/746

1 Like

so i’m in the midst of an intense programming bootcamp and we’re just getting into node.js. i’ve started the grid studies for it, but was curious if there are any actual node.js apps for the grid or not. i perused https://github.com/monome-community/collected-ms and https://monome.org/docs/app/, but i didn’t spot anything.

i suppose i could always program my own, but would love to see someone else’s work to see how i can get to similar places.

cheers!

edit: thanks to whom ever moved this under the appropriate thread.