Skip to content

Commit

Permalink
fixes + additions
Browse files Browse the repository at this point in the history
- addresses #32 by naming clocks and providing a management system (k1 + k2 to reset all, k1+k3 to reset selected)
- added "sync bpm to free pats?" parameter which allows any free pattern to sync the bpm
- added a `.name` attribute to pattern_time, so I can track which pattern clock is being synced to
- fixed persistent state PARAMS, so they all load/save correctly between sessions/changes
- added "link all" feature to [delay] where all params inside of a delay menu can be linked with k1+k3
- reversing delay linked rates now works
- changed around some of the [loops] UI for better conceptual flow
- grid arps no longer auto-trigger when on the arps page
- current collection is displayed on main menu screen
  • Loading branch information
dndrks committed Sep 27, 2020
1 parent 8036b36 commit a31a84f
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 594 deletions.
616 changes: 89 additions & 527 deletions cheat_codes.lua

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion lib/cc_pattern_time.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local pattern = {}
pattern.__index = pattern

--- constructor
function pattern.new()
function pattern.new(id)
local i = {}
setmetatable(i, pattern)
i.rec = 0
Expand All @@ -28,6 +28,7 @@ function pattern.new()
i.clock_time = 4
i.rec_clock = nil
i.mode = "unquantized"
i.name = id

i.metro = metro.init(function() i:next_event() end,1,1)

Expand Down Expand Up @@ -96,6 +97,9 @@ function pattern:rec_stop()
self:calculate_quantum(i)
end
self:calculate_duration()
if self.playmode == 1 then
sync_clock_to_loop(self,"pattern")
end
--tab.print(self.time)
else
print("no events recorded")
Expand Down
17 changes: 17 additions & 0 deletions lib/delay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ function delays.init(target)
delay[i].selected_bundle = 0
delay[i].wobble_hold = false
delay[i].reverse = false
-- delay[i].external_left = false
-- delay[i].external_right = false
end

delay_links = {{}}
Expand Down Expand Up @@ -107,6 +109,18 @@ function delays.links(prm)
end
end

function delays.link_all(k)
local prms =
{
[1] = {"mode",delay[1].mode == "clocked" and "div/mult" or "free length","fade time","rate","feedback"},
[2] = {"filter cut","filter q","filter lp","filter hp","filter bp","filter dry"},
[3] = {"level1","level2","level3","thur1","thru2","thru3","global level"}
}
for i = 1,#prms[k] do
delay_links[delays.lookup_prm(k,i)] = not delay_links[delays.lookup_prm(k,i)]
end
end

function delays.build_bundle(target,slot)
-- delay[target].saver_active = true -- declare this external to the function
clock.sleep(1)
Expand Down Expand Up @@ -243,6 +257,9 @@ function delays.quick_action(target,param,state)
softcut.level(target+4,params:get(target == 1 and "delay L: global level" or "delay R: global level"))
elseif param == "reverse" then
delay[target].reverse = not delay[target].reverse
if delay_links["rate"] then
delay[target == 1 and 2 or 1].reverse = delay[target].reverse
end
local rate = {"delay L: rate", "delay R: rate"}
softcut.rate(target+4,params:get(rate[target])*(delay[target].reverse and -1 or 1))
end
Expand Down
15 changes: 4 additions & 11 deletions lib/encoder_actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function encoder_actions.init(n,d)
end
end
else
if page.loops_view[id] == 2 then
if page.loops_view[id] ~= 1 then
ea.change_buffer(rec,d)
else
ea.move_rec_window(rec,d)
Expand Down Expand Up @@ -111,7 +111,7 @@ function encoder_actions.init(n,d)
if page.loops_view[id] == 3 then
params:delta("rec_loop",d)
elseif page.loops_view[id] == 2 then
params:delta("live_buff_rate",d)
params:delta("random_rec_clock_prob",d)
elseif page.loops_view[id] == 1 then
local lbr = {1,2,4}
local res;
Expand Down Expand Up @@ -264,10 +264,10 @@ function encoder_actions.init(n,d)
end
elseif id == 4 then
if page.loops_view[id] == 3 then
params:delta("random_rec_clock_prob",d)
params:delta("live_buff_rate",d)
elseif page.loops_view[id] == 2 then
params:delta("live_rec_feedback",d)
else
elseif page.loops_view[id] == 1 then
local lbr = {1,2,4}
local res;
if params:get("rec_loop_enc_resolution") == 1 then
Expand Down Expand Up @@ -971,17 +971,10 @@ end

function ea.delta_delay_param(target,prm,d)
params:delta("delay "..target..": "..prm,d)
-- ea.check_delay_links(target, target == "L" and "R" or "L",prm)
end

function ea.set_delay_param(target,prm,val)
params:set("delay "..target..": "..prm,val)
-- ea.check_delay_links(target, target == "L" and "R" or "L",prm)
end

function ea.change_filter_q(target,d)

