diff --git a/BootTidal.hs b/BootTidal.hs index dfc574f00..49194c2af 100644 --- a/BootTidal.hs +++ b/BootTidal.hs @@ -6,7 +6,7 @@ import Sound.Tidal.Context import System.IO (hSetEncoding, stdout, utf8) hSetEncoding stdout utf8 -tidal <- startTidal (superdirtTarget {oLatency = 0.1, oAddress = "127.0.0.1", oPort = 57120}) (defaultConfig {cVerbose = True, cFrameTimespan = 1/20}) +tidal <- startTidal (superdirtTarget {oLatency = 0.05, oAddress = "127.0.0.1", oPort = 57120}) (defaultConfig {cVerbose = True, cFrameTimespan = 1/20}) :{ let only = (hush >>) diff --git a/src/Sound/Tidal/Config.hs b/src/Sound/Tidal/Config.hs index 7fac843c2..c9d2e9f00 100644 --- a/src/Sound/Tidal/Config.hs +++ b/src/Sound/Tidal/Config.hs @@ -45,7 +45,7 @@ defaultConfig = Config {cCtrlListen = True, cCtrlBroadcast = False, cFrameTimespan = 1/20, cEnableLink = True, - cProcessAhead = 1/4, + cProcessAhead = 3/10, cTempoAddr = "127.0.0.1", cTempoPort = 9160, cTempoClientPort = 0, -- choose at random diff --git a/src/Sound/Tidal/Stream.hs b/src/Sound/Tidal/Stream.hs index 6044fccdf..db9577e2d 100644 --- a/src/Sound/Tidal/Stream.hs +++ b/src/Sound/Tidal/Stream.hs @@ -551,19 +551,20 @@ setPreviousPatternOrSilence stream = -- Send events live by delaying the thread send :: Maybe O.UDP -> Cx -> Double -> Double -> (Double, Bool, O.Message) -> IO () send listen cx latency extraLatency (time, isBusMsg, m) - | oSchedule target == Pre BundleStamp = sendBndl isBusMsg listen cx $ O.Bundle (time + extraLatency) [m] + | oSchedule target == Pre BundleStamp = sendBndl isBusMsg listen cx $ O.Bundle timeWithLatency [m] | oSchedule target == Pre MessageStamp = sendO isBusMsg listen cx $ addtime m | otherwise = do _ <- forkOS $ do now <- O.time - threadDelay $ floor $ (time - now - latency + extraLatency) * 1000000 + threadDelay $ floor $ (timeWithLatency - now) * 1000000 sendO isBusMsg listen cx m return () where addtime (O.Message mpath params) = O.Message mpath ((O.int32 sec):((O.int32 usec):params)) - ut = O.ntpr_to_ut (time + extraLatency) + ut = O.ntpr_to_ut timeWithLatency sec :: Int sec = floor ut usec :: Int usec = floor $ 1000000 * (ut - (fromIntegral sec)) target = cxTarget cx + timeWithLatency = time - latency + extraLatency -- Interaction