Skip to content

Instantly share code, notes, and snippets.

@carltesta
Created March 26, 2021 23:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carltesta/5b2f67c15106a0355bcd9c4cdb2ca275 to your computer and use it in GitHub Desktop.
Save carltesta/5b2f67c15106a0355bcd9c4cdb2ca275 to your computer and use it in GitHub Desktop.
Sensel Morph Test Script
-- Sensel Morph Test Script
--
-- displays up to 4 touches
-- setup Sensel Morph for 14bit MIDI on CCs x=72, y=74, z=76
local xmsb = {0,0,0,0,0,0,0,0}
local xlsb = {0,0,0,0,0,0,0,0}
local xvalue = {0,0,0,0,0,0,0,0}
local ymsb = {0,0,0,0,0,0,0,0}
local ylsb = {0,0,0,0,0,0,0,0}
local yvalue = {0,0,0,0,0,0,0,0}
local zmsb = {0,0,0,0,0,0,0,0}
local zlsb = {0,0,0,0,0,0,0,0}
local zvalue = {0,0,0,0,0,0,0,0}
m = midi.connect()
m.event = function(data)
local d = midi.to_msg(data)
if d.ch < 5 then
if d.cc == 72 then
--print("cc " .. d.cc .. " = " .. d.val)
xmsb[d.ch] = d.val
end
if d.cc == 104 then
xlsb[d.ch] = d.val
end
if d.cc == 74 then
ymsb[d.ch] = d.val
end
if d.cc == 106 then
ylsb[d.ch] = d.val
end
if d.cc == 76 then
zmsb[d.ch] = d.val
end
if d.cc == 108 then
zlsb[d.ch] = d.val
end
xvalue[d.ch] = bit32.lshift(xmsb[d.ch],7) + xlsb[d.ch]
yvalue[d.ch] = bit32.lshift(ymsb[d.ch],7) + ylsb[d.ch]
zvalue[d.ch] = bit32.lshift(zmsb[d.ch],7) + zlsb[d.ch]
else end
end
function init()
t = metro.init()
t.count = 0
t.time = 1/200
t.event = function(stage)
redraw()
end
t:start()
end
function redraw()
screen.clear()
screen.aa(1)
for i=1,4 do
screen.stroke()
screen.circle(xvalue[i]/16383*128,64-(yvalue[i]/16383*64),zvalue[i]/16383*32)
end
screen.update()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment