From 4b5848938c0b162964005b566a0a39e12bd1f7af Mon Sep 17 00:00:00 2001 From: dan derks Date: Wed, 24 Nov 2021 16:08:45 -0500 Subject: [PATCH] LTS4: clean up patterns + arp snags --- cheat_codes_2.lua | 58 ++++++++++++++++++++++++++++++++++++++------ lib/arp_actions.lua | 54 ----------------------------------------- lib/grid_actions.lua | 50 +++++--------------------------------- 3 files changed, 56 insertions(+), 106 deletions(-) diff --git a/cheat_codes_2.lua b/cheat_codes_2.lua index 1624b87..09f2f37 100755 --- a/cheat_codes_2.lua +++ b/cheat_codes_2.lua @@ -1,6 +1,6 @@ -- cheat codes 2 -- a sample playground --- rev: 211113 - LTS3.1 +-- rev: 211124 - LTS4 -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- need help? -- please visit: @@ -2137,7 +2137,7 @@ function alt_synced_loop(target,state,style,mod_table) -- print("arp thing") if grid_pat[tab.key(name_to_id,target.name)].play == 1 then grid_pat[tab.key(name_to_id,target.name)]:stop() - grid_pat[tab.key(name_to_id,target.name)]:clear() + -- grid_pat[tab.key(name_to_id,target.name)]:clear() end local destination = tab.key(name_to_id,target.name) local arp_start = @@ -2240,9 +2240,16 @@ function start_pattern(target,start_type,style,mod_table) end if mod_table ~= nil then load_pattern(mod_table[1],mod_table[2]) - target:start() + print("starting a pattern!", type_of_pattern_loaded[destination]) + if type_of_pattern_loaded[destination] == "grid" then + if arp[destination].playing then + arps.toggle("stop",destination) + end + target:start() + end else print("????") + print("starting a pattern2") target:start() end end @@ -6040,7 +6047,9 @@ function reset_step_seq(i,val) -- TODO: funky on some... end function quick_save_pattern(i) - if grid_pat[i].count > 0 and grid_pat[i].rec == 0 then + if (grid_pat[i].count > 0 and grid_pat[i].rec == 0 and grid_pat[i].play == 1) -- if it's playing, then save pattern + or (grid_pat[i].count > 0 and grid_pat[i].rec == 0 and not arp[i].playing) -- if it's dormant and arp isn't playing, save pattern + then copy_entire_pattern(i) save_pattern(i,pattern_saver[i].save_slot+8*(i-1),"pattern") pattern_saver[i].saved[pattern_saver[i].save_slot] = 1 @@ -6049,7 +6058,9 @@ function quick_save_pattern(i) g:led(math.floor((i-1)*5)+1,9-pattern_saver[i].save_slot,15) end -- g:refresh() - elseif #arp[i].notes > 0 then + elseif (#arp[i].notes > 0 and arp[i].playing) + or (#arp[i].notes > 0 and not arp[i].playing and grid_pat[i].play == 0) + then save_pattern(i,pattern_saver[i].save_slot+8*(i-1),"arp") pattern_saver[i].saved[pattern_saver[i].save_slot] = 1 pattern_saver[i].load_slot = pattern_saver[i].save_slot @@ -6096,6 +6107,8 @@ function test_load(slot,destination,source) if pattern_saver[destination].load_slot ~= slot-((destination-1)*8) then pattern_saver[destination].load_slot = slot-((destination-1)*8) end + + -- if it isn't a grid press: if grid_pat[destination].play == 1 and source ~= "from_grid" then grid_pat[destination]:clear() elseif arp[destination].playing and source ~= "from_grid" then @@ -6108,6 +6121,7 @@ function test_load(slot,destination,source) -- quantized_grid_pat[destination].current_step = grid_pat[destination].start_point -- quantized_grid_pat[destination].sub_step = 1 end + if not transport.is_running then print("loading while transport is not running") load_pattern(slot,destination) @@ -6120,9 +6134,24 @@ function test_load(slot,destination,source) start_pattern(grid_pat[destination],"jumpstart") end -- print("loading "..clock.get_beats()) - elseif params:string("launch_quantization") == "next beat" and source == "from_grid" and type_of_pattern_loaded[destination] ~= "arp" and type_of_pattern_loaded[destination] ~= "euclid" then - -- print("going to start_pattern") - start_pattern(grid_pat[destination],"restart","delayed_load",{slot,destination}) + elseif params:string("launch_quantization") == "next beat" then + if source == "from_grid" + and type_of_pattern_loaded[destination] ~= "arp" + and type_of_pattern_loaded[destination] ~= "euclid" + then + print("going to start grid pattern with delayed load") + start_pattern(grid_pat[destination],"restart","delayed_load",{slot,destination}) + elseif source == "from_grid" then + print("dead zone...",type_of_pattern_loaded[destination]) + load_pattern(slot,destination) + print("starting a pattern!!!", type_of_pattern_loaded[destination]) + if type_of_pattern_loaded[destination] == "grid" then + if arp[destination].playing then + arps.toggle("stop",destination) + end + grid_pat[destination]:start() + end + end elseif params:string("launch_quantization") == "free" then if grid_pat[destination].play == 1 then grid_pat[destination]:clear() @@ -6145,6 +6174,7 @@ function test_load(slot,destination,source) -- print("loading whatever...") start_pattern(grid_pat[destination],"restart","delayed_load",{slot,destination}) elseif type_of_pattern_loaded[destination] == "arp" then + print("We've GOT AN ARP") if loading_arp_from_grid[destination] ~= nil then clock.cancel(loading_arp_from_grid[destination]) end @@ -6617,6 +6647,18 @@ function load_pattern(slot,destination,print_also) ignore_external_timing = true end + if type_of_pattern_loaded[destination] == "grid" then + print("loading up a grid pattern") + elseif type_of_pattern_loaded[destination] == "arp" then + print("loading up an arp!") + if grid_pat[destination].play == 1 then + print("stopping pattern!") + stop_pattern(grid_pat[destination]) + -- grid_pat[destination]:clear() + end + end + + io.close(file) if not ignore_external_timing then print("see load_external_timing") diff --git a/lib/arp_actions.lua b/lib/arp_actions.lua index e5a3ba7..0f4ceb1 100755 --- a/lib/arp_actions.lua +++ b/lib/arp_actions.lua @@ -4,12 +4,6 @@ arp = {} arp_clock = {} --- arp_lattice = lattice:new{ --- auto = true, --- meter = 4, --- ppqn = 96 --- } - function arp_actions.init(target) arp[target] = {} arp[target].playing = false @@ -25,26 +19,8 @@ function arp_actions.init(target) arp[target].down = 0 arp[target].retrigger = true arp_clock[target] = clock.run(arp_actions.arpeggiate,target) - -- arp[target].lattice = arp_lattice:new_pattern{ - -- action = function() arp_actions.lattice_advance(target) end, - -- division = arp[target].time/4, - -- enabled = arp[target].enabled - -- } - -- clock.run(function() clock.sync(4) arp_lattice:start() end) end --- function arp_actions.toggle_arp(target,enable) --- if enable then --- clock.run(function() --- arp[target].lattice.phase = 0 --- clock.sync(arp[target].time) --- arp[target].lattice:start() --- end) --- else --- arp[target].lattice:stop() --- end --- end - function arp_actions.find_index(tab,el) local rev = {} for k,v in pairs(tab) do @@ -94,36 +70,6 @@ function arp_actions.toggle(state,target) end end --- function arp_actions.lattice_advance(target) --- if target == 1 then --- print(clock.get_beats()) --- if transport.is_running then --- if #arp[target].notes > 0 then --- if arp[target].pause == false then --- -- if arp[target].step == 1 then print("arp "..target, clock.get_beats()) end --- if menu ~= 1 then screen_dirty = true end --- if arp[target].mode == "fwd" then --- arp_actions.forward(target) --- elseif arp[target].mode == "bkwd" then --- arp_actions.backward(target) --- elseif arp[target].mode == "pend" then --- arp_actions.pendulum(target) --- elseif arp[target].mode == "rnd" then --- arp_actions.random(target) --- end --- arp[target].playing = true --- arp_actions.cheat(target,arp[target].step) --- grid_dirty = true --- else --- arp[target].playing = false --- end --- else --- arp[target].playing = false --- end --- end --- end --- end - function arp_actions.arpeggiate(target) while true do clock.sync(bank[target][bank[target].id].arp_time) diff --git a/lib/grid_actions.lua b/lib/grid_actions.lua index 969f910..2bbf780 100755 --- a/lib/grid_actions.lua +++ b/lib/grid_actions.lua @@ -54,39 +54,6 @@ function grid_actions.init(x,y,z) if z == 1 and x > 0 + (5*(i-1)) and x <= 4 + (5*(i-1)) and y >=5 then if bank[i].focus_hold == false then grid_actions.pad_down(i,(math.abs(y-9)+((x-1)*4))-(20*(i-1))) - -- if not grid_alt then - -- selected[i].x = x - -- selected[i].y = y - -- selected[i].id = (math.abs(y-9)+((x-1)*4))-(20*(i-1)) - -- bank[i].id = selected[i].id - -- which_bank = i - -- if menu == 11 then - -- help_menu = "banks" - -- end - -- pad_clipboard = nil - -- if bank[i].quantize_press == 0 then - -- if arp[i].enabled and grid_pat[i].rec == 0 and not arp[i].pause then - -- if arp[i].down == 0 and params:string("arp_"..i.."_hold_style") == "last pressed" then - -- for j = #arp[i].notes,1,-1 do - -- table.remove(arp[i].notes,j) - -- end - -- end - -- arp[i].time = bank[i][bank[i].id].arp_time - -- arps.momentary(i, bank[i].id, "on") - -- arp[i].down = arp[i].down + 1 - -- else - -- if rytm.track[i].k == 0 then - -- cheat(i, bank[i].id) - -- end - -- grid_pattern_watch(i) - -- end - -- else - -- table.insert(quantize_events[i],selected[i].id) - -- end - -- else - -- local released_pad = (math.abs(y-9)+((x-1)*4))-(20*(i-1)) - -- arps.momentary(i, released_pad, "off") - -- end else if not grid_alt then bank[i].focus_pad = (math.abs(y-9)+((x-1)*4))-(20*(i-1)) @@ -107,16 +74,6 @@ function grid_actions.init(x,y,z) elseif z == 0 and x > 0 + (5*(i-1)) and x <= 4 + (5*(i-1)) and y >=5 then if not bank[i].focus_hold then grid_actions.pad_up(i,(math.abs(y-9)+((x-1)*4))-(20*(i-1))) - -- local released_pad = (math.abs(y-9)+((x-1)*4))-(20*(i-1)) - -- if bank[i][released_pad].play_mode == "momentary" then - -- softcut.rate(i+1,0) - -- end - -- if (arp[i].enabled and not arp[i].hold) or (menu == 9 and not arp[i].hold) then - -- arps.momentary(i, released_pad, "off") - -- arp[i].down = arp[i].down - 1 - -- elseif (arp[i].enabled and arp[i].hold and not arp[i].pause) or (menu == 9 and arp[i].hold and not arp[i].pause) then - -- arp[i].down = arp[i].down - 1 - -- end end end end @@ -1547,6 +1504,7 @@ function grid_actions.pad_down(i,p) else local released_pad = p arps.momentary(i, released_pad, "off") + -- print("removing arp note") end end @@ -1556,10 +1514,14 @@ function grid_actions.pad_up(i,p) softcut.rate(i+1,0) end if (arp[i].enabled and not arp[i].hold) or (menu == 9 and not arp[i].hold) then + -- print("pad up 1") arps.momentary(i, released_pad, "off") arp[i].down = arp[i].down - 1 elseif (arp[i].enabled and arp[i].hold and not arp[i].pause) or (menu == 9 and arp[i].hold and not arp[i].pause) then - arp[i].down = arp[i].down - 1 + if not grid_alt then + -- print("pad up 2", grid_alt) + arp[i].down = arp[i].down - 1 + end end end