Throttling in `.csoundGetControlChannel()' of the API?

Hi everyone,

As I was experimenting with Nate Whetsell’s csound-api package in Node.js I ran into surprising behavior with his .GetControlChannel() method. I reported the issue in his GitHub repository where you can read the details.

Nate demonstrated that this is actually behavior of the Csound API itself and is independent of Node.js or his csound-api package.

Is it correct that the .csoundGetControlChannel() method of the Csound API can only output different control signal values at a rate of approximately 10 per second? Again, please see the full details in the GitHub issue linked above.

It’s very likely that I’m misunderstanding something, so please enlighten me if you’d be so kind.

Thanks!
Jason

If instead of running Csound in a separate thread, one calls csound->PerformKsmps() in a loop, I think it will behave as you imagine it should:

while(csound->PerformKsmps()==0)
{
    MYFLT meterValue = csoundGetControlChannel(csound, "meter", NULL);
    printf("%.17f\n", meterValue);
}

As far as I am aware, there is a yield callback that can be set when running Csound in a separate thread. This gets called on each k-boundary. That would be the place to call csoundGetControlChannel().

Thanks so much for the response, Rory! Your point about using PerformKsmps() made me realize there’s a .PerformKsmpsAsync() method in csound-api. I need to run the performance in another thread so that it doesn’t block the main Node.js thread, so the async option was ideal.

This allowed me to insert the .GetControlChannel() call into the yield callback at each k-boundary. It increased the transmission rate of .GetControlChannel() from about 10 values per second to about 26 values per second. That’s better, but it’s still slower than I thought I’d get in the Node.js environment. Nate suspects it has to do with a function in Node.js’s underlying libuv library.

I appreciate your help!

Jason

Perfect. I don’t think that function is part of the C interface. Nate probably implemented something based on the other yield callbacks. Nice :slight_smile: