[Method] Synth.getNumPressedKeysInRange
-
The existing method Synth.getNumPressedKeys is cool and all, but if the instrument features keyswitching, it's useless.
Custom solution is to loop through the given range calling Synth.isKeyDown(), but benchmarking shows it's around 72x slower than Synth.getNumPressedKeys. Given how this would be used primarily in real-time situations, I think a native implementation would be good.
-
@aaronventure or you just increase / decrease a counter on the onNoteOn / onNoteOff with a range filter. The native solution also isn‘t looping through all 127 notes.
-
@Christoph-Hart Right, I was thinking of the issues around the MIDI processing order we talked about yesterday. But after reading your post, it just occurred to me that I can implement exactly that, it'll just have to be added to every Script Processor.
Still getting used to this, sorry :face_with_tongue:
-
@aaronventure put it in an external file and include that in every script processor, then it shouldn't be much overhead.
If the logic is the same and there are only a few parameters that change (eg. the exact range), then you might also connect the script processors to an external file and set the range via two knobs on the script interface.
-
@Christoph-Hart I already have a "Configuration" processor where I put in all these instrument specifications as constants and simply pull the data from there wherever I need it.
Good to hear I got the right idea ;)
-
@aaronventure You might want to roll your own solution anyway because there is (maybe was) an issue with
getNumPressedKeys
. If I recall the function isn't actually returning the number of keys physically held down but uses some kind of counter.https://forum.hise.audio/topic/193/fade-out-and-numpressedkeys?_=1701793106892
-
@d-healey Yeah, will have my own counter. Overhead is non-existent and it's always correct.