d.healey last edited by d.healey
I'm trying to improve my breath controller script. It works like this, the user presses a key and blows into their breath controller, when the CC value crosses a threshold a note is played for the key that is held. When the key is released or the CC drops below the threshold the note is killed.
This I can do no problem.
Now I'm trying to do it polyphonicaly so that the user can hold any number of keys, and this is where I'm having difficulty. My current attempts have been using a MIDI list to keep track of held notes and a MIDI list to keep track of note IDs. Then in a loop I check every single note to see if it's held or playing (depending on the CC and keydown status).
The problem I'm having is a)
Synth.getNumPressedKeys()is a liar (it actually uses a note on/off counter from what I understand) and b) using a loop in the MIDI callbacks seems like a bad idea.
Is there an obvious solution that I'm missing?
Also, what does
Synth.addNote()do? I understand it adds a note to the buffer but how would one use this? And how do we determine the timestamp?
dustbro last edited by
what does Synth.addNote() do?
It's hard to tell. From what I read on the JUCE site, the variables are (channel, note, velocity). Not sure what the timestamp is for.
dustbro last edited by dustbro
My first thought is to create an array and use the Push command to send the note numbers to the array, and then use the Pop command on your noteOff to remove them from the array... but I don't think that function exists in HISE.
@Christoph-Hart is there an equivalent to Pop in HISE that can remove items from an array?
edit: after readying a little more, pop only removes the last element from an array... so that' not exactly helpful
@dustbro That's essentially what I'm doing with MIDI lists. Rather than use push/pop though I'm setting the note to true/false.
dustbro last edited by
I'm setting the note to true/false
And they don't change to False when you release the note? or they continue to play even though they are set to false?
I still got my training wheels on, so I'm trying to fully understand the problem (and solution)
@dustbro I'll put a snippet together
@Christoph-Hart I just discovered that you can't set a MIDI list entry's value to -1. This seems like a bug.
@dustbro I've solved the issue now I figured out the problem with MIDI lists.
Here's my breath controller script - https://raw.githubusercontent.com/davidhealey/HISE-Scripting-Framework/master/modules/breathControl.js
Rather than using a specific CC it has a Level knob that you can control from your main interface whichever way you like. This also avoids the issue of putting loops inside the MIDI callbacks.
Unfortunately I haven't been able to make it work with the hardcoded legato script or my own legato script.