FR: beginChangeGesture/endChangeGesture improvement

AudioProcessorParameter::beginChangeGesture is using isPerformingGesture flag to detect (in debug build) if beginChangeGesture has already been called and asserts if it has happened. This works fine in most cases.

I suggest to replace that flag with a counter that is incremented in beginChangeGesture and decremented in endChangeGesture. begin/end messages would only be sent when the counter is one.

This would allow multiple components (or MIDI routing) to control the same parameter at the same time without asserts (and extranous host-plugin messages). This can easily occur ie. when a parameter is adjusted at the same time from eg. a slider and external MIDI.

Example scenario:

Slider mouse down -> beginChangeGesture
MIDI input -> beginChangeGesture -> setValueNotifyingHost -> endChangeGesture
Slider mouse up -> endChangeGesture

With the current JUCE implementation we get an assert when we receive MIDI assigned to the parameter on the second line.

  • Jussi