1 module Reactogon.Global.Clock where
3 import Reactogon.Auxiliary.Auxiliary
4 import Reactogon.Semantics
9 tempo :: Tempo -> SF () Tempo
12 -- The initial value is arbitrary but never appears because the switch
14 metronome :: SF () Tempo -> SF () (Event Beat)
15 metronome tempo = switch ((repeatedly (tempoToDTime 60) ())
17 (discard ^>> tempo >>> onChange')) (metronome' tempo)
18 where metronome' :: SF () Tempo -> Tempo -> SF () (Event Beat)
19 metronome' tempo t = (switch ((repeatedly (tempoToDTime t) ())
21 (discard ^>> tempo >>> onChange))
24 tempoToDTime :: Tempo -> DTime
25 tempoToDTime = (60/) . fromIntegral