From 7429adc40025abd509c9af282034c2ae56990349 Mon Sep 17 00:00:00 2001 From: dndrks Date: Thu, 20 Aug 2020 10:09:43 -0500 Subject: [PATCH 1/9] massive improvements! - [loops] page now is navigable with e1 - k3 on any lane to swap b/w loop points and manual management (buffer + offset) - k1+k3 on any bank lane to toggle looping on/off for that pad - k1+k3 on live buffer to toggle rec on/off - k1 + e1 on loop play to move window - k1 + e1 on loop edit to change bank - k1 + e1 on live buffer edit to change live buffer --- cheat_codes.lua | 46 ++++++--- lib/encoder_actions.lua | 132 ++++++++---------------- lib/grid_actions.lua | 2 +- lib/main_menu.lua | 221 +++++++++++++++++++--------------------- lib/start_up.lua | 2 +- 5 files changed, 175 insertions(+), 228 deletions(-) diff --git a/cheat_codes.lua b/cheat_codes.lua index 17e8373..f38b590 100755 --- a/cheat_codes.lua +++ b/cheat_codes.lua @@ -690,6 +690,7 @@ function init() rec.end_point = 9 rec.loop = 1 rec.clear = 0 + rec.rate_offset = 1.0 params:add_separator("cheat codes params") @@ -854,8 +855,9 @@ function init() page = {} page.main_sel = 1 - page.loops_sel = 0 + page.loops_sel = 1 page.loops_page = 0 + page.loops_view = {1,1,1,1} page.levels_sel = 0 page.panning_sel = 1 page.filtering_sel = 0 @@ -2376,6 +2378,7 @@ function buff_flush() end function toggle_buffer(i) + grid_dirty = true softcut.level_slew_time(1,0.5) softcut.fade_time(1,0.01) @@ -2493,11 +2496,33 @@ function key(n,z) end elseif menu == 2 then if not key1_hold then - local loop_nav = (page.loops_sel + 1)%4 - page.loops_sel = loop_nav + page.loops_view[page.loops_sel] = (page.loops_view[page.loops_sel] % 2) + 1 else - page.loops_page = (page.loops_page+1)%2 + if page.loops_sel < 4 then + local id = page.loops_sel + bank[id][bank[id].id].loop = not bank[id][bank[id].id].loop + if bank[id][bank[id].id].loop then + softcut.loop(id+1,1) + softcut.position(id+1,bank[id][bank[id].id].start_point) + else + softcut.loop(id+1,0) + end + grid_dirty = true + elseif page.loops_sel == 4 then + toggle_buffer(rec.clip) + -- if params:get("rec_loop") == 1 then + -- rec.state = math.abs((rec.state % 2) - 1) + -- softcut.rec_level(1,rec.state) + -- else + -- softcut.position(1,rec.start_point) + -- rec.state = 1 + -- softcut.rec_level(1,rec.state) + -- end + + end end + + elseif menu == 3 then local level_nav = (page.levels_sel + 1)%3 page.levels_sel = level_nav @@ -2678,18 +2703,7 @@ function key(n,z) end elseif menu == 2 then if key1_hold then - if page.loops_page == 0 then - if page.loops_sel < 3 then - local id = page.loops_sel+1 - bank[id][bank[id].id].loop = not bank[id][bank[id].id].loop - if bank[id][bank[id].id].loop then - softcut.loop(id+1,1) - softcut.position(id+1,bank[id][bank[id].id].start_point) - else - softcut.loop(id+1,0) - end - end - end + -- else menu = 1 end diff --git a/lib/encoder_actions.lua b/lib/encoder_actions.lua index 0711cb8..64ff6d6 100755 --- a/lib/encoder_actions.lua +++ b/lib/encoder_actions.lua @@ -8,30 +8,38 @@ function encoder_actions.init(n,d) if menu == 1 then page.main_sel = util.clamp(page.main_sel+d,1,10) elseif menu == 2 then - local id = page.loops_sel + 1 + local id = page.loops_sel + if not key1_hold then + page.loops_sel = util.clamp(page.loops_sel+d,1,4) + id = page.loops_sel + end if id ~= 4 then - if page.loops_page == 1 then - ea.change_pad(id,d) - else - local which_pad = nil - if bank[id].focus_hold == false then - which_pad = bank[id].id - else - which_pad = bank[id].focus_pad + if key1_hold then + if page.loops_view[id] == 2 then + ea.change_pad(id,d) + elseif page.loops_view[id] == 1 then + local which_pad = nil + if bank[id].focus_hold == false then + which_pad = bank[id].id + else + which_pad = bank[id].focus_pad + end + local resolution = loop_enc_resolution + ea.move_play_window(bank[id][which_pad],d/resolution) + if bank[id].focus_hold == false then + ea.sc.move_play_window(id) + end end - local resolution = loop_enc_resolution * (key1_hold and 10 or 1) - ea.move_play_window(bank[id][which_pad],d/resolution) - end - if bank[id].focus_hold == false then - ea.sc.move_play_window(id) end elseif id == 4 then - if page.loops_page == 1 then - ea.change_buffer(rec,d) - else - ea.move_rec_window(rec,d) - end + if key1_hold then + if page.loops_view[id] == 2 then + ea.change_buffer(rec,d) + else + ea.move_rec_window(rec,d) + end ea.sc.move_rec_window(rec) + end end elseif menu == 6 then if page.delay_section == 1 then @@ -46,48 +54,7 @@ function encoder_actions.init(n,d) elseif menu == 7 then page.time_sel = util.clamp(page.time_sel+d,1,6) elseif menu == 8 then - rytm.track_edit = util.clamp(rytm.track_edit+d,1,3) - - -- if key1_hold then - -- if d > 0 then - -- rytm.screen_focus = "right" - -- elseif d < 0 then - -- rytm.screen_focus = "left" - -- end - -- else - -- rytm.track_edit = util.clamp(rytm.track_edit+d,1,3) - -- end - - --[==[ - if page.track_page_section[page.track_page] == 1 then - page.track_page = util.clamp(page.track_page+d,1,4) - for i = 1,3 do - tracker[i].recording = false - end - elseif page.track_page_section[page.track_page] == 3 then - if page.track_page < 4 then - local reasonable_max = nil - for i = 1,tracker[page.track_page].max_memory do - if tracker[page.track_page][i].pad ~= nil then - reasonable_max = i - end - end - if reasonable_max ~= nil then - page.track_sel[page.track_page] = util.clamp(page.track_sel[page.track_page]+d,1,reasonable_max+1) - end - end - elseif page.track_page_section[page.track_page] == 4 then - if key1_hold == false then - if tracker[page.track_page][page.track_sel[page.track_page]].pad ~= nil then - page.track_param_sel[page.track_page] = util.clamp(page.track_param_sel[page.track_page] + d,1,11) - end - else - page.track_sel[page.track_page] = util.clamp(page.track_sel[page.track_page] + d,tracker[page.track_page].start_point,tracker[page.track_page].end_point) - end - end - -]==] - elseif menu == 9 then if key1_hold then local working = arp[page.arp_page_sel].retrigger and 1 or 0 @@ -98,25 +65,17 @@ function encoder_actions.init(n,d) end elseif menu == 10 then page.rnd_page = util.clamp(page.rnd_page+d,1,3) - -- if page.rnd_page_section == 1 then - -- page.rnd_page = util.clamp(page.rnd_page+d,1,3) - -- elseif page.rnd_page_section == 2 then - -- local selected_slot = page.rnd_page_sel[page.rnd_page] - -- local current_param = rnd[page.rnd_page][selected_slot].param - -- local reasonable_max = (current_param == "loop" or current_param == "delay send") and 3 or 4 - -- page.rnd_page_edit[page.rnd_page] = util.clamp(page.rnd_page_edit[page.rnd_page]+d,1,reasonable_max) - -- end end end if n == 2 then if menu == 1 then page.main_sel = util.clamp(page.main_sel+d,1,10) elseif menu == 2 then - local id = page.loops_sel + 1 + local id = page.loops_sel if id ~=4 then - if page.loops_page == 1 then + if page.loops_view[id] == 2 then ea.change_pad_clip(id,d) - else + elseif page.loops_view[id] == 1 then local which_pad = nil if bank[id].focus_hold == false then which_pad = bank[id].id @@ -130,21 +89,9 @@ function encoder_actions.init(n,d) end end elseif id == 4 then - if page.loops_page == 1 then - local preadjust = rec.state - rec.state = util.clamp(rec.state+d,0,1) - if preadjust ~= rec.state then - softcut.recpre_slew_time(1,0.5) - softcut.level_slew_time(1,0.5) - softcut.fade_time(1,0.01) - softcut.rec_level(1,rec.state) - if rec.state == 1 then - softcut.pre_level(1,params:get("live_rec_feedback")) - else - softcut.pre_level(1,1) - end - end - else + if page.loops_view[id] == 2 then + params:delta("live_buff_rate",d) + elseif page.loops_view[id] == 1 then local lbr = {1,2,4} if d >= 0 and util.round(rec.start_point + ((d/rec_loop_enc_resolution)/lbr[params:get("live_buff_rate")]),0.01) < util.round(rec.end_point,0.01) then rec.start_point = util.clamp(rec.start_point+((d/rec_loop_enc_resolution)/lbr[params:get("live_buff_rate")]),(1+(8*(rec.clip-1))),(8.9+(8*(rec.clip-1)))) @@ -394,9 +341,9 @@ function encoder_actions.init(n,d) end if n == 3 then if menu == 2 then - local id = page.loops_sel + 1 + local id = page.loops_sel if id ~= 4 then - if page.loops_page == 1 then + if page.loops_view[id] == 2 then local focused_pad = nil if grid_pat[id].play == 0 and grid_pat[id].tightened_start == 0 and not arp[id].playing and midi_pat[id].play == 0 then focused_pad = bank[id].id @@ -422,7 +369,7 @@ function encoder_actions.init(n,d) bank[id][i].offset = bank[id][focused_pad].offset end end - else + elseif page.loops_view[id] == 1 then local which_pad = nil if bank[id].focus_hold == false then which_pad = bank[id].id @@ -436,8 +383,8 @@ function encoder_actions.init(n,d) end end elseif id == 4 then - if page.loops_page == 1 then - params:delta("live_buff_rate",d) + if page.loops_view[id] == 2 then + else local lbr = {1,2,4} if d <= 0 and util.round(rec.start_point,0.01) < util.round(rec.end_point + ((d/rec_loop_enc_resolution)/lbr[params:get("live_buff_rate")]),0.01) then @@ -916,6 +863,7 @@ function ea.change_pad(target,delta) else pad.focus_pad = util.clamp(pad.focus_pad + delta,1,16) end + grid_dirty = true end function ea.change_buffer(target,delta) @@ -924,6 +872,7 @@ function ea.change_buffer(target,delta) target.clip = util.clamp(target.clip+delta,1,3) target.start_point = target.start_point - ((pre_adjust - target.clip)*8) target.end_point = target.start_point + current_difference + grid_dirty = true end function ea.change_pad_clip(target,delta) @@ -960,6 +909,7 @@ function ea.change_pad_clip(target,delta) bank[target][i].end_point = bank[target][i].start_point + current_difference end end + grid_dirty = true end function ea.move_start(target,delta) diff --git a/lib/grid_actions.lua b/lib/grid_actions.lua index 7a8f7fe..0d35ca6 100755 --- a/lib/grid_actions.lua +++ b/lib/grid_actions.lua @@ -527,7 +527,7 @@ function grid_actions.init(x,y,z) if key1_hold == true then key1_hold = false end if y == 4 then menu = 2 - page.loops_sel = math.floor((x/4)-1) + page.loops_sel = math.floor((x/4)) end redraw() end diff --git a/lib/main_menu.lua b/lib/main_menu.lua index 2ad5788..9f853f6 100755 --- a/lib/main_menu.lua +++ b/lib/main_menu.lua @@ -39,161 +39,144 @@ function main_menu.init() screen.text_right("no midi device!") end elseif menu == 2 then + screen.move(0,10) screen.level(3) screen.text("loops") - local rate_to_frac = - { ["-4.0"] = "-4" - , ["-3.0"] = "-3" - , ["-2.5"] = "-2.5" - , ["-2.0"] = "-2" - , ["-1.5"] = "-1.5" - , ["-1.0"] = "-1" - , ["-0.75"] = "-3/4" - , ["-0.5"] = "-1/2" - , ["-0.375"] = "-3/8" - , ["-0.25"] = "-1/4" - , ["-0.188"] = "-3/16" - , ["-0.125"] = "-1/8" - , ["0.125"] = "1/8" - , ["0.188"] = "3/16" - , ["0.25"] = "1/4" - , ["0.375"] = "3/8" - , ["0.5"] = "1/2" - , ["0.75"] = "3/4" - , ["1.0"] = "1" - , ["1.5"] = "1.5" - , ["2.0"] = "2" - , ["2.5"] = "2.5" - , ["3.0"] = "3" - , ["4.0"] = "4" - } - local bank_a = rate_to_frac[tostring(util.round(bank[1][bank[1].id].rate, 0.001))] - local bank_b = rate_to_frac[tostring(util.round(bank[2][bank[2].id].rate, 0.001))] - local bank_c = rate_to_frac[tostring(util.round(bank[3][bank[3].id].rate, 0.001))] - if page.loops_page == 0 then - screen.move(120,10) - screen.text_right(bank_a.."x \\ "..bank_b.."x \\ "..bank_c.."x") + local bank_rate = {} + for i = 1,3 do + bank_rate[i] = string.format("%.4g",bank[i][bank[i].id].rate) end - --if key1_hold then - if page.loops_page == 1 then - local id = page.loops_sel+1 - local focused_pad = nil - if grid.alt == 1 then - screen.move(0,20) - screen.level(6) - screen.text("(grid-ALT sets offset for all)") - end - for i = 1,3 do - if grid_pat[i].play == 0 and grid_pat[i].tightened_start == 0 and not arp[i].playing and midi_pat[i].play == 0 then - focused_pad = bank[i].id - else - focused_pad = bank[i].focus_pad - end - if page.loops_sel == i-1 then - if page.loops_sel < 3 and focused_pad == 16 and grid.alt == 0 then - screen.move(0,20) - screen.level(6) - screen.text("(pad 16 overwrites bank!)") - end - if grid_pat[i].play == 1 or grid_pat[i].tightened_start == 1 or arp[i].playing or midi_pat[i].play == 1 then - screen.move(0,10) - screen.level(3) - screen.text("loops: bank "..i.." is pad-locked") - end - end - screen.move(0,20+(i*10)) - screen.level(page.loops_sel == i-1 and 15 or 3) - if grid.alt == 0 then - local loops_to_screen_options = {"a", "b", "c"} - screen.text(loops_to_screen_options[i]..""..focused_pad) - else - local loops_to_screen_options = {"(a)","(b)","(c)"} - screen.text(loops_to_screen_options[i]) - end - screen.move(20,20+(i*10)) - screen.text((bank[i][focused_pad].mode == 1 and "Live" or "Clip")..":") - screen.move(40,20+(i*10)) - screen.text(bank[i][focused_pad].clip) - screen.move(55,20+(i*10)) - screen.text("offset: "..string.format("%.0f",((math.log(bank[i][focused_pad].offset)/math.log(0.5))*-12)).." st") - end - screen.level(page.loops_sel == 3 and 15 or 3) - screen.move(0,60) - screen.text("L"..rec.clip) - screen.move(20,60) - screen.text(rec.state == 1 and "recording" or "not recording") - screen.move(88,60) - local rate_options = {"8 s","16 s","32 s"} - screen.text(rate_options[params:get"live_buff_rate"]) - screen.move(111,60) - screen.level(3) - screen.text(string.format("%0.f",util.linlin(rec.start_point-(8*(rec.clip-1)),rec.end_point-(8*(rec.clip-1)),0,100,(poll_position_new[1] - (8*(rec.clip-1))))).."%") - else + screen.move(120,10) + screen.text_right(bank_rate[1].."x | "..bank_rate[2].."x | "..bank_rate[3].."x") + + for i = 1,3 do local which_pad = nil screen.line_width(1) - for i = 1,3 do - if bank[i].focus_hold == false then - which_pad = bank[i].id - else - which_pad = bank[i].focus_pad - end - screen.move(0,10+(i*15)) - screen.level(page.loops_sel == i-1 and 15 or 3) + if bank[i].focus_hold == false then + which_pad = bank[i].id + else + which_pad = bank[i].focus_pad + end + screen.move(0,8+(i*14)) + screen.level(page.loops_sel == i and 15 or 3) + + -- local loops_to_screen_options = {"a", "b", "c"} + -- screen.text(loops_to_screen_options[i]..""..which_pad) + + if grid.alt == 0 then local loops_to_screen_options = {"a", "b", "c"} screen.text(loops_to_screen_options[i]..""..which_pad) - screen.move(15,10+(i*15)) - screen.line(120,10+(i*15)) + else + local loops_to_screen_options = {"(a)","(b)","(c)"} + screen.text(loops_to_screen_options[i]) + end + + + if page.loops_view[i] == 1 then + screen.move(15,8+(i*14)) + screen.line(120,8+(i*14)) screen.close() screen.stroke() - end - for i = 1,3 do if bank[i].focus_hold == false then which_pad = bank[i].id else which_pad = bank[i].focus_pad end - screen.level(page.loops_sel == i-1 and 15 or 3) + screen.level(page.loops_sel == i and 15 or 3) local duration = bank[i][which_pad].mode == 1 and 8 or clip[bank[i][which_pad].clip].sample_length local s_p = bank[i][which_pad].mode == 1 and live[bank[i][which_pad].clip].min or clip[bank[i][which_pad].clip].min local e_p = bank[i][which_pad].mode == 1 and live[bank[i][which_pad].clip].max or clip[bank[i][which_pad].clip].max - - --local start_to_screen = util.linlin(1,(duration+1),15,120,(bank[i][which_pad].start_point - (duration*(bank[i][which_pad].clip-1)))) local start_to_screen = util.linlin(s_p,e_p,15,120,bank[i][which_pad].start_point) - screen.move(start_to_screen,24+(15*(i-1))) + screen.move(start_to_screen,21+(14*(i-1))) screen.text("|") - --local end_to_screen = util.linlin(1,(duration+1),15,120,bank[i][which_pad].end_point - (duration*(bank[i][which_pad].clip-1))) local end_to_screen = util.linlin(s_p,e_p,15,120,bank[i][which_pad].end_point) - screen.move(end_to_screen,30+(15*(i-1))) + screen.move(end_to_screen,27+(14*(i-1))) screen.text("|") if bank[i].focus_hold == false or bank[i].id == bank[i].focus_pad then - --local current_to_screen = util.linlin(1,(duration+1),15,120,(poll_position_new[i+1] - (duration*(bank[i][bank[i].id].clip-1)))) local current_to_screen = util.linlin(s_p,e_p,15,120,poll_position_new[i+1]) - screen.move(current_to_screen,27+(15*(i-1))) + screen.move(current_to_screen,24+(14*(i-1))) screen.text("|") end + elseif page.loops_view[i] == 2 then + screen.move(15,8+(i*14)) + local id = page.loops_sel + local focused_pad = nil + -- if grid.alt == 1 then + -- screen.move(0,20) + -- screen.level(6) + -- screen.text("(grid-ALT sets offset for all)") + -- end + + if grid_pat[i].play == 0 and grid_pat[i].tightened_start == 0 and not arp[i].playing and midi_pat[i].play == 0 then + focused_pad = bank[i].id + else + focused_pad = bank[i].focus_pad + end + -- if page.loops_sel == i-1 then + -- if page.loops_sel < 3 and focused_pad == 16 and grid.alt == 0 then + -- screen.move(0,20) + -- screen.level(6) + -- screen.text("(pad 16 overwrites bank!)") + -- end + -- if grid_pat[i].play == 1 or grid_pat[i].tightened_start == 1 or arp[i].playing or midi_pat[i].play == 1 then + -- screen.move(0,10) + -- screen.level(3) + -- screen.text("loops: bank "..i.." is pad-locked") + -- end + -- end + screen.move(0,8+(i*14)) + screen.level(page.loops_sel == i and 15 or 3) + if grid.alt == 0 then + local loops_to_screen_options = {"a", "b", "c"} + screen.text(loops_to_screen_options[i]..""..focused_pad) + else + local loops_to_screen_options = {"(a)","(b)","(c)"} + screen.text(loops_to_screen_options[i]) + end + screen.move(25,8+(i*14)) + screen.text((bank[i][focused_pad].mode == 1 and "Live" or "Clip")..": "..bank[i][focused_pad].clip) + screen.move(60,8+(i*14)) + screen.text("offset: "..string.format("%.0f",((math.log(bank[i][focused_pad].offset)/math.log(0.5))*-12)).." st") + end - screen.level(page.loops_sel == 3 and 15 or 3) + end + + screen.level(page.loops_sel == 4 and 15 or 3) + if page.loops_view[4] == 1 then local recording_playhead = util.linlin(1,9,15,120,(poll_position_new[1] - (8*(rec.clip-1)))) if rec.state == 1 then - screen.move(recording_playhead,64) - screen.text(".") + screen.font_size(4) + screen.move(recording_playhead,62) + screen.text(">") + screen.font_size(8) elseif rec.state == 0 then - screen.move(recording_playhead,67) - screen.text_center("||") + screen.font_size(8) + screen.move(recording_playhead,62) + screen.text_center(".") + screen.font_size(8) end local recording_start = util.linlin(1,9,15,120,(rec.start_point - (8*(rec.clip-1)))) - screen.move(recording_start,66) + screen.move(recording_start,62) screen.text("|") local recording_end = util.linlin(1,9,15,120,rec.end_point - (8*(rec.clip-1))) - screen.move(recording_end,66) + screen.move(recording_end,62) screen.text("|") - screen.move(123,64) - screen.text(rec.clip) + screen.move(0,62) + screen.text("L"..rec.clip) + elseif page.loops_view[4] == 2 then + screen.move(0,62) + screen.text("L"..rec.clip) + screen.move(15,62) + local rate_options = {"8 s","16 s","32 s"} + screen.text(rate_options[params:get"live_buff_rate"]) + screen.move(45,62) + screen.text("offset: "..string.format("%.0f",((math.log(rec.rate_offset)/math.log(0.5))*-12)).." st") + screen.move(111,62) + screen.level(3) + screen.text(string.format("%0.f",util.linlin(rec.start_point-(8*(rec.clip-1)),rec.end_point-(8*(rec.clip-1)),0,100,(poll_position_new[1] - (8*(rec.clip-1))))).."%") end - screen.level(3) - screen.move(0,64) - screen.text("...") + elseif menu == 3 then screen.move(0,10) screen.level(3) diff --git a/lib/start_up.lua b/lib/start_up.lua index e004ed5..2e192bd 100755 --- a/lib/start_up.lua +++ b/lib/start_up.lua @@ -77,7 +77,7 @@ function start_up.init() params:add_separator("clips") for i = 1,3 do - params:add_file("clip "..i.." sample", "clip "..i.." sample") + params:add_file("clip "..i.." sample", "clip "..i.." sample", "/home/we/dust/audio/") params:set_action("clip "..i.." sample", function(file) load_sample(file,i) end) end From e2b72ee26a91280449327a3b7e87ffc362ebff45 Mon Sep 17 00:00:00 2001 From: dndrks Date: Tue, 25 Aug 2020 09:58:27 -0500 Subject: [PATCH 2/9] [levels] changes + small fixed - introduced a global level for each bank, which allows pads to be faded in/out without destroying their individual level settings - introduced two new envelope shapes: rising and rise/fall - introcuced an envelope loop action which loops the current envelope shape - changed the floor of envelope timing to 50ms - fixed rnd's delay send to send current level instead of being a binary which required re-cheat - fixed rnd's delay send clicking - fixed delay send level to be based on delay send level instead of panning - fixed rnd's rate slew "destructive" mode to affect each pad's `rate_slew` param - fixed [arp] screen --- cheat_codes.lua | 252 +++++++++++++++++++++++----- lib/arc_actions.lua | 2 +- lib/delay.lua | 8 +- lib/encoder_actions.lua | 355 ++++++++++++++++++++-------------------- lib/euclid.lua | 1 + lib/grid_actions.lua | 2 +- lib/main_menu.lua | 116 ++++++++----- lib/rnd_actions.lua | 24 ++- lib/start_up.lua | 12 +- lib/zilchmos.lua | 28 ++-- 10 files changed, 519 insertions(+), 281 deletions(-) diff --git a/cheat_codes.lua b/cheat_codes.lua index f38b590..536e5eb 100755 --- a/cheat_codes.lua +++ b/cheat_codes.lua @@ -115,6 +115,8 @@ for i = 1,3 do env_counter[i] = metro.init() env_counter[i].time = 0.01 env_counter[i].butt = 1 + env_counter[i].stage = nil + -- env_counter[i].mode = 1 -- this needs to be per pad!! env_counter[i].event = function() envelope(i) end end @@ -893,6 +895,8 @@ function init() page.track_param_sel[i] = 1 end page.arp_page_sel = 1 + page.arp_param = {1,1,1} + page.arp_alt = {false,false,false} page.arp_param_group = {} for i = 1,3 do page.arp_param_group[i] = 1 @@ -1166,7 +1170,7 @@ function init() slew_filter(i,slew_counter[i].prev_tilt,pad.tilt,pad.q,pad.q,15) elseif d.cc == 4 then pad.level = util.linlin(0,127,0,2,d.val) - softcut.level(i+1,pad.level) + softcut.level(i+1,pad.level*bank[i].global_level) end end end @@ -2075,6 +2079,7 @@ function reset_all_banks( banks ) b.quantize_press = 0 b.quantize_press_div = 1 b.alt_lock = false + b.global_level = 1.0 for k = 1,16 do -- TODO suggest nesting tables for delay,filter,tilt etc b[k] = {} @@ -2118,7 +2123,9 @@ function reset_all_banks( banks ) pad.cf_exp_dry = 1 pad.filter_type = 4 pad.enveloped = false + pad.envelope_mode = 0 pad.envelope_time = 3.0 + pad.envelope_loop = false pad.clock_resolution = 4 pad.offset = 1.0 pad.crow_pad_execute = 1 @@ -2147,40 +2154,36 @@ end function cheat(b,i) env_counter[b]:stop() local pad = bank[b][i] + softcut.rate_slew_time(b+1,pad.rate_slew) if pad.enveloped then - env_counter[b].butt = pad.level - softcut.level(b+1,pad.level) - if not delay[1].send_mute then - if pad.left_delay_thru then - softcut.level_cut_cut(b+1,5,util.linlin(-1,1,0,1,pad.pan)*(pad.left_delay_level)) - else - softcut.level_cut_cut(b+1,5,util.linlin(-1,1,0,1,pad.pan)*(pad.left_delay_level*pad.level)) - end - end - if not delay[2].send_mute then - if pad.right_delay_thru then - softcut.level_cut_cut(b+1,6,util.linlin(-1,1,1,0,pad.pan)*(pad.right_delay_level)) - else - softcut.level_cut_cut(b+1,6,util.linlin(-1,1,1,0,pad.pan)*(pad.right_delay_level*pad.level)) - end + if pad.envelope_mode == 1 then + env_counter[b].butt = pad.level + softcut.level_slew_time(b+1,0.01) + softcut.level(b+1,pad.level*bank[b].global_level) + elseif pad.envelope_mode == 2 or pad.envelope_mode == 3 then + softcut.level_slew_time(b+1,0.1) + softcut.level(b+1,0*bank[b].global_level) + softcut.level_cut_cut(b+1,5,0) + softcut.level_cut_cut(b+1,6,0) + env_counter[b].butt = 0 end env_counter[b].time = (pad.envelope_time/(pad.level/0.05)) env_counter[b]:start() else softcut.level_slew_time(b+1,0.1) - softcut.level(b+1,pad.level) + softcut.level(b+1,pad.level*bank[b].global_level) if not delay[1].send_mute then if pad.left_delay_thru then - softcut.level_cut_cut(b+1,5,util.linlin(-1,1,0,1,pad.pan)*(pad.left_delay_level)) + softcut.level_cut_cut(b+1,5,pad.left_delay_level) else - softcut.level_cut_cut(b+1,5,util.linlin(-1,1,0,1,pad.pan)*(pad.left_delay_level*pad.level)) + softcut.level_cut_cut(b+1,5,(pad.left_delay_level*pad.level)*bank[b].global_level) end end if not delay[2].send_mute then if pad.right_delay_thru then - softcut.level_cut_cut(b+1,6,util.linlin(-1,1,1,0,pad.pan)*(pad.right_delay_level)) + softcut.level_cut_cut(b+1,6,pad.right_delay_level) else - softcut.level_cut_cut(b+1,6,util.linlin(-1,1,1,0,pad.pan)*(pad.right_delay_level*pad.level)) + softcut.level_cut_cut(b+1,6,(pad.right_delay_level*pad.level)*bank[b].global_level) end end end @@ -2261,19 +2264,81 @@ function cheat(b,i) end function envelope(i) - softcut.level_slew_time(i+1,0.01) - env_counter[i].butt = env_counter[i].butt - 0.05 + softcut.level_slew_time(i+1,0.1) + if bank[i][bank[i].id].envelope_mode == 1 then + falling_envelope(i) + elseif bank[i][bank[i].id].envelope_mode == 2 then + rising_envelope(i) + elseif bank[i][bank[i].id].envelope_mode == 3 then + if env_counter[i].stage == nil then env_counter[i].stage = "rising" end + if env_counter[i].stage == "rising" then + rising_envelope(i) + elseif env_counter[i].stage == "falling" then + falling_envelope(i) + end + end +end + +function falling_envelope(i) + if env_counter[i].butt > 0.05 then + env_counter[i].butt = env_counter[i].butt - 0.05 + else + env_counter[i].butt = 0 + end + -- print(env_counter[i].butt) if env_counter[i].butt > 0 then - softcut.level(i+1,env_counter[i].butt) - softcut.level_cut_cut(i+1,5,env_counter[i].butt*bank[i][bank[i].id].left_delay_level) - softcut.level_cut_cut(i+1,6,env_counter[i].butt*bank[i][bank[i].id].right_delay_level) + softcut.level(i+1,env_counter[i].butt*bank[i].global_level) + softcut.level_cut_cut(i+1,5,env_counter[i].butt*(bank[i][bank[i].id].left_delay_level*bank[i].global_level)) + softcut.level_cut_cut(i+1,6,env_counter[i].butt*(bank[i][bank[i].id].right_delay_level*bank[i].global_level)) else env_counter[i]:stop() - softcut.level(i+1,0) + softcut.level(i+1,0*bank[i].global_level) env_counter[i].butt = bank[i][bank[i].id].level softcut.level_cut_cut(i+1,5,0) softcut.level_cut_cut(i+1,6,0) softcut.level_slew_time(i+1,1.0) + if bank[i][bank[i].id].envelope_mode == 3 then + env_counter[i].stage = nil + env_counter[i].butt = 0 + end + if bank[i][bank[i].id].envelope_loop == true then + env_counter[i]:start() + end + end +end + +function rising_envelope(i) + env_counter[i].butt = env_counter[i].butt + 0.05 + -- print(env_counter[i].butt, env_counter[i].time) + if env_counter[i].butt < bank[i][bank[i].id].level then + softcut.level(i+1,env_counter[i].butt*bank[i].global_level) + softcut.level_cut_cut(i+1,5,env_counter[i].butt*(bank[i][bank[i].id].left_delay_level*bank[i].global_level)) + softcut.level_cut_cut(i+1,6,env_counter[i].butt*(bank[i][bank[i].id].right_delay_level*bank[i].global_level)) + else + -- print("stopping") + env_counter[i]:stop() + softcut.level(i+1,bank[i][bank[i].id].level*bank[i].global_level) + env_counter[i].butt = 0 + if bank[i][bank[i].id].left_delay_thru then + softcut.level_cut_cut(i+1,5,bank[i][bank[i].id].left_delay_level) + else + softcut.level_cut_cut(i+1,5,(bank[i][bank[i].id].left_delay_level*bank[i][bank[i].id].level)*bank[i].global_level) + end + if bank[i][bank[i].id].right_delay_thru then + softcut.level_cut_cut(i+1,6,bank[i][bank[i].id].left_delay_level) + else + softcut.level_cut_cut(i+1,6,(bank[i][bank[i].id].left_delay_level*bank[i][bank[i].id].level)*bank[i].global_level) + end + softcut.level_slew_time(i+1,1.0) + if bank[i][bank[i].id].envelope_mode == 3 then + env_counter[i].stage = "falling" + env_counter[i].butt = bank[i][bank[i].id].level*bank[i].global_level + env_counter[i].time = (bank[i][bank[i].id].envelope_time/(bank[i][bank[i].id].level/0.05)) + env_counter[i]:start() + end + if bank[i][bank[i].id].envelope_loop == true then + env_counter[i]:start() + end end end @@ -2496,7 +2561,7 @@ function key(n,z) end elseif menu == 2 then if not key1_hold then - page.loops_view[page.loops_sel] = (page.loops_view[page.loops_sel] % 2) + 1 + page.loops_view[page.loops_sel] = (page.loops_view[page.loops_sel] % 3) + 1 else if page.loops_sel < 4 then local id = page.loops_sel @@ -2524,7 +2589,7 @@ function key(n,z) elseif menu == 3 then - local level_nav = (page.levels_sel + 1)%3 + local level_nav = (page.levels_sel + 1)%4 page.levels_sel = level_nav elseif menu == 5 then local filter_nav = (page.filtering_sel + 1)%3 @@ -2653,10 +2718,38 @@ function key(n,z) end elseif menu == 9 then - arp[page.arp_page_sel].hold = not arp[page.arp_page_sel].hold - if not arp[page.arp_page_sel].hold then - arps.clear(page.arp_page_sel) + -- arp[page.arp_page_sel].hold = not arp[page.arp_page_sel].hold + local id = page.arp_page_sel + if not arp[id].hold then + if not arp[id].enabled then + arp[id].enabled = true + end + if #arp[id].notes > 0 then + arp[id].hold = true + else + arp[id].enabled = false + end + else + if #arp[id].notes > 0 then + if arp[id].playing == true then + arp[id].hold = not arp[id].hold + if not arp[id].hold then + arps.clear(id) + end + arp[id].enabled = false + -- else + -- arp[id].step = arp[id].start_point-1 + -- arp[id].pause = false + -- arp[id].playing = true + end + end end + grid_dirty = true + + + -- if not arp[page.arp_page_sel].hold then + -- arps.clear(page.arp_page_sel) + -- end elseif menu == 10 then if key1_hold then local rnd_bank = page.rnd_page @@ -2728,10 +2821,7 @@ function key(n,z) key1_hold = true elseif menu == 9 then key1_hold = true - page.arp_param_group[page.arp_page_sel] = (page.arp_param_group[page.arp_page_sel] % 2) + 1 - if not arp[page.arp_page_sel].hold then - arps.clear(page.arp_page_sel) - end + page.arp_alt[page.arp_page_sel] = not page.arp_alt[page.arp_page_sel] else key1_hold = true end @@ -3496,7 +3586,7 @@ function new_arc_pattern_execute(entry) elseif entry.param == 5 then bank[id][which_pad].level = (entry.level + arc_offset) if bank[id].id == which_pad then - softcut.level(id+1, (entry.level + arc_offset)) + softcut.level(id+1, (entry.level + arc_offset)*bank[id].global_level) end elseif entry.param == 6 then bank[id][which_pad].pan = (entry.pan + arc_offset) @@ -3679,6 +3769,93 @@ function persistent_state_restore() end end +function testsavestate() + + local dirname = _path.data.."cheat_codes2/" + local collection = params:get("collection") + if os.rename(dirname, dirname) == nil then + os.execute("mkdir " .. dirname) + end + + local dirname = _path.data.."cheat_codes2/collection-"..collection.."/" + if os.rename(dirname, dirname) == nil then + os.execute("mkdir " .. dirname) + end + + local dirnames = {"banks/","params/","arc-pat/","grid-pat/","step-seq/","arps/","euclid/","rnd/","delays/"} + for i = 1,#dirnames do + -- print(_path.data.."cheat_codes2/collection-"..collection.."/"..dirnames[i]) + local directory = _path.data.."cheat_codes2/collection-"..collection.."/"..dirnames[i] + if os.rename(directory, directory) == nil then + os.execute("mkdir " .. directory) + end + end + + for i = 1,3 do + tab.save(bank[i],_path.data .. "cheat_codes2/collection-"..collection.."/banks/"..i..".data") + tab.save(arc_pat[i],_path.data .. "cheat_codes2/collection-"..collection.."/arc-pat/"..i..".data") + tab.save(step_seq[i],_path.data .. "cheat_codes2/collection-"..collection.."/step-seq/"..i..".data") + -- tab.save(grid_pat[i],_path.data .. "cheat_codes2/collection-"..collection.."/grid-pat/"..i..".data") + tab.save(arp[i],_path.data .. "cheat_codes2/collection-"..collection.."/arps/"..i..".data") + tab.save(rytm.track[i],_path.data .. "cheat_codes2/collection-"..collection.."/euclid/euclid"..i..".data") + end + for i = 1,2 do + tab.save(delay[i],_path.data .. "cheat_codes2/collection-"..collection.."/delays/delay"..(i == 1 and "L" or "R")..".data") + end + params:write(_path.data.."cheat_codes2/collection-"..collection.."/params/all.pset") + + for i = 1,3 do + tab.save(rnd[i],_path.data .. "cheat_codes2/collection-"..collection.."/rnd/"..i..".data") + end + +end + + +function testloadstate() + local collection = params:get("collection") + params:read(_path.data.."cheat_codes2/collection-"..collection.."/params/all.pset") + -- params:bang() + for i = 1,3 do + if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/banks/"..i..".data") ~= nil then + bank[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/banks/"..i..".data") + end + -- if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/arc-pat/"..i..".data") ~= nil then + -- arc_pat[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/arc-pat/"..i..".data") + -- end + if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/step-seq/"..i..".data") ~= nil then + step_seq[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/step-seq/"..i..".data") + end + -- if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/grid-pat/"..i..".data") ~= nil then + -- grid_pat[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/grid-pat/"..i..".data") + -- end + if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/arps/"..i..".data") ~= nil then + arp[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/arps/"..i..".data") + end + if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/rnd/"..i..".data") ~= nil then + rnd[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/rnd/"..i..".data") + for j = 1,#rnd[i] do + rnd[i][j].clock = nil + if rnd[i][j].playing then + rnd[i][j].clock = clock.run(rnd.advance, i, j) + end + end + end + if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/euclid/euclid"..i..".data") ~= nil then + rytm.track[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/euclid/euclid"..i..".data") + end + rytm.reset_pattern() + end + + for i = 1,2 do + if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/delays/delay"..(i == 1 and "L" or "R")..".data") ~= nil then + delay[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/delays/delay"..(i == 1 and "L" or "R")..".data") + end + end + + grid_dirty = true + +end + function savestate() local file = io.open(_path.data .. "cheat_codes/collections"..tonumber(string.format("%.0f",params:get("collection")))..".data", "w+") io.output(file) @@ -4123,6 +4300,7 @@ function loadstate() end end del.loadstate(selected_coll) + grid_dirty = true end function test_save(i) diff --git a/lib/arc_actions.lua b/lib/arc_actions.lua index 72020d2..9b88cc3 100755 --- a/lib/arc_actions.lua +++ b/lib/arc_actions.lua @@ -174,7 +174,7 @@ function aa.sc.change_pan(enc, target) end function aa.sc.change_level(enc, target) - softcut.level(enc+1,target.level) + softcut.level(enc+1,target.level*bank[enc].global_level) end aa.actions = diff --git a/lib/delay.lua b/lib/delay.lua index bc901f4..33c48d6 100755 --- a/lib/delay.lua +++ b/lib/delay.lua @@ -205,7 +205,9 @@ function delays.set_value(target,index,param) bank[delay_grid.bank][i].left_delay_level = send_levels[index] end end - softcut.level_cut_cut(delay_grid.bank+1,5,util.linlin(-1,1,0,1,b.pan)*(b.left_delay_level*b.level)) + softcut.level_slew_time(5,0.25) + -- softcut.level_cut_cut(delay_grid.bank+1,5,util.linlin(-1,1,0,1,b.pan)*(b.left_delay_level*b.level)) + softcut.level_cut_cut(delay_grid.bank+1,5,(b.left_delay_level*b.level)*bank[delay_grid.bank].global_level) else if param == "send" then b.right_delay_level = send_levels[index] @@ -214,7 +216,9 @@ function delays.set_value(target,index,param) bank[delay_grid.bank][i].right_delay_level = send_levels[index] end end - softcut.level_cut_cut(delay_grid.bank+1,6,util.linlin(-1,1,1,0,b.pan)*(b.right_delay_level*b.level)) + softcut.level_slew_time(6,0.25) + -- softcut.level_cut_cut(delay_grid.bank+1,6,util.linlin(-1,1,1,0,b.pan)*(b.right_delay_level*b.level)) + softcut.level_cut_cut(delay_grid.bank+1,6,(b.right_delay_level*b.level)*bank[delay_grid.bank].global_level) end end end diff --git a/lib/encoder_actions.lua b/lib/encoder_actions.lua index 64ff6d6..e047591 100755 --- a/lib/encoder_actions.lua +++ b/lib/encoder_actions.lua @@ -15,9 +15,9 @@ function encoder_actions.init(n,d) end if id ~= 4 then if key1_hold then - if page.loops_view[id] == 2 then + if page.loops_view[id] > 1 then ea.change_pad(id,d) - elseif page.loops_view[id] == 1 then + else local which_pad = nil if bank[id].focus_hold == false then which_pad = bank[id].id @@ -56,13 +56,7 @@ function encoder_actions.init(n,d) elseif menu == 8 then rytm.track_edit = util.clamp(rytm.track_edit+d,1,3) elseif menu == 9 then - if key1_hold then - local working = arp[page.arp_page_sel].retrigger and 1 or 0 - working = util.clamp(working+d,0,1) - arp[page.arp_page_sel].retrigger = (working == 1 and true or false) - else - page.arp_page_sel = util.clamp(page.arp_page_sel+d,1,3) - end + page.arp_page_sel = util.clamp(page.arp_page_sel+d,1,3) elseif menu == 10 then page.rnd_page = util.clamp(page.rnd_page+d,1,3) end @@ -74,6 +68,24 @@ function encoder_actions.init(n,d) local id = page.loops_sel if id ~=4 then if page.loops_view[id] == 2 then + local focused_pad = nil + if grid_pat[id].play == 0 and grid_pat[id].tightened_start == 0 and not arp[id].playing and midi_pat[id].play == 0 then + focused_pad = bank[id].id + else + focused_pad = bank[id].focus_pad + end + params:delta("rate "..id,d) + if focused_pad == 16 then + for i = 1,15 do + bank[id][i].rate = bank[id][16].rate + end + end + if grid.alt == 1 then + for i = 1,16 do + bank[id][i].rate = bank[id][focused_pad].rate + end + end + elseif page.loops_view[id] == 3 then ea.change_pad_clip(id,d) elseif page.loops_view[id] == 1 then local which_pad = nil @@ -220,112 +232,8 @@ function encoder_actions.init(n,d) rytm.track[rytm.track_edit].mode = "single" end end - - - --[==[ - if page.track_page_section[page.track_page] == 1 then - --[[ - page.track_page = util.clamp(page.track_page+d,1,4) - for i = 1,3 do - tracker[i].recording = false - end - --]] - elseif page.track_page_section[page.track_page] == 3 then - if page.track_page < 4 then - if tracker[page.track_page][page.track_sel[page.track_page]].pad == nil then - tracker[page.track_page][page.track_sel[page.track_page]].pad = 0 - tracker[page.track_page][page.track_sel[page.track_page]].time = 3 - if page.track_sel[page.track_page] > tracker[page.track_page].end_point then - tracker[page.track_page].end_point = page.track_sel[page.track_page] - end - end - tracker[page.track_page][page.track_sel[page.track_page]].pad = util.clamp(tracker[page.track_page][page.track_sel[page.track_page]].pad+d,1,16) - trackers.map_to(page.track_page,page.track_sel[page.track_page]) - else - tracker[1].snake = util.clamp(tracker[1].snake+d,1,8) - end - elseif page.track_page_section[page.track_page] == 4 then - local id = page.track_page - local sel = page.track_param_sel[id] - local line = page.track_sel[id] - if sel == 1 then - if tracker[id][line].pad == nil then tracker[id][line].pad = 0 end - tracker[id][line].pad = util.clamp(tracker[id][line].pad+d,1,16) - trackers.map_to(id,line) - elseif sel == 2 then - local rate_to_int = - { [-4] = 1 - , [-2] = 2 - , [-1] = 3 - , [-0.5] = 4 - , [-0.25] = 5 - , [-0.125] = 6 - , [0.125] = 7 - , [0.25] = 8 - , [0.5] = 9 - , [1] = 10 - , [2] = 11 - , [4] = 12 - } - local tracker_rate = rate_to_int[tracker[id][line].rate] - local tracker_rate = util.clamp(tracker_rate+d,1,12) - local int_to_rate = {-4,-2,-1,-0.5,-0.25,-0.125,0.125,0.25,0.5,1,2,4} - tracker[id][line].rate = int_to_rate[tracker_rate] - elseif sel == 3 then - ea.move_start(tracker[id][line],d/loop_enc_resolution) - elseif sel == 4 then - ea.move_end(tracker[id][line],d/loop_enc_resolution) - elseif sel == 5 then - local bool_to_string = {["false"] = 1, ["true"] = 2} - local tracker_loop = bool_to_string[tostring(tracker[id][line].loop)] - tracker_loop = util.clamp(tracker_loop+d,1,2) - local int_to_bool = {false, true} - tracker[id][line].loop = int_to_bool[tracker_loop] - elseif sel == 6 then - local pre_adjust = tracker[id][line].clip - local current_difference = (tracker[id][line].end_point - tracker[id][line].start_point) - if tracker[id][line].mode == 1 and tracker[id][line].clip + d > 3 then - tracker[id][line].mode = 2 - tracker[id][line].clip = 1 - elseif tracker[id][line].mode == 2 and tracker[id][line].clip + d < 1 then - tracker[id][line].mode = 1 - tracker[id][line].clip = 3 - else - tracker[id][line].clip = util.clamp(tracker[id][line].clip+d,1,3) - end - tracker[id][line].start_point = tracker[id][line].start_point - ((pre_adjust - tracker[id][line].clip)*8) - tracker[id][line].end_point = tracker[id][line].start_point + current_difference - end - --trackers.map_similar(id,line) - end - --]==] elseif menu == 9 then - local focus_arp = arp[page.arp_page_sel] - if page.arp_param_group[page.arp_page_sel] == 2 then - focus_arp.start_point = util.clamp(focus_arp.start_point+d,1,focus_arp.end_point) - else - local deci_to_int = - { ["0.125"] = 1 --1/32 - , ["0.1667"] = 2 --1/16T - , ["0.25"] = 3 -- 1/16 - , ["0.3333"] = 4 -- 1/8T - , ["0.5"] = 5 -- 1/8 - , ["0.6667"] = 6 -- 1/4T - , ["1.0"] = 7 -- 1/4 - , ["1.3333"] = 8 -- 1/2T - , ["2.0"] = 9 -- 1/2 - , ["2.6667"] = 10 -- 1T - , ["4.0"] = 11 -- 1 - } - local rounded = util.round(focus_arp.time,0.0001) - local working = deci_to_int[tostring(rounded)] - working = util.clamp(working+d,1,11) - local int_to_deci = {0.125,1/6,0.25,1/3,0.5,2/3,1,4/3,2,8/3,4} - focus_arp.time = int_to_deci[working] - for i = 1,16 do - bank[page.arp_page_sel][i].arp_time = focus_arp.time - end - end + page.arp_param[page.arp_page_sel] = util.clamp(page.arp_param[page.arp_page_sel] + d,1,5) elseif menu == 10 then local selected_slot = page.rnd_page_sel[page.rnd_page] if page.rnd_page_section == 1 then @@ -343,7 +251,7 @@ function encoder_actions.init(n,d) if menu == 2 then local id = page.loops_sel if id ~= 4 then - if page.loops_view[id] == 2 then + if page.loops_view[id] == 3 then local focused_pad = nil if grid_pat[id].play == 0 and grid_pat[id].tightened_start == 0 and not arp[id].playing and midi_pat[id].play == 0 then focused_pad = bank[id].id @@ -369,6 +277,27 @@ function encoder_actions.init(n,d) bank[id][i].offset = bank[id][focused_pad].offset end end + + elseif page.loops_view[id] == 2 then + local focused_pad = nil + if grid_pat[id].play == 0 and grid_pat[id].tightened_start == 0 and not arp[id].playing and midi_pat[id].play == 0 then + focused_pad = bank[id].id + else + focused_pad = bank[id].focus_pad + end + bank[id][focused_pad].rate_slew = util.clamp(bank[id][focused_pad].rate_slew+d/10,0,4) + softcut.rate_slew_time(id+1,bank[id][focused_pad].rate_slew) + if focused_pad == 16 then + for i = 1,15 do + bank[id][i].rate_slew = bank[id][16].rate_slew + end + end + if grid.alt == 1 then + for i = 1,16 do + bank[id][i].rate_slew = bank[id][focused_pad].rate_slew + end + end + elseif page.loops_view[id] == 1 then local which_pad = nil if bank[id].focus_hold == false then @@ -546,45 +475,59 @@ function encoder_actions.init(n,d) rytm.track[rytm.track_edit].clock_div = tonumber(deci[new_value]) end - --[==[ - if page.track_page_section[page.track_page] == 3 then - if tracker[page.track_page][page.track_sel[page.track_page]].pad ~= nil then - local numerator_to_sel = - { [2] = 1 --1/16T - , [3] = 2 -- 1/16 - , [4] = 3 -- 1/8T - , [6] = 4 -- 1/8 - , [8] = 5 -- 1/4T - , [12] = 6 -- 1/4 - , [16] = 7 -- 1/2T - , [24] = 8 -- 1/2 - , [32] = 9 -- 1T - , [48] = 10 -- 1 - } - local working = numerator_to_sel[tracker[page.track_page][page.track_sel[page.track_page]].time] - working = util.clamp(working+d,1,10) - local int_to_numerator = {2,3,4,6,8,12,16,24,32,48} - tracker[page.track_page][page.track_sel[page.track_page]].time = int_to_numerator[working] - end - end - --]==] elseif menu == 9 then - if page.arp_param_group[page.arp_page_sel] == 2 then - if #arp[page.arp_page_sel].notes > 0 then - arp[page.arp_page_sel].end_point = util.clamp(arp[page.arp_page_sel].end_point+d,arp[page.arp_page_sel].start_point,#arp[page.arp_page_sel].notes) + local focus_arp = arp[page.arp_page_sel] + local id = page.arp_page_sel + if page.arp_param[id] == 1 then + local deci_to_int = + { ["0.125"] = 1 --1/32 + , ["0.1667"] = 2 --1/16T + , ["0.25"] = 3 -- 1/16 + , ["0.3333"] = 4 -- 1/8T + , ["0.5"] = 5 -- 1/8 + , ["0.6667"] = 6 -- 1/4T + , ["1.0"] = 7 -- 1/4 + , ["1.3333"] = 8 -- 1/2T + , ["2.0"] = 9 -- 1/2 + , ["2.6667"] = 10 -- 1T + , ["4.0"] = 11 -- 1 + } + local rounded = util.round(focus_arp.time,0.0001) + local working = deci_to_int[tostring(rounded)] + working = util.clamp(working+d,1,11) + local int_to_deci = {0.125,1/6,0.25,1/3,0.5,2/3,1,4/3,2,8/3,4} + if page.arp_alt[page.arp_page_sel] then + bank[page.arp_page_sel][bank[page.arp_page_sel].id].arp_time = int_to_deci[working] + focus_arp.time = bank[page.arp_page_sel][bank[page.arp_page_sel].id].arp_time + else + focus_arp.time = int_to_deci[working] + for i = 1,16 do + bank[page.arp_page_sel][i].arp_time = focus_arp.time + end end - else + elseif page.arp_param[id] == 2 then local dir_to_int = { ["fwd"] = 1 , ["bkwd"] = 2 , ["pend"] = 3 , ["rnd"] = 4 } - local dir = dir_to_int[arp[page.arp_page_sel].mode] + local dir = dir_to_int[focus_arp.mode] dir = util.clamp(dir+d,1,4) local int_to_dir = {"fwd","bkwd","pend","rnd"} - arp[page.arp_page_sel].mode = int_to_dir[dir] + focus_arp.mode = int_to_dir[dir] + elseif page.arp_param[id] == 3 then + focus_arp.start_point = util.clamp(focus_arp.start_point+d,1,focus_arp.end_point) + elseif page.arp_param[id] == 4 then + if #focus_arp.notes > 0 then + focus_arp.end_point = util.clamp(focus_arp.end_point+d,focus_arp.start_point,#focus_arp.notes) + end + elseif page.arp_param[id] == 5 then + local working = arp[page.arp_page_sel].retrigger and 0 or 1 + working = util.clamp(working+d,0,1) + arp[page.arp_page_sel].retrigger = (working == 0 and true or false) end + elseif menu == 10 then local current = rnd[page.rnd_page][page.rnd_page_sel[page.rnd_page]] if page.rnd_page_section == 2 then @@ -673,63 +616,120 @@ function encoder_actions.init(n,d) end if page.levels_sel == 0 then if key1_hold or grid.alt == 1 then - for i = 1,16 do - bank[n][i].level = util.clamp(bank[n][i].level+d/10,0,2) - end + -- for i = 1,16 do + -- bank[n][i].level = util.clamp(bank[n][i].level+d/10,0,2) + -- end + bank[n].global_level = util.clamp(bank[n].global_level+d/10,0,2) else bank[n][focused_pad].level = util.clamp(bank[n][focused_pad].level+d/10,0,2) end - if bank[n][bank[n].id].enveloped == false then + -- TODO figure out of this is necessary: + -- it wouldn't let you adjust the volume on an enveloped + -- if bank[n][bank[n].id].enveloped == false then + if bank[n][bank[n].id].envelope_mode == 2 or bank[n][bank[n].id].enveloped == false then if bank[n].focus_hold == false then softcut.level_slew_time(n+1,1.0) - softcut.level(n+1,bank[n][bank[n].id].level) - softcut.level_cut_cut(n+1,5,util.linlin(-1,1,0,1,bank[n][bank[n].id].pan)*(bank[n][bank[n].id].left_delay_level*bank[n][bank[n].id].level)) - softcut.level_cut_cut(n+1,6,util.linlin(-1,1,1,0,bank[n][bank[n].id].pan)*(bank[n][bank[n].id].right_delay_level*bank[n][bank[n].id].level)) + softcut.level(n+1,bank[n][bank[n].id].level*bank[n].global_level) + softcut.level_cut_cut(n+1,5,(bank[n][bank[n].id].left_delay_level*bank[n][bank[n].id].level)*bank[n].global_level) + softcut.level_cut_cut(n+1,6,(bank[n][bank[n].id].right_delay_level*bank[n][bank[n].id].level)*bank[n].global_level) end end elseif page.levels_sel == 1 then + if key1_hold or grid.alt == 1 then for j = 1,16 do local pre_enveloped = bank[n][j].enveloped - if bank[n][j].enveloped then - if d < 0 then - bank[n][j].enveloped = false - if pre_enveloped ~= bank[n][j].enveloped then - cheat(n, bank[n].id) - end - end + local pre_mode = bank[n][j].envelope_mode + + bank[n][j].envelope_mode = util.clamp(bank[n][j].envelope_mode + d,0,3) + + if bank[n][j].envelope_mode == 0 then + bank[n][j].enveloped = false + -- TODO: figure out if this is necessary + -- if pre_enveloped ~= bank[n][j].enveloped then + -- cheat(n, bank[n].id) + -- end else - if d > 0 then - bank[n][j].enveloped = true - if pre_enveloped ~= bank[n][j].enveloped then - cheat(n, bank[n].id) - end + bank[n][j].enveloped = true + if pre_enveloped ~= bank[n][j].enveloped then + cheat(n, bank[n].id) end end + + -- if bank[n][j].enveloped then + -- if d < 0 then + -- bank[n][j].enveloped = false + -- if pre_enveloped ~= bank[n][j].enveloped then + -- cheat(n, bank[n].id) + -- end + -- end + -- else + -- if d > 0 then + -- bank[n][j].enveloped = true + -- if pre_enveloped ~= bank[n][j].enveloped then + -- cheat(n, bank[n].id) + -- end + -- end + -- end + end + else + local pre_enveloped = bank[n][focused_pad].enveloped - if bank[n][focused_pad].enveloped then - if d < 0 then - bank[n][focused_pad].enveloped = false - if pre_enveloped ~= bank[n][bank[n].id].enveloped then - if bank[n].focus_hold == false then - cheat(n, bank[n].id) - end + local pre_mode = bank[n][focused_pad].envelope_mode + bank[n][focused_pad].envelope_mode = util.clamp(bank[n][focused_pad].envelope_mode + d,0,3) + + if bank[n][focused_pad].envelope_mode == 0 then + bank[n][focused_pad].enveloped = false + -- if pre_enveloped ~= bank[n][bank[n].id].enveloped then + -- if bank[n].focus_hold == false then + -- cheat(n, bank[n].id) + -- end + -- end + else + bank[n][focused_pad].enveloped = true + if pre_enveloped ~= bank[n][focused_pad].enveloped then + if bank[n].focus_hold == false then + cheat(n, bank[n].id) + end + elseif pre_mode ~= bank[n][focused_pad].envelope_mode then + if bank[n].focus_hold == false then + cheat(n, bank[n].id) end end - else - if d > 0 then - bank[n][focused_pad].enveloped = true - if pre_enveloped ~= bank[n][focused_pad].enveloped then + end + + end + + elseif page.levels_sel == 2 then + if key1_hold or grid.alt == 1 then + for j = 1,16 do + if bank[n][j].enveloped then + if d>0 then + bank[n][j].envelope_loop = true + else + bank[n][j].envelope_loop = false + end + end + end + else + if bank[n][focused_pad].enveloped then + local pre_loop = bank[n][focused_pad].envelope_loop + if d>0 then + bank[n][focused_pad].envelope_loop = true + if pre_loop ~= bank[n][focused_pad].envelope_loop then if bank[n].focus_hold == false then cheat(n, bank[n].id) end end + else + bank[n][focused_pad].envelope_loop = false end end end - elseif page.levels_sel == 2 then + + elseif page.levels_sel == 3 then if key1_hold or grid.alt == 1 then for j = 1,16 do if bank[n][j].enveloped then @@ -740,11 +740,12 @@ function encoder_actions.init(n,d) end else if bank[n][focused_pad].enveloped then - bank[n][focused_pad].envelope_time = util.explin(0.1,60,0.1,60,bank[n][focused_pad].envelope_time) - bank[n][focused_pad].envelope_time = util.clamp(bank[n][focused_pad].envelope_time+d/10,0.1,60) - bank[n][focused_pad].envelope_time = util.linexp(0.1,60,0.1,60,bank[n][focused_pad].envelope_time) + bank[n][focused_pad].envelope_time = util.explin(0.05,60,0.05,60,bank[n][focused_pad].envelope_time) + bank[n][focused_pad].envelope_time = util.clamp(bank[n][focused_pad].envelope_time+d/10,0.05,60) + bank[n][focused_pad].envelope_time = util.linexp(0.05,60,0.05,60,bank[n][focused_pad].envelope_time) end end + env_counter[n].time = (bank[n][focused_pad].envelope_time/(bank[n][focused_pad].level/0.05)) end end if menu == 4 then diff --git a/lib/euclid.lua b/lib/euclid.lua index cc519a6..f45cdcb 100755 --- a/lib/euclid.lua +++ b/lib/euclid.lua @@ -24,6 +24,7 @@ function euclid.trig(target) end cheat(target,euclid.rotate_pads(euclid.track[target].pos + euclid.track[target].pad_offset)) end + grid_dirty = true end end diff --git a/lib/grid_actions.lua b/lib/grid_actions.lua index 0d35ca6..28e57b9 100755 --- a/lib/grid_actions.lua +++ b/lib/grid_actions.lua @@ -456,7 +456,7 @@ function grid_actions.init(x,y,z) end elseif grid.alt == 1 then if y == 8 then - sixteen_slices(x/5) + -- sixteen_slices(x/5) elseif y == 7 then rec_to_pad(x/5) elseif y == 6 then diff --git a/lib/main_menu.lua b/lib/main_menu.lua index 9f853f6..82387c2 100755 --- a/lib/main_menu.lua +++ b/lib/main_menu.lua @@ -99,6 +99,29 @@ function main_menu.init() screen.text("|") end elseif page.loops_view[i] == 2 then + + local id = page.loops_sel + local focused_pad = nil + if grid_pat[i].play == 0 and grid_pat[i].tightened_start == 0 and not arp[i].playing and midi_pat[i].play == 0 then + focused_pad = bank[i].id + else + focused_pad = bank[i].focus_pad + end + screen.move(0,8+(i*14)) + screen.level(page.loops_sel == i and 15 or 3) + if grid.alt == 0 then + local loops_to_screen_options = {"a", "b", "c"} + screen.text(loops_to_screen_options[i]..""..focused_pad) + else + local loops_to_screen_options = {"(a)","(b)","(c)"} + screen.text(loops_to_screen_options[i]) + end + screen.move(20,8+(i*14)) + screen.text("rate: "..string.format("%.4g",bank[i][bank[i].id].rate).."x") + screen.move(75,8+(i*14)) + screen.text("slew: "..string.format("%.1f",bank[i][bank[i].id].rate_slew).."s") + + elseif page.loops_view[i] == 3 then screen.move(15,8+(i*14)) local id = page.loops_sel local focused_pad = nil @@ -138,7 +161,6 @@ function main_menu.init() screen.text((bank[i][focused_pad].mode == 1 and "Live" or "Clip")..": "..bank[i][focused_pad].clip) screen.move(60,8+(i*14)) screen.text("offset: "..string.format("%.0f",((math.log(bank[i][focused_pad].offset)/math.log(0.5))*-12)).." st") - end end @@ -182,7 +204,7 @@ function main_menu.init() screen.level(3) screen.text("levels") screen.line_width(1) - local level_options = {"levels","envelope enable","decay"} + local level_options = {"levels","envelope enable","loop","time"} local focused_pad = nil for i = 1,3 do if bank[i].focus_hold == true then @@ -203,32 +225,41 @@ function main_menu.init() screen.text(level_to_screen_options[i]..""..focused_pad) end screen.move(35+(20*(i-1)),57) - local level_to_screen = util.linlin(0,2,0,40,bank[i][focused_pad].level) + local level_to_screen = ((key1_hold or grid.alt == 1) and util.linlin(0,2,0,40,bank[i].global_level) or util.linlin(0,2,0,40,bank[i][focused_pad].level)) screen.line(35+(20*(i-1)),57-level_to_screen) screen.close() screen.stroke() screen.level(level_options[page.levels_sel+1] == "envelope enable" and 15 or 3) - screen.move(90,10) + screen.move(85,10) screen.text("env?") screen.move(90+((i-1)*15),20) + local shapes = {"\\","/","/\\"} if bank[i][focused_pad].enveloped then - screen.text("|\\") + screen.text_center(shapes[bank[i][focused_pad].envelope_mode]) else - screen.text("-") + screen.text_center("-") end - screen.level(level_options[page.levels_sel+1] == "decay" and 15 or 3) - screen.move(90,30) - screen.text("decay") - screen.move(90,30+((i)*10)) + screen.level(level_options[page.levels_sel+1] == "loop" and 15 or 3) + screen.move(90+((i-1)*15),30) + if bank[i][focused_pad].envelope_loop then + screen.text_center("∞") + else + screen.text_center("-") + end + + screen.level(level_options[page.levels_sel+1] == "time" and 15 or 3) + -- screen.move(85,30) + -- screen.text("time") + screen.move(85,34+((i)*10)) local envelope_to_screen_options = {"a", "b", "c"} if key1_hold or grid.alt == 1 then screen.text("("..envelope_to_screen_options[i]..")") else screen.text(envelope_to_screen_options[i]..""..focused_pad) end - screen.move(110,30+((i)*10)) + screen.move(105,34+((i)*10)) if bank[i][focused_pad].enveloped then - screen.text(string.format("%.1f", bank[i][focused_pad].envelope_time)) + screen.text(string.format("%.2g", bank[i][focused_pad].envelope_time).."s") else screen.text("---") end @@ -662,46 +693,47 @@ function main_menu.init() screen.level(page.arp_page_sel == page.arp_page_sel and 15 or 3) screen.move(75+(page.arp_page_sel*15),13) screen.text("_") - if key1_hold then - screen.move(0,20) - screen.level(15) - screen.text("retrigger: "..(tostring(focus_arp.retrigger) == "true" and "yes" or "no")) - end screen.move(100,10) screen.move(0,60) screen.font_size(15) screen.level(15) - screen.text(focus_arp.hold and "hold" or "") + screen.text((focus_arp.hold and focus_arp.playing) and "hold" or ((focus_arp.hold and not focus_arp.playing) and "pause" or "")) screen.font_size(40) screen.move(50,50) screen.text(#focus_arp.notes > 0 and focus_arp.notes[focus_arp.step] or "...") screen.font_size(8) - if page.arp_param_group[page.arp_page_sel] == 2 then - screen.move(125,50) - screen.text_right("s: "..focus_arp.start_point) - screen.move(125,60) - screen.text_right("e: "..focus_arp.end_point) - else - screen.move(125,50) - local deci_to_frac = - { ["0.125"] = "1/32" - , ["0.1667"] = "1/16t" - , ["0.25"] = "1/16" - , ["0.3333"] = "1/8t" - , ["0.5"] = "1/8" - , ["0.6667"] = "1/4t" - , ["1.0"] = "1/4" - , ["1.3333"] = "1/2t" - , ["2.0"] = "1/2" - , ["2.6667"] = "1t" - , ["4.0"] = "1" - } - screen.text_right(deci_to_frac[tostring(util.round(focus_arp.time, 0.0001))]) - screen.move(125,60) - screen.text_right(focus_arp.mode) - end + local deci_to_frac = + { ["0.125"] = "1/32" + , ["0.1667"] = "1/16t" + , ["0.25"] = "1/16" + , ["0.3333"] = "1/8t" + , ["0.5"] = "1/8" + , ["0.6667"] = "1/4t" + , ["1.0"] = "1/4" + , ["1.3333"] = "1/2t" + , ["2.0"] = "1/2" + , ["2.6667"] = "1t" + , ["4.0"] = "1" + } + screen.move(125,20) + screen.level(page.arp_param[page.arp_page_sel] == 1 and 15 or 3) + local banks = {"a","b","c"} + local pad = tostring(banks[page.arp_page_sel]..bank[page.arp_page_sel].id) + screen.text_right((page.arp_alt[page.arp_page_sel] and (pad..": ") or "")..deci_to_frac[tostring(util.round(focus_arp.time, 0.0001))]) + screen.move(125,30) + screen.level(page.arp_param[page.arp_page_sel] == 2 and 15 or 3) + screen.text_right(focus_arp.mode) + screen.move(125,40) + screen.level(page.arp_param[page.arp_page_sel] == 3 and 15 or 3) + screen.text_right("s: "..focus_arp.start_point) + screen.move(125,50) + screen.level(page.arp_param[page.arp_page_sel] == 4 and 15 or 3) + screen.text_right("e: "..(focus_arp.end_point > 0 and focus_arp.end_point or "1")) + screen.move(125,60) + screen.level(page.arp_param[page.arp_page_sel] == 5 and 15 or 3) + screen.text_right("retrig: "..(tostring(focus_arp.retrigger) == "true" and "y" or "n")) elseif menu == 10 then screen.move(0,10) diff --git a/lib/rnd_actions.lua b/lib/rnd_actions.lua index 4e3be25..908c324 100755 --- a/lib/rnd_actions.lua +++ b/lib/rnd_actions.lua @@ -72,7 +72,8 @@ end function rnd.restore_default(t,i) if rnd[t][i].param == "rate slew" then - softcut.rate_slew_time(t+1,params:get("rate slew time "..t)) + -- softcut.rate_slew_time(t+1,params:get("rate slew time "..t)) + softcut.rate_slew_time(t+1,bank[t][bank[t].id].rate_slew) elseif rnd[t][i].param == "pan" then softcut.pan(t+1,bank[t][bank[t].id].pan) elseif rnd[t][i].param == "delay send" then @@ -89,7 +90,10 @@ end function rnd.rate_slew(t,i) local min = util.round(rnd[t][i].rate_slew_min * 1000) local max = util.round(rnd[t][i].rate_slew_max * 1000) - local random_slew = math.random(min,max)/10000 + local random_slew = math.random(min,max)/1000 + if rnd[t][i].mode == "destructive" then + bank[t][bank[t].id].rate_slew = random_slew + end softcut.rate_slew_time(t+1,random_slew) end @@ -101,8 +105,6 @@ function rnd.pan(t,i) bank[t][bank[t].id].pan = rand_pan end softcut.pan(t+1,rand_pan) - -- rightangleslice.actions[3]['123'][1](bank[t][bank[t].id]) - -- rightangleslice.actions[3]['123'][2](bank[t][bank[t].id],t) end function rnd.rate(t,i) @@ -135,6 +137,7 @@ function rnd.loop(t) bank[t][bank[t].id].loop = false softcut.loop(t+1,0) end + grid_dirty = true end function rnd.delay_send(t,i) @@ -143,6 +146,19 @@ function rnd.delay_send(t,i) bank[t][j].left_delay_level = delay_send bank[t][j].right_delay_level = delay_send end + softcut.level_slew_time(5,1) + softcut.level_slew_time(6,1) + if bank[t][bank[t].id].left_delay_thru then + softcut.level_cut_cut(t+1,5,bank[t][bank[t].id].left_delay_level) + else + softcut.level_cut_cut(t+1,5,(bank[t][bank[t].id].left_delay_level*bank[t][bank[t].id].level)*bank[t].global_level) + end + if bank[t][bank[t].id].right_delay_thru then + softcut.level_cut_cut(t+1,6,bank[t][bank[t].id].right_delay_level) + else + softcut.level_cut_cut(t+1,6,(bank[t][bank[t].id].right_delay_level*bank[t][bank[t].id].level)*bank[t].global_level) + end + grid_dirty = true end function rnd.offset(t,i) diff --git a/lib/start_up.lua b/lib/start_up.lua index 2e192bd..2bbd889 100755 --- a/lib/start_up.lua +++ b/lib/start_up.lua @@ -77,7 +77,7 @@ function start_up.init() params:add_separator("clips") for i = 1,3 do - params:add_file("clip "..i.." sample", "clip "..i.." sample", "/home/we/dust/audio/") + params:add_file("clip "..i.." sample", "clip "..i.." sample") params:set_action("clip "..i.." sample", function(file) load_sample(file,i) end) end @@ -278,9 +278,9 @@ function start_up.init() params:set_action("level "..i, function(x) bank[i][bank[i].id].level = x if not bank[i][bank[i].id].enveloped then - softcut.level(i+1,x) - softcut.level_cut_cut(i+1,5,util.linlin(-1,1,0,1,bank[i][bank[i].id].pan)*(bank[i][bank[i].id].left_delay_level*bank[i][bank[i].id].level)) - softcut.level_cut_cut(i+1,6,util.linlin(-1,1,1,0,bank[i][bank[i].id].pan)*(bank[i][bank[i].id].right_delay_level*bank[i][bank[i].id].level)) + softcut.level(i+1,x*bank[i].global_level) + softcut.level_cut_cut(i+1,5,(bank[i][bank[i].id].left_delay_level*bank[i][bank[i].id].level)*bank[i].global_level) + softcut.level_cut_cut(i+1,6,(bank[i][bank[i].id].right_delay_level*bank[i][bank[i].id].level)*bank[i].global_level) end redraw() end) @@ -437,7 +437,7 @@ function start_up.init() params:add_control("delay L: ("..banks[i]..") send", "delay L: ("..banks[i]..") send", controlspec.new(0,1,'lin',0.1,0,"")) params:set_action("delay L: ("..banks[i]..") send", function(x) if bank[i][bank[i].id].enveloped == false then - softcut.level_cut_cut(i+1,5,x*bank[i][bank[i].id].level) + softcut.level_cut_cut(i+1,5,(x*bank[i][bank[i].id].level)*bank[i].global_level) end for j = 1,16 do bank[i][j].left_delay_level = x @@ -446,7 +446,7 @@ function start_up.init() params:add_control("delay R: ("..banks[i]..") send", "delay R: ("..banks[i]..") send", controlspec.new(0,1,'lin',0.1,0,"")) params:set_action("delay R: ("..banks[i]..") send", function(x) if bank[i][bank[i].id].enveloped == false then - softcut.level_cut_cut(i+1,6,x*bank[i][bank[i].id].level) + softcut.level_cut_cut(i+1,6,(x*bank[i][bank[i].id].level)*bank[i].global_level) end for j = 1,16 do bank[i][j].right_delay_level = x diff --git a/lib/zilchmos.lua b/lib/zilchmos.lua index 984e1ad..b2c5ed6 100755 --- a/lib/zilchmos.lua +++ b/lib/zilchmos.lua @@ -46,7 +46,6 @@ end function zilchmos.map( fn, bank ) -- this is a local bank, represents bank[i] for i=1,16 do -- will execute for each of the 16 elements in bank fn( bank[i] ) -- pass each pad to the supplied function - --trackers.inherit(which_bank,i) end end @@ -69,7 +68,13 @@ function z.slew_add( pad ) z.slew( pad, "add" ) end -- core pad modifiers function zilchmos.level_inc( pad, delta ) - pad.level = util.clamp( pad.level + delta, 0, 2 ) + if not bank[which_bank].alt_lock and grid.alt == 0 then + pad.level = util.clamp( pad.level + delta, 0, 2 ) + else + if pad.pad_id == 1 then + bank[which_bank].global_level = util.clamp( bank[which_bank].global_level + delta, 0, 2) + end + end end function zilchmos.pan_reverse( pad ) @@ -105,11 +110,12 @@ end function zilchmos.start_end_default( pad ) local duration; - if pad.mode == 1 and pad.clip == rec.clip then + -- if pad.mode == 1 and pad.clip == rec.clip then + if pad.mode == 1 then --slice within bounds duration = rec.end_point-rec.start_point - pad.start_point = rec.start_point+((duration/16) * (pad.pad_id-1)) - pad.end_point = rec.start_point+((duration/16) * (pad.pad_id)) + pad.start_point = (rec.start_point+((duration/16) * (pad.pad_id-1)))+((pad.clip-1)*8) + pad.end_point = (rec.start_point+((duration/16) * (pad.pad_id)))+((pad.clip-1)*8) else duration = pad.mode == 1 and 8 or clip[pad.clip].sample_length pad.start_point = ((duration/16)*(pad.pad_id-1)) + clip[pad.clip].min @@ -283,16 +289,16 @@ end function zilchmos.sc.level( pad, i ) if not pad.enveloped then softcut.level_slew_time(i+1,1.0) - softcut.level(i+1,pad.level) + softcut.level(i+1,pad.level*bank[i].global_level) if pad.left_delay_thru then - softcut.level_cut_cut(i+1,5,util.linlin(-1,1,0,1,pad.pan)*(pad.left_delay_level)) + softcut.level_cut_cut(i+1,5,pad.left_delay_level) else - softcut.level_cut_cut(i+1,5,util.linlin(-1,1,0,1,pad.pan)*(pad.left_delay_level*pad.level)) + softcut.level_cut_cut(i+1,5,(pad.left_delay_level*pad.level)*bank[i].global_level) end if pad.right_delay_thru then - softcut.level_cut_cut(i+1,6,util.linlin(-1,1,1,0,pad.pan)*(pad.right_delay_level)) + softcut.level_cut_cut(i+1,6,pad.right_delay_level) else - softcut.level_cut_cut(i+1,6,util.linlin(-1,1,1,0,pad.pan)*(pad.right_delay_level*pad.level)) + softcut.level_cut_cut(i+1,6,(pad.right_delay_level*pad.level)*bank[i].global_level) end end end @@ -305,7 +311,7 @@ function zilchmos.sc.play_toggle( pad, i ) if pad.enveloped then cheat( i, pad.pad_id ) else - softcut.level(i+1, pad.level) + softcut.level(i+1, pad.level*bank[i].global_level) end softcut.rate(i+1, pad.rate * pad.offset) end From 8e46ac46793daceccc910b65c1655ecf41d3abd6 Mon Sep 17 00:00:00 2001 From: dndrks Date: Thu, 27 Aug 2020 09:42:16 -0500 Subject: [PATCH 3/9] fixes FIXED: - collections now save cleanly, in folders - arc patterns now save - added more grid redraw flags ADDED: - arc enc 4 is meta param selector --- cheat_codes.lua | 1374 ++++++++++++++++++++----------------------- lib/arc_actions.lua | 50 +- lib/arp_actions.lua | 10 +- lib/delay.lua | 16 +- lib/euclid.lua | 10 +- lib/rnd_actions.lua | 10 +- 6 files changed, 700 insertions(+), 770 deletions(-) diff --git a/cheat_codes.lua b/cheat_codes.lua index 536e5eb..b30db60 100755 --- a/cheat_codes.lua +++ b/cheat_codes.lua @@ -48,6 +48,7 @@ arc_control = {} for i = 1,3 do arc_control[i] = i end +arc_meta_focus = 1 arc_offset = 0 --IMPORTANT TO REVISIT @@ -472,12 +473,12 @@ end function save_external_timing(bank,slot) - local dirname = _path.data.."cheat_codes/external-timing/" + local dirname = _path.data.."cheat_codes2/external-timing/" if os.rename(dirname, dirname) == nil then os.execute("mkdir " .. dirname) end - local file = io.open(_path.data .. "cheat_codes/external-timing/pattern"..selected_coll.."_"..slot.."_external-timing.data", "w+") + local file = io.open(_path.data .. "cheat_codes2/external-timing/pattern"..selected_coll.."_"..slot.."_external-timing.data", "w+") io.output(file) io.write("external clock timing for stored pad pattern: collection "..selected_coll.." + slot "..slot.."\n") local total_entry_count = 0 @@ -499,7 +500,7 @@ function save_external_timing(bank,slot) end function load_external_timing(bank,slot) - local file = io.open(_path.data .. "cheat_codes/external-timing/pattern"..selected_coll.."_"..slot.."_external-timing.data", "r") + local file = io.open(_path.data .. "cheat_codes2/external-timing/pattern"..selected_coll.."_"..slot.."_external-timing.data", "r") if file then io.input(file) if io.read() == "external clock timing for stored pad pattern: collection "..selected_coll.." + slot "..slot then @@ -1240,6 +1241,13 @@ function init() , 1/30, -1) hardware_redraw:start() + -- for i = 0,100 do + -- local dirname = _path.data.."cheat_codes2/collection-"..i + -- if os.rename(dirname, dirname) == nil then + -- os.execute("mkdir " .. dirname) + -- end + -- end + end --- @@ -2519,27 +2527,27 @@ function load_sample(file,sample) end function save_sample(i) - local dirname = _path.dust.."audio/cc_saved_samples/" + local dirname = _path.dust.."audio/cc2_saved_samples/" if os.rename(dirname, dirname) == nil then os.execute("mkdir " .. dirname) end - local name = "cc_"..os.date("%y%m%d_%X-buff")..i..".wav" + local name = "cc2_"..os.date("%y%m%d_%X-buff")..i..".wav" local save_pos = i - 1 - softcut.buffer_write_mono(_path.dust.."/audio/cc_saved_samples/"..name,1+(8*save_pos),8,1) + softcut.buffer_write_mono(_path.dust.."/audio/cc2_saved_samples/"..name,1+(8*save_pos),8,1) end function collect_samples(i) -- this works!!! - local dirname = _path.dust.."audio/cc_collection-samples/" + local dirname = _path.dust.."audio/cc2_live-audio/" if os.rename(dirname, dirname) == nil then os.execute("mkdir " .. dirname) end - local dirname = _path.dust.."audio/cc_collection-samples/"..params:get("collection").."/" + local dirname = _path.dust.."audio/cc2_live-audio/"..params:get("collection").."/" if os.rename(dirname, dirname) == nil then os.execute("mkdir " .. dirname) end - local name = "cc_"..params:get("collection").."-"..i..".wav" + local name = "cc2_"..params:get("collection").."-"..i..".wav" local save_pos = i - 1 - softcut.buffer_write_mono(_path.dust.."audio/cc_collection-samples/"..params:get("collection").."/"..name,1+(8*save_pos),8,1) + softcut.buffer_write_mono(_path.dust.."audio/cc2_live-audio/"..params:get("collection").."/"..name,1+(8*save_pos),8,1) end function reload_collected_samples(file,sample) @@ -2548,6 +2556,7 @@ function reload_collected_samples(file,sample) end if file ~= "-" then softcut.buffer_read_mono(file, 0, 1+(8 * (sample-1)), 8, 1, 1) + print("reloaded previous session's audio") end end @@ -3717,24 +3726,30 @@ arc_redraw = function() end end - for i = 1,13 do - local arc_left_delay_level = (params:get("delay L: div/mult") == i and 15 or 5) - local arc_right_delay_level = (params:get("delay R: div/mult") == i and 15 or 5) - local arc_try = params:get("delay L: div/mult") - if arc.alt == nil or arc.alt == 0 then - a:led(4,(41+((i-1)*4)-16),arc_left_delay_level) - else - a:led(4,(41+((i-1)*4)-16),arc_right_delay_level) - end + -- for i = 1,13 do + -- local arc_left_delay_level = (params:get("delay L: div/mult") == i and 15 or 5) + -- local arc_right_delay_level = (params:get("delay R: div/mult") == i and 15 or 5) + -- local arc_try = params:get("delay L: div/mult") + -- if arc.alt == nil or arc.alt == 0 then + -- a:led(4,(41+((i-1)*4)-16),arc_left_delay_level) + -- else + -- a:led(4,(41+((i-1)*4)-16),arc_right_delay_level) + -- end + -- end + + arc_meta_level = {} + for i = 1,6 do + arc_meta_level[i] = util.round(arc_meta_focus) == i and 15 or 5 + a:led(4,((i-1)*8)+25,arc_meta_level[i]) end - + a:refresh() end --file loading function persistent_state_save() - local file = io.open(_path.data.. "cheat_codes/persistent_state.data", "w+") + local file = io.open(_path.data.. "cheat_codes2/persistent_state.data", "w+") io.output(file) io.write("midi_control_enabled: "..params:get("midi_control_enabled").."\n") io.write("midi_control_device: "..params:get("midi_control_device").."\n") @@ -3757,10 +3772,10 @@ function count_lines_in(file) end function persistent_state_restore() - local file = io.open(_path.data .. "cheat_codes/persistent_state.data", "r") + local file = io.open(_path.data .. "cheat_codes2/persistent_state.data", "r") if file then io.input(file) - for i = 1,count_lines_in(_path.data.. "cheat_codes/persistent_state.data") do + for i = 1,count_lines_in(_path.data.. "cheat_codes2/persistent_state.data") do local s = io.read() local param,val = s:match("(.+): (.+)") params:set(param,tonumber(val)) @@ -3769,10 +3784,10 @@ function persistent_state_restore() end end -function testsavestate() +function savestate() local dirname = _path.data.."cheat_codes2/" - local collection = params:get("collection") + local collection = tonumber(string.format("%.0f",params:get("collection"))) if os.rename(dirname, dirname) == nil then os.execute("mkdir " .. dirname) end @@ -3782,9 +3797,8 @@ function testsavestate() os.execute("mkdir " .. dirname) end - local dirnames = {"banks/","params/","arc-pat/","grid-pat/","step-seq/","arps/","euclid/","rnd/","delays/"} + local dirnames = {"banks/","params/","arc-rec/","patterns/","step-seq/","arps/","euclid/","rnd/","delays/","rec/"} for i = 1,#dirnames do - -- print(_path.data.."cheat_codes2/collection-"..collection.."/"..dirnames[i]) local directory = _path.data.."cheat_codes2/collection-"..collection.."/"..dirnames[i] if os.rename(directory, directory) == nil then os.execute("mkdir " .. directory) @@ -3793,41 +3807,75 @@ function testsavestate() for i = 1,3 do tab.save(bank[i],_path.data .. "cheat_codes2/collection-"..collection.."/banks/"..i..".data") - tab.save(arc_pat[i],_path.data .. "cheat_codes2/collection-"..collection.."/arc-pat/"..i..".data") tab.save(step_seq[i],_path.data .. "cheat_codes2/collection-"..collection.."/step-seq/"..i..".data") - -- tab.save(grid_pat[i],_path.data .. "cheat_codes2/collection-"..collection.."/grid-pat/"..i..".data") tab.save(arp[i],_path.data .. "cheat_codes2/collection-"..collection.."/arps/"..i..".data") tab.save(rytm.track[i],_path.data .. "cheat_codes2/collection-"..collection.."/euclid/euclid"..i..".data") + tab.save(rnd[i],_path.data .. "cheat_codes2/collection-"..collection.."/rnd/"..i..".data") + if params:get("collect_live") == 2 then + collect_samples(i) + end end + for i = 1,2 do tab.save(delay[i],_path.data .. "cheat_codes2/collection-"..collection.."/delays/delay"..(i == 1 and "L" or "R")..".data") end + params:write(_path.data.."cheat_codes2/collection-"..collection.."/params/all.pset") + tab.save(rec,_path.data .. "cheat_codes2/collection-"..collection.."/rec/rec.data") + + -- GRID pattern save + if selected_coll ~= collection then + meta_copy_coll(selected_coll,collection) + end + meta_shadow(collection) + selected_coll = collection + --/ GRID pattern save + -- MIDI pattern save for i = 1,3 do - tab.save(rnd[i],_path.data .. "cheat_codes2/collection-"..collection.."/rnd/"..i..".data") + save_midi_pattern(i) + end + --/ MIDI pattern save + + -- ARC rec save + local arc_rec_dirty = {false,false,false} + for i = 1,3 do + for j = 1,4 do + if arc_pat[i][j].count > 0 then + arc_rec_dirty[i] = true + end + end + if arc_rec_dirty[i] then + save_arc_pattern(i) + else + local file = io.open(_path.data .. "cheat_codes2/collection-"..selected_coll.."/arc-rec/encoder-"..i..".data", "r") + if file then + io.input(file) + os.remove(_path.data .. "cheat_codes2/collection-"..selected_coll.."/arc-rec/encoder-"..i..".data") + io.close(file) + end + end end + --/ ARC rec save end -function testloadstate() - local collection = params:get("collection") +function loadstate() + local collection = tonumber(string.format("%.0f",params:get("collection"))) + selected_coll = collection params:read(_path.data.."cheat_codes2/collection-"..collection.."/params/all.pset") + if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/rec/rec.data") ~= nil then + rec = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/rec/rec.data") + end -- params:bang() for i = 1,3 do if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/banks/"..i..".data") ~= nil then bank[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/banks/"..i..".data") end - -- if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/arc-pat/"..i..".data") ~= nil then - -- arc_pat[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/arc-pat/"..i..".data") - -- end if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/step-seq/"..i..".data") ~= nil then step_seq[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/step-seq/"..i..".data") end - -- if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/grid-pat/"..i..".data") ~= nil then - -- grid_pat[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/grid-pat/"..i..".data") - -- end if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/arps/"..i..".data") ~= nil then arp[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/arps/"..i..".data") end @@ -3840,6 +3888,11 @@ function testloadstate() end end end + + if params:get("collect_live") == 2 then + reload_collected_samples(_path.dust.."audio/cc2_live-audio/"..collection.."/".."cc2_"..collection.."-"..i..".wav",i) + end + if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/euclid/euclid"..i..".data") ~= nil then rytm.track[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/euclid/euclid"..i..".data") end @@ -3852,457 +3905,478 @@ function testloadstate() end end - grid_dirty = true - -end - -function savestate() - local file = io.open(_path.data .. "cheat_codes/collections"..tonumber(string.format("%.0f",params:get("collection")))..".data", "w+") - io.output(file) - io.write("PERMANENCE".."\n") - for i = 1,3 do - for k = 1,16 do - io.write(bank[i].id .. "\n") - io.write(selected[i].x .. "\n") - io.write(selected[i].y .. "\n") - io.write(bank[i][k].clip .. "\n") - io.write(bank[i][k].mode .. "\n") - io.write(bank[i][k].start_point .. "\n") - io.write(bank[i][k].end_point .. "\n") - io.write(bank[i][k].rate .. "\n") - io.write(tostring(bank[i][k].pause) .. "\n") - io.write(tostring(bank[i][k].play_mode) .. "\n") - io.write(bank[i][k].level .. "\n") - io.write(tostring(bank[i][k].loop) .. "\n") - io.write(tostring(bank[i][k].fifth) .. "\n") - io.write(bank[i][k].pan .. "\n") - io.write(bank[i][k].fc .. "\n") - io.write(bank[i][k].q .. "\n") - io.write(bank[i][k].lp .. "\n") - io.write(bank[i][k].hp .. "\n") - io.write(bank[i][k].bp .. "\n") - io.write(bank[i][k].fd .. "\n") - io.write(bank[i][k].br .. "\n") - io.write(bank[i][k].filter_type .. "\n") - io.write(arc_control[i] .. "\n") - io.write(arc_param[i] .. "\n") - end - io.write(params:get("rate slew time ".. i) .. "\n") - io.write(tostring(params:get("clip "..i.." sample") .. "\n")) - local sides = {"delay L: ", "delay R: "} - for k = 1,2 do - io.write(params:get(sides[k].."div/mult") .. "\n") - io.write(params:get(sides[k].."global level") .. "\n") - io.write(params:get(sides[k].."feedback") .. "\n") - io.write(params:get(sides[k].."(a) send") .. "\n") - io.write(params:get(sides[k].."(b) send") .. "\n") - io.write(params:get(sides[k].."(c) send") .. "\n") - io.write(params:get(sides[k].."filter cut") .. "\n") - io.write(params:get(sides[k].."filter q") .. "\n") - io.write(params:get(sides[k].."filter lp") .. "\n") - io.write(params:get(sides[k].."filter hp") .. "\n") - io.write(params:get(sides[k].."filter bp") .. "\n") - io.write(params:get(sides[k].."filter dry") .. "\n") - end - end - io.write(params:get("offset").."\n") - -- v1.1 items - io.write("v1.1".."\n") - for i = 1,3 do - for k = 1,16 do - io.write(tostring(bank[i][k].enveloped) .. "\n") - io.write(bank[i][k].envelope_time .. "\n") - end - end - io.write(params:get("zilchmo_patterning") .. "\n") - io.write(params:get("rec_loop") .. "\n") - io.write(params:get("live_rec_feedback") .. "\n") - io.write(params:get("quantize_pads") .. "\n") - io.write(params:get("quantize_pats") .. "\n") - io.write(params:get("quant_div") .. "\n") - io.write(params:get("quant_div_pats") .. "\n") - io.write(params:get("bpm") .. "\n") - io.write(rec.clip .. "\n") - io.write(rec.start_point .. "\n") - io.write(rec.end_point .. "\n") - io.write("v1.1.1.1.1.1.1.1".."\n") - for i = 1,3 do - io.write(step_seq[i].active .. "\n") - io.write(step_seq[i].meta_duration .. "\n") - for k = 1,16 do - io.write(step_seq[i][k].meta_meta_duration .. "\n") - io.write(step_seq[i][k].assigned_to .. "\n") - io.write(bank[i][k].tilt .. "\n") - io.write(bank[i][k].tilt_ease_time .. "\n") - io.write(bank[i][k].tilt_ease_type .. "\n") - end - end - io.write("the last params".."\n") - --io.write(params:get("clock_out") .. "\n") - io.write("0".."\n") - --io.write(params:get("crow_clock_out") .. "\n") - io.write("0".."\n") - --io.write(params:get("midi_device") .. "\n") - io.write("0".."\n") - io.write(params:get("loop_enc_resolution") .."\n") - --io.write(params:get("clock") .. "\n") - io.write("0".."\n") - io.write(params:get("lock_pat") .. "\n") - for i = 1,3 do - io.write(bank[i].crow_execute .. "\n") - io.write(bank[i].snap_to_bars .. "\n") - end - for i = 1,3 do - for j = 1,16 do - io.write(bank[i][j].offset .. "\n") - end - end - io.write("crow execute count".."\n") - for i = 1,3 do - io.write(crow.count_execute[i] .. "\n") - end - io.write("step seq loop points".."\n") - for i = 1,3 do - io.write(step_seq[i].start_point .. "\n") - io.write(step_seq[i].end_point .. "\n") - end - io.write("Live buffer max".."\n") - io.write(params:get"live_buff_rate" .. "\n") - io.write("loop Pattern per step".."\n") - for i = 1,3 do - for k = 1,16 do - io.write(step_seq[i][k].loop_pattern.."\n") - end - end - io.write("collect live?".."\n") - io.write(params:get("collect_live").."\n") - if params:get("collect_live") == 2 then - io.write("sample refs".."\n") - for i = 1,3 do - io.write("/home/we/dust/audio/cc_collection-samples/"..params:get("collection").."/".."cc_"..params:get("collection").."-"..i..".wav".."\n") - collect_samples(i) - end - end - io.write("last Pattern playmode".."\n") - for i = 1,3 do - io.write(grid_pat[i].playmode.."\n") - end - io.write("1.2.1: arc patterning".."\n") - io.write(params:get("arc_patterning").."\n") - io.write("1.2.2: crow_pad_execute".."\n") - for i = 1,3 do - for k = 1,16 do - io.write(bank[i][k].crow_pad_execute.."\n") - end - end - io.write("1.3: Pattern random pitch range".."\n") - for i = 1,3 do - io.write(grid_pat[i].random_pitch_range.."\n") - end - io.write("1.3.1".."\n") - io.write("one_shot_clock_div: "..params:get("one_shot_clock_div").."\n") - io.write("rec_loop_enc_resolution: "..params:get("rec_loop_enc_resolution").."\n") - io.write("more 1.3.1".."\n") - io.write("random_rec_clock_prob: "..params:get("random_rec_clock_prob").."\n") - - io.write("cc2.0".."\n") - - io.close(file) - if selected_coll ~= params:get("collection") then - meta_copy_coll(selected_coll,params:get("collection")) - end - meta_shadow(params:get("collection")) - --maybe not this? want to clean up - selected_coll = params:get("collection") - for i = 1,3 do - if arc_pat[i][1].count > 0 then - save_arc_pattern(i) - end - save_midi_pattern(i) - end - for i = 1,2 do - del.savestate(i,selected_coll) - end - rnd.savestate() - arps.savestate() - rytm.savestate() -end - -function loadstate() - selected_coll = params:get("collection") - local file = io.open(_path.data .. "cheat_codes/collections"..selected_coll..".data", "r") - if file then - io.input(file) - pre_cc2_sample = { false, false, false } - restored_clip_file = {"","",""} - if io.read() == "PERMANENCE" then - for i = 1,3 do - for k = 1,16 do - bank[i].id = tonumber(io.read()) - selected[i].x = tonumber(io.read()) - selected[i].y = tonumber(io.read()) - bank[i][k].clip = tonumber(io.read()) - bank[i][k].mode = tonumber(io.read()) - bank[i][k].start_point = tonumber(io.read()) - bank[i][k].end_point = tonumber(io.read()) - bank[i][k].rate = tonumber(io.read()) - local pause_to_boolean = io.read() - if pause_to_boolean == "true" then - bank[i][k].pause = true - else - bank[i][k].pause = false - end - bank[i][k].play_mode = io.read() - bank[i][k].level = tonumber(io.read()) - local loop_to_boolean = io.read() - if loop_to_boolean == "true" then - bank[i][k].loop = true - else - bank[i][k].loop = false - end - local fifth_to_boolean = io.read() - if fifth_to_boolean == "true" then - bank[i][k].fifth = true - else - bank[i][k].fifth = false - end - bank[i][k].pan = tonumber(io.read()) - bank[i][k].fc = tonumber(io.read()) - bank[i][k].q = tonumber(io.read()) - bank[i][k].lp = tonumber(io.read()) - bank[i][k].hp = tonumber(io.read()) - bank[i][k].bp = tonumber(io.read()) - bank[i][k].fd = tonumber(io.read()) - bank[i][k].br = tonumber(io.read()) - tonumber(io.read()) - bank[i][k].filter_type = 4 - arc_control[i] = tonumber(io.read()) - arc_param[i] = tonumber(io.read()) - end - params:set("rate slew time ".. i,tonumber(io.read())) - local string_to_sample = io.read() - restored_clip_file[i] = string_to_sample - -- params:set("clip "..i.." sample", string_to_sample) - local sides = {"delay L: ", "delay R: "} - for k = 1,2 do - params:set(sides[k].."div/mult",tonumber(io.read())) - params:set(sides[k].."global level",tonumber(io.read())) - params:set(sides[k].."feedback",tonumber(io.read())) - params:set(sides[k].."(a) send",tonumber(io.read())) - params:set(sides[k].."(b) send",tonumber(io.read())) - params:set(sides[k].."(c) send",tonumber(io.read())) - params:set(sides[k].."filter cut",tonumber(io.read())) - params:set(sides[k].."filter q",tonumber(io.read())) - params:set(sides[k].."filter lp",tonumber(io.read())) - params:set(sides[k].."filter hp",tonumber(io.read())) - params:set(sides[k].."filter bp",tonumber(io.read())) - params:set(sides[k].."filter dry",tonumber(io.read())) - end - end - params:set("offset",tonumber(io.read())) - else - print("invalid data file") - end - if io.read() == "v1.1" then - for i = 1,3 do - for k = 1,16 do - local enveloped_to_boolean = io.read() - if enveloped_to_boolean == "true" then - bank[i][k].enveloped = true - else - bank[i][k].enveloped = false - end - bank[i][k].envelope_time = tonumber(io.read()) - end - end - params:set("zilchmo_patterning",tonumber(io.read())) - params:set("rec_loop",tonumber(io.read())) - params:set("live_rec_feedback",tonumber(io.read())) - tonumber(io.read()) -- kill off quantize_pads - params:set("quantize_pads",1) - tonumber(io.read()) -- kill off quantize_pats - params:set("quantize_pats",1) - tonumber(io.read()) -- kill off quant_div - params:set("quant_div",4) - params:set("quant_div_pats",tonumber(io.read())) - local bpm_to_clock = tonumber(io.read()) - params:set("bpm",bpm_to_clock) - params:set("clock_tempo",bpm_to_clock) - rec.clip = tonumber(io.read()) - rec.start_point = tonumber(io.read()) - rec.end_point = tonumber(io.read()) - softcut.loop_start(1,rec.start_point) - softcut.loop_end(1,rec.end_point-0.01) - softcut.position(1,rec.start_point) - end - if io.read() == "v1.1.1.1.1.1.1.1" then - for i = 1,3 do - step_seq[i].active = tonumber(io.read()) - step_seq[i].meta_duration = tonumber(io.read()) - for k = 1,16 do - step_seq[i][k].meta_meta_duration = tonumber(io.read()) - step_seq[i][k].assigned_to = tonumber(io.read()) - bank[i][k].tilt = tonumber(io.read()) - bank[i][k].tilt_ease_time = tonumber(io.read()) - bank[i][k].tilt_ease_type = tonumber(io.read()) - end - end - end - if io.read() == "the last params" then - --params:set("clock_out",tonumber(io.read())) - local disregard = tonumber(io.read()) - --params:set("crow_clock_out",tonumber(io.read())) - local disregard = tonumber(io.read()) - --params:set("midi_device",tonumber(io.read())) - local disregard = tonumber(io.read()) - params:set("loop_enc_resolution",tonumber(io.read())) - --params:set("clock",tonumber(io.read())) - local disregard_the_clock_source = tonumber(io.read()) - local disregard = tonumber(io.read()) - params:set("lock_pat",1) - for i = 1,3 do - bank[i].crow_execute = tonumber(io.read()) - bank[i].snap_to_bars = tonumber(io.read()) - end - for i = 1,3 do - for j = 1,16 do - bank[i][j].offset = tonumber(io.read()) - end - end - end - if io.read() == "crow execute count" then - for i = 1,3 do - crow.count_execute[i] = tonumber(io.read()) - end - end - if io.read() == "step seq loop points" then - for i = 1,3 do - step_seq[i].start_point = tonumber(io.read()) - step_seq[i].current_step = step_seq[i].start_point - step_seq[i].end_point = tonumber(io.read()) - end - end - if io.read() == "Live buffer max" then - params:set("live_buff_rate",tonumber(io.read())) - end - if io.read() == "loop Pattern per step" then - for i = 1,3 do - for k = 1,16 do - step_seq[i][k].loop_pattern = tonumber(io.read()) - end - end - end - if io.read() == "collect live?" then - local restore_live = tonumber(io.read()) - params:set("collect_live",restore_live) - if restore_live == 2 then - if io.read() == "sample refs" then - for i = 1,3 do - local string_to_sample = io.read() - reload_collected_samples(string_to_sample,i) - end - end - end - end - if io.read() == "last Pattern playmode" then - for i = 1,3 do - local pm = tonumber(io.read()) - if pm == 3 or pm == 4 then - grid_pat[i].playmode = 2 - params:set("pattern_"..i.."_quantization",2) - else - grid_pat[i].playmode = 1 - end - end - end - if io.read() == "1.2.1: arc patterning" then - params:set("arc_patterning", tonumber(io.read())) - end - if io.read() == "1.2.2: crow_pad_execute" then - for i = 1,3 do - for k = 1,16 do - bank[i][k].crow_pad_execute = tonumber(io.read()) - end - end - end - if io.read() == "1.3: Pattern random pitch range" then - for i = 1,3 do - grid_pat[i].random_pitch_range = tonumber(io.read()) - end - end - if io.read() == "1.3.1" then - params:set("one_shot_clock_div", tonumber(string.match(io.read(), ': (.*)'))) - params:set("rec_loop_enc_resolution", tonumber(string.match(io.read(), ': (.*)'))) - end - if io.read() == "more 1.3.1" then - params:set("random_rec_clock_prob", tonumber(string.match(io.read(), ': (.*)'))) - end - if io.read() == "cc2.0" then - for i = 1,3 do - pre_cc2_sample[i] = true -- WHY - params:set("clip "..i.." sample", restored_clip_file[i]) - end - else - for i = 1,3 do - pre_cc2_sample[i] = true - params:set("clip "..i.." sample", restored_clip_file[i]) - end - end - - io.close(file) - - rnd.loadstate() - arps.loadstate() - rytm.loadstate() - - for i = 1,3 do - if bank[i][bank[i].id].loop == true then - cheat(i,bank[i].id) - else - softcut.loop(i+1, 0) - softcut.position(i+1,bank[i][bank[i].id].start_point) - end - end - end - already_saved() - - --- unpack quantized table here? - - for i = 1,3 do - if step_seq[i].active == 1 and step_seq[i][step_seq[i].current_step].assigned_to ~= 0 then - test_load(step_seq[i][step_seq[i].current_step].assigned_to+((i-1)*8),i) - end - end - --maybe? - if selected_coll ~= params:get("collection") then - print("not selected coll!") + -- GRID pattern restore + if selected_coll ~= collection then meta_shadow(selected_coll) - elseif selected_coll == params:get("collection") then + elseif selected_coll == collection then cleanup() end one_point_two() + -- / GRID pattern restore + for i = 1,3 do - local dirname = _path.data .. "cheat_codes/arc-patterns/collection-"..params:get("collection").."/encoder-"..i..".data" - if os.rename(dirname, dirname) ~= nil then - load_arc_pattern(i) - end + load_arc_pattern(i) end - -- for i = 1,3 do - -- local dirname = _path.data .. "cheat_codes/arc-patterns/collection-"..params:get("collection").."/encoder-"..i..".data" - -- if os.rename(dirname, dirname) ~= nil then - -- load_arc_pattern(i) - -- end - -- end + for i = 1,3 do - local dirname = _path.data .. "cheat_codes/midi-patterns/collection-"..params:get("collection").."/"..i..".data" + local dirname = _path.data .. "cheat_codes2/collection-"..selected_coll.."/patterns/midi"..i..".data" if os.rename(dirname, dirname) ~= nil then load_midi_pattern(i) end end - del.loadstate(selected_coll) + + grid_dirty = true + end +-- function testsavestate() +-- local file = io.open(_path.data .. "cheat_codes2/collections"..tonumber(string.format("%.0f",params:get("collection")))..".data", "w+") +-- io.output(file) +-- io.write("PERMANENCE".."\n") +-- for i = 1,3 do +-- for k = 1,16 do +-- io.write(bank[i].id .. "\n") +-- io.write(selected[i].x .. "\n") +-- io.write(selected[i].y .. "\n") +-- io.write(bank[i][k].clip .. "\n") +-- io.write(bank[i][k].mode .. "\n") +-- io.write(bank[i][k].start_point .. "\n") +-- io.write(bank[i][k].end_point .. "\n") +-- io.write(bank[i][k].rate .. "\n") +-- io.write(tostring(bank[i][k].pause) .. "\n") +-- io.write(tostring(bank[i][k].play_mode) .. "\n") +-- io.write(bank[i][k].level .. "\n") +-- io.write(tostring(bank[i][k].loop) .. "\n") +-- io.write(tostring(bank[i][k].fifth) .. "\n") +-- io.write(bank[i][k].pan .. "\n") +-- io.write(bank[i][k].fc .. "\n") +-- io.write(bank[i][k].q .. "\n") +-- io.write(bank[i][k].lp .. "\n") +-- io.write(bank[i][k].hp .. "\n") +-- io.write(bank[i][k].bp .. "\n") +-- io.write(bank[i][k].fd .. "\n") +-- io.write(bank[i][k].br .. "\n") +-- io.write(bank[i][k].filter_type .. "\n") +-- io.write(arc_control[i] .. "\n") +-- io.write(arc_param[i] .. "\n") +-- end +-- io.write(params:get("rate slew time ".. i) .. "\n") +-- io.write(tostring(params:get("clip "..i.." sample") .. "\n")) +-- local sides = {"delay L: ", "delay R: "} +-- for k = 1,2 do +-- io.write(params:get(sides[k].."div/mult") .. "\n") +-- io.write(params:get(sides[k].."global level") .. "\n") +-- io.write(params:get(sides[k].."feedback") .. "\n") +-- io.write(params:get(sides[k].."(a) send") .. "\n") +-- io.write(params:get(sides[k].."(b) send") .. "\n") +-- io.write(params:get(sides[k].."(c) send") .. "\n") +-- io.write(params:get(sides[k].."filter cut") .. "\n") +-- io.write(params:get(sides[k].."filter q") .. "\n") +-- io.write(params:get(sides[k].."filter lp") .. "\n") +-- io.write(params:get(sides[k].."filter hp") .. "\n") +-- io.write(params:get(sides[k].."filter bp") .. "\n") +-- io.write(params:get(sides[k].."filter dry") .. "\n") +-- end +-- end +-- io.write(params:get("offset").."\n") +-- -- v1.1 items +-- io.write("v1.1".."\n") +-- for i = 1,3 do +-- for k = 1,16 do +-- io.write(tostring(bank[i][k].enveloped) .. "\n") +-- io.write(bank[i][k].envelope_time .. "\n") +-- end +-- end +-- io.write(params:get("zilchmo_patterning") .. "\n") +-- io.write(params:get("rec_loop") .. "\n") +-- io.write(params:get("live_rec_feedback") .. "\n") +-- io.write(params:get("quantize_pads") .. "\n") +-- io.write(params:get("quantize_pats") .. "\n") +-- io.write(params:get("quant_div") .. "\n") +-- io.write(params:get("quant_div_pats") .. "\n") +-- io.write(params:get("bpm") .. "\n") +-- io.write(rec.clip .. "\n") +-- io.write(rec.start_point .. "\n") +-- io.write(rec.end_point .. "\n") +-- io.write("v1.1.1.1.1.1.1.1".."\n") +-- for i = 1,3 do +-- io.write(step_seq[i].active .. "\n") +-- io.write(step_seq[i].meta_duration .. "\n") +-- for k = 1,16 do +-- io.write(step_seq[i][k].meta_meta_duration .. "\n") +-- io.write(step_seq[i][k].assigned_to .. "\n") +-- io.write(bank[i][k].tilt .. "\n") +-- io.write(bank[i][k].tilt_ease_time .. "\n") +-- io.write(bank[i][k].tilt_ease_type .. "\n") +-- end +-- end +-- io.write("the last params".."\n") +-- --io.write(params:get("clock_out") .. "\n") +-- io.write("0".."\n") +-- --io.write(params:get("crow_clock_out") .. "\n") +-- io.write("0".."\n") +-- --io.write(params:get("midi_device") .. "\n") +-- io.write("0".."\n") +-- io.write(params:get("loop_enc_resolution") .."\n") +-- --io.write(params:get("clock") .. "\n") +-- io.write("0".."\n") +-- io.write(params:get("lock_pat") .. "\n") +-- for i = 1,3 do +-- io.write(bank[i].crow_execute .. "\n") +-- io.write(bank[i].snap_to_bars .. "\n") +-- end +-- for i = 1,3 do +-- for j = 1,16 do +-- io.write(bank[i][j].offset .. "\n") +-- end +-- end +-- io.write("crow execute count".."\n") +-- for i = 1,3 do +-- io.write(crow.count_execute[i] .. "\n") +-- end +-- io.write("step seq loop points".."\n") +-- for i = 1,3 do +-- io.write(step_seq[i].start_point .. "\n") +-- io.write(step_seq[i].end_point .. "\n") +-- end +-- io.write("Live buffer max".."\n") +-- io.write(params:get"live_buff_rate" .. "\n") +-- io.write("loop Pattern per step".."\n") +-- for i = 1,3 do +-- for k = 1,16 do +-- io.write(step_seq[i][k].loop_pattern.."\n") +-- end +-- end +-- io.write("collect live?".."\n") +-- io.write(params:get("collect_live").."\n") +-- if params:get("collect_live") == 2 then +-- io.write("sample refs".."\n") +-- for i = 1,3 do +-- io.write("/home/we/dust/audio/cc_collection-samples/"..params:get("collection").."/".."cc_"..params:get("collection").."-"..i..".wav".."\n") +-- collect_samples(i) +-- end +-- end +-- io.write("last Pattern playmode".."\n") +-- for i = 1,3 do +-- io.write(grid_pat[i].playmode.."\n") +-- end +-- io.write("1.2.1: arc patterning".."\n") +-- io.write(params:get("arc_patterning").."\n") +-- io.write("1.2.2: crow_pad_execute".."\n") +-- for i = 1,3 do +-- for k = 1,16 do +-- io.write(bank[i][k].crow_pad_execute.."\n") +-- end +-- end +-- io.write("1.3: Pattern random pitch range".."\n") +-- for i = 1,3 do +-- io.write(grid_pat[i].random_pitch_range.."\n") +-- end +-- io.write("1.3.1".."\n") +-- io.write("one_shot_clock_div: "..params:get("one_shot_clock_div").."\n") +-- io.write("rec_loop_enc_resolution: "..params:get("rec_loop_enc_resolution").."\n") +-- io.write("more 1.3.1".."\n") +-- io.write("random_rec_clock_prob: "..params:get("random_rec_clock_prob").."\n") + +-- io.write("cc2.0".."\n") + +-- io.close(file) +-- if selected_coll ~= params:get("collection") then +-- meta_copy_coll(selected_coll,params:get("collection")) +-- end +-- meta_shadow(params:get("collection")) +-- --maybe not this? want to clean up +-- selected_coll = params:get("collection") +-- for i = 1,3 do +-- if arc_pat[i][1].count > 0 then +-- save_arc_pattern(i) +-- end +-- save_midi_pattern(i) +-- end +-- for i = 1,2 do +-- del.savestate(i,selected_coll) +-- end +-- rnd.savestate() +-- arps.savestate() +-- rytm.savestate() +-- end + +-- function testloadstate() +-- selected_coll = params:get("collection") +-- local file = io.open(_path.data .. "cheat_codes2/collections"..selected_coll..".data", "r") +-- if file then +-- io.input(file) +-- pre_cc2_sample = { false, false, false } +-- restored_clip_file = {"","",""} +-- if io.read() == "PERMANENCE" then +-- for i = 1,3 do +-- for k = 1,16 do +-- bank[i].id = tonumber(io.read()) +-- selected[i].x = tonumber(io.read()) +-- selected[i].y = tonumber(io.read()) +-- bank[i][k].clip = tonumber(io.read()) +-- bank[i][k].mode = tonumber(io.read()) +-- bank[i][k].start_point = tonumber(io.read()) +-- bank[i][k].end_point = tonumber(io.read()) +-- bank[i][k].rate = tonumber(io.read()) +-- local pause_to_boolean = io.read() +-- if pause_to_boolean == "true" then +-- bank[i][k].pause = true +-- else +-- bank[i][k].pause = false +-- end +-- bank[i][k].play_mode = io.read() +-- bank[i][k].level = tonumber(io.read()) +-- local loop_to_boolean = io.read() +-- if loop_to_boolean == "true" then +-- bank[i][k].loop = true +-- else +-- bank[i][k].loop = false +-- end +-- local fifth_to_boolean = io.read() +-- if fifth_to_boolean == "true" then +-- bank[i][k].fifth = true +-- else +-- bank[i][k].fifth = false +-- end +-- bank[i][k].pan = tonumber(io.read()) +-- bank[i][k].fc = tonumber(io.read()) +-- bank[i][k].q = tonumber(io.read()) +-- bank[i][k].lp = tonumber(io.read()) +-- bank[i][k].hp = tonumber(io.read()) +-- bank[i][k].bp = tonumber(io.read()) +-- bank[i][k].fd = tonumber(io.read()) +-- bank[i][k].br = tonumber(io.read()) +-- tonumber(io.read()) +-- bank[i][k].filter_type = 4 +-- arc_control[i] = tonumber(io.read()) +-- arc_param[i] = tonumber(io.read()) +-- end +-- params:set("rate slew time ".. i,tonumber(io.read())) +-- local string_to_sample = io.read() +-- restored_clip_file[i] = string_to_sample +-- -- params:set("clip "..i.." sample", string_to_sample) +-- local sides = {"delay L: ", "delay R: "} +-- for k = 1,2 do +-- params:set(sides[k].."div/mult",tonumber(io.read())) +-- params:set(sides[k].."global level",tonumber(io.read())) +-- params:set(sides[k].."feedback",tonumber(io.read())) +-- params:set(sides[k].."(a) send",tonumber(io.read())) +-- params:set(sides[k].."(b) send",tonumber(io.read())) +-- params:set(sides[k].."(c) send",tonumber(io.read())) +-- params:set(sides[k].."filter cut",tonumber(io.read())) +-- params:set(sides[k].."filter q",tonumber(io.read())) +-- params:set(sides[k].."filter lp",tonumber(io.read())) +-- params:set(sides[k].."filter hp",tonumber(io.read())) +-- params:set(sides[k].."filter bp",tonumber(io.read())) +-- params:set(sides[k].."filter dry",tonumber(io.read())) +-- end +-- end +-- params:set("offset",tonumber(io.read())) +-- else +-- print("invalid data file") +-- end +-- if io.read() == "v1.1" then +-- for i = 1,3 do +-- for k = 1,16 do +-- local enveloped_to_boolean = io.read() +-- if enveloped_to_boolean == "true" then +-- bank[i][k].enveloped = true +-- else +-- bank[i][k].enveloped = false +-- end +-- bank[i][k].envelope_time = tonumber(io.read()) +-- end +-- end +-- params:set("zilchmo_patterning",tonumber(io.read())) +-- params:set("rec_loop",tonumber(io.read())) +-- params:set("live_rec_feedback",tonumber(io.read())) +-- tonumber(io.read()) -- kill off quantize_pads +-- params:set("quantize_pads",1) +-- tonumber(io.read()) -- kill off quantize_pats +-- params:set("quantize_pats",1) +-- tonumber(io.read()) -- kill off quant_div +-- params:set("quant_div",4) +-- params:set("quant_div_pats",tonumber(io.read())) +-- local bpm_to_clock = tonumber(io.read()) +-- params:set("bpm",bpm_to_clock) +-- params:set("clock_tempo",bpm_to_clock) +-- rec.clip = tonumber(io.read()) +-- rec.start_point = tonumber(io.read()) +-- rec.end_point = tonumber(io.read()) +-- softcut.loop_start(1,rec.start_point) +-- softcut.loop_end(1,rec.end_point-0.01) +-- softcut.position(1,rec.start_point) +-- end +-- if io.read() == "v1.1.1.1.1.1.1.1" then +-- for i = 1,3 do +-- step_seq[i].active = tonumber(io.read()) +-- step_seq[i].meta_duration = tonumber(io.read()) +-- for k = 1,16 do +-- step_seq[i][k].meta_meta_duration = tonumber(io.read()) +-- step_seq[i][k].assigned_to = tonumber(io.read()) +-- bank[i][k].tilt = tonumber(io.read()) +-- bank[i][k].tilt_ease_time = tonumber(io.read()) +-- bank[i][k].tilt_ease_type = tonumber(io.read()) +-- end +-- end +-- end +-- if io.read() == "the last params" then +-- --params:set("clock_out",tonumber(io.read())) +-- local disregard = tonumber(io.read()) +-- --params:set("crow_clock_out",tonumber(io.read())) +-- local disregard = tonumber(io.read()) +-- --params:set("midi_device",tonumber(io.read())) +-- local disregard = tonumber(io.read()) +-- params:set("loop_enc_resolution",tonumber(io.read())) +-- --params:set("clock",tonumber(io.read())) +-- local disregard_the_clock_source = tonumber(io.read()) +-- local disregard = tonumber(io.read()) +-- params:set("lock_pat",1) +-- for i = 1,3 do +-- bank[i].crow_execute = tonumber(io.read()) +-- bank[i].snap_to_bars = tonumber(io.read()) +-- end +-- for i = 1,3 do +-- for j = 1,16 do +-- bank[i][j].offset = tonumber(io.read()) +-- end +-- end +-- end +-- if io.read() == "crow execute count" then +-- for i = 1,3 do +-- crow.count_execute[i] = tonumber(io.read()) +-- end +-- end +-- if io.read() == "step seq loop points" then +-- for i = 1,3 do +-- step_seq[i].start_point = tonumber(io.read()) +-- step_seq[i].current_step = step_seq[i].start_point +-- step_seq[i].end_point = tonumber(io.read()) +-- end +-- end +-- if io.read() == "Live buffer max" then +-- params:set("live_buff_rate",tonumber(io.read())) +-- end +-- if io.read() == "loop Pattern per step" then +-- for i = 1,3 do +-- for k = 1,16 do +-- step_seq[i][k].loop_pattern = tonumber(io.read()) +-- end +-- end +-- end +-- if io.read() == "collect live?" then +-- local restore_live = tonumber(io.read()) +-- params:set("collect_live",restore_live) +-- if restore_live == 2 then +-- if io.read() == "sample refs" then +-- for i = 1,3 do +-- local string_to_sample = io.read() +-- reload_collected_samples(string_to_sample,i) +-- end +-- end +-- end +-- end +-- if io.read() == "last Pattern playmode" then +-- for i = 1,3 do +-- local pm = tonumber(io.read()) +-- if pm == 3 or pm == 4 then +-- grid_pat[i].playmode = 2 +-- params:set("pattern_"..i.."_quantization",2) +-- else +-- grid_pat[i].playmode = 1 +-- end +-- end +-- end +-- if io.read() == "1.2.1: arc patterning" then +-- params:set("arc_patterning", tonumber(io.read())) +-- end +-- if io.read() == "1.2.2: crow_pad_execute" then +-- for i = 1,3 do +-- for k = 1,16 do +-- bank[i][k].crow_pad_execute = tonumber(io.read()) +-- end +-- end +-- end +-- if io.read() == "1.3: Pattern random pitch range" then +-- for i = 1,3 do +-- grid_pat[i].random_pitch_range = tonumber(io.read()) +-- end +-- end +-- if io.read() == "1.3.1" then +-- params:set("one_shot_clock_div", tonumber(string.match(io.read(), ': (.*)'))) +-- params:set("rec_loop_enc_resolution", tonumber(string.match(io.read(), ': (.*)'))) +-- end +-- if io.read() == "more 1.3.1" then +-- params:set("random_rec_clock_prob", tonumber(string.match(io.read(), ': (.*)'))) +-- end +-- if io.read() == "cc2.0" then +-- for i = 1,3 do +-- pre_cc2_sample[i] = true -- WHY +-- params:set("clip "..i.." sample", restored_clip_file[i]) +-- end +-- else +-- for i = 1,3 do +-- pre_cc2_sample[i] = true +-- params:set("clip "..i.." sample", restored_clip_file[i]) +-- end +-- end + +-- io.close(file) + +-- rnd.loadstate() +-- arps.loadstate() +-- rytm.loadstate() + +-- for i = 1,3 do +-- if bank[i][bank[i].id].loop == true then +-- cheat(i,bank[i].id) +-- else +-- softcut.loop(i+1, 0) +-- softcut.position(i+1,bank[i][bank[i].id].start_point) +-- end +-- end +-- end +-- already_saved() + +-- --- unpack quantized table here? + +-- for i = 1,3 do +-- if step_seq[i].active == 1 and step_seq[i][step_seq[i].current_step].assigned_to ~= 0 then +-- test_load(step_seq[i][step_seq[i].current_step].assigned_to+((i-1)*8),i) +-- end +-- end +-- --maybe? +-- if selected_coll ~= params:get("collection") then +-- print("not selected coll!") +-- meta_shadow(selected_coll) +-- elseif selected_coll == params:get("collection") then +-- cleanup() +-- end +-- one_point_two() +-- for i = 1,3 do +-- local dirname = _path.data .. "cheat_codes2/arc-patterns/collection-"..params:get("collection").."/encoder-"..i..".data" +-- if os.rename(dirname, dirname) ~= nil then +-- load_arc_pattern(i) +-- end +-- end +-- -- for i = 1,3 do +-- -- local dirname = _path.data .. "cheat_codes2/arc-patterns/collection-"..params:get("collection").."/encoder-"..i..".data" +-- -- if os.rename(dirname, dirname) ~= nil then +-- -- load_arc_pattern(i) +-- -- end +-- -- end +-- for i = 1,3 do +-- local dirname = _path.data .. "cheat_codes2/midi-patterns/collection-"..params:get("collection").."/"..i..".data" +-- if os.rename(dirname, dirname) ~= nil then +-- load_midi_pattern(i) +-- end +-- end +-- del.loadstate(selected_coll) +-- grid_dirty = true +-- end + function test_save(i) pattern_saver[i].active = true clock.sleep(1) @@ -4366,7 +4440,18 @@ function test_load(slot,destination) end function save_pattern(source,slot,style) - local file = io.open(_path.data .. "cheat_codes/pattern"..selected_coll.."_"..slot..".data", "w+") + + local dirname = _path.data.."cheat_codes2/collection-"..selected_coll.."/" + if os.rename(dirname, dirname) == nil then + os.execute("mkdir " .. dirname) + end + local dirname = _path.data.."cheat_codes2/collection-"..selected_coll.."/patterns/" + if os.rename(dirname, dirname) == nil then + os.execute("mkdir " .. dirname) + end + + local file = io.open(_path.data .. "cheat_codes2/collection-"..selected_coll.."/patterns/"..slot..".data", "w+") + -- local file = io.open(_path.data .. "cheat_codes2/pattern"..selected_coll.."_"..slot..".data", "w+") io.output(file) if style == "pattern" then io.write("stored pad pattern: collection "..selected_coll.." + slot "..slot.."\n") @@ -4454,7 +4539,7 @@ function save_pattern(source,slot,style) --/GIRAFFE print("saved pattern "..source.." to slot "..slot) elseif style == "arp" then - tab.save(arp[source],_path.data .. "cheat_codes/pattern"..selected_coll.."_"..slot..".data") + tab.save(arp[source],_path.data .. "cheat_codes2/collection-"..selected_coll.."/patterns/"..slot..".data") print("saved arp "..source.." to slot "..slot) end end @@ -4462,21 +4547,20 @@ end function already_saved() for i = 1,24 do local line_count = 0 - local file = io.open(_path.data .. "cheat_codes/pattern"..selected_coll.."_"..i..".data", "r") + local file = io.open(_path.data .. "cheat_codes2/collection-"..selected_coll.."/patterns/"..i..".data", "r") if file then io.input(file) - for lines in io.lines(_path.data .. "cheat_codes/pattern"..selected_coll.."_"..i..".data") do + for lines in io.lines(_path.data .. "cheat_codes2/collection-"..selected_coll.."/patterns/"..i..".data") do line_count = line_count + 1 end if line_count > 0 then - -- if io.read() == "stored pad pattern: collection "..selected_coll.." + slot "..i then local current = math.floor((i-1)/8)+1 pattern_saver[current].saved[i-(8*(current-1))] = 1 else local current = math.floor((i-1)/8)+1 pattern_saver[current].saved[i-(8*(current-1))] = 0 -- print("killing yr file4387") - os.remove(_path.data .. "cheat_codes/pattern" ..selected_coll.."_"..i..".data") + os.remove(_path.data .. "cheat_codes2/collection-"..selected_coll.."/patterns/"..i..".data") end io.close(file) else @@ -4488,32 +4572,13 @@ end function one_point_two() for i = 1,24 do - local file = io.open(_path.data .. "cheat_codes/pattern"..selected_coll.."_"..i..".data", "r") - -- print(file) + local file = io.open(_path.data .. "cheat_codes2/collection-"..selected_coll.."/patterns/"..i..".data", "r") if file then io.input(file) local current = math.floor((i-1)/8)+1 load_pattern(i,current) io.close(file) end - - - - -- io.input(file) - -- if io.read() == "stored pad pattern: collection "..selected_coll.." + slot "..i then - -- local current = math.floor((i-1)/8)+1 - -- --- - -- --create pre-1.2 external files - -- local ext_file = io.open(_path.data .. "cheat_codes/external-timing/pattern"..selected_coll.."_"..i.."_external-timing.data", "r") - -- if ext_file then - -- io.close(ext_file) - -- else - -- load_pattern(i,current) - -- end - -- else - -- end - -- io.close(file) - -- end end for i = 1,3 do grid_pat[i]:rec_stop() @@ -4526,53 +4591,36 @@ end function clear_zero() for i = 1,24 do - local file = io.open(_path.data .. "cheat_codes/pattern0_"..i..".data", "r") + local file = io.open(_path.data .. "cheat_codes2/collection-0/patterns/"..i..".data", "r") if file then io.input(file) local line_count = 0 - for lines in io.lines(_path.data .. "cheat_codes/pattern0_"..i..".data") do + for lines in io.lines(_path.data .. "cheat_codes2/collection-0/patterns/"..i..".data") do line_count = line_count + 1 end if line_count > 0 then - -- if io.read() == "stored pad pattern: collection 0 + slot "..i then - os.remove(_path.data .. "cheat_codes/pattern0_"..i..".data") + os.remove(_path.data .. "cheat_codes2/collection-0/patterns/"..i..".data") print("cleared default pattern") end io.close(file) end end - -- for i = 1,24 do - -- local external_timing_file = io.open(_path.data .. "cheat_codes/external-timing/pattern0_"..i.."_external-timing.data", "r") - -- if external_timing_file then - -- io.input(external_timing_file) - -- if io.read() == "external clock timing for stored pad pattern: collection 0 + slot "..i then - -- os.remove(_path.data .. "cheat_codes/external-timing/pattern0_"..i.."_external-timing.data") - -- print("cleared default external timing") - -- end - -- io.close(external_timing_file) - -- end - -- end end function delete_pattern(slot) - local file = io.open(_path.data .. "cheat_codes/pattern"..selected_coll.."_"..slot..".data", "w+") + local file = io.open(_path.data .. "cheat_codes2/collection-"..selected_coll.."/patterns/"..slot..".data", "w+") io.output(file) io.write() io.close(file) print("deleted pattern from slot "..slot) - -- local external_timing_file = io.open(_path.data .. "cheat_codes/external-timing/pattern"..selected_coll.."_"..slot.."_external-timing.data", "w+") - -- io.output(external_timing_file) - -- io.write() - -- io.close(external_timing_file) - -- print("deleted external timing from slot "..slot) end function copy_pattern_across_coll(read_coll,write_coll,slot) - local infile = io.open(_path.data .. "cheat_codes/pattern"..read_coll.."_"..slot..".data", "r") - local outfile = io.open(_path.data .. "cheat_codes/pattern"..write_coll.."_"..slot..".data", "w+") + print("4610: "..read_coll,write_coll,slot) + local infile = io.open(_path.data .. "cheat_codes2/collection-"..read_coll.."/patterns/"..slot..".data", "r") + local outfile = io.open(_path.data .. "cheat_codes2/collection-"..write_coll.."/patterns/"..slot..".data", "w+") io.output(outfile) for line in infile:lines() do - -- io.write(line.."\n") if line == "stored pad pattern: collection "..read_coll.." + slot "..slot then io.write("stored pad pattern: collection "..write_coll.." + slot "..slot.."\n") else @@ -4581,27 +4629,12 @@ function copy_pattern_across_coll(read_coll,write_coll,slot) end io.close(infile) io.close(outfile) - - --/externalshadow - -- local external_timing_infile = io.open(_path.data .. "cheat_codes/external-timing/pattern"..read_coll.."_"..slot.."_external-timing.data", "r") - -- local external_timing_outfile = io.open(_path.data .. "cheat_codes/external-timing/pattern"..write_coll.."_"..slot.."_external-timing.data", "w+") - -- io.output(external_timing_outfile) - -- for line in external_timing_infile:lines() do - -- if line == "external clock timing for stored pad pattern: collection "..read_coll.." + slot "..slot then - -- io.write("external clock timing for stored pad pattern: collection "..write_coll.." + slot "..slot.."\n") - -- else - -- io.write(line.."\n") - -- end - -- end - -- io.close(external_timing_infile) - -- io.close(external_timing_outfile) - --externalshadow/ end function shadow_pattern(read_coll,write_coll,slot) - local infile = io.open(_path.data .. "cheat_codes/pattern"..read_coll.."_"..slot..".data", "r") - local outfile = io.open(_path.data .. "cheat_codes/shadow-pattern"..write_coll.."_"..slot..".data", "w+") + local infile = io.open(_path.data .. "cheat_codes2/collection-"..read_coll.."/patterns/"..slot..".data", "r") + local outfile = io.open(_path.data .. "cheat_codes2/collection-"..write_coll.."/patterns/shadow-pattern_"..slot..".data", "w+") io.output(outfile) for line in infile:lines() do -- io.write(line.."\n") @@ -4613,22 +4646,6 @@ function shadow_pattern(read_coll,write_coll,slot) end io.close(infile) io.close(outfile) - - --/externalshadow - -- local external_timing_infile = io.open(_path.data .. "cheat_codes/external-timing/pattern"..read_coll.."_"..slot.."_external-timing.data", "r") - -- local external_timing_outfile = io.open(_path.data .. "cheat_codes/external-timing/shadow-pattern"..write_coll.."_"..slot.."_external-timing.data", "w+") - -- io.output(external_timing_outfile) - -- for line in external_timing_infile:lines() do - -- if line == "external clock timing for stored pad pattern: collection "..read_coll.." + slot "..slot then - -- io.write("external clock timing for stored pad pattern: collection "..write_coll.." + slot "..slot.."\n") - -- else - -- io.write(line.."\n") - -- end - -- end - -- io.close(external_timing_infile) - -- io.close(external_timing_outfile) - --externalshadow/ - end function meta_shadow(coll) @@ -4637,22 +4654,12 @@ function meta_shadow(coll) if pattern_saver[i].saved[j] == 1 then shadow_pattern(coll,coll,j+(8*(i-1))) elseif pattern_saver[i].saved[j] == 0 then - local file = io.open(_path.data .. "cheat_codes/shadow-pattern"..coll.."_"..j+(8*(i-1))..".data", "w+") - -- need an already saved shadow thing here to clear out + local file = io.open(_path.data .. "cheat_codes2/collection-"..coll.."/patterns/shadow-pattern_"..j+(8*(i-1))..".data", "w+") if file then io.output(file) io.write() io.close(file) end - - --/externalshadow - -- local external_timing_file = io.open(_path.data .. "cheat_codes/external-timing/shadow-pattern"..coll.."_"..j+(8*(i-1)).."_external-timing.data", "w+") - -- if external_timing_file then - -- io.output(external_timing_file) - -- io.write() - -- io.close(external_timing_file) - -- end - --externalshadow/ end end end @@ -4660,21 +4667,20 @@ end function clear_empty_shadows(coll) for i = 1,24 do - local file = io.open(_path.data .. "cheat_codes/shadow-pattern"..coll.."_"..i..".data", "r") + local file = io.open(_path.data .. "cheat_codes2/collection-"..coll.."/patterns/shadow-pattern_"..i..".data", "r") if file then io.input(file) local line_count = 0 - for lines in io.lines(_path.data .. "cheat_codes/shadow-pattern"..coll.."_"..i..".data") do + for lines in io.lines(_path.data .. "cheat_codes2/collection-"..coll.."/patterns/shadow-pattern_"..i..".data") do line_count = line_count + 1 end - -- if io.read() == "stored pad pattern: collection "..coll.." + slot "..i then if line_count > 0 then local current = math.floor((i-1)/8)+1 pattern_saver[current].saved[i-(8*(current-1))] = 1 else local current = math.floor((i-1)/8)+1 pattern_saver[current].saved[i-(8*(current-1))] = 0 - os.remove(_path.data .. "cheat_codes/shadow-pattern" ..coll.."_"..i..".data") + os.remove(_path.data .. "cheat_codes2/collection-"..coll.."/patterns/shadow-pattern_"..i..".data") end io.close(file) else @@ -4682,34 +4688,14 @@ function clear_empty_shadows(coll) pattern_saver[current].saved[i-(8*(current-1))] = 0 end end - - --/externalshadow - -- for i = 1,24 do - -- local file = io.open(_path.data .. "cheat_codes/external-timing/shadow-pattern"..coll.."_"..i.."_external-timing.data", "r") - -- if file then - -- io.input(file) - -- if io.read() == "external clock timing for stored pad pattern: collection "..coll.." + slot "..i then - -- local current = math.floor((i-1)/8)+1 - -- pattern_saver[current].saved[i-(8*(current-1))] = 1 - -- else - -- local current = math.floor((i-1)/8)+1 - -- pattern_saver[current].saved[i-(8*(current-1))] = 0 - -- os.remove(_path.data .. "cheat_codes/external-timing/shadow-pattern" ..coll.."_"..i.."_external-timing.data") - -- end - -- io.close(file) - -- end - -- end - --externalshadow/ - end function shadow_to_play(coll,slot) - local infile = io.open(_path.data .. "cheat_codes/shadow-pattern"..coll.."_"..slot..".data", "r") - local outfile = io.open(_path.data .. "cheat_codes/pattern"..coll.."_"..slot..".data", "w+") + local infile = io.open(_path.data .. "cheat_codes2/collection-"..coll.."/patterns/shadow-pattern_"..slot..".data", "r") + local outfile = io.open(_path.data .. "cheat_codes2/collection-"..coll.."/patterns/"..slot..".data", "w+") io.output(outfile) if infile then for line in infile:lines() do - -- io.write(line.."\n") if line == "stored pad pattern: collection "..coll.." + slot "..slot then io.write("stored pad pattern: collection "..coll.." + slot "..slot.."\n") else @@ -4719,24 +4705,6 @@ function shadow_to_play(coll,slot) io.close(infile) io.close(outfile) end - - --/externalshadow - -- local external_timing_infile = io.open(_path.data .. "cheat_codes/external-timing/shadow-pattern"..coll.."_"..slot.."_external-timing.data", "r") - -- local external_timing_outfile = io.open(_path.data .. "cheat_codes/external-timing/pattern"..coll.."_"..slot.."_external-timing.data", "w+") - -- io.output(external_timing_outfile) - -- if external_timing_infile then - -- for line in external_timing_infile:lines() do - -- if line == "external clock timing for stored pad pattern: collection "..coll.." + slot "..slot then - -- io.write("external clock timing for stored pad pattern: collection "..coll.." + slot "..slot.."\n") - -- else - -- io.write(line.."\n") - -- end - -- end - -- io.close(external_timing_infile) - -- io.close(external_timing_outfile) - -- end - --externalshadow/ - end function meta_copy_coll(read_coll,write_coll) @@ -4745,22 +4713,12 @@ function meta_copy_coll(read_coll,write_coll) if pattern_saver[i].saved[j] == 1 then copy_pattern_across_coll(read_coll,write_coll,j+(8*(i-1))) elseif pattern_saver[i].saved[j] == 0 then - local file = io.open(_path.data .. "cheat_codes/pattern"..write_coll.."_"..j+(8*(i-1))..".data", "w+") + local file = io.open(_path.data .. "cheat_codes2/collection-"..write_coll.."/patterns/"..j+(8*(i-1))..".data", "w+") if file then io.output(file) io.write() io.close(file) - end - - --/externalshadow - -- local external_timing_file = io.open(_path.data .. "cheat_codes/external-timing/pattern"..write_coll.."_"..j+(8*(i-1)).."_external-timing.data", "w+") - -- if external_timing_file then - -- io.output(external_timing_file) - -- io.write() - -- io.close(external_timing_file) - -- end - --externalshadow/ - + end end end end @@ -4768,7 +4726,7 @@ end function load_pattern(slot,destination) local ignore_external_timing = false - local file = io.open(_path.data .. "cheat_codes/pattern"..selected_coll.."_"..slot..".data", "r") + local file = io.open(_path.data .. "cheat_codes2/collection-"..selected_coll.."/patterns/"..slot..".data", "r") if file then io.input(file) if io.read() == "stored pad pattern: collection "..selected_coll.." + slot "..slot then @@ -4892,7 +4850,8 @@ function load_pattern(slot,destination) --/new stuff, quantum and time_beats! else -- print("it's an arp!") - arp[destination] = tab.load(_path.data .. "cheat_codes/pattern"..selected_coll.."_"..slot..".data") + arp[destination] = tab.load(_path.data .. "cheat_codes2/collection-"..selected_coll.."/patterns/"..slot..".data") + -- arp[destination] = tab.load(_path.data .. "cheat_codes2/pattern"..selected_coll.."_"..slot..".data") ignore_external_timing = true end @@ -4915,24 +4874,20 @@ function cleanup() --need all this to just happen at cleanup after save for i = 1,24 do - local file = io.open(_path.data .. "cheat_codes/pattern"..selected_coll.."_"..i..".data", "r") + local file = io.open(_path.data .. "cheat_codes2/collection-"..selected_coll.."/patterns/"..i..".data", "r") if file then io.input(file) local line_count = 0 - for lines in io.lines(_path.data .. "cheat_codes/pattern"..selected_coll.."_"..i..".data") do + for lines in io.lines(_path.data .. "cheat_codes2/collection-"..selected_coll.."/patterns/"..i..".data") do line_count = line_count + 1 end - -- print(line_count, _path.data .. "cheat_codes/pattern" ..selected_coll.."_"..i..".data") if line_count > 0 then - -- if io.read() == "stored pad pattern: collection "..selected_coll.." + slot "..i then local current = math.floor((i-1)/8)+1 pattern_saver[current].saved[i-(8*(current-1))] = 1 - -- end else local current = math.floor((i-1)/8)+1 pattern_saver[current].saved[i-(8*(current-1))] = 0 - -- print("killing uyr file 4831", _path.data .. "cheat_codes/pattern" ..selected_coll.."_"..i..".data") - os.remove(_path.data .. "cheat_codes/pattern" ..selected_coll.."_"..i..".data") + os.remove(_path.data .. "cheat_codes2/collection-"..selected_coll.."/patterns/"..i..".data") end io.close(file) else @@ -4940,124 +4895,87 @@ function cleanup() pattern_saver[current].saved[i-(8*(current-1))] = 0 end end - - --/externalshadow - -- for i = 1,24 do - -- local file = io.open(_path.data .. "cheat_codes/external-timing/pattern"..selected_coll.."_"..i.."_external-timing.data", "r") - -- if file then - -- io.input(file) - -- if io.read() == "external clock timing for stored pad pattern: collection "..selected_coll.." + slot "..i then - -- local current = math.floor((i-1)/8)+1 - -- pattern_saver[current].saved[i-(8*(current-1))] = 1 - -- else - -- local current = math.floor((i-1)/8)+1 - -- pattern_saver[current].saved[i-(8*(current-1))] = 0 - -- os.remove(_path.data .. "cheat_codes/external-timing/pattern" ..selected_coll.."_"..i.."_external-timing.data") - -- end - -- io.close(file) - -- else - -- --print("can't clean these external files?") - -- end - -- end - --externalshadow/ - clear_empty_shadows(selected_coll) end -- arc pattern stuff! function save_arc_pattern(which) - local dirname = _path.data.."cheat_codes/arc-patterns/" - if os.rename(dirname, dirname) == nil then - os.execute("mkdir " .. dirname) - end - - local dirname = _path.data.."cheat_codes/arc-patterns/collection-"..selected_coll.."/" - if os.rename(dirname, dirname) == nil then - os.execute("mkdir " .. dirname) - end - - local file = io.open(_path.data .. "cheat_codes/arc-patterns/collection-"..selected_coll.."/encoder-"..which..".data", "w+") + local file = io.open(_path.data .. "cheat_codes2/collection-"..selected_coll.."/arc-rec/encoder-"..which..".data", "w+") io.output(file) io.write("stored arc pattern: collection "..selected_coll.." + encoder "..which.."\n") - io.write(arc_pat[which].count .. "\n") - for i = 1,arc_pat[which].count do - io.write(arc_pat[which].time[i] .. "\n") - io.write(arc_pat[which].event[i].i .. "\n") - io.write(arc_pat[which].event[i].param .. "\n") - io.write(arc_pat[which].event[i].pad .. "\n") - io.write(arc_pat[which].event[i].start_point .. "\n") - io.write(arc_pat[which].event[i].end_point .. "\n") - io.write(arc_pat[which].event[i].prev_tilt .. "\n") - io.write(arc_pat[which].event[i].tilt .. "\n") - end - io.write(arc_pat[which].metro.props.time .. "\n") - io.write(arc_pat[which].prev_time .. "\n") - io.write("start point: " .. arc_pat[which].start_point .. "\n") - io.write("end point: " .. arc_pat[which].end_point .. "\n") + for j = 1,4 do + io.write("total events in recording "..j..": "..arc_pat[which][j].count .. "\n") + for i = 1,arc_pat[which][j].count do + io.write("event "..i.." time: "..arc_pat[which][j].time[i] .. "\n") + io.write("event "..i.." i1: "..arc_pat[which][j].event[i].i1 .. "\n") + io.write("event "..i.." i2: "..arc_pat[which][j].event[i].i2 .. "\n") + io.write("event "..i.." param: "..arc_pat[which][j].event[i].param .. "\n") + io.write("event "..i.." pad: "..arc_pat[which][j].event[i].pad .. "\n") + io.write("event "..i.." start point: "..arc_pat[which][j].event[i].start_point .. "\n") + io.write("event "..i.." end point: "..arc_pat[which][j].event[i].end_point .. "\n") + io.write("event "..i.." prev tilt: "..arc_pat[which][j].event[i].prev_tilt .. "\n") + io.write("event "..i.." tilt: "..arc_pat[which][j].event[i].tilt .. "\n") + io.write("event "..i.." pan: "..arc_pat[which][j].event[i].pan .. "\n") + io.write("event "..i.." level: "..arc_pat[which][j].event[i].level .. "\n") + end + io.write("recording "..j.." props time: "..arc_pat[which][j].metro.props.time .. "\n") + io.write("recording "..j.." prev time: "..arc_pat[which][j].prev_time .. "\n") + io.write("recording "..j.." start point: " .. arc_pat[which][j].start_point .. "\n") + io.write("recording "..j.." end point: " .. arc_pat[which][j].end_point .. "\n") + end io.close(file) print("saved arc pattern for encoder "..which) end function load_arc_pattern(which) - local file = io.open(_path.data .. "cheat_codes/arc-patterns/collection-"..selected_coll.."/encoder-"..which..".data", "r") + local file = io.open(_path.data .. "cheat_codes2/collection-"..selected_coll.."/arc-rec/encoder-"..which..".data", "r") if file then io.input(file) if io.read() == "stored arc pattern: collection "..selected_coll.." + encoder "..which then - arc_pat[which].event = {} - arc_pat[which].count = tonumber(io.read()) - for i = 1,arc_pat[which].count do - arc_pat[which].time[i] = tonumber(io.read()) - arc_pat[which].event[i] = {} - arc_pat[which].event[i].i = {} - arc_pat[which].event[i].param = {} - arc_pat[which].event[i].pad = {} - arc_pat[which].event[i].start_point = {} - arc_pat[which].event[i].end_point = {} - arc_pat[which].event[i].prev_tilt = {} - arc_pat[which].event[i].tilt = {} - -- - arc_pat[which].event[i].i = tonumber(io.read()) - arc_pat[which].event[i].param = tonumber(io.read()) - arc_pat[which].event[i].pad = tonumber(io.read()) - arc_pat[which].event[i].start_point = tonumber(io.read()) - arc_pat[which].event[i].end_point = tonumber(io.read()) - arc_pat[which].event[i].prev_tilt = tonumber(io.read()) - arc_pat[which].event[i].tilt = tonumber(io.read()) - end - arc_pat[which].metro.props.time = tonumber(io.read()) - arc_pat[which].prev_time = tonumber(io.read()) - local new_arc_array = io.read() - if new_arc_array ~= nil then - arc_pat[which].start_point = tonumber(string.match(new_arc_array, ': (.*)')) - else - arc_pat[which].start_point = 1 - end - local new_arc_array = io.read() - if new_arc_array ~= nil then - arc_pat[which].end_point = tonumber(string.match(new_arc_array, ': (.*)')) - else - arc_pat[which].end_point = arc_pat[which].count + for j = 1,4 do + arc_pat[which][j].event = {} + arc_pat[which][j].count = tonumber(string.match(io.read(), ': (.*)')) + for i = 1,arc_pat[which][j].count do + arc_pat[which][j].time[i] = tonumber(string.match(io.read(), ': (.*)')) + arc_pat[which][j].event[i] = {} + arc_pat[which][j].event[i].i1 = {} + arc_pat[which][j].event[i].i2 = {} + arc_pat[which][j].event[i].param = {} + arc_pat[which][j].event[i].pad = {} + arc_pat[which][j].event[i].start_point = {} + arc_pat[which][j].event[i].end_point = {} + arc_pat[which][j].event[i].prev_tilt = {} + arc_pat[which][j].event[i].tilt = {} + arc_pat[which][j].event[i].pan = {} + arc_pat[which][j].event[i].level = {} + -- + arc_pat[which][j].event[i].i1 = tonumber(string.match(io.read(), ': (.*)')) + arc_pat[which][j].event[i].i2 = tonumber(string.match(io.read(), ': (.*)')) + arc_pat[which][j].event[i].param = tonumber(string.match(io.read(), ': (.*)')) + arc_pat[which][j].event[i].pad =tonumber(string.match(io.read(), ': (.*)')) + arc_pat[which][j].event[i].start_point = tonumber(string.match(io.read(), ': (.*)')) + arc_pat[which][j].event[i].end_point = tonumber(string.match(io.read(), ': (.*)')) + arc_pat[which][j].event[i].prev_tilt = tonumber(string.match(io.read(), ': (.*)')) + arc_pat[which][j].event[i].tilt = tonumber(string.match(io.read(), ': (.*)')) + arc_pat[which][j].event[i].pan = tonumber(string.match(io.read(), ': (.*)')) + arc_pat[which][j].event[i].level = tonumber(string.match(io.read(), ': (.*)')) + end + arc_pat[which][j].metro.props.time = tonumber(string.match(io.read(), ': (.*)')) + arc_pat[which][j].prev_time = tonumber(string.match(io.read(), ': (.*)')) + arc_pat[which][j].start_point = tonumber(string.match(io.read(), ': (.*)')) + arc_pat[which][j].end_point = tonumber(string.match(io.read(), ': (.*)')) end end io.close(file) + grid_dirty = true else print("nofile") end end function save_midi_pattern(which) - local dirname = _path.data.."cheat_codes/midi-patterns/" - if os.rename(dirname, dirname) == nil then - os.execute("mkdir " .. dirname) - end - - local dirname = _path.data.."cheat_codes/midi-patterns/collection-"..selected_coll.."/" - if os.rename(dirname, dirname) == nil then - os.execute("mkdir " .. dirname) - end - - local file = io.open(_path.data .. "cheat_codes/midi-patterns/collection-"..selected_coll.."/"..which..".data", "w+") + local file = io.open(_path.data .. "cheat_codes2/collection-"..selected_coll.."/patterns/midi"..which..".data", "w+") io.output(file) if midi_pat[which].count > 0 then io.write("stored midi pattern: collection "..selected_coll..", pattern "..which.."\n") @@ -5081,7 +4999,7 @@ function save_midi_pattern(which) end function load_midi_pattern(which) - local file = io.open(_path.data .. "cheat_codes/midi-patterns/collection-"..selected_coll.."/"..which..".data", "r") + local file = io.open(_path.data .. "cheat_codes2/collection-"..selected_coll.."/patterns/midi"..which..".data", "r") if file then io.input(file) if io.read() == "stored midi pattern: collection "..selected_coll..", pattern "..which then diff --git a/lib/arc_actions.lua b/lib/arc_actions.lua index 9b88cc3..83a7d4e 100755 --- a/lib/arc_actions.lua +++ b/lib/arc_actions.lua @@ -37,9 +37,10 @@ function aa.init(n,d) aa.record(n) end else - local side = (arc.alt == nil or arc.alt == 0) and "L" or "R" - aa.delay_rate(d,side) - aa.record_delay(side) + -- local side = (arc.alt == nil or arc.alt == 0) and "L" or "R" + -- aa.delay_rate(d,side) + -- aa.record_delay(side) + aa.change_param_focus(d) end redraw() end @@ -79,28 +80,39 @@ function aa.map(fn, bank, delta, enc) end end -function aa.delay_rate(d,side) - local chan = side == "L" and 1 or 2 - delay[chan].arc_rate_tracker = util.clamp(delay[chan].arc_rate_tracker + d/10,1,13) - delay[chan].arc_rate = math.floor(delay[chan].arc_rate_tracker) - params:set("delay "..side..": rate",math.floor(delay[chan].arc_rate_tracker)) +function aa.change_param_focus(d) + local start = util.round(arc_meta_focus) + arc_meta_focus = util.clamp(arc_meta_focus+d/33,1,6) + if start ~= util.round(arc_meta_focus) then + for i = 1,3 do + arc_param[i] = util.round(arc_meta_focus) + end + grid_dirty = true + end end +-- function aa.delay_rate(d,side) +-- local chan = side == "L" and 1 or 2 +-- delay[chan].arc_rate_tracker = util.clamp(delay[chan].arc_rate_tracker + d/10,1,13) +-- delay[chan].arc_rate = math.floor(delay[chan].arc_rate_tracker) +-- params:set("delay "..side..": rate",math.floor(delay[chan].arc_rate_tracker)) +-- end + function aa.record(enc) aa.new_pattern_watch(enc) end -function aa.record_delay(side) - arc_p[side] = {} - arc_p[side].i = side - if grid.alt == 0 then - arc_p[side].delay_focus = "L" - arc_p[side].left_delay_value = params:get("delay L: rate") - else - arc_p[side].delay_focus = "R" - arc_p[side].right_delay_value = params:get("delay R: rate") - end -end +-- function aa.record_delay(side) +-- arc_p[side] = {} +-- arc_p[side].i = side +-- if grid.alt == 0 then +-- arc_p[side].delay_focus = "L" +-- arc_p[side].left_delay_value = params:get("delay L: rate") +-- else +-- arc_p[side].delay_focus = "R" +-- arc_p[side].right_delay_value = params:get("delay R: rate") +-- end +-- end function aa.move_window(target, delta) local duration = target.mode == 1 and 8 or clip[target.clip].sample_length diff --git a/lib/arp_actions.lua b/lib/arp_actions.lua index f136575..969c9f5 100755 --- a/lib/arp_actions.lua +++ b/lib/arp_actions.lua @@ -147,26 +147,26 @@ end function arp_actions.savestate() local collection = params:get("collection") - local dirname = _path.data.."cheat_codes/arp/" + local dirname = _path.data.."cheat_codes2/arp/" if os.rename(dirname, dirname) == nil then os.execute("mkdir " .. dirname) end - local dirname = _path.data.."cheat_codes/arp/collection-"..collection.."/" + local dirname = _path.data.."cheat_codes2/arp/collection-"..collection.."/" if os.rename(dirname, dirname) == nil then os.execute("mkdir " .. dirname) end for i = 1,3 do - tab.save(arp[i],_path.data .. "cheat_codes/arp/collection-"..collection.."/"..i..".data") + tab.save(arp[i],_path.data .. "cheat_codes2/arp/collection-"..collection.."/"..i..".data") end end function arp_actions.loadstate() local collection = params:get("collection") for i = 1,3 do - if tab.load(_path.data .. "cheat_codes/arp/collection-"..collection.."/"..i..".data") ~= nil then - arp[i] = tab.load(_path.data .. "cheat_codes/arp/collection-"..collection.."/"..i..".data") + if tab.load(_path.data .. "cheat_codes2/arp/collection-"..collection.."/"..i..".data") ~= nil then + arp[i] = tab.load(_path.data .. "cheat_codes2/arp/collection-"..collection.."/"..i..".data") -- arp[i].clock = nil -- arp[i].pause = true -- arp[i].playing = false diff --git a/lib/delay.lua b/lib/delay.lua index 33c48d6..346b03f 100755 --- a/lib/delay.lua +++ b/lib/delay.lua @@ -120,24 +120,24 @@ end function delays.savestate(source,collection) local del_name = source == 1 and "L" or "R" - local dirname = _path.data.."cheat_codes/delays/" + local dirname = _path.data.."cheat_codes2/delays/" if os.rename(dirname, dirname) == nil then os.execute("mkdir " .. dirname) end - local dirname = _path.data.."cheat_codes/delays/collection-"..collection.."/" + local dirname = _path.data.."cheat_codes2/delays/collection-"..collection.."/" if os.rename(dirname, dirname) == nil then os.execute("mkdir " .. dirname) end - tab.save(delay_bundle[source],_path.data .. "cheat_codes/delays/collection-"..collection.."/"..del_name..".data") + tab.save(delay_bundle[source],_path.data .. "cheat_codes2/delays/collection-"..collection.."/"..del_name..".data") end function delays.loadstate(collection) local del_name = {"L","R"} for i = 1,2 do - if tab.load(_path.data .. "cheat_codes/delays/collection-"..collection.."/"..del_name[i]..".data") ~= nil then - delay_bundle[i] = tab.load(_path.data .. "cheat_codes/delays/collection-"..collection.."/"..del_name[i]..".data") + if tab.load(_path.data .. "cheat_codes2/delays/collection-"..collection.."/"..del_name[i]..".data") ~= nil then + delay_bundle[i] = tab.load(_path.data .. "cheat_codes2/delays/collection-"..collection.."/"..del_name[i]..".data") end end end @@ -297,12 +297,12 @@ end function delays.save_delay(source) - local dirname = _path.dust.."audio/cc_saved_delays/" + local dirname = _path.dust.."audio/cc2_saved-delays/" if os.rename(dirname, dirname) == nil then os.execute("mkdir " .. dirname) end - local dirname = _path.dust.."audio/cc_saved_delays/"..os.date("%y%m%d").."/" + local dirname = _path.dust.."audio/cc2_saved-delays/"..os.date("%y%m%d").."/" if os.rename(dirname, dirname) == nil then os.execute("mkdir " .. dirname) end @@ -310,7 +310,7 @@ function delays.save_delay(source) local id = os.date("%X") local name = id.."-"..(source == 1 and "L-" or "R-")..params:get("bpm")..".wav" local duration = delay[source].mode == "clocked" and delay[source].end_point-delay[source].start_point or delay[source].free_end_point-delay[source].start_point - softcut.buffer_write_mono(_path.dust.."audio/cc_saved_delays/"..os.date("%y%m%d").."/"..name,delay[source].start_point,duration,1) + softcut.buffer_write_mono(_path.dust.."audio/cc2_saved-delays/"..os.date("%y%m%d").."/"..name,delay[source].start_point,duration,1) end function delays.load_delay(file,destination) diff --git a/lib/euclid.lua b/lib/euclid.lua index f45cdcb..8443433 100755 --- a/lib/euclid.lua +++ b/lib/euclid.lua @@ -113,26 +113,26 @@ end function euclid.savestate() local collection = params:get("collection") - local dirname = _path.data.."cheat_codes/rytm/" + local dirname = _path.data.."cheat_codes2/rytm/" if os.rename(dirname, dirname) == nil then os.execute("mkdir " .. dirname) end - local dirname = _path.data.."cheat_codes/rytm/collection-"..collection.."/" + local dirname = _path.data.."cheat_codes2/rytm/collection-"..collection.."/" if os.rename(dirname, dirname) == nil then os.execute("mkdir " .. dirname) end for i = 1,3 do - tab.save(euclid.track[i],_path.data .. "cheat_codes/rytm/collection-"..collection.."/"..i..".data") + tab.save(euclid.track[i],_path.data .. "cheat_codes2/rytm/collection-"..collection.."/"..i..".data") end end function euclid.loadstate() local collection = params:get("collection") for i = 1,3 do - if tab.load(_path.data .. "cheat_codes/rytm/collection-"..collection.."/"..i..".data") ~= nil then - euclid.track[i] = tab.load(_path.data .. "cheat_codes/rytm/collection-"..collection.."/"..i..".data") + if tab.load(_path.data .. "cheat_codes2/rytm/collection-"..collection.."/"..i..".data") ~= nil then + euclid.track[i] = tab.load(_path.data .. "cheat_codes2/rytm/collection-"..collection.."/"..i..".data") end end euclid.reset_pattern() diff --git a/lib/rnd_actions.lua b/lib/rnd_actions.lua index 908c324..e2928c2 100755 --- a/lib/rnd_actions.lua +++ b/lib/rnd_actions.lua @@ -194,26 +194,26 @@ end function rnd.savestate() local collection = params:get("collection") - local dirname = _path.data.."cheat_codes/rnd/" + local dirname = _path.data.."cheat_codes2/rnd/" if os.rename(dirname, dirname) == nil then os.execute("mkdir " .. dirname) end - local dirname = _path.data.."cheat_codes/rnd/collection-"..collection.."/" + local dirname = _path.data.."cheat_codes2/rnd/collection-"..collection.."/" if os.rename(dirname, dirname) == nil then os.execute("mkdir " .. dirname) end for i = 1,3 do - tab.save(rnd[i],_path.data .. "cheat_codes/rnd/collection-"..collection.."/"..i..".data") + tab.save(rnd[i],_path.data .. "cheat_codes2/rnd/collection-"..collection.."/"..i..".data") end end function rnd.loadstate() local collection = params:get("collection") for i = 1,3 do - if tab.load(_path.data .. "cheat_codes/rnd/collection-"..collection.."/"..i..".data") ~= nil then - rnd[i] = tab.load(_path.data .. "cheat_codes/rnd/collection-"..collection.."/"..i..".data") + if tab.load(_path.data .. "cheat_codes2/rnd/collection-"..collection.."/"..i..".data") ~= nil then + rnd[i] = tab.load(_path.data .. "cheat_codes2/rnd/collection-"..collection.."/"..i..".data") for j = 1,#rnd[i] do rnd[i][j].clock = nil if rnd[i][j].playing then From d964d69f6251ce36fbc0569674947bb9b8061e51 Mon Sep 17 00:00:00 2001 From: dndrks Date: Thu, 27 Aug 2020 09:58:46 -0500 Subject: [PATCH 4/9] arc global level control ADDED: - if K1 is held or alt_lock is turned on for a bank or grid alt is held, the arc encoder for level will control *global* level instead of pad level --- cheat_codes.lua | 13 +++++++++---- lib/arc_actions.lua | 12 +++++++++--- lib/zilchmos.lua | 2 +- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/cheat_codes.lua b/cheat_codes.lua index b30db60..9b0dc0e 100755 --- a/cheat_codes.lua +++ b/cheat_codes.lua @@ -3713,10 +3713,15 @@ arc_redraw = function() end end if arc_param[i] == 5 then - local level_to_led = bank[i][bank[i].id].level - for j = 1,17 do - a:led(i,(math.floor(util.linlin(0,2,5,70,(level_to_led)-(1/8*j))))+16,15) - end + local level_to_led; + if not key1_hold and not bank[i].alt_lock and grid.alt == 0 then + level_to_led = bank[i][bank[i].id].level + else + level_to_led = bank[i].global_level + end + for j = 1,17 do + a:led(i,(math.floor(util.linlin(0,2,5,70,(level_to_led)-(1/8*j))))+16,15) + end end if arc_param[i] == 6 then local pan_to_led = bank[i][bank[i].id].pan diff --git a/lib/arc_actions.lua b/lib/arc_actions.lua index 83a7d4e..361c036 100755 --- a/lib/arc_actions.lua +++ b/lib/arc_actions.lua @@ -17,13 +17,13 @@ function aa.init(n,d) local this_pad = this_bank[which_pad] local p_action = aa.actions[arc_param[n]][1] local sc_action = aa.actions[arc_param[n]][2] - if grid.alt == 0 then + if not this_bank.alt_lock and grid.alt == 0 then if arc_param[n] ~= 4 then p_action(this_pad,d) else aa.map(p_action, this_bank, d/1000, n) end - else + elseif this_bank.alt_lock or grid.alt == 1 then if arc_param[n] ~= 4 then aa.map(p_action,this_bank,d) else @@ -161,7 +161,13 @@ function aa.change_pan(target, delta) end function aa.change_level(target, delta) - target.level = util.clamp(target.level + delta/1000,0,2) + if not bank[target.bank_id].alt_lock and grid.alt == 0 then + target.level = util.clamp(target.level + delta/1000,0,2) + else + if target.pad_id == 1 then + bank[target.bank_id].global_level = util.clamp(bank[target.bank_id].global_level + delta/1000,0,2) + end + end end function aa.sc.move_window(enc, target) diff --git a/lib/zilchmos.lua b/lib/zilchmos.lua index b2c5ed6..0125452 100755 --- a/lib/zilchmos.lua +++ b/lib/zilchmos.lua @@ -71,7 +71,7 @@ function zilchmos.level_inc( pad, delta ) if not bank[which_bank].alt_lock and grid.alt == 0 then pad.level = util.clamp( pad.level + delta, 0, 2 ) else - if pad.pad_id == 1 then + if pad.pad_id == 1 then -- only do this once... bank[which_bank].global_level = util.clamp( bank[which_bank].global_level + delta, 0, 2) end end From 27ef18f81a67bd4f8819d1ec4abe4aad2d9aabd0 Mon Sep 17 00:00:00 2001 From: dndrks Date: Thu, 27 Aug 2020 10:08:11 -0500 Subject: [PATCH 5/9] add global level to arc recording ADDED: - global level changes can be recorded --- cheat_codes.lua | 4 ++++ lib/arc_actions.lua | 1 + 2 files changed, 5 insertions(+) diff --git a/cheat_codes.lua b/cheat_codes.lua index 9b0dc0e..017a246 100755 --- a/cheat_codes.lua +++ b/cheat_codes.lua @@ -3594,6 +3594,7 @@ function new_arc_pattern_execute(entry) end elseif entry.param == 5 then bank[id][which_pad].level = (entry.level + arc_offset) + bank[id].global_level = (entry.global_level + arc_offset) if bank[id].id == which_pad then softcut.level(id+1, (entry.level + arc_offset)*bank[id].global_level) end @@ -4923,6 +4924,7 @@ function save_arc_pattern(which) io.write("event "..i.." tilt: "..arc_pat[which][j].event[i].tilt .. "\n") io.write("event "..i.." pan: "..arc_pat[which][j].event[i].pan .. "\n") io.write("event "..i.." level: "..arc_pat[which][j].event[i].level .. "\n") + io.write("event "..i.." global level: "..arc_pat[which][j].event[i].global_level .. "\n") end io.write("recording "..j.." props time: "..arc_pat[which][j].metro.props.time .. "\n") io.write("recording "..j.." prev time: "..arc_pat[which][j].prev_time .. "\n") @@ -4954,6 +4956,7 @@ function load_arc_pattern(which) arc_pat[which][j].event[i].tilt = {} arc_pat[which][j].event[i].pan = {} arc_pat[which][j].event[i].level = {} + arc_pat[which][j].event[i].global_level = {} -- arc_pat[which][j].event[i].i1 = tonumber(string.match(io.read(), ': (.*)')) arc_pat[which][j].event[i].i2 = tonumber(string.match(io.read(), ': (.*)')) @@ -4965,6 +4968,7 @@ function load_arc_pattern(which) arc_pat[which][j].event[i].tilt = tonumber(string.match(io.read(), ': (.*)')) arc_pat[which][j].event[i].pan = tonumber(string.match(io.read(), ': (.*)')) arc_pat[which][j].event[i].level = tonumber(string.match(io.read(), ': (.*)')) + arc_pat[which][j].event[i].global_level = tonumber(string.match(io.read(), ': (.*)')) end arc_pat[which][j].metro.props.time = tonumber(string.match(io.read(), ': (.*)')) arc_pat[which][j].prev_time = tonumber(string.match(io.read(), ': (.*)')) diff --git a/lib/arc_actions.lua b/lib/arc_actions.lua index 361c036..22e0042 100755 --- a/lib/arc_actions.lua +++ b/lib/arc_actions.lua @@ -70,6 +70,7 @@ function aa.new_pattern_watch(enc) --new new! arc_p[enc][a_p].pan = bank[id][bank[id].id].pan arc_p[enc][a_p].level = bank[id][bank[id].id].level + arc_p[enc][a_p].global_level = bank[id].global_level --/new new! arc_pat[enc][a_p]:watch(arc_p[enc][a_p]) end From 658f305266a73ae036e54e8ea77a25e873ebb9ad Mon Sep 17 00:00:00 2001 From: dndrks Date: Thu, 27 Aug 2020 14:23:32 -0500 Subject: [PATCH 6/9] loading/saving UI ADDED: - UI screens for loading / saving collections - cancellation option for saving collections --- cheat_codes.lua | 660 ++++++++++++++++++++++++---------------------- lib/main_menu.lua | 76 ++++++ 2 files changed, 419 insertions(+), 317 deletions(-) diff --git a/cheat_codes.lua b/cheat_codes.lua index 017a246..359166c 100755 --- a/cheat_codes.lua +++ b/cheat_codes.lua @@ -676,6 +676,8 @@ local lit = {} function init() + collection_loaded = false + all_loaded = false for i = 1,3 do @@ -702,7 +704,11 @@ function init() params:add_number("collection", "collection", 1,100,1) params:add{type = "trigger", id = "load", name = "load", action = loadstate} params:add_option("collect_live","collect Live buffers?",{"no","yes"}) - params:add{type = "trigger", id = "save", name = "save", action = savestate} + params:add{type = "trigger", id = "save", name = "save", action = function() + collection_save_clock = clock.run(save_screen) + _norns.key(1,1) + _norns.key(1,0) + end} menu = 1 @@ -2561,326 +2567,335 @@ function reload_collected_samples(file,sample) end function key(n,z) - if n == 3 and z == 1 then - if menu == 1 then - for i = 1,10 do - if page.main_sel == i then - menu = i+1 - end - end - elseif menu == 2 then - if not key1_hold then - page.loops_view[page.loops_sel] = (page.loops_view[page.loops_sel] % 3) + 1 - else - if page.loops_sel < 4 then - local id = page.loops_sel - bank[id][bank[id].id].loop = not bank[id][bank[id].id].loop - if bank[id][bank[id].id].loop then - softcut.loop(id+1,1) - softcut.position(id+1,bank[id][bank[id].id].start_point) - else - softcut.loop(id+1,0) + if menu == "load screen" then + elseif menu == "save screen" then + if z == 1 then + clock.cancel(collection_save_clock) + print("cancel save") + clock.run(canceled_save) + end + else + if n == 3 and z == 1 then + if menu == 1 then + for i = 1,10 do + if page.main_sel == i then + menu = i+1 end - grid_dirty = true - elseif page.loops_sel == 4 then - toggle_buffer(rec.clip) - -- if params:get("rec_loop") == 1 then - -- rec.state = math.abs((rec.state % 2) - 1) - -- softcut.rec_level(1,rec.state) - -- else - -- softcut.position(1,rec.start_point) - -- rec.state = 1 - -- softcut.rec_level(1,rec.state) - -- end + end + elseif menu == 2 then + if not key1_hold then + page.loops_view[page.loops_sel] = (page.loops_view[page.loops_sel] % 3) + 1 + else + if page.loops_sel < 4 then + local id = page.loops_sel + bank[id][bank[id].id].loop = not bank[id][bank[id].id].loop + if bank[id][bank[id].id].loop then + softcut.loop(id+1,1) + softcut.position(id+1,bank[id][bank[id].id].start_point) + else + softcut.loop(id+1,0) + end + grid_dirty = true + elseif page.loops_sel == 4 then + toggle_buffer(rec.clip) + -- if params:get("rec_loop") == 1 then + -- rec.state = math.abs((rec.state % 2) - 1) + -- softcut.rec_level(1,rec.state) + -- else + -- softcut.position(1,rec.start_point) + -- rec.state = 1 + -- softcut.rec_level(1,rec.state) + -- end + end end - end - elseif menu == 3 then - local level_nav = (page.levels_sel + 1)%4 - page.levels_sel = level_nav - elseif menu == 5 then - local filter_nav = (page.filtering_sel + 1)%3 - page.filtering_sel = filter_nav - elseif menu == 6 then - if page.delay_section < 3 then - page.delay_section = (page.delay_section%3)+1 - end - elseif menu == 7 then - local time_nav = page.time_sel - local id = time_nav - if time_nav >= 1 and time_nav < 4 then - if g.device == nil and grid_pat[time_nav].count == 0 then - if page.time_page_sel[time_nav] == 1 then - if midi_pat[time_nav].playmode < 3 then - if midi_pat[time_nav].rec == 0 then - if midi_pat[time_nav].count == 0 then - if midi_pat[time_nav].playmode == 1 then - midi_pat[time_nav]:rec_start() + elseif menu == 3 then + local level_nav = (page.levels_sel + 1)%4 + page.levels_sel = level_nav + elseif menu == 5 then + local filter_nav = (page.filtering_sel + 1)%3 + page.filtering_sel = filter_nav + elseif menu == 6 then + if page.delay_section < 3 then + page.delay_section = (page.delay_section%3)+1 + end + elseif menu == 7 then + local time_nav = page.time_sel + local id = time_nav + if time_nav >= 1 and time_nav < 4 then + if g.device == nil and grid_pat[time_nav].count == 0 then + if page.time_page_sel[time_nav] == 1 then + if midi_pat[time_nav].playmode < 3 then + if midi_pat[time_nav].rec == 0 then + if midi_pat[time_nav].count == 0 then + if midi_pat[time_nav].playmode == 1 then + midi_pat[time_nav]:rec_start() + else + midi_pat[time_nav].rec_clock = clock.run(synced_record_start,midi_pat[time_nav],time_nav) + end else - midi_pat[time_nav].rec_clock = clock.run(synced_record_start,midi_pat[time_nav],time_nav) - end - else - if midi_pat[time_nav].play == 1 then - midi_pat[time_nav].overdub = midi_pat[time_nav].overdub == 0 and 1 or 0 + if midi_pat[time_nav].play == 1 then + midi_pat[time_nav].overdub = midi_pat[time_nav].overdub == 0 and 1 or 0 + end end - end - elseif midi_pat[time_nav].rec == 1 then - midi_pat[time_nav]:rec_stop() - if midi_pat[time_nav].playmode == 1 then - --midi_pat[time_nav]:start() - start_pattern(midi_pat[time_nav]) - elseif midi_pat[time_nav].playmode == 2 then - --midi_pat[time_nav]:start() - print("line 2196") - --start_synced_loop(midi_pat[time_nav]) + elseif midi_pat[time_nav].rec == 1 then midi_pat[time_nav]:rec_stop() - clock.cancel(midi_pat[time_nav].rec_clock) - if midi_pat[time_nav].clock ~= nil then - print("clearing clock: "..midi_pat[time_nav].clock) - clock.cancel(midi_pat[time_nav].clock) + if midi_pat[time_nav].playmode == 1 then + --midi_pat[time_nav]:start() + start_pattern(midi_pat[time_nav]) + elseif midi_pat[time_nav].playmode == 2 then + --midi_pat[time_nav]:start() + print("line 2196") + --start_synced_loop(midi_pat[time_nav]) + midi_pat[time_nav]:rec_stop() + clock.cancel(midi_pat[time_nav].rec_clock) + if midi_pat[time_nav].clock ~= nil then + print("clearing clock: "..midi_pat[time_nav].clock) + clock.cancel(midi_pat[time_nav].clock) + end + midi_pat[id]:clear() end - midi_pat[id]:clear() end end end end - end - if page.time_page_sel[time_nav] == 2 then - if g.device ~= nil then - print("random grid pat!", id) - random_grid_pat(id,2) - else - shuffle_midi_pat(id) - ("random midi pat!") - end - elseif page.time_page_sel[time_nav] == 5 then - if not key1_hold then + if page.time_page_sel[time_nav] == 2 then if g.device ~= nil then - if grid_pat[id].playmode == 3 or grid_pat[id].playmode == 4 then - clock.run(random_grid_pat, id, 3) + print("random grid pat!", id) + random_grid_pat(id,2) + else + shuffle_midi_pat(id) + ("random midi pat!") + end + elseif page.time_page_sel[time_nav] == 5 then + if not key1_hold then + if g.device ~= nil then + if grid_pat[id].playmode == 3 or grid_pat[id].playmode == 4 then + clock.run(random_grid_pat, id, 3) + else + random_grid_pat(id,3) + end else - random_grid_pat(id,3) + random_midi_pat(id) end - else - random_midi_pat(id) end end - end - if key1_hold then - if grid_pat[id].count > 0 then - grid_pat[id]:rec_stop() - grid_pat[id]:stop() - grid_pat[id].tightened_start = 0 - grid_pat[id]:clear() - pattern_saver[id].load_slot = 0 - end - if midi_pat[id].count > 0 then - midi_pat[id]:rec_stop() - if midi_pat[id].clock ~= nil then - print("clearing clock: "..midi_pat[id].clock) - clock.cancel(midi_pat[id].clock) + if key1_hold then + if grid_pat[id].count > 0 then + grid_pat[id]:rec_stop() + grid_pat[id]:stop() + grid_pat[id].tightened_start = 0 + grid_pat[id]:clear() + pattern_saver[id].load_slot = 0 + end + if midi_pat[id].count > 0 then + midi_pat[id]:rec_stop() + if midi_pat[id].clock ~= nil then + print("clearing clock: "..midi_pat[id].clock) + clock.cancel(midi_pat[id].clock) + end + midi_pat[id]:clear() end - midi_pat[id]:clear() end - end - elseif time_nav >= 4 then - if a.device ~= nil then - local pattern = arc_pat[time_nav-3][page.time_page_sel[time_nav]] - if page.time_page_sel[page.time_sel] <= 4 then - if not key1_hold then - if pattern.rec == 0 and pattern.play == 0 and pattern.count == 0 then - pattern:rec_start() - elseif pattern.rec == 1 then - pattern:rec_stop() - pattern:start() - elseif pattern.play == 1 then - pattern:stop() - elseif (pattern.rec == 0 and pattern.play == 0 and pattern.count > 0) then - pattern:start() + elseif time_nav >= 4 then + if a.device ~= nil then + local pattern = arc_pat[time_nav-3][page.time_page_sel[time_nav]] + if page.time_page_sel[page.time_sel] <= 4 then + if not key1_hold then + if pattern.rec == 0 and pattern.play == 0 and pattern.count == 0 then + pattern:rec_start() + elseif pattern.rec == 1 then + pattern:rec_stop() + pattern:start() + elseif pattern.play == 1 then + pattern:stop() + elseif (pattern.rec == 0 and pattern.play == 0 and pattern.count > 0) then + pattern:start() + end + else + pattern:clear() end else - pattern:clear() - end - else - for i = 1,4 do - if page.time_page_sel[page.time_sel] == 5 then - if arc_pat[time_nav-3][i].count > 0 then - arc_pat[time_nav-3][i]:start() + for i = 1,4 do + if page.time_page_sel[page.time_sel] == 5 then + if arc_pat[time_nav-3][i].count > 0 then + arc_pat[time_nav-3][i]:start() + end + elseif page.time_page_sel[page.time_sel] == 6 then + arc_pat[time_nav-3][i]:stop() + elseif page.time_page_sel[page.time_sel] == 7 then + arc_pat[time_nav-3][i]:clear() end - elseif page.time_page_sel[page.time_sel] == 6 then - arc_pat[time_nav-3][i]:stop() - elseif page.time_page_sel[page.time_sel] == 7 then - arc_pat[time_nav-3][i]:clear() end end end end - end - elseif menu == 8 then - - if key1_hold then - rytm.track[rytm.track_edit].pos = 0 - else - rytm.screen_focus = rytm.screen_focus == "left" and "right" or "left" - end + elseif menu == 8 then - elseif menu == 9 then - -- arp[page.arp_page_sel].hold = not arp[page.arp_page_sel].hold - local id = page.arp_page_sel - if not arp[id].hold then - if not arp[id].enabled then - arp[id].enabled = true - end - if #arp[id].notes > 0 then - arp[id].hold = true + if key1_hold then + rytm.track[rytm.track_edit].pos = 0 else - arp[id].enabled = false + rytm.screen_focus = rytm.screen_focus == "left" and "right" or "left" end - else - if #arp[id].notes > 0 then - if arp[id].playing == true then - arp[id].hold = not arp[id].hold - if not arp[id].hold then - arps.clear(id) - end + + elseif menu == 9 then + -- arp[page.arp_page_sel].hold = not arp[page.arp_page_sel].hold + local id = page.arp_page_sel + if not arp[id].hold then + if not arp[id].enabled then + arp[id].enabled = true + end + if #arp[id].notes > 0 then + arp[id].hold = true + else arp[id].enabled = false - -- else - -- arp[id].step = arp[id].start_point-1 - -- arp[id].pause = false - -- arp[id].playing = true + end + else + if #arp[id].notes > 0 then + if arp[id].playing == true then + arp[id].hold = not arp[id].hold + if not arp[id].hold then + arps.clear(id) + end + arp[id].enabled = false + -- else + -- arp[id].step = arp[id].start_point-1 + -- arp[id].pause = false + -- arp[id].playing = true + end end end - end - grid_dirty = true + grid_dirty = true - -- if not arp[page.arp_page_sel].hold then - -- arps.clear(page.arp_page_sel) - -- end - elseif menu == 10 then - if key1_hold then - local rnd_bank = page.rnd_page - local rnd_slot = page.rnd_page_sel[rnd_bank] - local state = tostring(rnd[rnd_bank][rnd_slot].playing) - rnd.transport(rnd_bank,rnd_slot,state == "false" and "on" or "off") - if state == "true" then - rnd.restore_default(rnd_bank,rnd_slot) + -- if not arp[page.arp_page_sel].hold then + -- arps.clear(page.arp_page_sel) + -- end + elseif menu == 10 then + if key1_hold then + local rnd_bank = page.rnd_page + local rnd_slot = page.rnd_page_sel[rnd_bank] + local state = tostring(rnd[rnd_bank][rnd_slot].playing) + rnd.transport(rnd_bank,rnd_slot,state == "false" and "on" or "off") + if state == "true" then + rnd.restore_default(rnd_bank,rnd_slot) + end + else + page.rnd_page_section = page.rnd_page_section == 1 and 2 or 1 end - else - page.rnd_page_section = page.rnd_page_section == 1 and 2 or 1 end - end - elseif n == 2 and z == 1 then - if menu == 11 then - if help_menu ~= "welcome" then - help_menu = "welcome" - else - menu = 1 - end - elseif menu == 8 then - if key1_hold then - rytm.reset_pattern() - else - menu = 1 - end - elseif menu == 10 then - if key1_hold then - for i = 1,#rnd.targets do - rnd.transport(page.rnd_page,i,"off") - rnd.restore_default(page.rnd_page,i) + elseif n == 2 and z == 1 then + if menu == 11 then + if help_menu ~= "welcome" then + help_menu = "welcome" + else + menu = 1 + end + elseif menu == 8 then + if key1_hold then + rytm.reset_pattern() + else + menu = 1 + end + elseif menu == 10 then + if key1_hold then + for i = 1,#rnd.targets do + rnd.transport(page.rnd_page,i,"off") + rnd.restore_default(page.rnd_page,i) + end + else + menu = 1 + end + elseif menu == 6 then + if page.delay_section == 3 then + page.delay_section = 2 + elseif page.delay_section == 2 then + page.delay_section = 1 + else + menu = 1 + end + elseif menu == 2 then + if key1_hold then + -- + else + menu = 1 end else menu = 1 end - elseif menu == 6 then - if page.delay_section == 3 then - page.delay_section = 2 - elseif page.delay_section == 2 then - page.delay_section = 1 - else - menu = 1 - end - elseif menu == 2 then - if key1_hold then - -- - else - menu = 1 + if menu ~= 2 and menu ~= 8 then + if key1_hold == true then key1_hold = false end end - else - menu = 1 end - if menu ~= 2 and menu ~= 8 then - if key1_hold == true then key1_hold = false end - end - end - if n == 1 and z == 1 then - if menu == 5 or menu == 11 then - if key1_hold == false then + if n == 1 and z == 1 then + if menu == 5 or menu == 11 then + if key1_hold == false then + key1_hold = true + else + key1_hold = false + end + elseif menu == 7 then + key1_hold = true + elseif menu == 8 then key1_hold = true + elseif menu == 9 then + key1_hold = true + page.arp_alt[page.arp_page_sel] = not page.arp_alt[page.arp_page_sel] else + key1_hold = true + end + + elseif n == 1 and z == 0 then + if menu ~= 5 and menu ~= 11 then key1_hold = false end - elseif menu == 7 then - key1_hold = true - elseif menu == 8 then - key1_hold = true - elseif menu == 9 then - key1_hold = true - page.arp_alt[page.arp_page_sel] = not page.arp_alt[page.arp_page_sel] - else - key1_hold = true - end - - elseif n == 1 and z == 0 then - if menu ~= 5 and menu ~= 11 then - key1_hold = false - end - if menu == 7 then - if page.time_sel < 4 then - if key1_hold_and_modify == false then - local time_nav = page.time_sel - local id = time_nav - if midi_pat[id].play == 1 then - if midi_pat[id].clock ~= nil then - clock.cancel(midi_pat[id].clock) - print("pausing clock") - midi_pat[id].step = 1 - end - midi_pat[id]:stop() - else - if midi_pat[id].count > 0 then - if midi_pat[id].playmode == 1 then - --midi_pat[id]:start() - start_pattern(midi_pat[id]) - elseif midi_pat[id].playmode == 2 then - print("line 2387") - --midi_pat[id].clock = clock.run(synced_loop, midi_pat[id], "restart") - midi_pat[id].clock = clock.run(alt_synced_loop, midi_pat[id], "restart") + if menu == 7 then + if page.time_sel < 4 then + if key1_hold_and_modify == false then + local time_nav = page.time_sel + local id = time_nav + if midi_pat[id].play == 1 then + if midi_pat[id].clock ~= nil then + clock.cancel(midi_pat[id].clock) + print("pausing clock") + midi_pat[id].step = 1 + end + midi_pat[id]:stop() + else + if midi_pat[id].count > 0 then + if midi_pat[id].playmode == 1 then + --midi_pat[id]:start() + start_pattern(midi_pat[id]) + elseif midi_pat[id].playmode == 2 then + print("line 2387") + --midi_pat[id].clock = clock.run(synced_loop, midi_pat[id], "restart") + midi_pat[id].clock = clock.run(alt_synced_loop, midi_pat[id], "restart") + end end end - end - if grid_pat[id].count > 0 then - if grid_pat[id].quantize == 0 then - if grid_pat[id].play == 1 then - --grid_pat[id]:stop() - stop_pattern(grid_pat[id]) + if grid_pat[id].count > 0 then + if grid_pat[id].quantize == 0 then + if grid_pat[id].play == 1 then + --grid_pat[id]:stop() + stop_pattern(grid_pat[id]) + else + --grid_pat[id]:start() + start_pattern(grid_pat[id]) + end else - --grid_pat[id]:start() - start_pattern(grid_pat[id]) + grid_pat[id].tightened_start = (grid_pat[id].tightened_start + 1)%2 + grid_pat[id].step = grid_pat[id].start_point + quantized_grid_pat[id].current_step = grid_pat[id].start_point + quantized_grid_pat[id].sub_step = 1 end - else - grid_pat[id].tightened_start = (grid_pat[id].tightened_start + 1)%2 - grid_pat[id].step = grid_pat[id].start_point - quantized_grid_pat[id].current_step = grid_pat[id].start_point - quantized_grid_pat[id].sub_step = 1 end + else + key1_hold_and_modify = false end - else - key1_hold_and_modify = false end end end @@ -3868,70 +3883,81 @@ end function loadstate() - local collection = tonumber(string.format("%.0f",params:get("collection"))) - selected_coll = collection - params:read(_path.data.."cheat_codes2/collection-"..collection.."/params/all.pset") - if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/rec/rec.data") ~= nil then - rec = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/rec/rec.data") - end - -- params:bang() - for i = 1,3 do - if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/banks/"..i..".data") ~= nil then - bank[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/banks/"..i..".data") - end - if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/step-seq/"..i..".data") ~= nil then - step_seq[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/step-seq/"..i..".data") - end - if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/arps/"..i..".data") ~= nil then - arp[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/arps/"..i..".data") + + local check_exist = io.open(_path.data.."cheat_codes2/collection-"..tonumber(string.format("%.0f",params:get("collection")))) + if check_exist then + local collection = tonumber(string.format("%.0f",params:get("collection"))) + selected_coll = collection + collection_loaded = true + io.close(check_exist) + _norns.key(1,1) + _norns.key(1,0) + clock.run(load_screen) + redraw() + params:read(_path.data.."cheat_codes2/collection-"..collection.."/params/all.pset") + if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/rec/rec.data") ~= nil then + rec = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/rec/rec.data") end - if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/rnd/"..i..".data") ~= nil then - rnd[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/rnd/"..i..".data") - for j = 1,#rnd[i] do - rnd[i][j].clock = nil - if rnd[i][j].playing then - rnd[i][j].clock = clock.run(rnd.advance, i, j) + -- params:bang() + for i = 1,3 do + if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/banks/"..i..".data") ~= nil then + bank[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/banks/"..i..".data") + end + if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/step-seq/"..i..".data") ~= nil then + step_seq[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/step-seq/"..i..".data") + end + if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/arps/"..i..".data") ~= nil then + arp[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/arps/"..i..".data") + end + if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/rnd/"..i..".data") ~= nil then + rnd[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/rnd/"..i..".data") + for j = 1,#rnd[i] do + rnd[i][j].clock = nil + if rnd[i][j].playing then + rnd[i][j].clock = clock.run(rnd.advance, i, j) + end end end - end - if params:get("collect_live") == 2 then - reload_collected_samples(_path.dust.."audio/cc2_live-audio/"..collection.."/".."cc2_"..collection.."-"..i..".wav",i) - end - - if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/euclid/euclid"..i..".data") ~= nil then - rytm.track[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/euclid/euclid"..i..".data") + if params:get("collect_live") == 2 then + reload_collected_samples(_path.dust.."audio/cc2_live-audio/"..collection.."/".."cc2_"..collection.."-"..i..".wav",i) + end + + if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/euclid/euclid"..i..".data") ~= nil then + rytm.track[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/euclid/euclid"..i..".data") + end + rytm.reset_pattern() end - rytm.reset_pattern() - end - for i = 1,2 do - if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/delays/delay"..(i == 1 and "L" or "R")..".data") ~= nil then - delay[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/delays/delay"..(i == 1 and "L" or "R")..".data") + for i = 1,2 do + if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/delays/delay"..(i == 1 and "L" or "R")..".data") ~= nil then + delay[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/delays/delay"..(i == 1 and "L" or "R")..".data") + end end - end - -- GRID pattern restore - if selected_coll ~= collection then - meta_shadow(selected_coll) - elseif selected_coll == collection then - cleanup() - end - one_point_two() - -- / GRID pattern restore + -- GRID pattern restore + if selected_coll ~= collection then + meta_shadow(selected_coll) + elseif selected_coll == collection then + cleanup() + end + one_point_two() + -- / GRID pattern restore - for i = 1,3 do - load_arc_pattern(i) - end + for i = 1,3 do + load_arc_pattern(i) + end - for i = 1,3 do - local dirname = _path.data .. "cheat_codes2/collection-"..selected_coll.."/patterns/midi"..i..".data" - if os.rename(dirname, dirname) ~= nil then - load_midi_pattern(i) + for i = 1,3 do + local dirname = _path.data .. "cheat_codes2/collection-"..selected_coll.."/patterns/midi"..i..".data" + if os.rename(dirname, dirname) ~= nil then + load_midi_pattern(i) + end end + else + collection_loaded = false end - grid_dirty = true end diff --git a/lib/main_menu.lua b/lib/main_menu.lua index 82387c2..563b378 100755 --- a/lib/main_menu.lua +++ b/lib/main_menu.lua @@ -1,5 +1,7 @@ local main_menu = {} +local dots = "." + function main_menu.init() if menu == 1 then screen.move(0,10) @@ -875,7 +877,81 @@ function main_menu.init() screen.move(0,64) screen.text("...") + elseif menu == "load screen" then + screen.level(15) + screen.move(62,15) + screen.font_size(10) + if collection_loaded then + screen.text_center("loading collection "..selected_coll) + screen.font_size(40) + screen.move(62,50) + screen.text_center(dots) + screen.font_size(8) + else + screen.move(62,40) + screen.font_size(20) + screen.text_center("no data!") + screen.font_size(8) + end + elseif menu == "save screen" then + screen.level(15) + screen.move(62,15) + screen.font_size(10) + screen.text_center("saving collection "..tonumber(string.format("%.0f",params:get("collection")))) + screen.font_size(40) + screen.move(62,50) + screen.text_center(dots) + screen.move(10,64) + screen.font_size(10) + if dots ~= "saved!" then + screen.text("K2 or K3 to cancel") + end + screen.font_size(8) + elseif menu == "canceled screen" then + screen.level(15) + screen.move(62,30) + screen.font_size(20) + screen.text_center("save") + screen.move(62,50) + screen.text_center("canceled") + end +end + +function load_screen() + dots = "..." + menu = "load screen" + clock.sleep(0.33) + dots = ".." + clock.sleep(0.33) + dots = "." + clock.sleep(0.33) + dots = "ready!" + clock.sleep(0.75) + menu = 1 + if not collection_loaded then + _norns.key(1,1) + _norns.key(1,0) end end +function save_screen() + dots = "3" + menu = "save screen" + clock.sleep(0.75) + dots = "2" + clock.sleep(0.75) + dots = "1" + clock.sleep(0.75) + dots = "saved!" + clock.sleep(0.33) + savestate() + menu = 1 +end + +function canceled_save() + menu = "canceled screen" + clock.sleep(0.75) + menu = 1 +end + return main_menu \ No newline at end of file From 9c8f3446e79bbfd8d650c8cd9ba6626614cadb74 Mon Sep 17 00:00:00 2001 From: dndrks Date: Sun, 30 Aug 2020 12:36:08 -0500 Subject: [PATCH 7/9] overhaul collections entirely new now! - you can name a collection anything - load collections by name - delete collections - overwrite collections --- cheat_codes.lua | 462 ++++++++++++++++++++++++++++++++++--------- lib/arc_actions.lua | 16 +- lib/delay.lua | 19 +- lib/grid_actions.lua | 6 +- lib/main_menu.lua | 85 ++++++-- 5 files changed, 456 insertions(+), 132 deletions(-) diff --git a/cheat_codes.lua b/cheat_codes.lua index 359166c..011f055 100755 --- a/cheat_codes.lua +++ b/cheat_codes.lua @@ -9,6 +9,7 @@ local pattern_time = include 'lib/cc_pattern_time' fileselect = require 'fileselect' +textentry = require 'textentry' help_menus = include 'lib/help_menus' main_menu = include 'lib/main_menu' encoder_actions = include 'lib/encoder_actions' @@ -116,6 +117,8 @@ for i = 1,3 do env_counter[i] = metro.init() env_counter[i].time = 0.01 env_counter[i].butt = 1 + env_counter[i].l_del_butt = 0 + env_counter[i].r_del_butt = 0 env_counter[i].stage = nil -- env_counter[i].mode = 1 -- this needs to be per pad!! env_counter[i].event = function() envelope(i) end @@ -268,6 +271,11 @@ local snakes = function random_grid_pat(which,mode) local pattern = grid_pat[which] + + -- if pattern.playmode == 1 then + -- pattern.playmode = 2 + -- pattern.rec_clock_time = 8 + -- end if mode == 1 then for i = #pattern.time,2,-1 do @@ -305,6 +313,9 @@ function random_grid_pat(which,mode) local auto_pat = params:get("random_patterning_"..which) if auto_pat ~= 1 then params:set("pattern_"..which.."_quantization", 2) + local vals_to_dur = {4,8,16,32,64,math.random(4,32)} + local note_val = params:get("rand_pattern_"..which.."_note_length") + pattern.rec_clock_time = vals_to_dur[note_val] end if pattern.playmode == 3 or pattern.playmode == 4 then --clock.sync(1/4) @@ -312,7 +323,9 @@ function random_grid_pat(which,mode) pattern.playmode = 2 -- /new stuff! end - local count = auto_pat == 1 and math.random(2,24) or 16 + local potential_total = pattern.rec_clock_time*4 + -- local count = auto_pat == 1 and math.random(2,24) or 16 + local count = auto_pat == 1 and (pattern.rec_clock_time * 4) or 16 if pattern.count > 0 or pattern.rec == 1 then pattern:rec_stop() stop_pattern(pattern) @@ -364,14 +377,14 @@ function random_grid_pat(which,mode) end constructed.action = "pads" constructed.i = which + local tempo = clock.get_beat_sec() local divisors = { 4,2,1,0.5,0.25,math.pow(2,math.random(-2,2)) } local note_length = (tempo / divisors[params:get("rand_pattern_"..which.."_note_length")]) pattern.time[i] = note_length - --new stuff! pattern.time_beats[i] = pattern.time[i] / tempo pattern:calculate_quantum(i) - --/new stuff! + end pattern.count = count pattern.start_point = 1 @@ -471,60 +484,32 @@ function snap_to_bars_midi(bank,bar_count) end end -function save_external_timing(bank,slot) - - local dirname = _path.data.."cheat_codes2/external-timing/" - if os.rename(dirname, dirname) == nil then - os.execute("mkdir " .. dirname) - end - - local file = io.open(_path.data .. "cheat_codes2/external-timing/pattern"..selected_coll.."_"..slot.."_external-timing.data", "w+") - io.output(file) - io.write("external clock timing for stored pad pattern: collection "..selected_coll.." + slot "..slot.."\n") - local total_entry_count = 0 - local number_of_events = #quantized_grid_pat[bank].event - for i = 1,number_of_events do - total_entry_count = total_entry_count + #quantized_grid_pat[bank].event[i] - end - io.write(total_entry_count.."\n") - io.write(number_of_events.."\n") - for i = 1,number_of_events do - io.write("event: "..i.."\n") - io.write("total entries: "..#quantized_grid_pat[bank].event[i].."\n") - for j = 1,#quantized_grid_pat[bank].event[i] do - io.write(quantized_grid_pat[bank].event[i][j].."\n") - end - end - io.close(file) - print("saved external timing for pattern "..bank.." to slot "..slot) -end - -function load_external_timing(bank,slot) - local file = io.open(_path.data .. "cheat_codes2/external-timing/pattern"..selected_coll.."_"..slot.."_external-timing.data", "r") - if file then - io.input(file) - if io.read() == "external clock timing for stored pad pattern: collection "..selected_coll.." + slot "..slot then - quantized_grid_pat[bank].event = {} - local total_entry_count = tonumber(io.read()) - local number_of_events = tonumber(io.read()) - for i = 1,number_of_events do - local event_id = tonumber(string.match(io.read(), '%d+')) - local entry_count = tonumber(string.match(io.read(), '%d+')) - quantized_grid_pat[bank].event[i] = {} - for j = 1,entry_count do - quantized_grid_pat[bank].event[i][j] = io.read() - end - end - end - print("unpacking old quantized table") - unpack_quantized_table(bank) - io.close(file) - else - print("creating external timing file...") - midi_clock_linearize(bank) - save_external_timing(bank,slot) - end -end +-- function load_external_timing(bank,slot) +-- local file = io.open(_path.data .. "cheat_codes2/external-timing/pattern"..selected_coll.."_"..slot.."_external-timing.data", "r") +-- if file then +-- io.input(file) +-- if io.read() == "external clock timing for stored pad pattern: collection "..selected_coll.." + slot "..slot then +-- quantized_grid_pat[bank].event = {} +-- local total_entry_count = tonumber(io.read()) +-- local number_of_events = tonumber(io.read()) +-- for i = 1,number_of_events do +-- local event_id = tonumber(string.match(io.read(), '%d+')) +-- local entry_count = tonumber(string.match(io.read(), '%d+')) +-- quantized_grid_pat[bank].event[i] = {} +-- for j = 1,entry_count do +-- quantized_grid_pat[bank].event[i][j] = io.read() +-- end +-- end +-- end +-- print("unpacking old quantized table") +-- unpack_quantized_table(bank) +-- io.close(file) +-- else +-- print("creating external timing file...") +-- midi_clock_linearize(bank) +-- save_external_timing(bank,slot) +-- end +-- end function copy_entire_pattern(bank) original_pattern = {} @@ -699,16 +684,30 @@ function init() params:add_separator("cheat codes params") - params:add_group("collections",4) + params:add_group("collections",8) - params:add_number("collection", "collection", 1,100,1) - params:add{type = "trigger", id = "load", name = "load", action = loadstate} + -- params:add_number("collection", "collection", 1,100,1) + -- params:add{type = "trigger", id = "load", name = "load", action = loadstate} + -- params:add_option("collect_live","collect Live buffers?",{"no","yes"}) + -- params:add{type = "trigger", id = "save", name = "save", action = function() + -- collection_save_clock = clock.run(save_screen) + -- _norns.key(1,1) + -- _norns.key(1,0) + -- end} + params:add_separator("prefs") params:add_option("collect_live","collect Live buffers?",{"no","yes"}) - params:add{type = "trigger", id = "save", name = "save", action = function() - collection_save_clock = clock.run(save_screen) - _norns.key(1,1) - _norns.key(1,0) - end} + params:add_separator("save/load") + params:add_trigger("save", "save new collection") + params:set_action("save", function(x) + textentry.enter(pre_save) + end) + params:add_trigger("load", "load collection") + params:set_action("load", function(x) fileselect.enter(_path.data.."cheat_codes2/names/", named_loadstate) end) + params:add_separator("danger zone!") + params:add_trigger("overwrite_coll", "overwrite collection") + params:set_action("overwrite_coll", function(x) fileselect.enter(_path.data.."cheat_codes2/names/", named_overwrite) end) + params:add_trigger("delete_coll", "delete collection") + params:set_action("delete_coll", function(x) fileselect.enter(_path.data.."cheat_codes2/names/", named_delete) end) menu = 1 @@ -1258,6 +1257,23 @@ end --- +function sync_clock_to_loop(source) + -- if delay[source].mode == "free" and delay[source].free_end_point-delay[source].start_point > 0.1 then + local duration = source.end_point-source.start_point + local quarter = duration/4 + local derived_bpm = 60/quarter + while derived_bpm < 70 do + derived_bpm = derived_bpm * 2 + if derived_bpm > 160 then break end + end + while derived_bpm > 160 do + derived_bpm = derived_bpm/2 + if derived_bpm <= 70 then break end + end + params:set("clock_tempo",util.round(derived_bpm,0.01)) + -- end +end + function midi_pattern_watch(target,note) if note ~= "pause" then midi_p[target] = {} @@ -2172,14 +2188,20 @@ function cheat(b,i) if pad.enveloped then if pad.envelope_mode == 1 then env_counter[b].butt = pad.level - softcut.level_slew_time(b+1,0.01) + env_counter[b].l_del_butt = pad.left_delay_level + env_counter[b].r_del_butt = pad.right_delay_level + softcut.level_slew_time(b+1,0.05) softcut.level(b+1,pad.level*bank[b].global_level) + softcut.level_cut_cut(b+1,5,(pad.level*bank[b].global_level)*bank[i][bank[i].id].left_delay_level) + softcut.level_cut_cut(i+1,6,(pad.level*bank[b].global_level)*bank[i][bank[i].id].right_delay_level) elseif pad.envelope_mode == 2 or pad.envelope_mode == 3 then - softcut.level_slew_time(b+1,0.1) + softcut.level_slew_time(b+1,0) softcut.level(b+1,0*bank[b].global_level) softcut.level_cut_cut(b+1,5,0) softcut.level_cut_cut(b+1,6,0) env_counter[b].butt = 0 + env_counter[b].l_del_butt = 0 + env_counter[b].r_del_butt = 0 end env_counter[b].time = (pad.envelope_time/(pad.level/0.05)) env_counter[b]:start() @@ -2207,6 +2229,7 @@ function cheat(b,i) if pad.end_point == 9 or pad.end_point == 17 or pad.end_point == 25 then pad.end_point = pad.end_point-0.01 end + softcut.fade_time(b+1,0.01) softcut.loop_start(b+1,pad.start_point) softcut.loop_end(b+1,pad.end_point) softcut.buffer(b+1,pad.mode) @@ -2220,7 +2243,6 @@ function cheat(b,i) else softcut.loop(b+1,1) end - softcut.fade_time(b+1,0.01) if pad.rate > 0 then softcut.position(b+1,pad.start_point+0.05) elseif pad.rate < 0 then @@ -2278,7 +2300,7 @@ function cheat(b,i) end function envelope(i) - softcut.level_slew_time(i+1,0.1) + -- softcut.level_slew_time(i+1,0.1) if bank[i][bank[i].id].envelope_mode == 1 then falling_envelope(i) elseif bank[i][bank[i].id].envelope_mode == 2 then @@ -2299,18 +2321,36 @@ function falling_envelope(i) else env_counter[i].butt = 0 end - -- print(env_counter[i].butt) if env_counter[i].butt > 0 then + softcut.level_slew_time(i+1,0.05) softcut.level(i+1,env_counter[i].butt*bank[i].global_level) - softcut.level_cut_cut(i+1,5,env_counter[i].butt*(bank[i][bank[i].id].left_delay_level*bank[i].global_level)) - softcut.level_cut_cut(i+1,6,env_counter[i].butt*(bank[i][bank[i].id].right_delay_level*bank[i].global_level)) + -- softcut.level_cut_cut(i+1,5,(env_counter[i].butt*bank[i].global_level)*bank[i][bank[i].id].left_delay_level) + -- softcut.level_cut_cut(i+1,6,(env_counter[i].butt*bank[i].global_level)*bank[i][bank[i].id].right_delay_level) + if delay[1].send_mute then + if bank[i][bank[i].id].left_delay_level == 0 then + softcut.level_cut_cut(i+1,5,(env_counter[i].butt*bank[i].global_level)*1) + else + softcut.level_cut_cut(i+1,5,(env_counter[i].butt*bank[i].global_level)*0) + end + else + softcut.level_cut_cut(i+1,5,(env_counter[i].butt*bank[i].global_level)*bank[i][bank[i].id].left_delay_level) + end + if delay[2].send_mute then + if bank[i][bank[i].id].right_delay_level == 0 then + softcut.level_cut_cut(i+1,6,(env_counter[i].butt*bank[i].global_level)*1) + else + softcut.level_cut_cut(i+1,6,(env_counter[i].butt*bank[i].global_level)*0) + end + else + softcut.level_cut_cut(i+1,6,(env_counter[i].butt*bank[i].global_level)*bank[i][bank[i].id].right_delay_level) + end else env_counter[i]:stop() + softcut.level_slew_time(i+1,1.0) softcut.level(i+1,0*bank[i].global_level) env_counter[i].butt = bank[i][bank[i].id].level softcut.level_cut_cut(i+1,5,0) softcut.level_cut_cut(i+1,6,0) - softcut.level_slew_time(i+1,1.0) if bank[i][bank[i].id].envelope_mode == 3 then env_counter[i].stage = nil env_counter[i].butt = 0 @@ -2323,13 +2363,31 @@ end function rising_envelope(i) env_counter[i].butt = env_counter[i].butt + 0.05 - -- print(env_counter[i].butt, env_counter[i].time) if env_counter[i].butt < bank[i][bank[i].id].level then + softcut.level_slew_time(i+1,0.1) softcut.level(i+1,env_counter[i].butt*bank[i].global_level) - softcut.level_cut_cut(i+1,5,env_counter[i].butt*(bank[i][bank[i].id].left_delay_level*bank[i].global_level)) - softcut.level_cut_cut(i+1,6,env_counter[i].butt*(bank[i][bank[i].id].right_delay_level*bank[i].global_level)) + -- softcut.level_cut_cut(i+1,5,env_counter[i].butt*(bank[i][bank[i].id].left_delay_level*bank[i].global_level)) + -- softcut.level_cut_cut(i+1,6,env_counter[i].butt*(bank[i][bank[i].id].right_delay_level*bank[i].global_level)) + if delay[1].send_mute then + if bank[i][bank[i].id].left_delay_level == 0 then + softcut.level_cut_cut(i+1,5,(env_counter[i].butt*bank[i].global_level)*1) + else + softcut.level_cut_cut(i+1,5,(env_counter[i].butt*bank[i].global_level)*0) + end + else + softcut.level_cut_cut(i+1,5,(env_counter[i].butt*bank[i].global_level)*bank[i][bank[i].id].left_delay_level) + end + if delay[2].send_mute then + if bank[i][bank[i].id].right_delay_level == 0 then + softcut.level_cut_cut(i+1,6,(env_counter[i].butt*bank[i].global_level)*1) + else + softcut.level_cut_cut(i+1,6,(env_counter[i].butt*bank[i].global_level)*0) + end + else + softcut.level_cut_cut(i+1,6,(env_counter[i].butt*bank[i].global_level)*bank[i][bank[i].id].right_delay_level) + end else - -- print("stopping") + print("stopping") env_counter[i]:stop() softcut.level(i+1,bank[i][bank[i].id].level*bank[i].global_level) env_counter[i].butt = 0 @@ -2346,7 +2404,8 @@ function rising_envelope(i) softcut.level_slew_time(i+1,1.0) if bank[i][bank[i].id].envelope_mode == 3 then env_counter[i].stage = "falling" - env_counter[i].butt = bank[i][bank[i].id].level*bank[i].global_level + softcut.level_slew_time(i+1,0.05) + env_counter[i].butt = bank[i][bank[i].id].level env_counter[i].time = (bank[i][bank[i].id].envelope_time/(bank[i][bank[i].id].level/0.05)) env_counter[i]:start() end @@ -2542,18 +2601,18 @@ function save_sample(i) softcut.buffer_write_mono(_path.dust.."/audio/cc2_saved_samples/"..name,1+(8*save_pos),8,1) end -function collect_samples(i) -- this works!!! +function collect_samples(i,collection) -- this works!!! local dirname = _path.dust.."audio/cc2_live-audio/" if os.rename(dirname, dirname) == nil then os.execute("mkdir " .. dirname) end - local dirname = _path.dust.."audio/cc2_live-audio/"..params:get("collection").."/" + local dirname = _path.dust.."audio/cc2_live-audio/"..collection.."/" if os.rename(dirname, dirname) == nil then os.execute("mkdir " .. dirname) end - local name = "cc2_"..params:get("collection").."-"..i..".wav" + local name = "cc2_"..collection.."-"..i..".wav" local save_pos = i - 1 - softcut.buffer_write_mono(_path.dust.."audio/cc2_live-audio/"..params:get("collection").."/"..name,1+(8*save_pos),8,1) + softcut.buffer_write_mono(_path.dust.."audio/cc2_live-audio/"..collection.."/"..name,1+(8*save_pos),8,1) end function reload_collected_samples(file,sample) @@ -2584,7 +2643,7 @@ function key(n,z) end elseif menu == 2 then if not key1_hold then - page.loops_view[page.loops_sel] = (page.loops_view[page.loops_sel] % 3) + 1 + page.loops_view[page.loops_sel] = (page.loops_view[page.loops_sel] % (page.loops_sel ~= 4 and 3 or 2)) + 1 else if page.loops_sel < 4 then local id = page.loops_sel @@ -2672,11 +2731,7 @@ function key(n,z) elseif page.time_page_sel[time_nav] == 5 then if not key1_hold then if g.device ~= nil then - if grid_pat[id].playmode == 3 or grid_pat[id].playmode == 4 then - clock.run(random_grid_pat, id, 3) - else - random_grid_pat(id,3) - end + random_grid_pat(id,3) else random_midi_pat(id) end @@ -2819,7 +2874,7 @@ function key(n,z) end elseif menu == 2 then if key1_hold then - -- + sync_clock_to_loop(bank[page.loops_sel][bank[page.loops_sel].id]) else menu = 1 end @@ -3731,9 +3786,9 @@ arc_redraw = function() if arc_param[i] == 5 then local level_to_led; if not key1_hold and not bank[i].alt_lock and grid.alt == 0 then - level_to_led = bank[i][bank[i].id].level - else level_to_led = bank[i].global_level + else + level_to_led = bank[i][bank[i].id].level end for j = 1,17 do a:led(i,(math.floor(util.linlin(0,2,5,70,(level_to_led)-(1/8*j))))+16,15) @@ -3805,6 +3860,126 @@ function persistent_state_restore() end end +function named_overwrite(path) + if path ~= 'cancel' then + local file = io.open(path, "r") + if file then + io.input(file) + local collection = io.read() + io.close(file) + pre_save(collection) + end + end +end + +function named_delete(path) + if path ~= 'cancel' then + local file = io.open(path, "r") + if file then + io.input(file) + os.remove(path) + io.close(file) + end + end +end + +function pre_save(text) + if text then + collection_save_clock = clock.run(save_screen,text) + _norns.key(1,1) + _norns.key(1,0) + else + print("nothing saved") + end +end + +function named_savestate(text) + + local collection = text + local dirname = _path.data.."cheat_codes2/" + -- local collection = tonumber(string.format("%.0f",params:get("collection"))) + if os.rename(dirname, dirname) == nil then + os.execute("mkdir " .. dirname) + end + + local dirname = _path.data.."cheat_codes2/names/" + if os.rename(dirname, dirname) == nil then + os.execute("mkdir " .. dirname) + end + local name_file = io.open(_path.data .. "cheat_codes2/names/"..collection..".cc2", "w+") + io.output(name_file) + io.write(collection) + io.close(name_file) + + local dirname = _path.data.."cheat_codes2/collection-"..collection.."/" + if os.rename(dirname, dirname) == nil then + os.execute("mkdir " .. dirname) + end + + local dirnames = {"banks/","params/","arc-rec/","patterns/","step-seq/","arps/","euclid/","rnd/","delays/","rec/","misc/"} + for i = 1,#dirnames do + local directory = _path.data.."cheat_codes2/collection-"..collection.."/"..dirnames[i] + if os.rename(directory, directory) == nil then + os.execute("mkdir " .. directory) + end + end + + for i = 1,3 do + tab.save(bank[i],_path.data .. "cheat_codes2/collection-"..collection.."/banks/"..i..".data") + tab.save(step_seq[i],_path.data .. "cheat_codes2/collection-"..collection.."/step-seq/"..i..".data") + tab.save(arp[i],_path.data .. "cheat_codes2/collection-"..collection.."/arps/"..i..".data") + tab.save(rytm.track[i],_path.data .. "cheat_codes2/collection-"..collection.."/euclid/euclid"..i..".data") + tab.save(rnd[i],_path.data .. "cheat_codes2/collection-"..collection.."/rnd/"..i..".data") + if params:get("collect_live") == 2 then + collect_samples(i,collection) + end + end + + for i = 1,2 do + tab.save(delay[i],_path.data .. "cheat_codes2/collection-"..collection.."/delays/delay"..(i == 1 and "L" or "R")..".data") + end + + params:write(_path.data.."cheat_codes2/collection-"..collection.."/params/all.pset") + tab.save(rec,_path.data .. "cheat_codes2/collection-"..collection.."/rec/rec.data") + + -- GRID pattern save + if selected_coll ~= collection then + meta_copy_coll(selected_coll,collection) + end + meta_shadow(collection) + + selected_coll = collection + --/ GRID pattern save + + -- MIDI pattern save + for i = 1,3 do + save_midi_pattern(i) + end + --/ MIDI pattern save + + -- ARC rec save + local arc_rec_dirty = {false,false,false} + for i = 1,3 do + for j = 1,4 do + if arc_pat[i][j].count > 0 then + arc_rec_dirty[i] = true + end + end + if arc_rec_dirty[i] then + save_arc_pattern(i) + else + local file = io.open(_path.data .. "cheat_codes2/collection-"..selected_coll.."/arc-rec/encoder-"..i..".data", "r") + if file then + io.input(file) + os.remove(_path.data .. "cheat_codes2/collection-"..selected_coll.."/arc-rec/encoder-"..i..".data") + io.close(file) + end + end + end + --/ ARC rec save + +end + function savestate() local dirname = _path.data.."cheat_codes2/" @@ -3818,7 +3993,7 @@ function savestate() os.execute("mkdir " .. dirname) end - local dirnames = {"banks/","params/","arc-rec/","patterns/","step-seq/","arps/","euclid/","rnd/","delays/","rec/"} + local dirnames = {"banks/","params/","arc-rec/","patterns/","step-seq/","arps/","euclid/","rnd/","delays/","rec/","misc/"} for i = 1,#dirnames do local directory = _path.data.."cheat_codes2/collection-"..collection.."/"..dirnames[i] if os.rename(directory, directory) == nil then @@ -3881,6 +4056,91 @@ function savestate() end +function named_loadstate(path) + + print("loading...") + print(path) + local file = io.open(path, "r") + if file then + io.input(file) + local collection = io.read() + io.close(file) + selected_coll = collection + collection_loaded = true + _norns.key(1,1) + _norns.key(1,0) + clock.run(load_screen) + redraw() + params:read(_path.data.."cheat_codes2/collection-"..collection.."/params/all.pset") + if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/rec/rec.data") ~= nil then + rec = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/rec/rec.data") + end + -- params:bang() + for i = 1,3 do + if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/banks/"..i..".data") ~= nil then + bank[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/banks/"..i..".data") + end + if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/step-seq/"..i..".data") ~= nil then + step_seq[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/step-seq/"..i..".data") + end + if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/arps/"..i..".data") ~= nil then + arp[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/arps/"..i..".data") + end + if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/rnd/"..i..".data") ~= nil then + rnd[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/rnd/"..i..".data") + for j = 1,#rnd[i] do + rnd[i][j].clock = nil + if rnd[i][j].playing then + rnd[i][j].clock = clock.run(rnd.advance, i, j) + end + end + end + + if params:get("collect_live") == 2 then + reload_collected_samples(_path.dust.."audio/cc2_live-audio/"..collection.."/".."cc2_"..collection.."-"..i..".wav",i) + end + + if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/euclid/euclid"..i..".data") ~= nil then + rytm.track[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/euclid/euclid"..i..".data") + end + rytm.reset_pattern() + end + + for i = 1,2 do + if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/delays/delay"..(i == 1 and "L" or "R")..".data") ~= nil then + delay[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/delays/delay"..(i == 1 and "L" or "R")..".data") + end + end + + -- GRID pattern restore + if selected_coll ~= collection then + meta_shadow(selected_coll) + elseif selected_coll == collection then + cleanup() + end + one_point_two() + -- / GRID pattern restore + + for i = 1,3 do + load_arc_pattern(i) + end + + for i = 1,3 do + local dirname = _path.data .. "cheat_codes2/collection-"..selected_coll.."/patterns/midi"..i..".data" + if os.rename(dirname, dirname) ~= nil then + load_midi_pattern(i) + end + end + else + _norns.key(1,1) + _norns.key(1,0) + collection_loaded = false + clock.run(load_fail_screen) + end + + grid_dirty = true + +end function loadstate() @@ -3955,7 +4215,10 @@ function loadstate() end end else + _norns.key(1,1) + _norns.key(1,0) collection_loaded = false + clock.run(load_fail_screen) end grid_dirty = true @@ -4889,14 +5152,20 @@ function load_pattern(slot,destination) io.close(file) if not ignore_external_timing then - load_external_timing(destination,slot) + print("see load_external_timing") + -- load_external_timing(destination,slot) end else - print("nofile") + print("no grid patterns to load!") end end function cleanup() + + for i = 1,3 do + env_counter[i]:stop() + end + clear_zero() for i = 1,3 do for j = 1,8 do @@ -4928,6 +5197,7 @@ function cleanup() end end clear_empty_shadows(selected_coll) + end -- arc pattern stuff! @@ -5005,7 +5275,7 @@ function load_arc_pattern(which) io.close(file) grid_dirty = true else - print("nofile") + print("no arc patterns to load") end end @@ -5055,6 +5325,6 @@ function load_midi_pattern(which) end io.close(file) else - print("nofile") + print("no midi patterns to load") end end \ No newline at end of file diff --git a/lib/arc_actions.lua b/lib/arc_actions.lua index 22e0042..15d1d13 100755 --- a/lib/arc_actions.lua +++ b/lib/arc_actions.lua @@ -18,16 +18,20 @@ function aa.init(n,d) local p_action = aa.actions[arc_param[n]][1] local sc_action = aa.actions[arc_param[n]][2] if not this_bank.alt_lock and grid.alt == 0 then - if arc_param[n] ~= 4 then + -- if arc_param[n] ~= 4 then + -- if arc_param[n] < 4 then + if arc_param[n] ~= 4 and arc_param[n] ~= 5 then p_action(this_pad,d) else - aa.map(p_action, this_bank, d/1000, n) + aa.map(p_action, this_bank, arc_param[n] == 4 and d/1000 or d, n) end elseif this_bank.alt_lock or grid.alt == 1 then - if arc_param[n] ~= 4 then + -- if arc_param[n] ~= 4 then + -- if arc_param[n] < 4 then + if arc_param[n] ~= 4 and arc_param[n] ~= 5 then aa.map(p_action,this_bank,d) else - p_action(this_pad,d/1000, n) + p_action(this_pad, arc_param[n] == 4 and d/1000 or d, n) end end if this_bank.focus_hold == false or this_bank.focus_pad == this_bank.id then @@ -163,11 +167,11 @@ end function aa.change_level(target, delta) if not bank[target.bank_id].alt_lock and grid.alt == 0 then - target.level = util.clamp(target.level + delta/1000,0,2) - else if target.pad_id == 1 then bank[target.bank_id].global_level = util.clamp(bank[target.bank_id].global_level + delta/1000,0,2) end + else + target.level = util.clamp(target.level + delta/1000,0,2) end end diff --git a/lib/delay.lua b/lib/delay.lua index 346b03f..f139f92 100755 --- a/lib/delay.lua +++ b/lib/delay.lua @@ -167,15 +167,24 @@ function delays.quick_action(target,param) softcut.pre_level(target+4,params:get(target == 1 and "delay L: feedback" or "delay R: feedback")/100) end elseif param == "send mute" then + -- softcut.level_slew_time(target+4,0.25) + local pad = bank[delay_grid.bank][bank[delay_grid.bank].id] delay[target].send_mute = not delay[target].send_mute if delay[target].send_mute then - if (target == 1 and bank[delay_grid.bank][bank[delay_grid.bank].id].left_delay_level or bank[delay_grid.bank][bank[delay_grid.bank].id].right_delay_level) == 0 then - softcut.level_cut_cut(delay_grid.bank+1,target+4,1) + if (target == 1 and pad.left_delay_level or pad.right_delay_level) == 0 then + if pad.enveloped then + else + softcut.level_cut_cut(delay_grid.bank+1,target+4,1) + end else - softcut.level_cut_cut(delay_grid.bank+1,target+4,0) + if not pad.enveloped then + softcut.level_cut_cut(delay_grid.bank+1,target+4,0) + end end else - softcut.level_cut_cut(delay_grid.bank+1,target+4,target == 1 and bank[delay_grid.bank][bank[delay_grid.bank].id].left_delay_level or bank[delay_grid.bank][bank[delay_grid.bank].id].right_delay_level) + if not pad.eveloped then + softcut.level_cut_cut(delay_grid.bank+1,target+4,target == 1 and bank[delay_grid.bank][bank[delay_grid.bank].id].left_delay_level or bank[delay_grid.bank][bank[delay_grid.bank].id].right_delay_level) + end end elseif param == "clear" then softcut.level(target+4,0) @@ -271,7 +280,7 @@ function delays.sync_clock_to_length(source) derived_bpm = derived_bpm/2 if derived_bpm <= 70 then break end end - params:set("bpm",derived_bpm) + params:set("clock_tempo",derived_bpm) end end diff --git a/lib/grid_actions.lua b/lib/grid_actions.lua index 28e57b9..6bb7f2d 100755 --- a/lib/grid_actions.lua +++ b/lib/grid_actions.lua @@ -533,11 +533,7 @@ function grid_actions.init(x,y,z) end elseif bank[i].alt_lock or grid.alt == 1 then if y == 2 then - if grid_pat[math.ceil(x/4)].playmode == 3 or grid_pat[math.ceil(x/4)].playmode == 4 then - clock.run(random_grid_pat, math.ceil(x/4), 3) - else - random_grid_pat(math.ceil(x/4),3) - end + random_grid_pat(math.ceil(x/4),3) end if y == 3 then page.arp_page_sel = i diff --git a/lib/main_menu.lua b/lib/main_menu.lua index 563b378..3a17f47 100755 --- a/lib/main_menu.lua +++ b/lib/main_menu.lua @@ -45,12 +45,40 @@ function main_menu.init() screen.move(0,10) screen.level(3) screen.text("loops") - local bank_rate = {} - for i = 1,3 do - bank_rate[i] = string.format("%.4g",bank[i][bank[i].id].rate) - end + + -- local bank_rate = {} + -- for i = 1,3 do + -- bank_rate[i] = string.format("%.4g",bank[i][bank[i].id].rate) + -- end + -- screen.move(120,10) + -- screen.text_right(bank_rate[1].."x | "..bank_rate[2].."x | "..bank_rate[3].."x") + screen.move(120,10) - screen.text_right(bank_rate[1].."x | "..bank_rate[2].."x | "..bank_rate[3].."x") + if page.loops_sel ~= 4 then + local pad = bank[page.loops_sel][bank[page.loops_sel].id] + local s_p = pad.mode == 1 and live[pad.clip].min or clip[pad.clip].min + local e_p = pad.mode == 1 and live[pad.clip].max or clip[pad.clip].max + local dur = e_p-s_p + + -- if pad.mode == 1 then + -- --slice within bounds + -- dur = rec.end_point-rec.start_point + -- s_p = (rec.start_point+((duration/16) * (pad.pad_id-1)))+((pad.clip-1)*8) + -- e_p = (rec.start_point+((duration/16) * (pad.pad_id)))+((pad.clip-1)*8) + -- else + -- duration = pad.mode == 1 and 8 or clip[pad.clip].sample_length + -- pad.start_point = ((duration/16)*(pad.pad_id-1)) + clip[pad.clip].min + -- pad.end_point = pad.start_point + (duration/16) + -- print(duration, pad.start_point, pad.end_point) + -- end + + local off = pad.mode == 1 and (((pad.clip-1)*8)+1) or clip[pad.clip].min + local display_end = pad.mode == 1 and (pad.end_point == 8.99 and 9 or pad.end_point) or pad.end_point + screen.text_right("s: "..string.format("%.4g",(pad.start_point)-off).."s | e: "..string.format("%.4g",(display_end)-off).."s") + else + local off = ((rec.clip-1)*8)+1 + screen.text_right("s: "..string.format("%.4g",rec.start_point-off).."s | e: "..string.format("%.4g",rec.end_point-off).."s") + end for i = 1,3 do local which_pad = nil @@ -259,7 +287,7 @@ function main_menu.init() else screen.text(envelope_to_screen_options[i]..""..focused_pad) end - screen.move(105,34+((i)*10)) + screen.move(103,34+((i)*10)) if bank[i][focused_pad].enveloped then screen.text(string.format("%.2g", bank[i][focused_pad].envelope_time).."s") else @@ -882,29 +910,36 @@ function main_menu.init() screen.move(62,15) screen.font_size(10) if collection_loaded then - screen.text_center("loading collection "..selected_coll) - screen.font_size(40) - screen.move(62,50) + screen.text_center("loading collection") + screen.font_size(30) + screen.move(62,43) + screen.text_center(selected_coll) + screen.font_size(15) + screen.move(62,60) screen.text_center(dots) screen.font_size(8) - else - screen.move(62,40) - screen.font_size(20) - screen.text_center("no data!") - screen.font_size(8) end + elseif menu == "load fail screen" then + screen.level(15) + screen.move(62,30) + screen.font_size(20) + screen.text_center("no data!") + screen.move(62,60) + screen.font_size(15) + screen.text_center("try another...") + screen.font_size(8) elseif menu == "save screen" then screen.level(15) screen.move(62,15) screen.font_size(10) - screen.text_center("saving collection "..tonumber(string.format("%.0f",params:get("collection")))) + screen.text_center("saving collection") screen.font_size(40) screen.move(62,50) screen.text_center(dots) - screen.move(10,64) + screen.move(62,64) screen.font_size(10) if dots ~= "saved!" then - screen.text("K2 or K3 to cancel") + screen.text_center("K2 or K3 to cancel") end screen.font_size(8) elseif menu == "canceled screen" then @@ -925,7 +960,7 @@ function load_screen() clock.sleep(0.33) dots = "." clock.sleep(0.33) - dots = "ready!" + dots = "loaded!" clock.sleep(0.75) menu = 1 if not collection_loaded then @@ -934,7 +969,17 @@ function load_screen() end end -function save_screen() +function load_fail_screen() + menu = "load fail screen" + clock.sleep(1) + menu = 1 + if not collection_loaded then + _norns.key(1,1) + _norns.key(1,0) + end +end + +function save_screen(text) dots = "3" menu = "save screen" clock.sleep(0.75) @@ -944,7 +989,7 @@ function save_screen() clock.sleep(0.75) dots = "saved!" clock.sleep(0.33) - savestate() + named_savestate(text) menu = 1 end From 5062b8726c113ae3092da61bd5412b82eae5bb90 Mon Sep 17 00:00:00 2001 From: dndrks Date: Mon, 31 Aug 2020 12:02:33 -0500 Subject: [PATCH 8/9] much fixed FIXED: - arc + norns encoders were not tuned correctly for variable-sized clips - zlichmo gestures weren't tuned correctly for variable-sized clips - arc + norns encoders respond to alt.locks - arc + norns encoders respect envelopes - delays respect envelopes - delay wobble is now "fifth up" at all rates - arc loop points (win/start/end) have an awareness of force and perform more severe jumps - triangle envelope can be restarted if killed before release finishes --- cheat_codes.lua | 35 +++++++++++++------ lib/arc_actions.lua | 77 +++++++++++++++++++++-------------------- lib/delay.lua | 27 +++++++++------ lib/encoder_actions.lua | 31 +++++++++++++---- lib/main_menu.lua | 6 ++-- lib/zilchmos.lua | 17 +++++++++ 6 files changed, 124 insertions(+), 69 deletions(-) diff --git a/cheat_codes.lua b/cheat_codes.lua index 011f055..330fbab 100755 --- a/cheat_codes.lua +++ b/cheat_codes.lua @@ -684,7 +684,7 @@ function init() params:add_separator("cheat codes params") - params:add_group("collections",8) + params:add_group("collections",7) -- params:add_number("collection", "collection", 1,100,1) -- params:add{type = "trigger", id = "load", name = "load", action = loadstate} @@ -694,15 +694,14 @@ function init() -- _norns.key(1,1) -- _norns.key(1,0) -- end} - params:add_separator("prefs") + params:add_separator("load/save") + params:add_trigger("load", "load collection") + params:set_action("load", function(x) fileselect.enter(_path.data.."cheat_codes2/names/", named_loadstate) end) params:add_option("collect_live","collect Live buffers?",{"no","yes"}) - params:add_separator("save/load") params:add_trigger("save", "save new collection") params:set_action("save", function(x) textentry.enter(pre_save) end) - params:add_trigger("load", "load collection") - params:set_action("load", function(x) fileselect.enter(_path.data.."cheat_codes2/names/", named_loadstate) end) params:add_separator("danger zone!") params:add_trigger("overwrite_coll", "overwrite collection") params:set_action("overwrite_coll", function(x) fileselect.enter(_path.data.."cheat_codes2/names/", named_overwrite) end) @@ -2182,8 +2181,22 @@ function find_the_key(t,val) end function cheat(b,i) - env_counter[b]:stop() local pad = bank[b][i] + if env_counter[b].is_running then + -- if pad.enveloped then + -- if pad.envelope_mode == 2 or pad.envelope_mode == 3 then + -- print("should not clip") + -- softcut.level_slew_time(b+1,0.5) + -- softcut.level(b+1,0*bank[b].global_level) + -- softcut.level_cut_cut(b+1,5,0) + -- softcut.level_cut_cut(b+1,6,0) + -- env_counter[b].butt = 0 + -- env_counter[b].l_del_butt = 0 + -- env_counter[b].r_del_butt = 0 + -- end + -- end + env_counter[b]:stop() + end softcut.rate_slew_time(b+1,pad.rate_slew) if pad.enveloped then if pad.envelope_mode == 1 then @@ -2192,16 +2205,17 @@ function cheat(b,i) env_counter[b].r_del_butt = pad.right_delay_level softcut.level_slew_time(b+1,0.05) softcut.level(b+1,pad.level*bank[b].global_level) - softcut.level_cut_cut(b+1,5,(pad.level*bank[b].global_level)*bank[i][bank[i].id].left_delay_level) - softcut.level_cut_cut(i+1,6,(pad.level*bank[b].global_level)*bank[i][bank[i].id].right_delay_level) + softcut.level_cut_cut(b+1,5,(pad.level*bank[b].global_level)*pad.left_delay_level) + softcut.level_cut_cut(i+1,6,(pad.level*bank[b].global_level)*pad.right_delay_level) elseif pad.envelope_mode == 2 or pad.envelope_mode == 3 then - softcut.level_slew_time(b+1,0) + softcut.level_slew_time(b+1,0.01) softcut.level(b+1,0*bank[b].global_level) softcut.level_cut_cut(b+1,5,0) softcut.level_cut_cut(b+1,6,0) env_counter[b].butt = 0 env_counter[b].l_del_butt = 0 env_counter[b].r_del_butt = 0 + if pad.envelope_mode == 3 then env_counter[b].stage = "rising" end end env_counter[b].time = (pad.envelope_time/(pad.level/0.05)) env_counter[b]:start() @@ -2387,7 +2401,6 @@ function rising_envelope(i) softcut.level_cut_cut(i+1,6,(env_counter[i].butt*bank[i].global_level)*bank[i][bank[i].id].right_delay_level) end else - print("stopping") env_counter[i]:stop() softcut.level(i+1,bank[i][bank[i].id].level*bank[i].global_level) env_counter[i].butt = 0 @@ -3785,7 +3798,7 @@ arc_redraw = function() end if arc_param[i] == 5 then local level_to_led; - if not key1_hold and not bank[i].alt_lock and grid.alt == 0 then + if key1_hold or bank[i].alt_lock or grid.alt == 1 then level_to_led = bank[i].global_level else level_to_led = bank[i][bank[i].id].level diff --git a/lib/arc_actions.lua b/lib/arc_actions.lua index 15d1d13..fbd4035 100755 --- a/lib/arc_actions.lua +++ b/lib/arc_actions.lua @@ -18,17 +18,13 @@ function aa.init(n,d) local p_action = aa.actions[arc_param[n]][1] local sc_action = aa.actions[arc_param[n]][2] if not this_bank.alt_lock and grid.alt == 0 then - -- if arc_param[n] ~= 4 then - -- if arc_param[n] < 4 then - if arc_param[n] ~= 4 and arc_param[n] ~= 5 then + if arc_param[n] ~= 4 then p_action(this_pad,d) else aa.map(p_action, this_bank, arc_param[n] == 4 and d/1000 or d, n) end elseif this_bank.alt_lock or grid.alt == 1 then - -- if arc_param[n] ~= 4 then - -- if arc_param[n] < 4 then - if arc_param[n] ~= 4 and arc_param[n] ~= 5 then + if arc_param[n] ~= 4 then aa.map(p_action,this_bank,d) else p_action(this_pad, arc_param[n] == 4 and d/1000 or d, n) @@ -41,9 +37,6 @@ function aa.init(n,d) aa.record(n) end else - -- local side = (arc.alt == nil or arc.alt == 0) and "L" or "R" - -- aa.delay_rate(d,side) - -- aa.record_delay(side) aa.change_param_focus(d) end redraw() @@ -96,52 +89,60 @@ function aa.change_param_focus(d) end end --- function aa.delay_rate(d,side) --- local chan = side == "L" and 1 or 2 --- delay[chan].arc_rate_tracker = util.clamp(delay[chan].arc_rate_tracker + d/10,1,13) --- delay[chan].arc_rate = math.floor(delay[chan].arc_rate_tracker) --- params:set("delay "..side..": rate",math.floor(delay[chan].arc_rate_tracker)) --- end - function aa.record(enc) aa.new_pattern_watch(enc) end --- function aa.record_delay(side) --- arc_p[side] = {} --- arc_p[side].i = side --- if grid.alt == 0 then --- arc_p[side].delay_focus = "L" --- arc_p[side].left_delay_value = params:get("delay L: rate") --- else --- arc_p[side].delay_focus = "R" --- arc_p[side].right_delay_value = params:get("delay R: rate") --- end --- end - function aa.move_window(target, delta) + local force = math.abs(delta) >= 5 and true or false local duration = target.mode == 1 and 8 or clip[target.clip].sample_length local current_difference = (target.end_point - target.start_point) + local s_p = target.mode == 1 and live[target.clip].min or clip[target.clip].min local current_clip = duration*(target.clip-1) - if target.start_point + current_difference <= (duration+1)+current_clip then - target.start_point = util.clamp(target.start_point + delta/300, 1+current_clip, (duration+1)+current_clip) + local reasonable_max = target.mode == 1 and 9 or clip[target.clip].max+1 + local adjusted_delta = force and (duration > 15 and (delta/25) or (delta/100)) or (delta/300) + if target.start_point + current_difference <= reasonable_max then + target.start_point = util.clamp(target.start_point + adjusted_delta, s_p, reasonable_max) target.end_point = target.start_point + current_difference else - target.end_point = ((duration+1)+current_clip) + target.end_point = reasonable_max + target.start_point = target.end_point - current_difference + end + if target.end_point > reasonable_max then + target.end_point = reasonable_max target.start_point = target.end_point - current_difference end + end function aa.move_start(target, delta) + + local force = math.abs(delta) >= 5 and true or false + local duration = target.mode == 1 and 8 or clip[target.clip].sample_length - local current_clip = duration*(target.clip-1) - target.start_point = util.clamp(target.start_point + delta/300, (1+current_clip), target.end_point-0.01) + local s_p = target.mode == 1 and live[target.clip].min or clip[target.clip].min + local adjusted_delta = force and (delta/100) or (delta/300) + if adjusted_delta >= 0 and target.start_point < (target.end_point - 0.05) then + target.start_point = util.clamp(target.start_point+adjusted_delta,s_p,s_p+duration) + elseif adjusted_delta < 0 then + target.start_point = util.clamp(target.start_point+adjusted_delta,s_p,s_p+duration) + end + end function aa.move_end(target, delta) + + local force = math.abs(delta) >= 5 and true or false + local duration = target.mode == 1 and 8 or clip[target.clip].sample_length - local current_clip = duration*(target.clip-1) - target.end_point = util.clamp(target.end_point + delta/300, target.start_point+0.01, ((duration+1)+current_clip)) + local s_p = target.mode == 1 and live[target.clip].min or clip[target.clip].min + local adjusted_delta = force and (delta/100) or (delta/300) + if adjusted_delta <= 0 and target.start_point < (target.end_point - 0.05) then + target.end_point = util.clamp(target.end_point+adjusted_delta,s_p,s_p+duration) + elseif adjusted_delta > 0 then + target.end_point = util.clamp(target.end_point+adjusted_delta,s_p,s_p+duration) + end + end function aa.change_tilt(target, delta, enc) @@ -166,7 +167,7 @@ function aa.change_pan(target, delta) end function aa.change_level(target, delta) - if not bank[target.bank_id].alt_lock and grid.alt == 0 then + if bank[target.bank_id].alt_lock or grid.alt == 1 then if target.pad_id == 1 then bank[target.bank_id].global_level = util.clamp(bank[target.bank_id].global_level + delta/1000,0,2) end @@ -197,7 +198,9 @@ function aa.sc.change_pan(enc, target) end function aa.sc.change_level(enc, target) - softcut.level(enc+1,target.level*bank[enc].global_level) + if bank[enc][bank[enc].id].envelope_mode == 2 or not bank[enc][bank[enc].id].enveloped then + softcut.level(enc+1,target.level*bank[enc].global_level) + end end aa.actions = diff --git a/lib/delay.lua b/lib/delay.lua index f139f92..b6e0ad2 100755 --- a/lib/delay.lua +++ b/lib/delay.lua @@ -172,8 +172,7 @@ function delays.quick_action(target,param) delay[target].send_mute = not delay[target].send_mute if delay[target].send_mute then if (target == 1 and pad.left_delay_level or pad.right_delay_level) == 0 then - if pad.enveloped then - else + if not pad.enveloped then softcut.level_cut_cut(delay_grid.bank+1,target+4,1) end else @@ -182,7 +181,9 @@ function delays.quick_action(target,param) end end else - if not pad.eveloped then + if not pad.enveloped then + print(pad.enveloped) + print("sending 185") softcut.level_cut_cut(delay_grid.bank+1,target+4,target == 1 and bank[delay_grid.bank][bank[delay_grid.bank].id].left_delay_level or bank[delay_grid.bank][bank[delay_grid.bank].id].right_delay_level) end end @@ -214,9 +215,11 @@ function delays.set_value(target,index,param) bank[delay_grid.bank][i].left_delay_level = send_levels[index] end end - softcut.level_slew_time(5,0.25) - -- softcut.level_cut_cut(delay_grid.bank+1,5,util.linlin(-1,1,0,1,b.pan)*(b.left_delay_level*b.level)) - softcut.level_cut_cut(delay_grid.bank+1,5,(b.left_delay_level*b.level)*bank[delay_grid.bank].global_level) + if not b.enveloped then + softcut.level_slew_time(5,0.25) + -- softcut.level_cut_cut(delay_grid.bank+1,5,util.linlin(-1,1,0,1,b.pan)*(b.left_delay_level*b.level)) + softcut.level_cut_cut(delay_grid.bank+1,5,(b.left_delay_level*b.level)*bank[delay_grid.bank].global_level) + end else if param == "send" then b.right_delay_level = send_levels[index] @@ -225,9 +228,11 @@ function delays.set_value(target,index,param) bank[delay_grid.bank][i].right_delay_level = send_levels[index] end end - softcut.level_slew_time(6,0.25) - -- softcut.level_cut_cut(delay_grid.bank+1,6,util.linlin(-1,1,1,0,b.pan)*(b.right_delay_level*b.level)) - softcut.level_cut_cut(delay_grid.bank+1,6,(b.right_delay_level*b.level)*bank[delay_grid.bank].global_level) + if not b.enveloped then + softcut.level_slew_time(6,0.25) + -- softcut.level_cut_cut(delay_grid.bank+1,6,util.linlin(-1,1,1,0,b.pan)*(b.right_delay_level*b.level)) + softcut.level_cut_cut(delay_grid.bank+1,6,(b.right_delay_level*b.level)*bank[delay_grid.bank].global_level) + end end end end @@ -295,8 +300,8 @@ function delays.change_rate(target,param) end elseif param == "wobble" then local bump = {params:get("delay L: rate bump"), params:get("delay R: rate bump")} - local wobble = bump[target] == 1 and 0.5 or math.random(-75,75)/1000 - softcut.rate(target+4,params:get(rate[target])+wobble) + local wobble = bump[target] == 1 and (params:get(rate[target]) * 1.5) or (params:get(rate[target])+math.random(-75,75)/1000) + softcut.rate(target+4,wobble) delay[target].wobble_hold = true elseif param == "restore" then softcut.rate(target+4,params:get(rate[target])) diff --git a/lib/encoder_actions.lua b/lib/encoder_actions.lua index e047591..23ebd7e 100755 --- a/lib/encoder_actions.lua +++ b/lib/encoder_actions.lua @@ -615,7 +615,7 @@ function encoder_actions.init(n,d) focused_pad = bank[n].id end if page.levels_sel == 0 then - if key1_hold or grid.alt == 1 then + if key1_hold or grid.alt == 1 or bank[n].alt_lock then -- for i = 1,16 do -- bank[n][i].level = util.clamp(bank[n][i].level+d/10,0,2) -- end @@ -636,7 +636,7 @@ function encoder_actions.init(n,d) end elseif page.levels_sel == 1 then - if key1_hold or grid.alt == 1 then + if key1_hold or grid.alt == 1 or bank[n].alt_lock then for j = 1,16 do local pre_enveloped = bank[n][j].enveloped local pre_mode = bank[n][j].envelope_mode @@ -703,7 +703,7 @@ function encoder_actions.init(n,d) end elseif page.levels_sel == 2 then - if key1_hold or grid.alt == 1 then + if key1_hold or grid.alt == 1 or bank[n].alt_lock then for j = 1,16 do if bank[n][j].enveloped then if d>0 then @@ -730,7 +730,7 @@ function encoder_actions.init(n,d) end elseif page.levels_sel == 3 then - if key1_hold or grid.alt == 1 then + if key1_hold or grid.alt == 1 or bank[n].alt_lock then for j = 1,16 do if bank[n][j].enveloped then bank[n][j].envelope_time = util.explin(0.1,60,0.1,60,bank[n][j].envelope_time) @@ -823,15 +823,32 @@ function encoder_actions.init(n,d) end function ea.move_play_window(target,delta) + -- local duration = target.mode == 1 and 8 or clip[target.clip].sample_length + -- local current_difference = (target.end_point - target.start_point) + -- local s_p = target.mode == 1 and live[target.clip].min or clip[target.clip].min + -- local current_clip = duration*(target.clip-1) + -- if target.start_point + current_difference <= s_p+duration then + -- target.start_point = util.clamp(target.start_point + delta, s_p, s_p+duration) + -- target.end_point = target.start_point + current_difference + -- else + -- target.end_point = s_p+duration + -- target.start_point = target.end_point - current_difference + -- end + local duration = target.mode == 1 and 8 or clip[target.clip].sample_length local current_difference = (target.end_point - target.start_point) local s_p = target.mode == 1 and live[target.clip].min or clip[target.clip].min local current_clip = duration*(target.clip-1) - if target.start_point + current_difference <= s_p+duration then - target.start_point = util.clamp(target.start_point + delta, s_p, s_p+duration) + local reasonable_max = target.mode == 1 and 9 or clip[target.clip].max+1 + if target.start_point + current_difference <= reasonable_max then + target.start_point = util.clamp(target.start_point + delta, s_p, reasonable_max) target.end_point = target.start_point + current_difference else - target.end_point = s_p+duration + target.end_point = reasonable_max + target.start_point = target.end_point - current_difference + end + if target.end_point > reasonable_max then + target.end_point = reasonable_max target.start_point = target.end_point - current_difference end end diff --git a/lib/main_menu.lua b/lib/main_menu.lua index 3a17f47..8c75741 100755 --- a/lib/main_menu.lua +++ b/lib/main_menu.lua @@ -249,13 +249,13 @@ function main_menu.init() screen.move(10+(i*20),64) screen.level(level_options[page.levels_sel+1] == "levels" and 15 or 3) local level_to_screen_options = {"a", "b", "c"} - if key1_hold or grid.alt == 1 then + if key1_hold or grid.alt == 1 or bank[i].alt_lock then screen.text("("..level_to_screen_options[i]..")") else screen.text(level_to_screen_options[i]..""..focused_pad) end screen.move(35+(20*(i-1)),57) - local level_to_screen = ((key1_hold or grid.alt == 1) and util.linlin(0,2,0,40,bank[i].global_level) or util.linlin(0,2,0,40,bank[i][focused_pad].level)) + local level_to_screen = ((key1_hold or grid.alt == 1 or bank[i].alt_lock) and util.linlin(0,2,0,40,bank[i].global_level) or util.linlin(0,2,0,40,bank[i][focused_pad].level)) screen.line(35+(20*(i-1)),57-level_to_screen) screen.close() screen.stroke() @@ -282,7 +282,7 @@ function main_menu.init() -- screen.text("time") screen.move(85,34+((i)*10)) local envelope_to_screen_options = {"a", "b", "c"} - if key1_hold or grid.alt == 1 then + if key1_hold or grid.alt == 1 or bank[i].alt_lock then screen.text("("..envelope_to_screen_options[i]..")") else screen.text(envelope_to_screen_options[i]..""..focused_pad) diff --git a/lib/zilchmos.lua b/lib/zilchmos.lua index 0125452..4260569 100755 --- a/lib/zilchmos.lua +++ b/lib/zilchmos.lua @@ -151,6 +151,9 @@ function zilchmos.start_random( pad ) else min_start = math.floor(rec.start_point * 100) -- this sucks... end + elseif pad.mode == 2 then + max_end = math.floor(pad.end_point * 100) + min_start = math.floor(clip[pad.clip].min * 100) else --duration = math.modf(clip[pad.clip].sample_length) duration = pad.mode == 1 and 8 or math.modf(clip[pad.clip].sample_length) @@ -179,6 +182,9 @@ function zilchmos.end_random( pad ) else min_start = math.floor(rec.start_point * 100) end + elseif pad.mode == 2 then + max_end = math.floor(clip[pad.clip].max * 100) + min_start = math.floor(pad.start_point * 100) else duration = util.round(clip[pad.clip].sample_length) max_end = math.floor(((duration*pad.clip)+1) * 100) @@ -223,6 +229,17 @@ function zilchmos.start_end_random( pad ) case2(8) end end + elseif pad.mode == 2 then + local s_p = math.floor(clip[pad.clip].min * 100) + local e_p = math.floor(clip[pad.clip].max * 100) + local j = math.random(s_p, e_p) / 100 + if j + current_difference >= clip[pad.clip].max then + pad.end_point = clip[pad.clip].max + pad.start_point = pad.end_point - current_difference + else + pad.start_point = j + pad.end_point = pad.start_point + current_difference + end else case2(pad.mode == 1 and 8 or math.modf(clip[pad.clip].sample_length)) end From c69c143926b95a3600ba5b93888c7c97eb7088ad Mon Sep 17 00:00:00 2001 From: dndrks Date: Tue, 1 Sep 2020 10:48:45 -0500 Subject: [PATCH 9/9] only grid.alt!! replaced all instances of grid.alt_pp and grid.alt_delay with grid.alt, which makes it a lot easier to replicate functions across pages. --- cheat_codes.lua | 259 +++++++++++++--------------------------- lib/arc_actions.lua | 13 +- lib/delay.lua | 3 +- lib/encoder_actions.lua | 30 ++--- lib/grid_actions.lua | 239 +++++++++++++++++++++--------------- lib/main_menu.lua | 81 ++++++++++--- lib/zilchmos.lua | 8 +- 7 files changed, 316 insertions(+), 317 deletions(-) diff --git a/cheat_codes.lua b/cheat_codes.lua index 330fbab..b6f35f7 100755 --- a/cheat_codes.lua +++ b/cheat_codes.lua @@ -638,9 +638,9 @@ end key1_hold = false key1_hold_and_modify = false -grid.alt = 0 -grid.alt_pp = 0 -grid.alt_delay = false +grid.alt = false +-- grid.alt_pp = 0 +-- grid.alt_delay = false grid.loop_mod = 0 local function crow_flush() @@ -706,7 +706,7 @@ function init() params:add_trigger("overwrite_coll", "overwrite collection") params:set_action("overwrite_coll", function(x) fileselect.enter(_path.data.."cheat_codes2/names/", named_overwrite) end) params:add_trigger("delete_coll", "delete collection") - params:set_action("delete_coll", function(x) fileselect.enter(_path.data.."cheat_codes2/names/", named_delete) end) + params:set_action("delete_coll", function(x) fileselect.enter(_path.data.."cheat_codes2/names/", pre_delete) end) menu = 1 @@ -1911,7 +1911,7 @@ osc_in = function(path, args, from) osc.send(dest, "/buffer_LED_"..i, {1}) --[[ - if rec.loop == 0 and grid.alt == 0 then + if rec.loop == 0 and not grid.alt then clock.run(one_shot_clock) end @@ -2237,12 +2237,16 @@ function cheat(b,i) end end end - if pad.end_point - pad.start_point < 0.11 then - pad.end_point = pad.start_point + 0.1 - end - if pad.end_point == 9 or pad.end_point == 17 or pad.end_point == 25 then - pad.end_point = pad.end_point-0.01 + -- OH ALL THIS SUCKS TODO FIXME + -- if pad.end_point - pad.start_point < 0.11 then + -- pad.end_point = pad.start_point + 0.1 + -- end + if pad.mode == 1 then + if pad.end_point == 9 or pad.end_point == 17 or pad.end_point == 25 then + pad.end_point = pad.end_point-0.01 + end end + --/ OH ALL THIS SUCKS TODO FIXME softcut.fade_time(b+1,0.01) softcut.loop_start(b+1,pad.start_point) softcut.loop_end(b+1,pad.end_point) @@ -2446,7 +2450,7 @@ function easing_slew(i) slew_counter[i].slewedVal = slew_counter[i].ease(slew_counter[i].current,slew_counter[i].beginVal,slew_counter[i].change,slew_counter[i].duration) slew_counter[i].slewedQ = slew_counter[i].ease(slew_counter[i].current,slew_counter[i].beginQ,slew_counter[i].changeQ,slew_counter[i].duration) slew_counter[i].current = slew_counter[i].current + 0.01 - if grid.alt == 1 then + if grid.alt then try_tilt_process(i,bank[i].id,slew_counter[i].slewedVal,slew_counter[i].slewedQ) else for j = 1,16 do @@ -2548,9 +2552,9 @@ function toggle_buffer(i) rec.end_point = rec.start_point + current_difference end - if rec.loop == 0 and grid.alt == 0 then + if rec.loop == 0 and not grid.alt then clock.run(one_shot_clock) - elseif rec.loop == 0 and grid.alt == 1 then + elseif rec.loop == 0 and grid.alt then buff_flush() end @@ -2640,12 +2644,18 @@ end function key(n,z) if menu == "load screen" then - elseif menu == "save screen" then + elseif menu == "overwrite screen" then if z == 1 then - clock.cancel(collection_save_clock) - print("cancel save") + clock.cancel(collection_overwrite_clock) + print("cancel overwrite") clock.run(canceled_save) end + elseif menu == "delete screen" then + if z == 1 then + clock.cancel(collection_delete_clock) + print("cancel delete") + clock.run(canceled_delete) + end else if n == 3 and z == 1 then if menu == 1 then @@ -3250,7 +3260,7 @@ function grid_redraw() g:led(e.x, e.y,15) end - g:led(16,8,(grid.alt*12)+3) + g:led(16,8,(grid.alt and 12 or 0)+3) for i = 1,3 do if bank[i].focus_hold == false then @@ -3369,7 +3379,7 @@ function grid_redraw() end end - g:led(16,8,(grid.alt_pp*12)+3) + g:led(16,8,(grid.alt and 12 or 0)+3) g:led(16,2,(grid.loop_mod*9)+3) if grid.loop_mod == 1 then @@ -3554,7 +3564,20 @@ function grid_redraw() end end - g:led(16,8,(grid.alt_delay == true and 12 or 0)+3) + --arp button + if not arp[delay_grid.bank].enabled then + g:led(12,2,0) + else + if arp[delay_grid.bank].playing and arp[delay_grid.bank].hold then + g:led(12,2,10) + elseif arp[delay_grid.bank].hold then + g:led(12,2,6) + else + g:led(12,2,4) + end + end + + g:led(16,8,(grid.alt == true and 12 or 0)+3) end local page_led = {[0] = 0, [1] = 7, [2] = 15} @@ -3798,7 +3821,7 @@ arc_redraw = function() end if arc_param[i] == 5 then local level_to_led; - if key1_hold or bank[i].alt_lock or grid.alt == 1 then + if key1_hold or bank[i].alt_lock or grid.alt then level_to_led = bank[i].global_level else level_to_led = bank[i][bank[i].id].level @@ -3880,8 +3903,10 @@ function named_overwrite(path) io.input(file) local collection = io.read() io.close(file) - pre_save(collection) + pre_overwrite(collection) end + else + print("nothing overwritten") end end @@ -3892,12 +3917,33 @@ function named_delete(path) io.input(file) os.remove(path) io.close(file) + print("collection deleted") end end end +function pre_overwrite(text) + if text ~= 'cancel' then + collection_overwrite_clock = clock.run(overwrite_screen,text) + _norns.key(1,1) + _norns.key(1,0) + else + print("nothing overwritten") + end +end + +function pre_delete(text) + if text ~= 'cancel' then + collection_delete_clock = clock.run(delete_screen,text) + _norns.key(1,1) + _norns.key(1,0) + else + print("nothing deleted") + end +end + function pre_save(text) - if text then + if text ~= 'cancel' then collection_save_clock = clock.run(save_screen,text) _norns.key(1,1) _norns.key(1,0) @@ -3991,87 +4037,21 @@ function named_savestate(text) end --/ ARC rec save -end - -function savestate() - - local dirname = _path.data.."cheat_codes2/" - local collection = tonumber(string.format("%.0f",params:get("collection"))) - if os.rename(dirname, dirname) == nil then - os.execute("mkdir " .. dirname) - end - - local dirname = _path.data.."cheat_codes2/collection-"..collection.."/" - if os.rename(dirname, dirname) == nil then - os.execute("mkdir " .. dirname) - end - - local dirnames = {"banks/","params/","arc-rec/","patterns/","step-seq/","arps/","euclid/","rnd/","delays/","rec/","misc/"} - for i = 1,#dirnames do - local directory = _path.data.."cheat_codes2/collection-"..collection.."/"..dirnames[i] - if os.rename(directory, directory) == nil then - os.execute("mkdir " .. directory) - end - end - - for i = 1,3 do - tab.save(bank[i],_path.data .. "cheat_codes2/collection-"..collection.."/banks/"..i..".data") - tab.save(step_seq[i],_path.data .. "cheat_codes2/collection-"..collection.."/step-seq/"..i..".data") - tab.save(arp[i],_path.data .. "cheat_codes2/collection-"..collection.."/arps/"..i..".data") - tab.save(rytm.track[i],_path.data .. "cheat_codes2/collection-"..collection.."/euclid/euclid"..i..".data") - tab.save(rnd[i],_path.data .. "cheat_codes2/collection-"..collection.."/rnd/"..i..".data") - if params:get("collect_live") == 2 then - collect_samples(i) - end - end - - for i = 1,2 do - tab.save(delay[i],_path.data .. "cheat_codes2/collection-"..collection.."/delays/delay"..(i == 1 and "L" or "R")..".data") - end - - params:write(_path.data.."cheat_codes2/collection-"..collection.."/params/all.pset") - tab.save(rec,_path.data .. "cheat_codes2/collection-"..collection.."/rec/rec.data") - - -- GRID pattern save - if selected_coll ~= collection then - meta_copy_coll(selected_coll,collection) - end - meta_shadow(collection) - selected_coll = collection - --/ GRID pattern save - - -- MIDI pattern save - for i = 1,3 do - save_midi_pattern(i) - end - --/ MIDI pattern save - - -- ARC rec save - local arc_rec_dirty = {false,false,false} - for i = 1,3 do - for j = 1,4 do - if arc_pat[i][j].count > 0 then - arc_rec_dirty[i] = true - end - end - if arc_rec_dirty[i] then - save_arc_pattern(i) - else - local file = io.open(_path.data .. "cheat_codes2/collection-"..selected_coll.."/arc-rec/encoder-"..i..".data", "r") - if file then - io.input(file) - os.remove(_path.data .. "cheat_codes2/collection-"..selected_coll.."/arc-rec/encoder-"..i..".data") - io.close(file) - end - end + -- misc save + local file = io.open(_path.data .. "cheat_codes2/collection-"..selected_coll.."/misc/misc.data", "w+") + if file then + io.output(file) + io.write("clock_tempo: "..params:get("clock_tempo").."\n") + io.close(file) end - --/ ARC rec save + --/ misc save end function named_loadstate(path) print("loading...") + reset_all_banks(bank) print(path) local file = io.open(path, "r") if file then @@ -4144,89 +4124,14 @@ function named_loadstate(path) load_midi_pattern(i) end end - else - _norns.key(1,1) - _norns.key(1,0) - collection_loaded = false - clock.run(load_fail_screen) - end - - grid_dirty = true - -end - -function loadstate() - - local check_exist = io.open(_path.data.."cheat_codes2/collection-"..tonumber(string.format("%.0f",params:get("collection")))) - if check_exist then - local collection = tonumber(string.format("%.0f",params:get("collection"))) - selected_coll = collection - collection_loaded = true - io.close(check_exist) - _norns.key(1,1) - _norns.key(1,0) - clock.run(load_screen) - redraw() - params:read(_path.data.."cheat_codes2/collection-"..collection.."/params/all.pset") - if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/rec/rec.data") ~= nil then - rec = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/rec/rec.data") - end - -- params:bang() - for i = 1,3 do - if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/banks/"..i..".data") ~= nil then - bank[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/banks/"..i..".data") - end - if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/step-seq/"..i..".data") ~= nil then - step_seq[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/step-seq/"..i..".data") - end - if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/arps/"..i..".data") ~= nil then - arp[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/arps/"..i..".data") - end - if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/rnd/"..i..".data") ~= nil then - rnd[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/rnd/"..i..".data") - for j = 1,#rnd[i] do - rnd[i][j].clock = nil - if rnd[i][j].playing then - rnd[i][j].clock = clock.run(rnd.advance, i, j) - end - end - end - - if params:get("collect_live") == 2 then - reload_collected_samples(_path.dust.."audio/cc2_live-audio/"..collection.."/".."cc2_"..collection.."-"..i..".wav",i) - end - - if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/euclid/euclid"..i..".data") ~= nil then - rytm.track[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/euclid/euclid"..i..".data") - end - rytm.reset_pattern() - end - - for i = 1,2 do - if tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/delays/delay"..(i == 1 and "L" or "R")..".data") ~= nil then - delay[i] = tab.load(_path.data .. "cheat_codes2/collection-"..collection.."/delays/delay"..(i == 1 and "L" or "R")..".data") - end - end - - -- GRID pattern restore - if selected_coll ~= collection then - meta_shadow(selected_coll) - elseif selected_coll == collection then - cleanup() - end - one_point_two() - -- / GRID pattern restore - for i = 1,3 do - load_arc_pattern(i) + local file = io.open(_path.data .. "cheat_codes2/collection-"..selected_coll.."/misc/misc.data", "r") + if file then + io.input(file) + params:set("clock_tempo", tonumber(string.match(io.read(), ': (.*)'))) + io.close(file) end - for i = 1,3 do - local dirname = _path.data .. "cheat_codes2/collection-"..selected_coll.."/patterns/midi"..i..".data" - if os.rename(dirname, dirname) ~= nil then - load_midi_pattern(i) - end - end else _norns.key(1,1) _norns.key(1,0) @@ -4689,7 +4594,7 @@ function test_save(i) pattern_saver[i].active = true clock.sleep(1) -- if pattern_saver[i].active then - if grid.alt_pp == 0 then + if not grid.alt then if grid_pat[i].count > 0 and grid_pat[i].rec == 0 then copy_entire_pattern(i) save_pattern(i,pattern_saver[i].save_slot+8*(i-1),"pattern") diff --git a/lib/arc_actions.lua b/lib/arc_actions.lua index fbd4035..80211e6 100755 --- a/lib/arc_actions.lua +++ b/lib/arc_actions.lua @@ -17,13 +17,13 @@ function aa.init(n,d) local this_pad = this_bank[which_pad] local p_action = aa.actions[arc_param[n]][1] local sc_action = aa.actions[arc_param[n]][2] - if not this_bank.alt_lock and grid.alt == 0 then + if not this_bank.alt_lock and not grid.alt then if arc_param[n] ~= 4 then p_action(this_pad,d) else aa.map(p_action, this_bank, arc_param[n] == 4 and d/1000 or d, n) end - elseif this_bank.alt_lock or grid.alt == 1 then + elseif this_bank.alt_lock or grid.alt then if arc_param[n] ~= 4 then aa.map(p_action,this_bank,d) else @@ -99,7 +99,7 @@ function aa.move_window(target, delta) local current_difference = (target.end_point - target.start_point) local s_p = target.mode == 1 and live[target.clip].min or clip[target.clip].min local current_clip = duration*(target.clip-1) - local reasonable_max = target.mode == 1 and 9 or clip[target.clip].max+1 + local reasonable_max = target.mode == 1 and 9 or clip[target.clip].max local adjusted_delta = force and (duration > 15 and (delta/25) or (delta/100)) or (delta/300) if target.start_point + current_difference <= reasonable_max then target.start_point = util.clamp(target.start_point + adjusted_delta, s_p, reasonable_max) @@ -122,8 +122,9 @@ function aa.move_start(target, delta) local duration = target.mode == 1 and 8 or clip[target.clip].sample_length local s_p = target.mode == 1 and live[target.clip].min or clip[target.clip].min local adjusted_delta = force and (delta/100) or (delta/300) - if adjusted_delta >= 0 and target.start_point < (target.end_point - 0.05) then + if adjusted_delta >= 0 and target.start_point < (target.end_point - 0.055) then target.start_point = util.clamp(target.start_point+adjusted_delta,s_p,s_p+duration) + print(target.end_point) elseif adjusted_delta < 0 then target.start_point = util.clamp(target.start_point+adjusted_delta,s_p,s_p+duration) end @@ -137,7 +138,7 @@ function aa.move_end(target, delta) local duration = target.mode == 1 and 8 or clip[target.clip].sample_length local s_p = target.mode == 1 and live[target.clip].min or clip[target.clip].min local adjusted_delta = force and (delta/100) or (delta/300) - if adjusted_delta <= 0 and target.start_point < (target.end_point - 0.05) then + if adjusted_delta <= 0 and target.start_point < (target.end_point - 0.055) then target.end_point = util.clamp(target.end_point+adjusted_delta,s_p,s_p+duration) elseif adjusted_delta > 0 then target.end_point = util.clamp(target.end_point+adjusted_delta,s_p,s_p+duration) @@ -167,7 +168,7 @@ function aa.change_pan(target, delta) end function aa.change_level(target, delta) - if bank[target.bank_id].alt_lock or grid.alt == 1 then + if bank[target.bank_id].alt_lock or grid.alt then if target.pad_id == 1 then bank[target.bank_id].global_level = util.clamp(bank[target.bank_id].global_level + delta/1000,0,2) end diff --git a/lib/delay.lua b/lib/delay.lua index b6e0ad2..923b207 100755 --- a/lib/delay.lua +++ b/lib/delay.lua @@ -83,6 +83,7 @@ function delays.build_bundle(target,slot) delay[target].selected_bundle = slot end delay[target].saver_active = false + grid_dirty = true end function delays.restore_bundle(target,slot) @@ -182,8 +183,6 @@ function delays.quick_action(target,param) end else if not pad.enveloped then - print(pad.enveloped) - print("sending 185") softcut.level_cut_cut(delay_grid.bank+1,target+4,target == 1 and bank[delay_grid.bank][bank[delay_grid.bank].id].left_delay_level or bank[delay_grid.bank][bank[delay_grid.bank].id].right_delay_level) end end diff --git a/lib/encoder_actions.lua b/lib/encoder_actions.lua index 23ebd7e..9df4fe4 100755 --- a/lib/encoder_actions.lua +++ b/lib/encoder_actions.lua @@ -6,7 +6,7 @@ ea.sc = {} function encoder_actions.init(n,d) if n == 1 then if menu == 1 then - page.main_sel = util.clamp(page.main_sel+d,1,10) + page.main_sel = util.clamp(page.main_sel+d,1,9) elseif menu == 2 then local id = page.loops_sel if not key1_hold then @@ -63,7 +63,7 @@ function encoder_actions.init(n,d) end if n == 2 then if menu == 1 then - page.main_sel = util.clamp(page.main_sel+d,1,10) + page.main_sel = util.clamp(page.main_sel+d,1,9) elseif menu == 2 then local id = page.loops_sel if id ~=4 then @@ -80,7 +80,7 @@ function encoder_actions.init(n,d) bank[id][i].rate = bank[id][16].rate end end - if grid.alt == 1 then + if grid.alt then for i = 1,16 do bank[id][i].rate = bank[id][focused_pad].rate end @@ -272,7 +272,7 @@ function encoder_actions.init(n,d) bank[id][i].offset = bank[id][16].offset end end - if grid.alt == 1 then + if grid.alt then for i = 1,16 do bank[id][i].offset = bank[id][focused_pad].offset end @@ -292,7 +292,7 @@ function encoder_actions.init(n,d) bank[id][i].rate_slew = bank[id][16].rate_slew end end - if grid.alt == 1 then + if grid.alt then for i = 1,16 do bank[id][i].rate_slew = bank[id][focused_pad].rate_slew end @@ -615,7 +615,7 @@ function encoder_actions.init(n,d) focused_pad = bank[n].id end if page.levels_sel == 0 then - if key1_hold or grid.alt == 1 or bank[n].alt_lock then + if key1_hold or grid.alt or bank[n].alt_lock then -- for i = 1,16 do -- bank[n][i].level = util.clamp(bank[n][i].level+d/10,0,2) -- end @@ -636,7 +636,7 @@ function encoder_actions.init(n,d) end elseif page.levels_sel == 1 then - if key1_hold or grid.alt == 1 or bank[n].alt_lock then + if key1_hold or grid.alt or bank[n].alt_lock then for j = 1,16 do local pre_enveloped = bank[n][j].enveloped local pre_mode = bank[n][j].envelope_mode @@ -703,7 +703,7 @@ function encoder_actions.init(n,d) end elseif page.levels_sel == 2 then - if key1_hold or grid.alt == 1 or bank[n].alt_lock then + if key1_hold or grid.alt or bank[n].alt_lock then for j = 1,16 do if bank[n][j].enveloped then if d>0 then @@ -730,7 +730,7 @@ function encoder_actions.init(n,d) end elseif page.levels_sel == 3 then - if key1_hold or grid.alt == 1 or bank[n].alt_lock then + if key1_hold or grid.alt or bank[n].alt_lock then for j = 1,16 do if bank[n][j].enveloped then bank[n][j].envelope_time = util.explin(0.1,60,0.1,60,bank[n][j].envelope_time) @@ -750,7 +750,7 @@ function encoder_actions.init(n,d) end if menu == 4 then local focused_pad = nil - if key1_hold or grid.alt == 1 then + if key1_hold or grid.alt then for i = 1,16 do bank[n][i].pan = util.clamp(bank[n][i].pan+d/10,-1,1) end @@ -767,7 +767,7 @@ function encoder_actions.init(n,d) local filt_page = page.filtering_sel + 1 if filt_page == 1 then if bank[n][bank[n].id].filter_type == 4 then - if key1_hold or grid.alt == 1 then + if key1_hold or grid.alt then if slew_counter[n] ~= nil then slew_counter[n].prev_tilt = bank[n][bank[n].id].tilt end @@ -802,7 +802,7 @@ function encoder_actions.init(n,d) end end elseif filt_page == 2 then - if key1_hold or grid.alt == 1 then + if key1_hold or grid.alt then bank[n][bank[n].id].tilt_ease_time = util.clamp(bank[n][bank[n].id].tilt_ease_time+(d/1), 5, 15000) else for j = 1,16 do @@ -810,7 +810,7 @@ function encoder_actions.init(n,d) end end elseif filt_page == 3 then - if key1_hold or grid.alt == 1 then + if key1_hold or grid.alt then bank[n][bank[n].id].tilt_ease_type = util.clamp(bank[n][bank[n].id].tilt_ease_type+d, 1, 2) else for j = 1,16 do @@ -933,7 +933,7 @@ end function ea.move_start(target,delta) local duration = target.mode == 1 and 8 or clip[target.clip].sample_length local s_p = target.mode == 1 and live[target.clip].min or clip[target.clip].min - if delta >= 0 and target.start_point < (target.end_point - delta) then + if delta >= 0 and target.start_point < (target.end_point - 0.05) then target.start_point = util.clamp(target.start_point+delta,s_p,s_p+duration) elseif delta < 0 then target.start_point = util.clamp(target.start_point+delta,s_p,s_p+duration) @@ -943,7 +943,7 @@ end function ea.move_end(target,delta) local duration = target.mode == 1 and 8 or clip[target.clip].sample_length local s_p = target.mode == 1 and live[target.clip].min or clip[target.clip].min - if delta <= 0 and target.start_point < target.end_point + delta then + if delta <= 0 and target.start_point < (target.end_point - 0.05) then target.end_point = util.clamp(target.end_point+delta,s_p,s_p+duration) elseif delta > 0 then target.end_point = util.clamp(target.end_point+delta,s_p,s_p+duration) diff --git a/lib/grid_actions.lua b/lib/grid_actions.lua index 6bb7f2d..007f8d2 100755 --- a/lib/grid_actions.lua +++ b/lib/grid_actions.lua @@ -20,7 +20,7 @@ function grid_actions.init(x,y,z) if grid_page == 0 then for i = 1,3 do - if grid.alt == 1 then + if grid.alt then if x == 1+(5*(i-1)) and y == 1 and z == 1 then bank[i].focus_hold = not bank[i].focus_hold end @@ -30,7 +30,7 @@ function grid_actions.init(x,y,z) for i = 1,3 do 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 - if grid.alt == 0 then + 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)) @@ -83,14 +83,14 @@ function grid_actions.init(x,y,z) arps.momentary(i, released_pad, "off") end else - if grid.alt == 0 then + if not grid.alt then bank[i].focus_pad = (math.abs(y-9)+((x-1)*4))-(20*(i-1)) --[[ if tracker[i].recording then add_to_tracker(i,{bank[i].focus_pad,0.25,"next"}) end --]] - elseif grid.alt == 1 then + elseif grid.alt then if not pad_clipboard then pad_clipboard = {} bank[i].focus_pad = (math.abs(y-9)+((x-1)*4))-(20*(i-1)) @@ -182,12 +182,12 @@ function grid_actions.init(x,y,z) for i = 1,3 do if z == 0 and x == (k+1)+(5*(i-1)) and y<=k then if grid_pat[i].quantize == 0 then -- still relevant - if bank[i].alt_lock and grid.alt == 0 then + if bank[i].alt_lock and not grid.alt then if grid_pat[i].play == 1 then grid_pat[i].overdub = grid_pat[i].overdub == 0 and 1 or 0 end else - if grid.alt == 1 then -- still relevant + if grid.alt then -- still relevant grid_pat[i]:rec_stop() grid_pat[i]:stop() --grid_pat[i].external_start = 0 @@ -222,7 +222,7 @@ function grid_actions.init(x,y,z) end end else - if grid.alt == 1 then + if grid.alt then grid_pat[i]:rec_stop() grid_pat[i]:stop() grid_pat[i].tightened_start = 0 @@ -250,7 +250,7 @@ function grid_actions.init(x,y,z) else a_p = arc_param[current] - 2 end - if grid.alt == 1 then + if grid.alt then arc_pat[current][a_p]:rec_stop() arc_pat[current][a_p]:stop() arc_pat[current][a_p]:clear() @@ -276,7 +276,7 @@ function grid_actions.init(x,y,z) which_bank = i local which_pad = bank[i].focus_hold == true and bank[i].focus_pad or bank[i].id bank[i][which_pad].loop = not bank[i][which_pad].loop - if bank[i].alt_lock or grid.alt == 1 then + if bank[i].alt_lock or grid.alt then for j = 1,16 do bank[i][j].loop = bank[i][which_pad].loop end @@ -293,18 +293,18 @@ function grid_actions.init(x,y,z) end if x == 16 and y == 8 then - if grid.alt_pp == 1 then - grid.alt_pp = 0 - end - if grid.alt_delay then - grid.alt_delay = false - end - grid.alt = z + -- if grid.alt_pp == 1 then + -- grid.alt_pp = 0 + -- end + -- if grid.alt_delay then + -- grid.alt_delay = false + -- end + grid.alt = z == 1 and true or false arc.alt = z if menu == 11 then - if grid.alt == 1 then + if grid.alt then help_menu = "alt" - elseif grid.alt == 0 then + elseif not grid.alt then help_menu = "welcome" end end @@ -316,8 +316,8 @@ function grid_actions.init(x,y,z) if x == 1 or x == 6 or x == 11 then local which_pad = nil local current = util.round(math.sqrt(math.abs(x-2))) - --if grid.alt == 0 then - if not bank[current].alt_lock and grid.alt == 0 then + --if not grid.alt then + if not bank[current].alt_lock and not grid.alt then if bank[current].focus_hold == false then --jump_live(current, bank[current].id, y, z) jump_clip(current, bank[current].id, y, z) @@ -325,7 +325,7 @@ function grid_actions.init(x,y,z) --jump_live(current, bank[current].focus_pad, y, z) jump_clip(current, bank[current].focus_pad, y, z) end - elseif bank[current].alt_lock or grid.alt == 1 then + elseif bank[current].alt_lock or grid.alt then for j = 1,16 do --jump_live(current, j, y, z) jump_clip(current, j, y, z) @@ -349,8 +349,8 @@ function grid_actions.init(x,y,z) for j = 2,12,5 do if x == j and y == i and z == 1 then local which_pad = nil - --if grid.alt == 0 then - if not bank[math.sqrt(math.abs(x-3))].alt_lock and grid.alt == 0 then + --if not grid.alt then + if not bank[math.sqrt(math.abs(x-3))].alt_lock and not grid.alt then local current = math.sqrt(math.abs(x-3)) if bank[current].focus_hold == false then local old_mode = bank[current][bank[current].id].mode @@ -365,7 +365,7 @@ function grid_actions.init(x,y,z) change_mode(bank[current][bank[current].focus_pad], old_mode) end end - elseif bank[math.sqrt(math.abs(x-3))].alt_lock or grid.alt == 1 then + elseif bank[math.sqrt(math.abs(x-3))].alt_lock or grid.alt then for k = 1,16 do local current = math.sqrt(math.abs(x-3)) local old_mode = bank[current][k].mode @@ -410,7 +410,7 @@ function grid_actions.init(x,y,z) for i = 7,5,-1 do if x == 16 and z == 1 and y == i then toggle_buffer(8-y) - if grid.alt == 1 then + if grid.alt then buff_flush() end @@ -424,7 +424,7 @@ function grid_actions.init(x,y,z) for i = 8,6,-1 do if x == 5 or x == 10 or x == 15 then if y == i then - if grid.alt == 0 then + if not grid.alt then if z == 1 then table.insert(arc_switcher[x/5],y) held_query[x/5] = #arc_switcher[x/5] @@ -454,7 +454,7 @@ function grid_actions.init(x,y,z) arc_switcher[x/5] = {} end end - elseif grid.alt == 1 then + elseif grid.alt then if y == 8 then -- sixteen_slices(x/5) elseif y == 7 then @@ -473,7 +473,7 @@ function grid_actions.init(x,y,z) if bank[i].focus_hold == true then if x == i*5 then bank[i][bank[i].focus_pad].crow_pad_execute = (bank[i][bank[i].focus_pad].crow_pad_execute + 1)%2 - if grid.alt == 1 then + if grid.alt then for j = 1,16 do bank[i][j].crow_pad_execute = bank[i][bank[i].focus_pad].crow_pad_execute end @@ -483,7 +483,7 @@ function grid_actions.init(x,y,z) end end if x == 5 or x == 10 or x == 15 then - if grid.alt == 0 then + if not grid.alt then bank[x/5].alt_lock = z == 1 and true or false else if z == 1 then @@ -499,30 +499,32 @@ function grid_actions.init(x,y,z) if z == 1 and x == k+(5*(i-1)) and y == k then --- - --if grid.alt == 0 then - if not bank[i].alt_lock and grid.alt == 0 then + --if not grid.alt then + if not bank[i].alt_lock and not grid.alt then if y == 3 then - if not arp[i].enabled then - arp[i].enabled = true - elseif not arp[i].hold then - if #arp[i].notes > 0 then - arp[i].hold = true - else - arp[i].enabled = false - end - else - if #arp[i].notes > 0 then - if arp[i].playing == true then - arp[i].pause = true - arp[i].playing = false - else - arp[i].step = arp[i].start_point-1 - arp[i].pause = false - arp[i].playing = true - end - end - end + grid_actions.arp_handler(i) + + -- if not arp[i].enabled then + -- arp[i].enabled = true + -- elseif not arp[i].hold then + -- if #arp[i].notes > 0 then + -- arp[i].hold = true + -- else + -- arp[i].enabled = false + -- end + -- else + -- if #arp[i].notes > 0 then + -- if arp[i].playing == true then + -- arp[i].pause = true + -- arp[i].playing = false + -- else + -- arp[i].step = arp[i].start_point-1 + -- arp[i].pause = false + -- arp[i].playing = true + -- end + -- end + -- end else if key1_hold == true then key1_hold = false end if y == 4 then @@ -531,21 +533,12 @@ function grid_actions.init(x,y,z) end redraw() end - elseif bank[i].alt_lock or grid.alt == 1 then + elseif bank[i].alt_lock or grid.alt then if y == 2 then random_grid_pat(math.ceil(x/4),3) end if y == 3 then - page.arp_page_sel = i - arp[i].hold = not arp[i].hold - if not arp[i].hold then - arps.clear(i) - end - arp[i].enabled = false - - - - --arp[i].pause = not arp[i].pause + grid_actions.kill_arp(i) end if y == 4 then local current = math.floor(x/5)+1 @@ -581,7 +574,7 @@ function grid_actions.init(x,y,z) else --if there's a pattern saved there... if pattern_saver[current].saved[9-y] == 1 then - if grid.alt_pp == 0 then + if not grid.alt then step_seq[current][step_seq[current].held].assigned_to = 9-y end end @@ -595,7 +588,7 @@ function grid_actions.init(x,y,z) -- print("killing save "..pattern_saver[math.floor(x/5)+1].clock) end pattern_saver[math.floor(x/5)+1].active = false - if grid.alt_pp == 0 and saved_pat == 1 then + if not grid.alt and saved_pat == 1 then if pattern_saver[current].saved[9-y] == 1 then pattern_saver[current].load_slot = 9-y test_load((9-y)+(8*(current-1)),current) @@ -621,7 +614,7 @@ function grid_actions.init(x,y,z) if z == 1 and x == i and y == j then local current = math.floor(x/5)+1 step_seq[current].held = 9-y - if grid.alt_pp == 1 then + if grid.alt then step_seq[current][step_seq[current].held].assigned_to = 0 end elseif z == 0 and x == i and y == j then @@ -630,7 +623,7 @@ function grid_actions.init(x,y,z) elseif z == 1 and x == i+1 and y == j then local current = math.floor(x/5)+1 step_seq[current].held = (9-y)+8 - if grid.alt_pp == 1 then + if grid.alt then step_seq[current][step_seq[current].held].assigned_to = 0 end elseif z == 0 and x == i+1 and y == j then @@ -649,7 +642,7 @@ function grid_actions.init(x,y,z) else step_seq[current][step_seq[current].held].meta_meta_duration = 9-y end - if grid.alt_pp == 1 then + if grid.alt then for k = 1,16 do step_seq[current][k].meta_meta_duration = 9-y end @@ -661,7 +654,7 @@ function grid_actions.init(x,y,z) for i = 7,5,-1 do if x == 16 and y == i and z == 1 then if step_seq[8-i].held == 0 then - if grid.alt_pp == 1 then + if grid.alt then step_seq[8-i].current_step = step_seq[8-i].start_point step_seq[8-i].meta_step = 1 step_seq[8-i].meta_meta_step = 1 @@ -679,7 +672,7 @@ function grid_actions.init(x,y,z) if x == 16 and y == 8 then - grid.alt_pp = z + grid.alt = z == 1 and true or false redraw() -- grid_redraw() end @@ -768,7 +761,8 @@ function grid_actions.init(x,y,z) del.set_value(6-y, x-3, "feedback") end elseif x == 9 then - if grid.alt_delay then + -- if grid.alt_delay then + if grid.alt then del.quick_action(6-y, "clear") end del.quick_action(6-y,"feedback mute") @@ -776,7 +770,8 @@ function grid_actions.init(x,y,z) elseif y == 1 or y == 8 then if x >= 10 and x <=14 then if z == 1 then - del.set_value(y == 8 and 1 or 2,x-9,grid.alt_delay == true and "send all" or "send") + -- del.set_value(y == 8 and 1 or 2,x-9,grid.alt_delay == true and "send all" or "send") + del.set_value(y == 8 and 1 or 2,x-9,grid.alt == true and "send all" or "send") end elseif x == 15 then del.quick_action(y == 8 and 1 or 2,"send mute") @@ -794,7 +789,8 @@ function grid_actions.init(x,y,z) delay[target].saver_active = true clock.run(del.build_bundle,target,bundle) elseif saved_already then - if grid.alt_delay then + -- if grid.alt_delay then + if grid.alt then del.clear_bundle(target,bundle) else del.restore_bundle(target,bundle) @@ -823,25 +819,43 @@ function grid_actions.init(x,y,z) end end + if x == 12 and y == 2 then + if z == 1 then + if grid.alt or bank[delay_grid.bank].alt_lock then + grid_actions.kill_arp(delay_grid.bank) + elseif not grid.alt and not bank[delay_grid.bank].alt_lock then + grid_actions.arp_handler(delay_grid.bank) + end + end + end + if x >= 10 and x <= 13 and y >=3 and y <=6 then local id = delay_grid.bank - if z == 1 then - local xval = {9,4,-1} - selected[id].x = x - xval[id] - selected[id].y = y + 2 - selected[id].id = (math.abs(selected[id].y-9)+((selected[id].x-1)*4))-(20*(id-1)) - bank[id].id = selected[id].id - -- if (arp[id].hold or (menu == 9)) and grid_pat[id].rec == 0 and not arp[id].pause then - if (arp[id].enabled or (menu == 9)) and grid_pat[id].rec == 0 and not arp[id].pause then - arp[id].time = bank[id][bank[id].id].arp_time - arps.momentary(id, bank[id].id, "on") + if not grid.alt then + if z == 1 then + local xval = {9,4,-1} + selected[id].x = x - xval[id] + selected[id].y = y + 2 + selected[id].id = (math.abs(selected[id].y-9)+((selected[id].x-1)*4))-(20*(id-1)) + bank[id].id = selected[id].id + -- if (arp[id].hold or (menu == 9)) and grid_pat[id].rec == 0 and not arp[id].pause then + if (arp[id].enabled or (menu == 9)) and grid_pat[id].rec == 0 and not arp[id].pause then + arp[id].time = bank[id][bank[id].id].arp_time + arps.momentary(id, bank[id].id, "on") + else + cheat(id, bank[id].id) + grid_pattern_watch(id) + end else - cheat(id, bank[id].id) - grid_pattern_watch(id) + -- if not arp[id].hold then + if arp[id].enabled and not arp[id].hold then + local xval = {9,4,-1} + local released_pad = (math.abs((y + 2)-9)+(((x - xval[id])-1)*4))-(20*(id-1)) + arps.momentary(id, released_pad, "off") + end end else - -- if not arp[id].hold then - if arp[id].enabled and not arp[id].hold then + if z == 1 then local xval = {9,4,-1} local released_pad = (math.abs((y + 2)-9)+(((x - xval[id])-1)*4))-(20*(id-1)) arps.momentary(id, released_pad, "off") @@ -850,14 +864,15 @@ function grid_actions.init(x,y,z) end if x == 16 and y == 8 then - grid.alt_delay = not grid.alt_delay + -- grid.alt_delay = not grid.alt_delay + grid.alt = not grid.alt end end if x == 16 and y == 1 and z == 1 then if grid_page == 0 then - if grid.alt == 0 then + if not grid.alt then grid_page = 1 if menu == 11 then if grid_page == 1 then @@ -869,24 +884,24 @@ function grid_actions.init(x,y,z) end else grid_page = 2 - grid.alt_delay = true - grid.alt = 0 + -- grid.alt_delay = true + grid.alt = true + -- grid.alt = 0 end elseif grid_page == 1 then - if grid.alt_pp == 0 then + if not grid.alt then grid_page = 2 else grid_page = 0 - grid.alt = 1 - grid.alt_pp = 0 + -- grid.alt = true end elseif grid_page == 2 then - if not grid.alt_delay then + -- if not grid.alt_delay then + if not grid.alt then grid_page = 0 else grid_page = 1 - grid.alt_pp = 1 - grid.alt_delay = false + -- grid.alt_delay = false end end end @@ -895,4 +910,36 @@ function grid_actions.init(x,y,z) end +function grid_actions.arp_handler(i) + if not arp[i].enabled then + arp[i].enabled = true + elseif not arp[i].hold then + if #arp[i].notes > 0 then + arp[i].hold = true + else + arp[i].enabled = false + end + else + if #arp[i].notes > 0 then + if arp[i].playing == true then + arp[i].pause = true + arp[i].playing = false + else + arp[i].step = arp[i].start_point-1 + arp[i].pause = false + arp[i].playing = true + end + end + end +end + +function grid_actions.kill_arp(i) + page.arp_page_sel = i + arp[i].hold = not arp[i].hold + if not arp[i].hold then + arps.clear(i) + end + arp[i].enabled = false +end + return grid_actions \ No newline at end of file diff --git a/lib/main_menu.lua b/lib/main_menu.lua index 8c75741..903bfe6 100755 --- a/lib/main_menu.lua +++ b/lib/main_menu.lua @@ -28,7 +28,7 @@ function main_menu.init() , " euclid" , " arp" , " rnd" - , " ?" + , " " } screen.text(page.main_sel == i and (">"..options[i]) or options[i]) end @@ -94,7 +94,7 @@ function main_menu.init() -- local loops_to_screen_options = {"a", "b", "c"} -- screen.text(loops_to_screen_options[i]..""..which_pad) - if grid.alt == 0 then + if not grid.alt then local loops_to_screen_options = {"a", "b", "c"} screen.text(loops_to_screen_options[i]..""..which_pad) else @@ -139,7 +139,7 @@ function main_menu.init() end screen.move(0,8+(i*14)) screen.level(page.loops_sel == i and 15 or 3) - if grid.alt == 0 then + if not grid.alt then local loops_to_screen_options = {"a", "b", "c"} screen.text(loops_to_screen_options[i]..""..focused_pad) else @@ -155,7 +155,7 @@ function main_menu.init() screen.move(15,8+(i*14)) local id = page.loops_sel local focused_pad = nil - -- if grid.alt == 1 then + -- if grid.alt then -- screen.move(0,20) -- screen.level(6) -- screen.text("(grid-ALT sets offset for all)") @@ -167,7 +167,7 @@ function main_menu.init() focused_pad = bank[i].focus_pad end -- if page.loops_sel == i-1 then - -- if page.loops_sel < 3 and focused_pad == 16 and grid.alt == 0 then + -- if page.loops_sel < 3 and focused_pad == 16 and not grid.alt then -- screen.move(0,20) -- screen.level(6) -- screen.text("(pad 16 overwrites bank!)") @@ -180,7 +180,7 @@ function main_menu.init() -- end screen.move(0,8+(i*14)) screen.level(page.loops_sel == i and 15 or 3) - if grid.alt == 0 then + if not grid.alt then local loops_to_screen_options = {"a", "b", "c"} screen.text(loops_to_screen_options[i]..""..focused_pad) else @@ -249,13 +249,13 @@ function main_menu.init() screen.move(10+(i*20),64) screen.level(level_options[page.levels_sel+1] == "levels" and 15 or 3) local level_to_screen_options = {"a", "b", "c"} - if key1_hold or grid.alt == 1 or bank[i].alt_lock then + if key1_hold or grid.alt or bank[i].alt_lock then screen.text("("..level_to_screen_options[i]..")") else screen.text(level_to_screen_options[i]..""..focused_pad) end screen.move(35+(20*(i-1)),57) - local level_to_screen = ((key1_hold or grid.alt == 1 or bank[i].alt_lock) and util.linlin(0,2,0,40,bank[i].global_level) or util.linlin(0,2,0,40,bank[i][focused_pad].level)) + local level_to_screen = ((key1_hold or grid.alt or bank[i].alt_lock) and util.linlin(0,2,0,40,bank[i].global_level) or util.linlin(0,2,0,40,bank[i][focused_pad].level)) screen.line(35+(20*(i-1)),57-level_to_screen) screen.close() screen.stroke() @@ -282,7 +282,7 @@ function main_menu.init() -- screen.text("time") screen.move(85,34+((i)*10)) local envelope_to_screen_options = {"a", "b", "c"} - if key1_hold or grid.alt == 1 or bank[i].alt_lock then + if key1_hold or grid.alt or bank[i].alt_lock then screen.text("("..envelope_to_screen_options[i]..")") else screen.text(envelope_to_screen_options[i]..""..focused_pad) @@ -316,7 +316,7 @@ function main_menu.init() screen.move(pan_to_screen,35+(10*(i-1))) local pan_to_screen_options = {"a", "b", "c"} screen.level(15) - if key1_hold or grid.alt == 1 then + if key1_hold or grid.alt then screen.text("("..pan_to_screen_options[i]..")") else screen.text(pan_to_screen_options[i]..""..focused_pad) @@ -334,7 +334,7 @@ function main_menu.init() screen.move(17+((i-1)*45),25) screen.level(15) local filters_to_screen_options = {"a", "b", "c"} - if key1_hold or grid.alt == 1 then + if key1_hold or grid.alt then screen.text_center(filters_to_screen_options[i]..""..bank[i].id) else screen.text_center("("..filters_to_screen_options[i]..")") @@ -919,6 +919,12 @@ function main_menu.init() screen.text_center(dots) screen.font_size(8) end + elseif menu == "save screen" then + screen.level(15) + screen.move(62,43) + screen.font_size(40) + screen.text_center("saved!") + screen.font_size(8) elseif menu == "load fail screen" then screen.level(15) screen.move(62,30) @@ -928,7 +934,7 @@ function main_menu.init() screen.font_size(15) screen.text_center("try another...") screen.font_size(8) - elseif menu == "save screen" then + elseif menu == "overwrite screen" then screen.level(15) screen.move(62,15) screen.font_size(10) @@ -942,16 +948,37 @@ function main_menu.init() screen.text_center("K2 or K3 to cancel") end screen.font_size(8) - elseif menu == "canceled screen" then + elseif menu == "delete screen" then + screen.level(15) + screen.move(62,15) + screen.font_size(10) + screen.text_center("deleting collection") + screen.font_size(40) + screen.move(62,50) + screen.text_center(dots) + screen.move(62,64) + screen.font_size(10) + if dots ~= "deleted!" then + screen.text_center("K2 or K3 to cancel") + end + screen.font_size(8) + elseif menu == "canceled overwrite screen" or menu == "canceled delete screen" then screen.level(15) screen.move(62,30) screen.font_size(20) - screen.text_center("save") + screen.text_center(menu == "canceled overwrite screen" and "overwrite" or "delete") screen.move(62,50) screen.text_center("canceled") end end +function save_screen(text) + menu = "save screen" + named_savestate(text) + clock.sleep(0.75) + menu = 1 +end + function load_screen() dots = "..." menu = "load screen" @@ -979,9 +1006,9 @@ function load_fail_screen() end end -function save_screen(text) +function overwrite_screen(text) dots = "3" - menu = "save screen" + menu = "overwrite screen" clock.sleep(0.75) dots = "2" clock.sleep(0.75) @@ -994,7 +1021,27 @@ function save_screen(text) end function canceled_save() - menu = "canceled screen" + menu = "canceled overwrite screen" + clock.sleep(0.75) + menu = 1 +end + +function delete_screen(text) + dots = "3" + menu = "delete screen" + clock.sleep(0.75) + dots = "2" + clock.sleep(0.75) + dots = "1" + clock.sleep(0.75) + dots = "(x_x)" + clock.sleep(0.33) + named_delete(text) + menu = 1 +end + +function canceled_delete() + menu = "canceled delete screen" clock.sleep(0.75) menu = 1 end diff --git a/lib/zilchmos.lua b/lib/zilchmos.lua index 4260569..4c107a1 100755 --- a/lib/zilchmos.lua +++ b/lib/zilchmos.lua @@ -30,11 +30,11 @@ function zilchmos.init(k,i) local sc_action = z.actions[k][finger][2] -- here's where we call the action - --if grid.alt == 0 then - if not b.alt_lock and grid.alt == 0 then + --if not grid.alt then + if not b.alt_lock and not grid.alt then p_action( b[p] ) --trackers.inherit(which_bank,p) - elseif b.alt_lock or grid.alt == 1 then + elseif b.alt_lock or grid.alt then z.map( p_action, b ) -- or map it over the whole bank end if not b.focus_hold then @@ -68,7 +68,7 @@ function z.slew_add( pad ) z.slew( pad, "add" ) end -- core pad modifiers function zilchmos.level_inc( pad, delta ) - if not bank[which_bank].alt_lock and grid.alt == 0 then + if not bank[which_bank].alt_lock and not grid.alt then pad.level = util.clamp( pad.level + delta, 0, 2 ) else if pad.pad_id == 1 then -- only do this once...