Skip to content

Commit

Permalink
formatting and grid hold
Browse files Browse the repository at this point in the history
  • Loading branch information
schollz committed Dec 28, 2022
1 parent 985ea5f commit 9db77c4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 26 deletions.
17 changes: 7 additions & 10 deletions amenbreak.lua
Original file line number Diff line number Diff line change
Expand Up @@ -360,24 +360,24 @@ function toggle_clock(on)
d.gate=1
d.rate=1
d.pitch=0
if g_.d.ci>0 then
if g_.d.ci>0 then
d.ci=g_.d.ci
d.retrig=g_.d.retrig
d.steps=g_.d.steps
if d.retrig>0 then
if d.retrig>0 then
d.db=math.random(-2,2)
d.pitch=math.random(-1,1)
end
if g_.d.stretch>1 then
if g_.d.stretch>1 then
d.stretch=1
d.steps=g_.d.stretch-1
end
if g_.d.delay>1 then
if g_.d.delay>1 then
d.delay=1
d.gate=math.random(25,75)/100
-- d.steps=g_.d.delay-1
end
if g_.d.gate>1 then
if g_.d.gate>1 then
d.gate=(17-g_.d.gate)/17
print(d.gate)
-- d.steps=g_.d.delay-1
Expand Down Expand Up @@ -413,7 +413,7 @@ function toggle_clock(on)
if math.random()<easing_function2(params:get("amen"),-3.1,-1.3,0.177,0.5) then
d.rate=-1
end

-- calculate the next position
if d.beat%(track_beats*4)==0 then
d.ci=ws[params:get("track")]:random_kick_pos()
Expand All @@ -432,7 +432,7 @@ function toggle_clock(on)
-- do a jump
d.ci=d.ci+math.random(-1*track_beats,track_beats)
end
end
end
-- do a small retrig sometimes based on amen
local p=easing_function3(params:get("amen"),2.6,7.6,1.8,1.2)
if d.retrig==0 and math.random()<p then
Expand All @@ -445,9 +445,6 @@ function toggle_clock(on)
params:set_raw("track",math.random())
end
d_=d
if g_.d.ci~=0 then
g_.d.ci=0
end
end

if math.random()<easing_function2(params:get("amen"),1,0.3,0.044,0.72)/48 and params:get("tape_gate")==0 and debounce_fn["tape_gate"]==nil then
Expand Down
34 changes: 18 additions & 16 deletions lib/ggrid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function GGrid:new(args)
{5,11},
{5,13},
{6,15},
{6,17},
{6,17},
}
m.d={retrig=0,ci=0,steps=1,retrigi=1,stretch=1,delay=1,gate=1}
return m
Expand All @@ -72,7 +72,6 @@ function GGrid:grid_key(x,y,z)
self:grid_redraw()
end


function GGrid:key_press(row,col,on)
local ct=clock.get_beats()*clock.get_beat_sec()
hold_time=0
Expand All @@ -83,17 +82,21 @@ function GGrid:key_press(row,col,on)
self.pressed_buttons[row..","..col]=nil
end

if not on then
self.d.ci=0
do return end
end

if row<=2 and on then
if row<=2 and on then
self.d.ci=col+16*(row-1)
elseif row==STRETCH and on then
elseif row==STRETCH and on then
self.d.stretch=col
elseif row==DELAY and on then
elseif row==DELAY and on then
self.d.delay=col
elseif row==GATE and on then
elseif row==GATE and on then
self.d.gate=col
print(self.d.gate)
elseif row==RETRIG and on then
elseif row==RETRIG and on then
self.d.retrigi=col
self.d.steps=self.retrigs[self.d.retrigi][1]
self.d.retrig=self.retrigs[self.d.retrigi][2]
Expand All @@ -104,18 +107,18 @@ function GGrid:get_visual()
-- clear visual
for row=1,8 do
for col=1,self.grid_width do
if self.visual[row][col]>0 then
self.visual[row][col]=0
end
if self.visual[row][col]>0 then
self.visual[row][col]=0
end
end
end

if d_.ci~=nil then
if d_.ci~=nil then
local row=1
local col=d_.ci
while col>16 do
col=col-16
row=row+1
local col=d_.ci
while col>16 do
col=col-16
row=row+1
end
self.visual[row][col]=14
end
Expand All @@ -133,7 +136,6 @@ function GGrid:get_visual()
self.visual[row][col]=14
end


return self.visual
end

Expand Down

0 comments on commit 9db77c4

Please sign in to comment.