crucialfelix / supercolliderjs

The JavaScript client library for SuperCollider
https://crucialfelix.github.io/supercolliderjs/
MIT License
478 stars 43 forks source link

Interpreting SC code that exports a sound file #106

Open SamKomesarook opened 3 years ago

SamKomesarook commented 3 years ago

Hello, thanks for the library!

What is the best way to pipe an audio signal into an external file using the API? The way I am attempting to do so at the moment is to boot the lang:

const sclang = await sc.lang.boot();

and then run the following:

result = await sc_lang.interpret(`( 
          {
          ({RHPF.ar(OnePole.ar(BrownNoise.ar, 0.99), LPF.ar(BrownNoise.ar, 14) * 400 + 500, 0.03, 0.003)}!2) + ({RHPF.ar(OnePole.ar(BrownNoise.ar, 0.99), LPF.ar(BrownNoise.ar, 20) * 800 + 1000, 0.03, 0.005)}!2) * 4
          }.play;
          s.record(duration: 3);
          )`);

If the interpreted code above is run in the SC IDE, it outputs an .aiff in a certain directory. However, the code as run above outputs nothing.

I thought this was because scsynth wasn't running, but when I try to boot it up immediately after sclang, I get the following error:

*** ERROR: failed to open UDP socket: address in use.

That is a separate issue I can try to debug, but I was curious if I was even on the right track for what I am trying to accomplish...

Thank you!