[Feature Request] - Buttons using Velocity (Like the Kontakt Keyboard)

Hey Jean, I have a feature request. I noticed that you implemented the Keyboard to work in a similar way to the Kontakt Keyboard and velocity changes as you press on different parts of each key. That's great. However, I was wondering if you could extend that functionality with buttons.

Here's the start of a Harp. It uses a fader to control Velocity. However, doing this just makes things unrealistic as nobody would ever play a Harp (or any other instrument you could use with this). So I started thinking, "What if the buttons acted like the Kontakt keyboard and when you run you finger over the buttons, you could go higher on the buttons and it would transmit higher velocities and when running your finger lower on the buttons, they would transmit lower velocities. It would truly make this harp a dynamic instrument. Having an option to use both Velocity and CC would be even better as Virtual Instruments use CCs to go through dynamic layers (and some have both options).

Here's a screen shot and if you can imagine when running you finger over it, the buttons respond from low to high. It would be killer!

1 Like

In next version, buttons will expose the touch coordinates in their script properties as locals.touchCoords

4 Likes

You are a Prince

This seems very nice!
But unfortunatly I'm very new with open stage control and coding (like very very new...)
Could you explain how to achieve this? (where to write what...?)

Thanks a lot!

First you'll need to install the latest v1.14.3, because I broke that feature in v1.14.0 :). Then the idea is to use the button's onValue scripting property to send custom messages when it's touched:

var y = locals.touchCoords[1] // between 0 (bottom) and 1 (top)
// you could do some maths with y here
send('127.0.0.1:5555', '/address', y)

Thank you so much for replying!
But sorry for my lack of understanding, after I wrote your script in "onValue" property of the button, the velocity is still following the ones in button's on and off values (0 when off, 127 when off), wherever I touch the button...
What am I missing here?

Thanks again for your time

The button sends its on and off values by default, you can prevent that by setting bypass to true.

Ok so if set bypass to true, the button doesn't send any midi message right? So I have to send it via script, a channel, a note (or cc), a target? And make the velocity correspond to y?
Sorry I am really a noob... Am I correct here? How could I do that?

Yes, bypass will prevent the default messages from being sent. Sending midi via scripting would look like this:

send('midi:port', '/control', 1, 10, 127) // channel 1, cc 10, value 127

Ok thank you, I'm making progress...
So I tried this :

var y = locals.touchCoords[1] 

send('midi:OSC', '/note', 1, 60, y) 

And now the button is sending a note, but only with velocity 0 or 1 (0 bottom, 1 top), and it doesn't act like a push button as I want. It is sending a note when on and the when off...

Any idea?

Ok I figured one thing,

send('midi:OSC', '/note', 1, 60, y*127) 

is working. Now I just need the push behavior.

y is between 0 and 1, you probably want to multiply that number by 127 to get a proper velocity out of it.

it doesn't act like a push button as I want. It is sending a note when on and the when off...

Then you'll need some more code

var velocity
if (value == getProp('this', 'on')) { // the actual value of the widget is still defined with the on/off properties
  velocity = locals.touchCoords[1]  * 127
} else {
  velocity = 0 // velocity 0 == note off
}
send('midi:OSC', '/note', 1, 60, velocity)

Perfect! Thank you so much for your time, and thank you for open stage control.
Sorry again, I know it's basic stuff but I'm learning...

Something else...
I want the note sent to be different if another button is toggled or not. (the id of the button is Toggle)
I tried this :

var velocity
if (value == getProp('this', 'on')) { // the actual value of the widget 
  velocity = locals.touchCoords[1]  * 127
} else {
  velocity = 0 // velocity 0 == note off
}

if (get(Toggle)==1){

send('midi:OSC', '/note', 1, 63, velocity)
} else {
 send('midi:OSC', '/note', 1, 73, velocity) 
}

It doesn't work and the line say : "Toggle is not defined"
How can I call a button value in another button's script?

You must write get("Toggle"), because without quotes Toggle would be a variable (which you didn't define, hence the error).

So simple... Thanks again!

Hey jono, Are those buttons you’re using to create the note on message? And how did you assign it to a particular note/range?

Would you be able to post that harp ?