Skip to content

Commit

Permalink
fix for nudge - was filtering out nudged events that went outside the…
Browse files Browse the repository at this point in the history
… current frame
  • Loading branch information
yaxu committed Aug 26, 2019
1 parent 7574f3c commit 40ebcbc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Sound/Tidal/Stream.hs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ onTick config sMapMV pMV cxs tempoMV st =
filterOns | cSendParts config = id
| otherwise = filter eventHasOnset
-- there should always be a whole (due to the eventHasOnset filter)
on e tempo' = (sched tempo' $ start $ wholeOrPart e) + eventNudge e
on e tempo' = (sched tempo' $ start $ wholeOrPart e)
eventNudge e = fromJust $ getF $ fromMaybe (VF 0) $ Map.lookup "nudge" $ value e
processCps :: T.Tempo -> [Event ControlMap] -> ([(T.Tempo, Event ControlMap)], T.Tempo)
processCps tempo [] = ([], tempo)
Expand All @@ -219,12 +219,13 @@ onTick config sMapMV pMV cxs tempoMV st =
(es', tempo'') = processCps tempo' es
latency target = oLatency target + cFrameTimespan config + T.nudged tempo
(tes, tempo') = processCps tempo es
mapM_ (\(Cx target udp) -> (do let ms = catMaybes $ map (\(t, e) -> do m <- toMessage config (on e t + latency target) target tempo e
mapM_ (\(Cx target udp) -> (do let ms = catMaybes $ map (\(t, e) -> do let nudge = eventNudge e
let onset = on e t
m <- toMessage config (onset + nudge + latency target) target tempo e
-- drop events that have gone out of frame (due to tempo
-- changes during the frame)
if (onset < frameEnd)
then Just (onset, m)
then Just (onset + nudge, m)
else Nothing
) tes
E.catch (mapM_ (send target (latency target) udp) ms)
Expand Down

0 comments on commit 40ebcbc

Please sign in to comment.