Skip to content

Commit

Permalink
Fix crash due to too many active effects
Browse files Browse the repository at this point in the history
This is just a hot fix, proper code design not included.
  • Loading branch information
jmiskovic committed Mar 16, 2021
1 parent 40504d5 commit 55015a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
15 changes: 4 additions & 11 deletions efx.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ local defaults = {
}
}


function efx.load()
function efx.load(trackName)
local self = setmetatable({}, efx)
self.uuid = l.uuid()
self.trackName = trackName or 'live'
for name, params in pairs(defaults) do
self[name] = {}
for param, value in pairs(params) do
Expand All @@ -69,18 +68,12 @@ end


function efx:effectName(effect)
return self.uuid .. '_' .. effect.type
return self.trackName .. '_' .. effect.type
end


function efx:addEffect(effect)
-- some platforms don't have all effects, ignore request if not available
local ok, result = pcall(love.audio.setEffect, self:effectName(effect), effect)
if ok then
table.insert(self.activeEffects, effect)
else log(err)
end
return ok
table.insert(self.activeEffects, effect)
end


Expand Down
4 changes: 4 additions & 0 deletions recorder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ end
function recorder.patchChanged(patch)
if recorder.state ~= states.off then
recorder.currentPatch = patch.load()
if recorder.currentPatch.efx then
recorder.currentPatch.efx.trackName = 'staging'
end
end
end

Expand Down Expand Up @@ -143,6 +146,7 @@ function tape:interpret(s, inSelector)
self.doneRecording = true
self.endTime = recorder.time
self.patch = recorder.currentPatch
self.patch.efx.trackName = 'track1'
self.patch:process(s) -- update efx parameters with current tilt
love.audio.stop() -- process() triggers samples, kill them
-- find all samplers used by patch, to be used for playback
Expand Down

0 comments on commit 55015a2

Please sign in to comment.