Skip to content

Commit

Permalink
use setTempoCPS for instant cps change instead of setCPS
Browse files Browse the repository at this point in the history
  • Loading branch information
polymorphicengine committed Jun 18, 2024
1 parent f237849 commit 81c1987
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Sound/Tidal/Stream/Process.hs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ processCps cconf cref ss = mapM processEvent
onPart <- Clock.timeAtBeat cconf ss partStartBeat
when (eventHasOnset e) (do
let cps' = Map.lookup "cps" (value e) >>= getF
maybe (return ()) (\newCps -> Clock.setCPS cconf cref newCps) (fmap toRational cps')
maybe (return ()) (\newCps -> Clock.setTempoCPS newCps on cconf ss) (fmap toRational cps')
)
off <- Clock.timeAtBeat cconf ss offBeat
bpm <- Clock.getTempo ss
Expand Down
3 changes: 3 additions & 0 deletions tidal-link/src/hs/Sound/Tidal/Clock.hs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ getZeroedSessionState config (ClockRef _ abletonLink) = do
getTempo :: Link.SessionState -> IO Time
getTempo ss = fmap toRational $ Link.getTempo ss

setTempoCPS :: Time -> Link.Micros -> ClockConfig -> Link.SessionState -> IO ()
setTempoCPS cps now conf ss = Link.setTempo ss (coerce $ cyclesToBeat conf ((fromRational cps) * 60)) now

timeAtBeat :: ClockConfig -> Link.SessionState -> Double -> IO Link.Micros
timeAtBeat config ss beat = Link.timeAtBeat ss (coerce beat) (cQuantum config)

Expand Down

0 comments on commit 81c1987

Please sign in to comment.