jassert in MidiKeyboardComponent::setVelocity



using juce in debug mode, I stumbled accross this seems-to-be small bug :

file juce_MidiKeyboardComponent.cpp:210
jassert ( velocity > 0 && velocity <= 1.0f)

problem : as the class is first initialised with a velocity of zero, the assertion fails when calling setVelocity

I suggest thus

jassert (velocity >= 0 && velocity <= 1.0f);



…sorry, I don’t see why you’d set the velocity to 0? That’d just generate a stream of useless events…


Hello Jules

indeed, the velocity is initialised to 1.

But what is peculiar is that the assertion on the the member class variable velocity and not on the argument velocity_ .

So a first call with setVelocity of value 0 will pass, but the second will cause the assertion failure.
Anyway, your documentation allows value from 0 to 1

Values are 0 to 1.0, where 1.0 is the heaviest.

and your limiter does not prevent 0

I am not continuously sending velocities of 0, it is just my initial state.
Shouldn’t be allowed ?

Best regards


Ah! Doh! Yes, of course that’s a typo - I obviously meant to check the incoming value! Though TBH as the value gets clamped anyway, it’s not a very useful assertion.