crucialfelix / API

simple Application Programming Interface framework for inter-application communication with SuperCollider
17 stars 3 forks source link

JSON parsing doesn't seem to handle arrays #1

Closed brianfay closed 9 years ago

brianfay commented 9 years ago

I would like to be able to pass arrays from javascript to SC, so that they could be used for things like arguments for a synth. If I use this handler:

newSynth: { arg reply, targetGroup, defName ... argsFromJs; var synth = Synth(defName, target:nodeDict.at(targetGroup), args: argsFromJs, addAction:'addToHead'); nodeDict.put(synth.nodeID, synth); reply.value(synth.nodeID); }

and my request from supercolliderjs is something like this: var res = yield callSC('triggerfish.newSynth',[1000, "mySynth","freq", 1000, "inBus", 0, "outBus", 1]);

Then everything is fine.

But it I pass an array for some of the buffers: var res = yield callSC('triggerfish.newSynth',[1000, "mySynth","freq", 1000, "inBus", [0, 1], "outBus", 1]);

It breaks - sclang actually does not format the response correctly and scjs throws an exception and dies (see my pull request in supercolliderjs). https://github.com/crucialfelix/supercolliderjs/pull/13

brianfay commented 9 years ago

Just realized that I'm using the old API from svn, so that could be part of the problem. I'll try again on sc 3.7

brianfay commented 9 years ago

Installed 3.7 and got the right version of API from git. It seems like this is actually working and I gave a false report - I need to do a little more testing to make sure it's definitely doing the right thing with the arrays, but it's not crashing the app like it was earlier!

brianfay commented 9 years ago

Alright, I've messed around a bit more with this, and I don't think this is a problem (the version on SVN is out of date, this version on git seems to work).

I'm enjoying a nice ping-pong delay right now, the arrays were set from javascript!

Sorry for the false issue, closing now.

crucialfelix commented 9 years ago

good to hear

On Mon, Apr 20, 2015 at 6:27 AM Brian Fay notifications@github.com wrote:

Closed #1 https://github.com/crucialfelix/API/issues/1.

— Reply to this email directly or view it on GitHub https://github.com/crucialfelix/API/issues/1#event-284898608.