crucialfelix / supercolliderjs

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

SC3 Plugins Not Found #55

Open aricallen opened 5 years ago

aricallen commented 5 years ago

Hi, I've been playing around with this for a while now and still haven't found a good reason why the sc3 plugins are not found or any good workaround. If I run supercollider IDE the plugins are found and compiled no problem. Similarly if I connect to the running server from the sc IDE following the process outlined in this issue, the plugins are found and I can send a message to one of the SynthDefs.

But if I try to boot the server from node like normal, I always get a FAILURE IN SERVER /s_new SynthDef not found error. I also tried manually setting the ugenPluginsPath option and passed to sc.server.boot, but that didn't fix anything.

Is this a known issue or have any thoughts as to what I'm doing wrong? I'm happy to help debug this as much as I can. I'm on macOS sierra 10.14.6 but also tried on Raspbian (Debian)

Here is the complete output from my simple test trying to use the BMoog synth def.

stderr : *** ERROR: open directory failed 'synthdefs'
stdout : Number of Devices: 7
stdout :    0 : "Built-in Microph"
stdout :    1 : "Built-in Output"
stdout :    2 : "USB audio CODEC"
stdout :    3 : "USB audio CODEC"
stdout :    4 : "PIONEER XDJ-R1"
stdout :    5 : "Soundflower (2ch)"
stdout :    6 : "Soundflower (64ch)"
stdout : "Built-in Microph" Input Device
stdout :    Streams: 1
                 0  channels 2
stdout : "PIONEER XDJ-R1" Output Device
              Streams: 1
                 0  channels 4
stdout : SC_AudioDriver: sample rate = 44100.000000, driver's block size = 512
stdout : SuperCollider 3 server ready.
sendosc: {
             "oscType": "message",
             "address": "/notify",
             "args": [
               1
             ]
           }
stdout : PublishPortToRendezvous 0 5855
rcvosc : [
             "/done",
             "/notify",
             0,
             64
           ]
sendosc: {
             "oscType": "message",
             "address": "/d_recv",
             "args": [
               {
                 "type": "Buffer",
                 "data": "5343676600020196d6f6f675f74657374000193f80003e99999a000040000c2c6003c23d7a40a000c0800042100042dc003dcccccd3d4ccccd3c9dcea34080003d1efea83d8ea183d3f1b3b3cd7d3303d301ce33cb78e2d3c3be5a3ba764cd3cbe62e33cb43ad3bc546660001000000014667265710000000157436f6e74726f6c10000000100154c465361772000200010000000000ffffffff000226456e7647656e100011000100ffffffff0000ffffffff0001ffffffff0002ffffffff0000ffffffff0003ffffffff0002ffffffff0003ffffffff0004ffffffff0004ffffffff0000ffffffff0005ffffffff0006ffffffff0007ffffffff0002ffffffff0000ffffffff0006ffffffff00071c42696e6172794f705547656e200020001020001000000020000284c464e6f6973653110001000100ffffffff0000164d756c4164641000300010000040000ffffffff0008ffffffff00091b556e6172794f705547656e1000100010110005000015424d6f6f67200040001000003000000060000ffffffff000affffffff000228416c6c706173734e2000400010000070000ffffffff000bffffffff000cffffffff000d28416c6c706173734e2000400010000080000ffffffff000bffffffff000fffffffff000d28416c6c706173734e2000400010000090000ffffffff000bffffffff00011ffffffff000d28416c6c706173734e20004000100000a0000ffffffff000bffffffff00013ffffffff000d28416c6c706173734e20004000100000b0000ffffffff000bffffffff00015ffffffff000d28416c6c706173734e20004000100000c0000ffffffff000bffffffff00017ffffffff000d28416c6c706173734e2000400010000070000ffffffff000bffffffff000effffffff000d28416c6c706173734e20004000100000e0000ffffffff000bffffffff00010ffffffff000d28416c6c706173734e20004000100000f0000ffffffff000bffffffff00012ffffffff000d28416c6c706173734e20004000100000100000ffffffff000bffffffff00014ffffffff000d28416c6c706173734e20004000100000110000ffffffff000bffffffff00016ffffffff000d28416c6c706173734e20004000100000120000ffffffff000bffffffff00018ffffffff000d234f757420003000000ffffffff0002000d000000013000000"
               },
               null
             ]
           }
stdout : exception in GraphDef_Recv: UGen 'BMoog' not installed.
rcvosc : [
             "/done",
             "/d_recv"
           ]
sendosc: {
             "oscType": "message",
             "address": "/s_new",
             "args": [
               "moog_test",
               -1,
               1,
               0,
               "freq",
               329.6275569128699
             ]
           }
stderr : *** ERROR: SynthDef moog_test not found
           FAILURE IN SERVER /s_new SynthDef not found
rcvosc : [
             "/fail",
             "/s_new",
             "SynthDef not found"
           ]
error  : [
             "/fail",
             "/s_new",
             "SynthDef not found"
           ]

here's the node script:

const ServerPlus = require('supercolliderjs/lib/server/ServerPlus.js').default;
const path = require('path');
const sc = require('supercolliderjs');
const { msg, map } = require('supercolliderjs');

const def = {
  name: 'moog_test',
  path: path.join(__dirname, 'synthdefs/bmoog.scd'),
};

const run = async () => {
  // WORKS must also increase max users in scide `s.options.maxLogins = 8;`
  // const server = await new ServerPlus().connect();

  // doesnt work
  const server = await sc.server.boot();

  // load scd files
  try {
    await server.loadSynthDef(def.name, def.path);
  } catch (err) {
    console.log(err);
  }
  const myMsg = msg.synthNew(def.name, -1, msg.AddActions.TAIL, 0, {
    freq: map.midiToFreq(64),
  });
  server.send.msg(myMsg);
};
run();
aricallen commented 5 years ago

I'll add that I am able to load and send messages to native UGen/SynthDefs from supercolliderjs as expected. This is only a problem when trying to send messages to a plugin synth.

crucialfelix commented 5 years ago

I just did a quick test myself running a synthdef with BMoog. It worked both in the IDE and using supercollider.js

Basically the same code as you have above: a simple compile synthdef and spawn a synth.

It worked.

But not for you.

If ugensPluginsPath is null then it should use the default paths which includes the Extensions folder.

It's odd that you tried setting it explicitly and it still didn't work.

I just tried it and got: stdout : exception in GraphDef_Recv: UGen 'Control' not installed. which makes sense because I just set ugensPluginsPath to Extensions and now the main class library is no longer included.

ugenPluginsPath should be null, string or array of strings.

aricallen commented 5 years ago

Thanks for the response. With your suggestions I was finally able to get it to work by specifying a : delimited string of paths like ${Platform.userExtensionDir}:${Platform.resourceDir}.

But it is still curious why I would need to specify it at all. My app lives where you'd expect.

➜  SuperCollider.app pwd
/Applications/SuperCollider/SuperCollider.app

Here are some more outputs from the IDE in case you may see where the problem is?

Platform.userExtensionDir
// -> /Users/[myusername]/Library/Application Support/SuperCollider/Extensions

Platform.resourceDir
// -> /private/var/folders/rs/c7w3mxnj27z8slhx3fm_1c8r0000gp/T/AppTranslocation/39C29491-032B-4A48-91B8-D57ED80038CC/d/SuperCollider.app/Contents/Resources

Platform.systemAppSupportDir
// -> /Library/Application Support/SuperCollider

Platform.userAppSupportDir
// -> /Users/[myusername]/Library/Application Support/SuperCollider

Because the Platform.resourceDir seems unpredictable... can you think of a way I could retrieve that from the node script before booting the server?