For sending a MIDI Note On on key 0 on channel 1 with a velocity of 127 on pot touch and sending a MIDI Note Off on key 0 on channel 1 with a velocity of 0 on pot release, do something like the following:
events.subscribe(POTS)
function events.onPotTouch(potId, controlId, touched)
if touched == true then
midi.sendNoteOn (PORT_1, 1, 0, 127)
else
midi.sendNoteOff (PORT_1, 1, 0, 0)
end
end
PotsToKeys =
{
-- Send note 64 when touching pot 1
64,
-- Send note 32 when touching pot 2
32,
-- You get the idea, fill the remaining 10 pots
}
function events.onPotTouch(potId, controlId, touched)
if touched == true then
-- we use potId+1 because Lua lists start at 1 but potIds start at 0
midi.sendNoteOn (PORT_1, 1, PotsToKeys[potId+1], 127)
else
midi.sendNoteOff (PORT_1, 1, PotsToKeys[potId+1], 0)
end
end
I don’t think the list is going to be useful in that scenario. Why would you want to use it?
Maybe you didn’t set the port to the one you want to use or you forgot to subscribe to the POTS event. The entire script should look like this:
events.subscribe(POTS)
function events.onPotTouch(potId, controlId, touched)
local controlset = pages.getActiveControlSet () - 1
local page = pages.getActive():getId() - 1
if touched == true then
-- we use potId+1 because Pots start at 0 while MIDI channel starts at 1
midi.sendNoteOn (PORT_1, potId+1, controlset + (page*3), 127)
else
midi.sendNoteOff (PORT_1, potId+1, controlset + (page*3), 0)
end
end
EDIT: Here’s a working preset with the code from above: Electra One App
Notes now start at C-2, is there a way to change this? the list was cool in a way you choose the notes to your desire ;-), it could be arbitrary, now its in order.
I see that changing (page*3) say to (page*1) its chromatic across pages, the same way (page*12) goes in octaves - thats nice !
Its a shame you can’t change pages while pot is touched…
I still would like Pot touched only on Page 2 notes (C2-G3-E1-F5-C3-A4) top row, and no notes on bottom row…
P.S. ohhh and what about Screen Faders affect notes touched, say CC74 ?
If you still want to control the actual note with a list, you can do something like this:
events.subscribe(POTS)
PotsToKeys =
{
-- Send note 64 when touching a pot on control set 1 on page 1
64,
-- Send note 32 when touching a pot on control set 2 on page 1
32,
-- Send note 16 when touching a pot on control set 3 on page 1
16,
-- Send note 15 when touching a pot on control set 1 on page 2
15,
-- you'll need 12 pages x 3 control sets = 36 entries in this list
}
function events.onPotTouch(potId, controlId, touched)
local controlset = pages.getActiveControlSet () - 1
local page = pages.getActive():getId() - 1
if touched == true then
-- we use potId+1 because Pots start at 0 while MIDI channel starts at 1
midi.sendNoteOn (PORT_1, potId+1, PotsToKeys[controlset + (page*3)], 127)
else
midi.sendNoteOff (PORT_1, potId+1, PotsToKeys[controlset + (page*3)], 0)
end
end
I still would like Pot touched only on Page 2 notes (C2-G3-E1-F5-C3-A4) top row, and no notes on bottom row…
You can easily add another if statement if you only want this to happen on on page 2 top row only:
if controlset == 1 and page == 1 then
-- the "if touched == true then" block from the code example above goes here
end
P.S. on and what about Screen Faders affect notes touched, say CC74 ?
events.subscribe(POTS)
PotsToKeys =
{
-- Send note 64 when touching a pot on control set 1 on page 1
64,
-- Send note 32 when touching a pot on control set 2 on page 1
32,
-- Send note 16 when touching a pot on control set 3 on page 1
16,
-- Send note 15 when touching a pot on control set 1 on page 2
15,
-- you'll need 12 pages x 3 control sets = 36 entries in this list
40,
41,
42,
43,
44,
45,
46,
47,
48,
}
function events.onPotTouch(potId, controlId, touched)
local controlset = pages.getActiveControlSet ()
local page = pages.getActive():getId()
if touched == true then
-- we use potId+1 because Pots start at 0 while MIDI channel starts at 1
midi.sendNoteOn (PORT_1, potId+1, PotsToKeys[controlset + (page*1)], 127)
else
midi.sendNoteOff (PORT_1, potId+1, PotsToKeys[controlset + (page*1)], 0)
end
end