BUG Report: CriticalSection in MPESynthesiserBase

Hi @juceteam

There seems to be a CriticalSection used inside a real time context in MPESynthesiserBase. As far as I can see it is used to synchronise changes of the sample rate with the rendering. To be honest, I don’t quite get why this is necessary. MPESynthesiserBase setCurrentSampleRate should most likely only be called in the prepare contexts so it will be automatically in sync with renderNextBlock contexts. If this lock serves a deeper usage, you might consider using a SpinLock instead?

Looking forward to hearing your opinion on that!
Best, Rincewind

1 Like

I totally agree, that one and the one in Synthesiser are totally not needed and I’d love to see them removed. That also goes for the lock in MidiKeyboardState::processNextMidiBuffer which would need re-thinking but is also a system call in the audio path.

1 Like

+1 for MidiKeyboardState::processNextMidiBuffer

I feel like the MidiKeyboardState is actually more complicated to remove as those methods are supposed to be called from any thread (noteOn and noteOff) and have to be synchronized with the processing. The two in the Sampler could just straight up be removed.