From 81c19870a81294e4b5def9cdc24365fa0b23e726 Mon Sep 17 00:00:00 2001 From: polymorphicengine Date: Tue, 18 Jun 2024 23:41:12 +0200 Subject: [PATCH] use setTempoCPS for instant cps change instead of setCPS --- src/Sound/Tidal/Stream/Process.hs | 2 +- tidal-link/src/hs/Sound/Tidal/Clock.hs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Sound/Tidal/Stream/Process.hs b/src/Sound/Tidal/Stream/Process.hs index 0053a491..eb6927bd 100644 --- a/src/Sound/Tidal/Stream/Process.hs +++ b/src/Sound/Tidal/Stream/Process.hs @@ -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 diff --git a/tidal-link/src/hs/Sound/Tidal/Clock.hs b/tidal-link/src/hs/Sound/Tidal/Clock.hs index 2e7f1f17..97dbd133 100644 --- a/tidal-link/src/hs/Sound/Tidal/Clock.hs +++ b/tidal-link/src/hs/Sound/Tidal/Clock.hs @@ -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)