supercolliderjs
supercolliderjs copied to clipboard
Receiving async notifications from sclang
Hi,
I'm just getting started with supercolliderjs and I'm not clear on the best way to receive data back from sclang. For example, I would like to boot the server in sclang and receive a response in node when it has booted. This is what I tried:
const sc = require('supercolliderjs')
sc.lang.boot().then(sclang => {
sclang.on('stdout', msg => {
if (msg === 'BOOTED') {
console.log('Server Running')
}
})
sclang.interpret('s.waitForBoot({ "BOOTED".post })')
})
It works sometimes but isn't consistent which makes me think there must be a better approach.
Thanks
Yeah this mixes two different ways of working which gets confusing.
supercolliderjs has promises, and then you are running s.waitForBoot in the language.
sc.lang.boot().then(sclang => {
sc.server.boot().then((server) => {
// now you have both running
})
})
or
Promise.all([sc.lang.boot(), sc.server.boot()]).then((sclang, server) => {
// both are running
});
There could be a short cut for that one.
I hope to get some time this summer to write a lot more docs and do a new release. Questions are appreciated
When I run this I get
stderr : *** ERROR: open directory failed 'synthdefs'
I need access to synthdefs created by the class library and haven't worked directly with the server before. How do I get the same functionality as I would by booting the server from sclang?