gogins / csound-webserver-opcodes

The "webserver" opcodes enable Csound to act as a local Web server that can host HTML5 GUIs and score generators.
GNU Lesser General Public License v2.1
0 stars 0 forks source link

csound.ScoreEvent function does not work #22

Closed gogins closed 2 years ago

gogins commented 2 years ago

This is reported by Jason Hallen.

Hi Mike,

I'm trying to use the ScoreEvent method in this way:

if (test_button.status === 1) { (async () => { await csound.ScoreEvent('i', [1, 0, -1]); })(); }

However, I'm getting this error and explanation:

POSThttp://localhost:8080/ScoreEvent [HTTP/1.1 500 Internal Server Error 2ms] [json.exception.type_error.302] type must be number, but is string

Am I not formatting the ScoreEvent parameters correctly or constructing the function correctly? I'll admit that I'm not strong on the concept of async functions, so I'm just following the lead from your bare-test.csd file.

gogins commented 2 years ago

The issue is not async, either a sync call or an async call will work in this context.

I had a bug in my code in that my JSON parser for char (the type of the score opcode) was not doing what I expected. I changed it to parse std::string and now it works fine.

Thanks for the report.