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