Trigger notes with xy pad?

I was thinking of making an interface where i could make an xy pad send a midi note when i touch it. Is there any code i can put in the OnTouch section in the scripting of the xy pad that can send a note?

1 Like

Hi,

In the OnTouch param, you can add a script like the following:

let channel = 1
let note = Math.round(value[0])
let velocity = Math.round(value[1])

if (event.type === "start") {
    send("midi:YOURMIDINAMEHERE", "/note", channel, note, velocity)
    send("midi:YOURMIDINAMEHERE", "/note_off", channel, note, 0)
}

if (event.type === "stop") {
  send("midi:cubaseInstrument", "/note_off", channel, note, 0)
}

I can't recall why I have the extra note_off, I believe it's cause I was getting stuck notes. Nonetheless, here is a basic script idea you can run with.

Just remember to set your xypad to output 0-127 (or 1-128?, can't remember how midi note numbers convert)

Cheers,
DMDComposer

2 Likes

Other solution based on your idea :

in onValue :

let channel = 1
let note = Math.round(value[0])
let velocity = Math.round(value[1])

    send("midi:virtual_midi", "/note", channel, note, velocity)
    //send("midi:virtual_midi", "/note_off", channel, note, 0)

in onTouch :

let channel = 1
let note = Math.round(value[0])
let velocity = Math.round(value[1])

if (event.type === "start") {
    //send("midi:virtual_midi", "/note", channel, note, velocity)
    //send("midi:virtual_midi", "/note_off", channel, note, 0)
}

if (event.type === "stop") {
  for (let i = 0; i < 127; i++){
  send("midi:virtual_midi", "/note_off", channel, i, 0)
  }
}

I want the notes to hold for as long as i hold. if i remove the middle line the notes just never stop even if move the xy and let go. Is it possible to do what i want?