Skip to content

Commit

Permalink
Merge pull request #17 from dndrks/loops-ui
Browse files Browse the repository at this point in the history
beta3
  • Loading branch information
dndrks authored Sep 1, 2020
2 parents 6707599 + c69c143 commit a754530
Show file tree
Hide file tree
Showing 11 changed files with 2,272 additions and 1,661 deletions.
2,385 changes: 1,359 additions & 1,026 deletions cheat_codes.lua

Large diffs are not rendered by default.

93 changes: 60 additions & 33 deletions lib/arc_actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ 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 not grid.alt then
if arc_param[n] ~= 4 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
else
elseif this_bank.alt_lock or grid.alt then
if arc_param[n] ~= 4 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
Expand All @@ -37,9 +37,7 @@ 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()
end
Expand Down Expand Up @@ -69,6 +67,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
Expand All @@ -79,52 +78,72 @@ 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.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
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.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

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.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)
end

end

function aa.change_tilt(target, delta, enc)
Expand All @@ -149,7 +168,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 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
else
target.level = util.clamp(target.level + delta/1000,0,2)
end
end

function aa.sc.move_window(enc, target)
Expand All @@ -174,7 +199,9 @@ function aa.sc.change_pan(enc, target)
end

function aa.sc.change_level(enc, target)
softcut.level(enc+1,target.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 =
Expand Down
10 changes: 5 additions & 5 deletions lib/arp_actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 34 additions & 17 deletions lib/delay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -120,24 +121,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
Expand Down Expand Up @@ -167,15 +168,23 @@ 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 not pad.enveloped then
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.enveloped 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)
Expand Down Expand Up @@ -205,7 +214,11 @@ 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))
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]
Expand All @@ -214,7 +227,11 @@ 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))
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
Expand Down Expand Up @@ -267,7 +284,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

Expand All @@ -282,8 +299,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]))
Expand All @@ -293,20 +310,20 @@ 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

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)
Expand Down
Loading

0 comments on commit a754530

Please sign in to comment.