@@ -45,7 +45,7 @@ instance Show O.UDP where
45
45
type TransitionMapper = P. Time -> [P. ControlPattern ] -> P. ControlPattern
46
46
47
47
data TempoAction =
48
- ResetCycles
48
+ SetCycle P. Time
49
49
| SingleTick P. ControlPattern
50
50
| SetNudge Double
51
51
| StreamReplace ID P. ControlPattern
@@ -76,8 +76,8 @@ data LinkOperations =
76
76
cyclesToBeat :: CDouble -> CDouble
77
77
}
78
78
79
- resetCycles :: MVar [TempoAction ] -> IO ()
80
- resetCycles actionsMV = modifyMVar_ actionsMV (\ actions -> return $ ResetCycles : actions)
79
+ setCycle :: P. Time -> MVar [TempoAction ] -> IO ()
80
+ setCycle cyc actionsMV = modifyMVar_ actionsMV (\ actions -> return $ SetCycle cyc : actions)
81
81
82
82
setNudge :: MVar [TempoAction ] -> Double -> IO ()
83
83
setNudge actionsMV nudge = modifyMVar_ actionsMV (\ actions -> return $ SetNudge nudge : actions)
@@ -209,20 +209,22 @@ clocked config stateMV mapMV actionsMV ac abletonLink
209
209
return $! st'
210
210
handleActions :: State -> [TempoAction ] -> P. ValueMap -> IO (State , P. ValueMap )
211
211
handleActions st [] streamState = return (st, streamState)
212
- handleActions st (ResetCycles : otherActions) streamState =
212
+ handleActions st (SetCycle cyc : otherActions) streamState =
213
213
do
214
214
(st', streamState') <- handleActions st otherActions streamState
215
215
sessionState <- Link. createAndCaptureAppSessionState abletonLink
216
216
217
217
now <- Link. clock abletonLink
218
218
let startAt = now + processAhead
219
- Link. requestBeatAtTime sessionState 0 startAt quantum
219
+ beat = (fromRational cyc) * (cBeatsPerCycle config)
220
+ Link. requestBeatAtTime sessionState beat startAt quantum
220
221
Link. commitAndDestroyAppSessionState abletonLink sessionState
222
+
221
223
222
224
let st'' = st' {
223
225
ticks = 0 ,
224
226
start = now,
225
- nowArc = P. Arc 0 0
227
+ nowArc = P. Arc cyc cyc
226
228
}
227
229
228
230
return (st'', streamState')
0 commit comments