I think this might explain what was happening.
Every time a parameter changes in a SynthVoice
that uses tree data this happens:
if (change) {
pipe.writeRt(/*struct with tree query parameters*/);
Bela_scheduleAuxiliaryTask(treeQueryTask);
}
This is in the audio thread.
It is very much possible that data is sent faster than it it consumed. There can be up to 8 SynthVoice
's per track and if each track has selected the SynthVoice
type that needs tree data there are up to 40 voices. Now if all of these voices are playing, and if the parameters have modulation each voice will write into the pipe each audio block (64 samples). And if the trees are very large and thus queries take some time, it is very much possible indeed that the Pipe
is not emptied fast enough.
This means that my fix of adding usleep(0)
into the recursive tree query doesn't really solve the issue. Dropouts did decrease quite a bit with usleep(0)
but I think I still heard the occasional dropout during demonstrations at Superbooth.
Now that I'm typing up this post I realize that I don't need request new data every block, but actually once every 8 blocks or less often. I'm going to try and see if it works by simply sending requests less often.
If that doesn't work perhaps another solution would be to empty the pipe at once, look for duplicate requests or requests that have been superseded by newer requests and then process only the newest requests. Is there a way to read the messages in Pipe
in LIFO?