]> Git — Sourcephile - tmp/julm/arpeggigon.git/blob - src/RMCA/Global/Clock.hs
Merge branch 'master' of gitlab.com:chupin/arpeggigon
[tmp/julm/arpeggigon.git] / src / RMCA / Global / Clock.hs
1 {-# LANGUAGE MultiParamTypeClasses #-}
2
3 module RMCA.Global.Clock ( AbsBeat
4 , maxAbsBeat
5 , metronome
6 , tempoToQNoteIvl
7 ) where
8
9 import FRP.Yampa
10 import RMCA.Auxiliary
11 import RMCA.Semantics
12
13 -- The absolute beat is the beat number of the global clock, there are
14 -- 16 starting from 1.
15 type AbsBeat = BeatNo
16
17 maxAbsBeat :: AbsBeat
18 maxAbsBeat = 16
19
20 -- The global system tempo beats every 16th note, each beat is tagged
21 -- with a beat number modulo sixteen. Each layer is then beating at
22 -- its own fraction, discarding the unecessary beats.
23 metronome :: SF Tempo (Event AbsBeat)
24 metronome = accumBy (\pb _ -> nextBeatNo maxAbsBeat pb) 1 <<<
25 repeatedlyS () <<^ (15*) <<^ (1/) <<^ fromIntegral
26
27 -- Tempo is the number of quarter notes per minute.
28 tempoToQNoteIvl :: Tempo -> DTime
29 tempoToQNoteIvl = (15/) . fromIntegral