Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial launchpad mini support #23

Open
wants to merge 10 commits into
base: vgrid_wip_apc
from
@@ -24,10 +24,14 @@ function midigrid._find_midigrid_devices()
--TODO should we use midi.vports?
for _, dev in pairs(midi.devices) do
local name = string.lower(dev.name)
for device, device_name in pairs(supported_devices) do
if name:find 'launchpad mini %d' then
table.insert(midi_devices, 'launchpadmini')
else
for device, device_name in pairs(supported_devices) do
if name == device_name then
table.insert(midi_devices, device)
end
end
end
end

@@ -143,4 +147,4 @@ function midigrid:rotation(rotate_to)
-- rotate the grid?
end

return midigrid
return midigrid
@@ -0,0 +1,43 @@
local launchpad = include('midigrid/lib/devices/generic_device')

--these are LP keys to the sides of our grid
--not necessary for strict grid emulation but handy!
--they are up to down, so 89 is the auxkey to row 1
launchpad.auxcol = {89,79,69,59,49,39,29,19}

--left to right, 91 is aux key to column 1
launchpad.auxrow = {91,92,93,94,95,96,97,98}
launchpad.quad_leds = {notes = {91,92,93,94}}

launchpad.grid_notes= {
{81,82,83,84,85,86,87,88},
{71,72,73,74,75,76,77,78},
{61,62,63,64,65,66,67,68},
{51,52,53,54,55,56,57,58},
{41,42,43,44,45,46,47,48},
{31,32,33,34,35,36,37,38},
{21,22,23,24,25,26,27,28},
{11,12,13,14,15,16,17,18}
}

launchpad.brightness_map = {0,
11,
100,
125,
83,
117,
14,
62,
99,
118,
126,
97,
109,
13,
12,
119
}

launchpad.device_name = 'launchpad_minimk3'

return launchpad
@@ -0,0 +1,25 @@
local launchpad = include('midigrid/lib/devices/launchpad_minimk3')

--Rotate the second LP, by transposing the grid notes.

--they are up to down, so 98 is the auxkey to row 1
launchpad.auxcol = {98,97,96,95,94,93,92,91}

--left to right, 89 is aux key to column 1
launchpad.auxrow = {89,79,69,59,49,39,29,19}
launchpad.quad_leds = {notes = {89,79,69,59}}

launchpad.grid_notes= {
{88,78,68,58,48,38,28,18},
{87,77,67,57,47,37,27,17},
{86,76,66,56,46,36,26,16},
{85,75,65,55,45,35,25,15},
{84,74,64,54,44,34,24,14},
{83,73,63,53,43,33,23,13},
{82,72,62,52,42,32,22,12},
{81,71,61,51,41,31,21,11}
}

launchpad.device_name = 'launchpad_minimk3_128'

return launchpad
@@ -76,9 +76,11 @@ function midigrid._find_midigrid_devices()

for _, dev in pairs(midi.devices) do
found_device = supported_devices.find_midi_device_type(dev)
print("Dev" .. dev.id .." FD "..found_device)

if found_device then mounted_devices[dev.id] = found_device end
if found_device then
print("Dev" .. dev.id .." FD "..found_device)
mounted_devices[dev.id] = found_device
end
end

print("mounted_devices")
@@ -2,10 +2,13 @@ local supported_devices = {
midi_devices = {
{ midi_base_name= 'launchpad', device_type='launchpad' },
{ midi_base_name= 'launchpad mini', device_type='launchpad' },
{ midi_base_name= 'launchpad mini 2', device_type='launchpad' },
{ midi_base_name= 'apc mini', device_type='apc_mini' },
{ midi_base_name= 'launchpad mini mk3 2', device_type='launchpad_minimk3' },
{ midi_base_name= 'launchpad mini mk3 2 2', device_type='launchpad_minimk3_128' },
{ midi_base_name= 'apc mini', device_type='apc_mini' },
{ midi_base_name= 'block 1', device_type='livid_block' },
--[[ known devices to be implemented, help required!
--[[ Known devices to be implemented, help required!
Old launchpad mini's have user set hardware ID 1 - 16:
e.g. ID 4 appears as midi_device.name "Launchpad Mini 4"
{ midi_base_name= 'launchpad mk2 ? ', device_type='launchpadmk2' },
{ midi_base_name= 'launchpad pro 2', device_type='launchpadpro2' },
{ midi_base_name: 'launchpad mk3' device_type:'launchpadmk3' },
@@ -17,14 +20,18 @@ function supported_devices.find_midi_device_type(midi_device)
print('finding device: ' .. midi_device.id .. " with name " .. midi_device.name)
local sysex_ident_resp = nil
-- TODO get response to sysex indentify call
local matched_device_type = nil
for _,device_def in pairs(supported_devices.midi_devices) do
if sysex_ident_resp and device_def.sysex_ident then
--TODO use General Sysex ident call to try and ID device

if string.lower(midi_device.name):find 'launchpad mini %d' then
return 'launchpad'
else
for _,device_def in pairs(supported_devices.midi_devices) do
if sysex_ident_resp and device_def.sysex_ident then
--TODO use General Sysex ident call to try and ID device
end
-- Fall back to midi name matching
-- TODO strip / ignore device name suffix for multiple devices
if (device_def.midi_base_name == string.lower(midi_device.name)) then return device_def.device_type end
end
-- Fall back to midi name matching
-- TODO strip / ignore device name suffix for multiple devices
if (device_def.midi_base_name == string.lower(midi_device.name)) then return device_def.device_type end
end
return nil
end
@@ -129,7 +129,9 @@ function Vgrid:set_all(z)
end

function Vgrid:refresh(device_id)
for _,quad in pairs(self.quads) do
for qid,quad in pairs(self.quads) do
--print('vgrid refresh ' .. qid)

quad:freeze_updates()

if device_id then
ProTip! Use n and p to navigate between commits in a pull request.