]> Git — Sourcephile - tmp/julm/arpeggigon.git/blob - RCMA/Layer/Layer.hs
Moved Reactogon to RCMA.
[tmp/julm/arpeggigon.git] / RCMA / Layer / Layer.hs
1 {-# LANGUAGE Arrows #-}
2
3 module Reactogon.Layer.Layer where
4
5 import Reactogon.Semantics
6 import Reactogon.Layer.Board
7 import Reactogon.Global.Clock
8 import FRP.Yampa
9
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
16 }
17
18 layerTempo :: SF (Tempo, Layer) Tempo
19 layerTempo = proc (t, Layer { relTempo = r }) -> do
20 returnA -< floor $ r * fromIntegral t
21
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 })
27
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