I know this is not actually for this board. But I’m hoping one of you had already tried a similar thing and maybe want to share how they achieved it.
I’m not at all a very good programmer a more technical guy. But I’m still trying this because I want to finish something that at least works.
Soo any help is very appreciated.
Info: I have got a working tool to find data (numbers) and pull it to my terminal in node.js. The program checks every 10 min for a new pull.
I want to use the pulled numbers and divide them with 540. So for example the pull gave me x / 540 = y.
The following last step is to send an osc message a simple (bang in maxmsp terms) alert to sonic pi for every second y is.
But I’m unable to first get it wrapped up in my head how to exactly do that. I know I should use setinterval.
Secondly and most important. I can’t seem to install npm i osc in to raspberry pi.
Any body who got this to work?? Because this is needed to communicate with Sonic Pi which is my eandgoal in this project.
how to use osc with npm via the osc npm package ? which version of raspberry pi ? which os on it ?
could you draw a scheme of your installation ? Which machine ? wich role ? which softwares ? what do you want ? Max send to ***** ? sonic pi receives from ???
@nlb ok I’ll try to explain it as good as possible bear with me
Version Raspberry Pi :
Linux raspberrypi 4.19.97-v7l+ #1294 SMP Thu Jan 30 13:21:14 GMT 2020 armv7l GNU/Linux
Buster latest
I can’t install the node js osc package on this raspberry pi without getting loads of errors.
I want to send a message from a js script to sonic pi. The message should just be a “signal” (I’ve compared it with a bang like in max msp) when this osc message is received in Sonic Pi I would translate it to run a sound in an array to a speaker.
The last part is no problem. But I can’t get the signal to be send to sonic pi from the js script.
The whole process would run from one single pi. The osc message would be send internally thus.
In that case, yes, quite likely. (At least as far as Sonic Pi itself is concerned). The version that came with the Pi is incomplete, as it was a build created externally, outside of Sam’s control. (OSC and MIDI do not work).
The latest official version of Sonic Pi is 3.2.2 - @robin.newman has kindly created a Raspberry Pi package for this: http://r.newman.ch/rpi/sonic-pi-3.2.2/ (it will only work on Raspbian Buster).
Give that a go, and hopefully it works for you
Once that’s working, it’s just a matter of getting the javascript set up.
But I reinstalled everything and know the package is in my node-modules.
So I thought just try the example and see if that works. When importing the library with node and running it, it gave me no errors. But then I tried the example code and got following error:
code:
var osc = require("osc");
var udpPort = new osc.UDPPort({
// This is the port we're listening on.
localAddress: "127.0.0.1",
localPort: 57121,
// This is where sclang is listening for OSC messages.
remoteAddress: "127.0.0.1",
remotePort: 57120,
metadata: true
});
// Open the socket.
udpPort.open();
// Every second, send an OSC message to SuperCollider
setInterval(function() {
var msg = {
address: "/hello/from/oscjs",
args: [
{
type: "f",
value: Math.random()
},
{
type: "f",
value: Math.random()
}
]
};
console.log("Sending message", msg.address, msg.args, "to", udpPort.options.remoteAddress + ":" + udpPort.options.remotePort);
udpPort.send(msg);
}, 1000);
error:
events.js:292
throw er; // Unhandled 'error' event
^
Error: bind EADDRINUSE 192.168.1.23:4559
at dgram.js:337:20
at processTicksAndRejections (internal/process/task_queues.js:85:21)
Emitted 'error' event on instance at:
at Socket.<anonymous> (/home/pi/Tools-for-Instagram/node_modules/osc/src/platforms/osc-node.js:79:18)
at Socket.emit (events.js:327:22)
at dgram.js:339:14
at processTicksAndRejections (internal/process/task_queues.js:85:21) {
errno: -98,
code: 'EADDRINUSE',
syscall: 'bind',
address: '192.168.1.23',
port: 4559
Not sure what you are trying to do here, but I can definitely help with the error - it says that it cannot listen on port 4559 because there is something else attached to it.
If you want to know what that is, just run a lsof -i -P | grep 4559 as root.
Whoops missed that one! Successfully installed it but nothing happens.
Weird thing is that I can’t change anything about the arguments or the code breaks. If I change the f type it breaks if I change the value to whatever it also breaks.