Skip to content

Commit

Permalink
Clear colored pads when changing key center
Browse files Browse the repository at this point in the history
  • Loading branch information
jmiskovic committed Apr 13, 2022
1 parent 812eff1 commit bac9083
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions patches/wurl/wurl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ local colorScheme = {
}

local keyCenter = 0
local keycenter_treshold = 0.9 -- how much of X tilt is needed for key center selection
local noteTracker = {} -- seconds since last note trigger, across octaves
local noteOctaveTracker = {10,10,10,10,10,10,10,10,10,10,10,10} -- seconds since last note trigger, flattened to single octave
noteOctaveTracker[0] = 10


function patch.load()
local self = setmetatable({}, patch)

Expand Down Expand Up @@ -82,8 +82,8 @@ function patch.drawCell(self, q, r, s, touch)
local noteDecay = 10
local ch, cs, cl

if s.tilt[1] > .9 and note ~= keyCenter then
ch, cs, cl = .0, .1, 0.9
if s.tilt[1] > keycenter_treshold and note ~= keyCenter then
ch, cs, cl = .1, .1, 0.9
else
ch, cs = nh, ns
cl = l.remap(noteTime, noteDecay * 0.9, noteDecay, nl, 1, 'clamp')
Expand All @@ -109,7 +109,7 @@ function patch.drawCell(self, q, r, s, touch)
scl = l.remap(noteTime, 0, 0.1, 0.6, scl, 'clamp')
--love.graphics.rotate(ampl * math.sin(freq * noteTime))
love.graphics.scale(scl)
love.graphics.circle('fill', 0, 0, 0.93, 6) --love.mouse.getY() / love.graphics.getHeight() * 2
love.graphics.circle('fill', 0, 0, 0.93, 6)
love.graphics.pop()
if self.displayNoteNames then
-- note name text
Expand All @@ -131,10 +131,15 @@ function patch:process(s)
noteOctaveTracker[touch.note % 12] = 0
noteTracker[touch.note] = 0
end
if s.tilt[1] > .9 then
if s.tilt[1] > keycenter_treshold then
keyCenter = touch.note or 0
end
end
if s.tilt[1] > keycenter_treshold then
for i = 0, #noteOctaveTracker do
noteOctaveTracker[i] = 10
end
end

self.efx.tremolo.frequency = l.remap(s.tilt.lp[1], -0.2, 0.2, 0, 5, 'clamp')
self.sampler.envelope.attack = l.remap(s.tilt.lp[2], -.1, -0.3, 0, 0.8, 'clamp')
Expand Down

0 comments on commit bac9083

Please sign in to comment.