Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Receiving async notifications from sclang #39

Open
jamesopstad opened this issue Apr 10, 2018 · 2 comments
Open

Receiving async notifications from sclang #39

jamesopstad opened this issue Apr 10, 2018 · 2 comments

Comments

@jamesopstad
Copy link

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

@crucialfelix
Copy link
Owner

crucialfelix commented Apr 12, 2018

Yeah this mixes two different ways of working which gets confusing.

supercolliderjs has promises, and then you are running s.waitForBoot in the language.

two horses

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

@jamesopstad
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants