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