Trying to control Reaper's virtual MIDI keyboard

Hello,

I am trying to control Reaper's virtual keyboard.

I have the keyboard widget and the address set as /vkb_midi/0/note/@

The 0 represents channel 1.

Also I set the data as integers by typing "ii" in the typeTags field.

If I open the OSC listener in Reaper, I see messages like this:

*/vkb_midi/0/note/@ [ii] 67 100 *
*/vkb_midi/0/note/@ [ii] 67 0 *
*/vkb_midi/0/note/@ [ii] 69 100 *
*/vkb_midi/0/note/@ [ii] 69 0 *
*/vkb_midi/0/note/@ [ii] 70 100 *
/vkb_midi/0/note/@ [ii] 70 0

However when recording the events in a MIDI container and displaying them as events, all the notes have all the pitchs at C-1 and the notes from the keyboard seem to be in the column dedicated to velocities.

What's the correct syntax?

Thank you in advance.

The keyboard widget sends channel, note and velocity as arguments, you need to apply some translation if want it to be formatted differently on the other end, here is a possible solution with the keyboard's onValue script (set bypass to true to prevent the default messages from being sent):

var ch = 0,
    note = id.split('/').pop(), // get note from key button's id
    vel = get(id) ? 100 : 0, // convert single key value (0 or 1) to velocity
    address = `/vkb_midi/${ch}/note/@`

send(address, note, vel) // assumes target is set

Note: just in case, "@" in the address does nothing in open stage control, it's sent as is.

2 Likes

This works for REAPER - yaay!

  1. Create a keyboard widget
  2. Set typeTags to i (or f)
  3. Set bypass to true
  4. Add below to onValue
var ch = 0,
    note = id.split('/').pop(), // get note from key button's id
    vel = get(id) ? 0 : 100, // convert single key value (0 or 1) to velocity
    address = `/vkb_midi/${ch}/note/` + note

send(address, vel) // assumes target is set
1 Like

Hi, this works great, but i doesn't send note off messages when key is released how could i solve that on OSC?

I used this fix:


var ch = 0,
    note = id.split('/').pop(), // get note from key button's id
    vel = get(this).reduce( (total,item) => total + item,0) ? 100:0,
    address = `/vkb_midi/${ch}/note/` + note
    send(address, vel) // assumes target is set

Don't know if its there a better way.

This is basically giving you the number of pressed key on the keyboard, not the state of the key, checkout the code above carefully, it works and does send note offs.