-- softcut.post_filter_rq(n+1,bank[n][bank[n].id].q)
end

return encoder_actions
27 changes: 16 additions & 11 deletions lib/euclid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,12 @@ end

function euclid.init()

euclid.reset = false
-- euclid.reset = false
euclid.alt = false
euclid.running = false
euclid.track_edit = 1
euclid.current_pattern = 0
euclid.clock_div = {1/2,1/2,1/2}
-- euclid.clock =
-- { clock.run(euclid.step,1)
-- , clock.run(euclid.step,2)
-- , clock.run(euclid.step,3)
-- }
euclid.screen_focus = "left"

euclid.track = {}
Expand All @@ -56,9 +51,17 @@ function euclid.init()
mode = "single",
clock_div = 1/2
}
clock.run(euclid.step,i)
-- clock.run(euclid.step,i)
end

euclid.clock =
{ clock.run(euclid.step,1)
, clock.run(euclid.step,2)
, clock.run(euclid.step,3)
}

euclid.reset = { false, false, false}

euclid.pattern = {}
for i = 1,112 do
euclid.pattern[i] = {
Expand All @@ -76,10 +79,12 @@ function euclid.init()

end

function euclid.reset_pattern()
euclid.reset = true
for i=1,3 do euclid.track[i].pos = 0 end
euclid.reset = false
function euclid.reset_pattern(target)
euclid.reset[target] = true
clock.cancel(euclid.clock[target])
euclid.track[target].pos = 0
euclid.reset[target] = false
euclid.clock[target] = clock.run(euclid.step,target)
end

function euclid.step(target)
Expand Down
38 changes: 8 additions & 30 deletions lib/grid_actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,39 +58,13 @@ function grid_actions.init(x,y,z)
end
pad_clipboard = nil
if bank[i].quantize_press == 0 then
-- if (arp[i].hold or (menu == 9)) and grid_pat[i].rec == 0 and not arp[i].pause then
if (arp[i].enabled or (menu == 9)) and grid_pat[i].rec == 0 and not arp[i].pause then
-- if (arp[i].enabled or (menu == 9)) and grid_pat[i].rec == 0 and not arp[i].pause then
if arp[i].enabled and grid_pat[i].rec == 0 and not arp[i].pause then
arp[i].time = bank[i][bank[i].id].arp_time
arps.momentary(i, bank[i].id, "on")
else
cheat(i, bank[i].id)

grid_pattern_watch(i)

--[==[
grid_p[i] = {}
grid_p[i].action = "pads"
grid_p[i].i = i
grid_p[i].id = selected[i].id
grid_p[i].x = selected[i].x
grid_p[i].y = selected[i].y
grid_p[i].rate = bank[i][bank[i].id].rate
grid_p[i].start_point = bank[i][bank[i].id].start_point
grid_p[i].end_point = bank[i][bank[i].id].end_point
grid_p[i].rate_adjusted = false
grid_p[i].loop = bank[i][bank[i].id].loop
grid_p[i].pause = bank[i][bank[i].id].pause
grid_p[i].mode = bank[i][bank[i].id].mode
grid_p[i].clip = bank[i][bank[i].id].clip
--[[
if grid_pat[i].rec == 1 and grid_pat[i].count == 0 then
print("grid happening")
clock.run(synced_pattern_record,grid_pat[i])
end
--]]
grid_pat[i]:watch(grid_p[i])
--]==]

end
else
table.insert(quantize_events[i],selected[i].id)
Expand Down Expand Up @@ -231,6 +205,9 @@ function grid_actions.init(x,y,z)
if grid_pat[i].mode ~= "quantized" then
--grid_pat[i]:start()
start_pattern(grid_pat[i])
--TODO: CONFIRM THIS IS OK...
elseif grid_pat[i].mode == "quantized" then
start_pattern(grid_pat[i])
end
grid_pat[i].loop = 1
elseif grid_pat[i].count == 0 then
Expand Down Expand Up @@ -554,8 +531,9 @@ function grid_actions.init(x,y,z)
if step_seq[current].held == 0 then
if pattern_saver[math.floor(x/5)+1].clock then
clock.cancel(pattern_saver[math.floor(x/5)+1].clock)
clock.cancel(pattern_saver[math.floor(x/5)+1].clock-1)
clock.cancel(pattern_saver[math.floor(x/5)+1].clock-2)
-- TODO: FIX THIS OVERWRITING...
-- clock.cancel(pattern_saver[math.floor(x/5)+1].clock-1)
-- clock.cancel(pattern_saver[math.floor(x/5)+1].clock-2)
-- print("killing save "..pattern_saver[math.floor(x/5)+1].clock)
end
pattern_saver[math.floor(x/5)+1].active = false
Expand Down
33 changes: 26 additions & 7 deletions lib/main_menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,18 @@ function main_menu.init()
}
screen.text(page.main_sel == i and (">"..options[i]) or options[i])
end
screen.move(128,10)
screen.move(128,selected_coll ~= 0 and 20 or 10)
screen.level(3)
local target = midi_dev[params:get("midi_control_device")]
if target.device ~= nil and target.device.port == params:get("midi_control_device") and params:get("midi_control_enabled") == 2 then
screen.text_right("("..util.trim_string_to_width(target.device.name,70)..")")
elseif target.device == nil and params:get("midi_control_enabled") == 2 then
screen.text_right("no midi device!")
screen.text_right("(no midi device!)")
end
if selected_coll ~= 0 then
screen.move(128,10)
screen.level(3)
screen.text_right("["..util.trim_string_to_width(selected_coll,70).."]")
end
elseif menu == 2 then

