1 {-# LANGUAGE Arrows #-}
3 module RMCA.Layer.Board where
7 import RMCA.Layer.Layer
10 data BoardRun = BoardStart | BoardStop deriving Eq
12 singleBoard :: [PlayHead]
13 -> SF (Board, Layer, Event BeatNo) (Event ([PlayHead], [Note]))
14 singleBoard iPh = proc (board, Layer { relPitch = rp
17 accumBy advanceHeads' (iPh,[]) -< ebno `tag` (board, fromEvent ebno, rp, s)
18 where advanceHeads' (ph,_) (board,bno,rp,s) = uncurry5 advanceHeads (board,bno,rp,s,ph)
20 boardSF :: SF (Board, Layer, Tempo, BoardRun) (Event ([PlayHead], [Note]))
21 boardSF = proc (board, l, t, br) -> do
22 ebno <- layerMetronome -< (t,l)
24 boardSwitch [] -< ((board, l, ebno), ess `tag` (br, startHeads board))
26 boardSwitch :: [PlayHead]
27 -> SF ((Board, Layer,Event BeatNo), Event (BoardRun, [PlayHead]))
28 (Event ([PlayHead],[Note]))
29 boardSwitch rPh = dSwitch (singleBoard rPh *** (identity >>> notYet)) fnSwitch
30 where fnSwitch (BoardStart, iPh) = boardSwitch iPh
31 fnSwitch (BoardStop, _) = boardSwitch []