VCVRack / VCV-Prototype

Other
130 stars 23 forks source link

Multiple instances at the same time? #11

Closed teknico closed 4 years ago

teknico commented 4 years ago

Are multiple instances supposed to be working at the same time?

A single instance works beautifully, and my script takes ~10% CPU. If I activate another instance (polyphony 2) I hear occasional scratching noises. With four instances I get a lot more, and with eight the noise is almost constant.

Does the Javascript interpreter use any global state that makes it unsafe to use in a concurrent environment?

AndrewBelt commented 4 years ago

As far as I know, Duktape (the JavaScript engine) is completely thread-safe and independent. I couldn't reproduce this by using 2-4 instances of a script with 10% CPU.

teknico commented 4 years ago

Here is a patch that reproduces the problem for me (sorry for the cable mess).

When I load it on Ubuntu 19.04 under JACK, I get ongoing xruns but can still play it with a keyboard and hear one note with some noise.

If I then increase the polyphony setting in MIDI-CV and enable more Prototype modules, the noise increases and the patch becomes unplayable.

AndrewBelt commented 4 years ago

Can't reproduce the behavior using your patch until enabling all 8 Prototypes.

teknico commented 4 years ago

Interesting. So you get no glitches at all with less than eight, and then a little or a lot of noise with eight?

AndrewBelt commented 4 years ago

7 was perfectly fine. 8 hit the audio buffer deadline, so a hiccup was inserted every buffer, as expected.

teknico commented 4 years ago

I see. Thanks for checking.

teknico commented 4 years ago

I tried on a Mac and the behavior is as you got, so it's definitely a problem with my Linux notebook.

8 hit the audio buffer deadline, so a hiccup was inserted every buffer, as expected.

Could you please add some detail to this? Not sure what you mean.