]> Git — Sourcephile - tmp/julm/arpeggigon.git/blob - Reactogon/Global/Clock.hs
Update README.md
[tmp/julm/arpeggigon.git] / Reactogon / Global / Clock.hs
1 module Reactogon.Global.Clock where
2
3 import Reactogon.Auxiliary.Auxiliary
4 import Reactogon.Semantics
5 import FRP.Yampa
6
7 import Debug.Trace
8
9 tempo :: Tempo -> SF () Tempo
10 tempo = constant
11
12 -- The initial value is arbitrary but never appears because the switch
13 -- is immediate.
14 metronome :: SF () Tempo -> SF () (Event Beat)
15 metronome tempo = switch ((repeatedly (tempoToDTime 60) ())
16 &&&
17 (discard ^>> tempo >>> onChange')) (metronome' tempo)
18 where metronome' :: SF () Tempo -> Tempo -> SF () (Event Beat)
19 metronome' tempo t = (switch ((repeatedly (tempoToDTime t) ())
20 &&&
21 (discard ^>> tempo >>> onChange))
22 (metronome' tempo))
23
24 tempoToDTime :: Tempo -> DTime
25 tempoToDTime = (60/) . fromIntegral