JUCE Synthesiser and Sostenuto Pedal - Please add this

If a player adds some notes under sostenuto pedal, then additionally uses the sustain pedal for some other notes and releases the sustain pedal, the notes under the sostenuto pedal shouldn’t be stopped.

@JUCE Team
Could you add here:

void Synthesiser::handleSustainPedal (int midiChannel, bool isDown)

this little if-addition:

if (! (voice->isKeyDown() || voice->sostenutoPedalDown))
                    stopVoice (voice, 1.0f, true);

instead of before:

if (! voice->isKeyDown())
                    stopVoice (voice, 1.0f, true);

Then it works like expected.


Yep, sounds sensible, I’ll take a look at that. Thanks!

One addition:

void Synthesiser::handleSostenutoPedal (int midiChannel, bool isDown)

it would avoid problems, if you’d only set sostenutoPedalDown = true for voices, whose key is down - e.g. some voices could already be in release or they haven’t been started on noteOn()

if (isDown) {
     if (voice->isKeyDown ())
         voice->sostenutoPedalDown = true;
else if...

I aske because once more


is a private member of voice and can’t be accessed from Synthesiser::

virtual void handleSostenutoPedal (int midiChannel, bool isDown) 

It would be handy to get another setter here (like the setKeyDown() you just added).
The same is true for


For the latter we would also need a setter for the private BigInteger Synthesiser::sustainPedalsDown…

FYI I’ve added some setter methods for this. Should be on develop soon.

Not sure about providing access to the BigInteger though, that’s really intended as more of a mirror for the actual midi stream state.

Thank you for this, too. I understand, that the BigInteger is an edge case. I would allow it nevertheless, because it’s not possible to get rid of Synthesiser::handleSustainPedal () - which contains a lock - without having access.

No, I really don’t want to open up internals like that, it’s just not something that should be public. Can you think of any other ways to get the result you need?

Yes, at the moment it’s ok for me to call Synthesiser::handleSustainPedal (int midiChannel, bool isDown) from my virtual one.