Sorry in case I have a wrong understanding how lattice should work …
@alanza
What i observed was that the transport
received in the actions of individual sprockets did not match with the defined ppqn
and were offset by 2.
When reading through the source code (norns/lattice.lua at main · monome/norns · GitHub). I discovered that there is probably a bug in function Lattice:pulse()
. The incrementation of transport
is done within the loop which handles the ordering of sprockets, which leads to a transport value dependent on the defined sprocket order and is multiplied by 5.
--- advance all sprockets in this lattice a single by pulse, call this manually if lattice.auto = false
function Lattice:pulse()
if self.enabled then
local ppc = self.ppqn * 4 -- pulses per cycle; "4" because in music a "quarter note" == "1/4"
local flagged=false
for i = 1, 5 do
for _, id in ipairs(self.sprocket_ordering[i]) do
local sprocket = self.sprockets[id]
if sprocket.enabled then
sprocket.phase = sprocket.phase + 1
local swing_val = 2 * sprocket.swing / 100
if not sprocket.downbeat then
swing_val = 1
end
if sprocket.phase > sprocket.division * ppc * swing_val then
sprocket.phase = sprocket.phase - (sprocket.division * ppc)
if sprocket.delay_new ~= nil then
sprocket.phase = sprocket.phase - (sprocket.division * ppc) * (1 - (sprocket.delay - sprocket.delay_new))
sprocket.delay = sprocket.delay_new
sprocket.delay_new = nil
end
sprocket.action(self.transport)
sprocket.downbeat = not sprocket.downbeat
end
elseif sprocket.flag then
self.sprockets[sprocket.id] = nil
flagged = true
end
end
if flagged then
self:order_sprockets()
end
-- OLD CODE
-- self.transport = self.transport + 1
end
-- FIX
self.transport = self.transport + 1
end
end