1 {-# LANGUAGE Arrows #-}
3 module RCMA.Layer.Layer where
6 import RCMA.Global.Clock
9 -- Data representing the state of a layer. It is updated continuously.
10 data Layer = Layer { relTempo :: Double
11 , relPitch :: RelPitch
12 , strength :: Strength
13 , beatsPerBar :: BeatsPerBar
14 , beatCounter :: BeatNo
17 layerTempo :: SF (Tempo, Layer) Tempo
18 layerTempo = proc (t, Layer { relTempo = r }) -> do
19 returnA -< floor $ r * fromIntegral t
21 -- The layer is modified after the beat as been
22 layerMetronome :: SF (Tempo, Layer) (Event (BeatNo, Layer))
23 layerMetronome = proc (t, l@Layer { beatCounter = b , beatsPerBar = bpb}) -> do
24 eb <- metronome <<< layerTempo -< (t, l)
25 returnA -< eb `tag` let nb = nextBeatNo b bpb in (nb, l { beatCounter = nb })
27 -- A layer is a producer of events triggered by the system beat clock.
28 layer :: SF () (Event Beat) -> SF Layer (Event Note)
29 layer beatSource = undefined