Closed esaruoho closed 3 years ago
looks like it needs its own private random number generator.
when painting, it will be using the standard c rand() function with a defined seed to draw the same each time, but in this case it will be called from the audio thread as well, causing it to randomly glitch.
That will make both the ui and the audio thread glitch right? Although imagine it is hard to hear that audio glitch.
The stdlib has rand_r which is reentrant but requires each thread to squirrel away the state. Guess the solution is to move to that (or some other reentrant rng but that’s a bigger change)
@baconpaul sure it will affect it, but since its just a random number it doesn't matter. We only want it to be deterministic when we are painting so we always get the same random sequence
Sigh OK this one is moderately annoying to fix.
It's easy enough to make a substitute for rand.
if( is_display )
{
std::default_random_engine engine;
engine.seed( 17 );
std::uniform_int_distribution dist( 0, RAND_MAX );
lfo_rng = std::bind( dist, engine );
}
else
{
lfo_rng = &rand
}
type thing. Then you have it as a member so the don't interfere. But then you have to plumb this down into correlated_noise_o2mk2 as the rng function to make the call there to rand a function pointer. I'm not 100% sure that it's worth it to fix this bug.
But that's how you would fix it. I'll ponder some more.
Actually I'm not sure if I see this issue at all anymore, at least on VST2 and VST3 Win. Maybe it's already fixed?
it's still there. can repro it no problem mac au. and it's still hard to fix.
Blimey. How come it doesn't happen on Windows, then?
i don't know. doesn't happen often on mac. the bug will depend on thread scheduling also so could be that on windows the audio thread isn't let back in while the separate display lfo is being sampled? lots of reasons.
Steps to replicate:
current results: S&H LFO drawing will stutter
got these results with Logic Pro X running newest build (8th January from Kzantow builds) AudioUnit.