Code:
-------------------------------------------------------------------------------
-- connect devices
-------------------------------------------------------------------------------
open_midi_device("traktor", "traktor", "Traktor to MM", "MM to Traktor");
open_midi_device("lpd8", "lpd8", "LPD8", "LPD8", 6);
--
-- function layout:
--
-- +--------+--------+--------+--------+
-- | slicer | loop | jump | deck |
-- | on/off | mode | mode | | \
-- +--------+-------- +-------+--------+ * PAD mode
-- | play | cue | sync | | /
-- | | | | |
-- +--------+--------+--------+--------+
-- | hot | hot | hot | hot |
-- | cue 1 | cue 2 | cue 3 | cue 4 | \
-- +--------+--------+--------+--------+ * CC mode
-- | loop | loop- | loop+ | shift | /
-- | | | | |
-- +--------+--------+--------+--------+
-- | slot | slot | slot | slot |
-- | c1 | c2 | c3 | c3 | \
-- +--------+--------+--------+--------+ * PC mode
-- | slot | slot | slot | slot | /
-- | d1 | d2 | d3 | d3 |
-- +--------+--------+--------+--------+
--
-- * when 'deck' pad is lit, controls are for deck b
-- * when slicer is active CC mode pads become the slicer pads
-- * shift & hotcue to delete else they set/jump
-- * shift & loop+ or loop- to tempo bend
-- * pots control eq+levels for decks a+b
--
-- pad names:
--
-- +--------+--------+--------+--------+
-- | 0,0 | 0,1 | 0,2 | 0,3 |
-- +--------+--------+--------+--------+
-- | 1,0 | 1,1 | 1,2 | 1,3 |
-- +--------+--------+--------+--------+
-- | 2,0 | 2,1 | 2,2 | 2,3 |
-- +--------+--------+--------+--------+
-- | 3,0 | 3,1 | 3,2 | 3,3 |
-- +--------+--------+--------+--------+
-- | 4,0 | 4,1 | 4,2 | 4,3 |
-- +--------+--------+--------+--------+
-- | 5,0 | 5,1 | 5,2 | 5,3 |
-- +--------+--------+--------+--------+
--
-- pages used:
--
-- page 0: global page, controls defined on page 0 will always be available
-- page 1: deck a
-- page 2: deck a / shift held
-- page 3: deck a / slicer active
-- page 4: deck b
-- page 5: deck b / shift held
-- page 6: deck b / slicer active
--
-------------------------------------------------------------------------------
-- a function to allow page changes
-------------------------------------------------------------------------------
function change_page()
local page
if deck_toggle == 0 then
if slicer_a_active == 0 then
if shift == 0 then
page = 1
else
page = 2
end
else
page = 3
end
else
if slicer_b_active == 0 then
if shift == 0 then
page = 4
else
page = 5
end
else
page = 6
end
end
--print("CHANGE PAGE ",deck_toggle, shift, slicer_a_active, slicer_a_active, "page="..page)
set_page("lpd8", page)
end
-------------------------------------------------------------------------------
-- a function to simplify assigning of hotcues
-------------------------------------------------------------------------------
function hotcue(d, e, p, deck, cuenum)
local set_hotcue = "select_set_store_hotcue_"..cuenum.."_"..deck
local delete_hotcue = "delete_hotcue_"..cuenum.."_"..deck
local hotcue_state = "hotcue"..cuenum.."_state_"..deck
capture(d, e, ALL, p, function(d, e, v, p)
-- either set/store or delete a hotcue if shift is pressed
if shift == 0 then
send("traktor", set_hotcue, v)
else
send("traktor", delete_hotcue, v)
end
-- the lpd8 turns the led off when u release, keep it on if hotcue is set
if v == 0 then
if get("traktor", hotcue_state) > 0 then
send(d, e, ON, p)
end
end
end)
-- always send traktors hotcue events back to the pad led
pipe("traktor", hotcue_state, 0, d, e, p)
end
-------------------------------------------------------------------------------
-- define our layout
-------------------------------------------------------------------------------
--
-- deck change toggle and shift button
--
toggle_modifier("lpd8", "0,3", 0, ON, OFF, "deck_toggle", "change_page")
hold_modifier("lpd8", "3,3", {1, 2, 4, 5}, ON, OFF, "shift", "change_page")
----------------------------------------------------------
-- PAD mode
----------------------------------------------------------
-- attach slicers for deck a and b
id = traktor_slicer("lpd8", grid("2,0", "3,3"), 1, "a", "slicer_a_active", "0,0", "0,1", "0,2", "change_page")
slicer.active_toggle("lpd8", "0,0", 2, id, "slicer_a_active", "change_page")
id = traktor_slicer("lpd8", grid("2,0", "3,3"), 3, "b", "slicer_b_active", "0,0", "0,1", "0,2", "change_page")
slicer.active_toggle("lpd8", "0,0", 4, id, "slicer_b_active", "change_page")
toggle("lpd8", "1,0", {1, 2}, ON, OFF, "traktor", "play_a")
button("lpd8", "1,1", {1, 2}, ON, OFF, "traktor", "cue_a")
toggle("lpd8", "1,2", {1, 2}, ON, OFF, "traktor", "beat_sync_a")
toggle("lpd8", "1,0", {3, 4}, ON, OFF, "traktor", "play_b")
button("lpd8", "1,1", {3, 4}, ON, OFF, "traktor", "cue_b")
toggle("lpd8", "1,2", {3, 4}, ON, OFF, "traktor", "beat_sync_b")
----------------------------------------------------------
-- CC mode (when slicer not active)
----------------------------------------------------------
-- hot cues 1-4 on top row
hotcue("lpd8", "2,0", {1, 2}, "a", 1)
hotcue("lpd8", "2,1", {1, 2}, "a", 2)
hotcue("lpd8", "2,2", {1, 2}, "a", 3)
hotcue("lpd8", "2,3", {1, 2}, "a", 4)
hotcue("lpd8", "2,0", {4, 5}, "b", 1)
hotcue("lpd8", "2,1", {4, 5}, "b", 2)
hotcue("lpd8", "2,2", {4, 5}, "b", 3)
hotcue("lpd8", "2,3", {4, 5}, "b", 4)
-- loop on/off and loop size
toggle("lpd8", "3,0", 1, ON, OFF, "traktor", "loop_active_a")
pipe("lpd8", "3,1", 1, "traktor", "loop_size_dec_a")
pipe("lpd8", "3,2", 1, "traktor", "loop_size_inc_a")
toggle("lpd8", "3,0", 3, ON, OFF, "traktor", "loop_active_b")
pipe("lpd8", "3,1", 3, "traktor", "loop_size_dec_b")
pipe("lpd8", "3,2", 3, "traktor", "loop_size_inc_b")
-- when shift pressed loop+/- pads become pitch bends
pipe("lpd8", "3,1", 2, "traktor", "tempo_bend_down_a")
pipe("lpd8", "3,1", 2, "traktor", "tempo_bend_up_a")
pipe("lpd8", "3,1", 4, "traktor", "tempo_bend_down_b")
pipe("lpd8", "3,1", 4, "traktor", "tempo_bend_up_b")
----------------------------------------------------------
-- PC mode
----------------------------------------------------------
pipe("lpd8", "4,0", 0, "traktor", "slot_retrigger_c1")
pipe("lpd8", "4,1", 0, "traktor", "slot_retrigger_c2")
pipe("lpd8", "4,2", 0, "traktor", "slot_retrigger_c3")
pipe("lpd8", "4,3", 0, "traktor", "slot_retrigger_c4")
pipe("lpd8", "5,0", 0, "traktor", "slot_retrigger_d1")
pipe("lpd8", "5,1", 0, "traktor", "slot_retrigger_d2")
pipe("lpd8", "5,2", 0, "traktor", "slot_retrigger_d3")
pipe("lpd8", "5,3", 0, "traktor", "slot_retrigger_d4")
----------------------------------------------------------
-- Pots
----------------------------------------------------------
pipe("lpd8", "fader1", 0, "traktor", "eq_low_a")
pipe("lpd8", "fader2", 0, "traktor", "eq_mid_a")
pipe("lpd8", "fader3", 0, "traktor", "eq_high_a")
pipe("lpd8", "fader4", 0, "traktor", "volume_fader_a")
pipe("lpd8", "fader5", 0, "traktor", "eq_low_b")
pipe("lpd8", "fader6", 0, "traktor", "eq_mid_b")
pipe("lpd8", "fader7", 0, "traktor", "eq_high_b")
pipe("lpd8", "fader8", 0, "traktor", "volume_fader_b")
Bookmarks