Expand Down Expand Up @@ -212,8 +217,7 @@ function main_menu.init()
screen.move(0,62)
screen.text("L"..rec.clip)
screen.move(15,62)
local rate_options = {"8s","16s","32s"}
screen.text("total: "..rate_options[params:get"live_buff_rate"])
screen.text("rnd: "..params:get("random_rec_clock_prob").."%")
screen.move(65,62)
-- screen.text("offset: "..string.format("%.0f",((math.log(rec.rate_offset)/math.log(0.5))*-12)).." st")
screen.text("fb: "..string.format("%0.f",params:get("live_rec_feedback")*100).."%")
Expand All @@ -226,8 +230,12 @@ function main_menu.init()
screen.move(15,62)
local loop_options = {"loop","shot"}
screen.text("mode: "..loop_options[params:get("rec_loop")])
screen.move(70,62)
screen.text("rnd prob: "..params:get("random_rec_clock_prob").."%")
screen.move(65,62)
local rate_options = {"8s","16s","32s"}
screen.text("time: "..rate_options[params:get"live_buff_rate"])
screen.move(105,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

elseif menu == 3 then
Expand Down Expand Up @@ -415,6 +423,17 @@ function main_menu.init()
screen.font_size(8)
screen.text("linked")
end
elseif page.delay_section == 1 then
if key1_hold then
screen.font_size(8)
if page.delay[page.delay_focus].menu ~= 3 then
screen.move(0,60)
screen.text("K3: toggle all links")
else
screen.move(128,10)
screen.text_right("K3: toggle all links")
end
end
end
screen.font_size(8)
local options = {"ctl","flt","mix"}
Expand Down Expand Up @@ -704,7 +723,7 @@ function main_menu.init()
screen.text_center(rytm.track[i].n)

for x = 1,rytm.track[i].n do
screen.level((rytm.track[i].pos == x and not rytm.reset) and 15 or 2)
screen.level((rytm.track[i].pos == x and not rytm.reset[i]) and 15 or 2)
screen.move(x*4 + 30, i*12 + 20)
if rytm.track[i].s[x] then
screen.line_rel(0,-8)
Expand Down
17 changes: 10 additions & 7 deletions lib/start_up.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ function start_up.init()
params:add{id="live_rec_feedback", name="live rec feedback", type="control",
controlspec=controlspec.new(0,1.0,'lin',0,0.25,""),
action=function(x)
if rec.state == 1 then
-- if rec.state == 1 then
softcut.pre_level(1,x)
end
-- end
end}

params:add_option("live_buff_rate", "live buffer max", {"8 sec", "16 sec", "32 sec"}, 1)
Expand Down Expand Up @@ -181,10 +181,16 @@ function start_up.init()

--params:add_option("zilchmo_bind_rand","bind random zilchmo?", {"no","yes"}, 1)

params:add_group("grid/arc pattern params",16)
params:add_separator("grid")
params:add_group("grid/arc pattern params",18)
params:add_separator("patterns")
params:add_option("zilchmo_patterning", "grid pat style", { "classic", "rad sauce" })
params:set_action("zilchmo_patterning", function() if all_loaded then persistent_state_save() end end)
params:add_option("arc_patterning", "arc pat style", { "passive", "active" })
params:set_action("arc_patterning", function() if all_loaded then persistent_state_save() end end)
for i = 1,3 do
params:add_option("sync_clock_to_pattern_"..i, "sync bpm to free pat "..i.."?", { "no", "yes" })
params:set_action("sync_clock_to_pattern_"..i, function() if all_loaded then persistent_state_save() end end)
end
params:add_separator("quantization")
for i = 1,3 do
params:add_option("pattern_"..i.."_quantization", "quantize pat "..i.."?", {"no", "yes"})
Expand Down Expand Up @@ -224,9 +230,6 @@ function start_up.init()
params:add_option("rand_pattern_"..i.."_note_length", "rand pat "..i.." note length", {"1/16", "1/8", "1/4", "1/2", "1", "rand"},6)
end

params:add_separator("arc")
params:add_option("arc_patterning", "arc pat style", { "passive", "active" })

params:add_group("manual control params",34)

params:add_separator("arc encoders")
Expand Down

0 comments on commit a31a84f

Please sign in to comment.