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

**URL:** <https://forum.csound.com/t/throttling-in-csoundgetcontrolchannel-of-the-api/812>\
**Category:** Developers\
**Created:** [August 11, 2022, 1:00pm UTC](https://forum.csound.com/t/throttling-in-csoundgetcontrolchannel-of-the-api/812 "2022-08-11T13:00:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JasonHallen](https://forum.csound.com/user_avatar/forum.csound.com/jasonhallen/32/32_2.png) [@JasonHallen](https://forum.csound.com/u/JasonHallen)\
**Post date:** [August 11, 2022, 1:00pm UTC](https://forum.csound.com/t/throttling-in-csoundgetcontrolchannel-of-the-api/812/1 "2022-08-11T13:00:02Z")

</div>

Hi everyone,

As I was experimenting with Nate Whetsell’s [`csound-api` package](https://www.npmjs.com/package/csound-api) in Node.js I ran into surprising behavior with his `.GetControlChannel()` method. I reported [the issue in his GitHub repository](https://github.com/nwhetsell/csound-api/issues/22) 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

---

<div class="post-metadata">

**Author:** ![rory](https://forum.csound.com/user_avatar/forum.csound.com/rory/32/7_2.png) [@rory](https://forum.csound.com/u/rory)\
**Post date:** [August 11, 2022, 1:42pm UTC](https://forum.csound.com/t/throttling-in-csoundgetcontrolchannel-of-the-api/812/2 "2022-08-11T13:42:58Z")

</div>

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:

```csound
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()`.

---

<div class="post-metadata">

**Author:** ![JasonHallen](https://forum.csound.com/user_avatar/forum.csound.com/jasonhallen/32/32_2.png) [@JasonHallen](https://forum.csound.com/u/JasonHallen)\
**Post date:** [August 12, 2022, 1:49am UTC](https://forum.csound.com/t/throttling-in-csoundgetcontrolchannel-of-the-api/812/3 "2022-08-12T01:49:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rory](https://forum.csound.com/user_avatar/forum.csound.com/rory/32/7_2.png) [@rory](https://forum.csound.com/u/rory)\
**Post date:** [August 13, 2022, 9:05am UTC](https://forum.csound.com/t/throttling-in-csoundgetcontrolchannel-of-the-api/812/4 "2022-08-13T09:05:45Z")

</div>

> [@JasonHallen](#):
>
> .PerformKsmpsAsync()

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