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