--[[---------------------------------------------------------------------------- -- Duplex.APC40MKII ----------------------------------------------------------------------------]]-- --[[ Inheritance: APC40MKII > MidiDevice > Device A device-specific class, valid for Akai APC40MKII models --]] --============================================================================== class "APC40MKII" (MidiDevice) function APC40MKII:__init(display_name, message_stream, port_in, port_out) MidiDevice.__init(self, display_name, message_stream, port_in, port_out) -- set device to "mode 1" self:send_sysex_message(0xF0,0x47,0x01,0x29,0x60,0x00,0x04,0x41,0x00,0x00,0x00,0xF7) -- define a default colorspace self.colorspace = {0xFF,0xFF,0xFF} end -------------------------------------------------------------------------------- --- override default Device method -- @see Device.output_boolean -- value: -- 0: off, 1: white, 2: blink, 3: white, 4: lachs, -- 5: red -- 9: yellow, 10: dark yellow, 11: cold yellow -- 13: yellowGreen, 14: darker yellowGreen, 15: darker -- 17: green neon, 18: green, 19: darker green, 20: mint, -- 21: green dark, 22: green darker, 23: green darker, 24: mint -- 29: turquoise, 30-31 darker -- 37: light blue -- 41: blue -- 49: pink, 53: neon pink -- 60: orange, -- 63: green neon, -- 64: green, -- 65: turquoise, -- 66: light blue, 67: blue, 68: mint, 69: flida, 72: red, 74: yellow, -- 75: l green, 76: green, 77: turquoise -- 67: blue like solo buttons -- 60: organge like dials function APC40MKII:output_boolean(pt,xarg,ui_obj) local value = nil local color = self:quantize_color(pt.color) -- use the local colorspace if it's available local colorspace = xarg.colorspace or self.colorspace if (colorspace[1]>1) then -- clip launch buttons can have multiple colors local red_dark = (pt.color[1]==0x40) local red = (pt.color[1]==0x80) local red_light = (pt.color[1]==0xFF) local green_dark = (pt.color[2]==0x40) local green = (pt.color[2]==0x80) local green_light = (pt.color[2]==0xFF) local blue_dark = (pt.color[3]==0x40) local blue = (pt.color[3]==0x80) local blue_light = (pt.color[3]==0xFF) value = 0 -- off as default if red then value = 5 elseif red_dark then value = 7 elseif red_light then value = 8 end if green then value = 64 elseif green_dark then value = 66 elseif green_light then value = 67 end if blue then value = 41 elseif blue_dark then value = 43 elseif blue_light then value = 44 end if red and green then value = 60 -- orange end if red_light and green_light then value = 74 -- yellow end if red_dark and green_dark then value = 62 -- dark orange end if red and blue then value = 50 -- lila end if red_light and blue_light then value = 53 -- pink neon end if red_dark and blue_dark then value = 69 -- flida end if green and blue then value = 29 -- turquoise end if green_light and blue_light then value = 68 -- mint end if green_dark and blue_dark then value = 31 -- turquoise dark end else -- normal LED buttons are monochrome value = (pt.val == true) and xarg.maximum or xarg.minimum end return value end