Change Slider Value via MIDI + Velocity
-
@d-healey Well, no shit. Thank you.
-
@d-healey What is the best way to get the slider to return to 0 following the release of the key? A timer?
-
@trillbilly Probably the
on note off
callback. -
Yes, I figured this out right after posting. Simple and silly.
Now, I'm trying to get the animation to happen only when certain keys are pressed. Right now Im working on C.
I've got this in my oninit:
const var slider = Content.getComponent("slider"); const var keySwitchesC = [24, 36, 48, 60, 72, 84, 96, 108, 120]; //Cs inline function cAnimation(index) { slider.setValue(value); }
And this in my onNoteOn:
function onNoteOn() { if (keySwitchesC.indexOf(Message.getVelocity())) { cAnimation(keySwitchesC.indexOf(Message.getVelocity())); } }
If I replace my onNoteon with simply this:
slider.setValue(Message.getVelocity());
The animation works as expected but on every key instead of just Cs. Where am I going wrong?
-
@trillbilly it looks like you're querying velocity instead of note number
-
@aaronventure I have swtiched from "getVelocity" to "getNoteNumber" in the onNoteOn but still does not work. The animation does nothing.
-
@trillbilly You're not passing anything to the setValue() method. Your parameters are not matching.
value
in this case isundefined
. -
@trillbilly did you actually mean this:
inline function cAnimation(index) { slider.setValue(index); }
-
It is still not functioning.
Now I've got this in on onInit:
const var slider = Content.getComponent("slider"); const var keySwitchesC = [24, 36, 48, 60, 72, 84, 96, 108, 120]; //Cs inline function cAnimation(index) { slider.setValue(index); }
And this in my onNoteOn:
function onNoteOn() { //slider.setValue(Message.getVelocity()); if (keySwitchesC.indexOf(Message.getNoteNumber())) { cAnimation(keySwitchesC.indexOf(Message.getNoteNumber()())); } }
-
@Lindon @aaronventure @d-healey
Here is a minimal snippet. It's basically everything mentioned above.
HiseSnippet 1221.3oc0W0uSabDD+NaeU3Ksnjpzp9mqh5eXjbAeDJgJTULXfHTiAKNBsRUUnk6Fauh6185cqAbihTdz5iPeTxaP6r2c125fCww0ToZI9XmcmY9MeOtSrvCRRDwFlUOcXDXX94VtC4x9s5SYbiC2yvbYq1zDIDSxHs6vHZRB3aXZV9EJBlUqXj94cOeWZ.k6AEjLLNSv7fWxBYxBpcZ9SrffCn9vor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a9RLwiFi9IXN8ENexq+M0302XkAWhpXj7uItsvSyVJC11Vi1EIEve03ijwliyGGsXugSoovQO5cENsVwTQXdOvicADLYfAajkqyTYjN0O8KSrnBWKjYVkmoYVK7vz7O+Zw.kSDCjLdu1Tr9D2UwB2E1EGg3AHR3bHPsIoYI0XfryMFs+lKv8SO723m7KcTmMyuzYzk+mniPpWr3bursQUkvKkRAsad5WdsJ9snwyDmwagZ0X0FF31cry87Tt6uC8OSmm0mCdd5bvyFyAOe+bvylyAOOaN3Yq6jG0L3cFHEYeQMLf1ty9Y8FL2mqZTjl0a7OvzVD4e
-
@trillbilly Do you see the error in the console?
-
@d-healey I messed up on naming the slider in the snippet. I have corrected it. Still does not work with the corrected slider names.
-
@trillbilly What error do you see? (Slider name seems fine to me btw)
-
@d-healey Ahh, I see what you are mentioning now. I was equating it to the wrongly named slider.
Now I see the issue is this line
cAnimation(keySwitchesC.indexOf(Message.getNoteNumber()()));
Where am I going wrong?
I've tried replacing it with
slider.setValue(Message.getVelocity());
But again, it reacts to all keys and not only C.
-
-
@d-healey Boobs!
-
@aaronventure @d-healey
I need a dunce cap and a beer because I am blind to this. Maybe I should continue banging my head on the keyboard until it works, I've done that a time or 2. -
-
@aaronventure @d-healey Yes, the boobs remark makes sense now. Now it is working on just the C but seems to be limited.
I have the slider set to min 0 - max 127 with steps 1.0.
With the new code, it doesn't surpass 3.
Should I be setting the slider up differently in this sense or am I missing something else.
-
@trillbilly You are passing the index of the array, based on the note you play. So if you play note 24 the knob will be set to 0, if you play 36 the knob will be set to 1, etc.