# Midi Note with velocity

**URL:** <https://forum.electra.one/t/midi-note-with-velocity/3656>\
**Category:** Developers\
**Created:** [April 22, 2025, 7:10pm UTC](https://forum.electra.one/t/midi-note-with-velocity/3656 "2025-04-22T19:10:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![flonky](https://avatars.discourse-cdn.com/v4/letter/f/ecc23a/32.png) [@flonky](https://forum.electra.one/u/flonky)\
**Post date:** [April 22, 2025, 7:10pm UTC](https://forum.electra.one/t/midi-note-with-velocity/3656/1 "2025-04-22T19:10:47Z")

</div>

Hi, I’m trying to build a preset for changing the keyswitches of the Cinematic Studio Series. I want to do it by keyswitches but I need to specify not only the Note Number but also the velocity number. Can anyone guide me thru a button that sends a specific Note Number with a specific velocity value? I think I need Lua but I never touched the Lua -side of the E1…

---

<div class="post-metadata">

**Author:** ![NewIgnis](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.electra.one/newignis/32/767_2.png) [@NewIgnis](https://forum.electra.one/u/NewIgnis)\
**Post date:** [April 23, 2025, 4:05pm UTC](https://forum.electra.one/t/midi-note-with-velocity/3656/2 "2025-04-23T16:05:39Z")

</div>

I assumed you want to use a pad for this, right?

Normally, you could use a pad with a momentary toggle with message type “Note”, but then you cannot control the velocity.

Therefor, you need to create a toggle of message type **Virtual** or None, and assign it a LUA function. Let’s assume you want it to use note 60 and velocity 78, you could:

- assign 60 as On Value to the Control toggle
- create a function **note78** and add some LUA to it.
- 

The lua comes in two parts: first you set some initialising variables, so you don’t have to redo your code if for instance you change the MIDI channel or the port your preset is used for.

Do this by entering the following in lua :

```auto
local deviceId = 1 -- the device ID used in the E1 preset
local device = devices.get(deviceId)
local devPort = device:getPort()
local devChannel = device:getChannel()

```

Then you create your function **note78** that will send the noteOn when you press the toggle (value = On Value, which is \> 0) , and noteOff when you stop pressing (value = Off Value, which is 0):

```auto
function note78(valueObject, value)
    if value> 0 then
        midi.sendNoteOn(devPort, devChannel, value, 78)
      else
        midi.sendNoteOff(devPort, devChannel, value, 78)
    end
end

```

So LUA would look like:

 ![image](https://europe1.discourse-cdn.com/flex017/uploads/electraone/original/2X/4/44d84f1e6a690b998a709a28bcd08ce35698c2a5.png)

and the toggle could look like:

 ![image](https://europe1.discourse-cdn.com/flex017/uploads/electraone/original/2X/2/265e8f122f5eba3efc08a20ac98a0d2caf8471b7.png)

Try it out
