]> Git — Sourcephile - tmp/julm/arpeggigon.git/blob - RCMA/Translator/Translator.hs
High to low level translation implemented for notes.
[tmp/julm/arpeggigon.git] / RCMA / Translator / Translator.hs
1 {-# LANGUAGE Arrows #-}
2
3 module RCMA.Translator.Translator where
4
5 import qualified Data.Bifunctor as BF
6 import FRP.Yampa
7 import RCMA.Auxiliary.Curry
8 import RCMA.Layer.Layer
9 import RCMA.Semantics
10 import RCMA.Translator.Clock
11 import RCMA.Translator.Controller
12 import RCMA.Translator.Message
13 import RCMA.Translator.Note
14 import RCMA.Translator.SortMessage
15
16 -- Uses function defined in SortMessage. This is a pure function and
17 -- it might not need to be a signal function.
18 readMessages :: [(Frames,RawMessage)]
19 -> ([(Frames,Note)], [(Frames,Controller)], [(Frames,RawMessage)])
20 readMessages = proc r -> do
21 (mes, raw) <- sortRawMessages -< r
22 (notes, ctrl) <- convertMessages <<< sortNotes -< mes
23 returnA -< (notes, ctrl, raw)
24
25 gatherMessages :: LTempo
26 -> SampleRate
27 -> Int
28 -> ([(Frames,Note)],[(Frames,Controller)],[(Frames,RawMessage)])
29 -> [(Frames, RawMessage)]
30 gatherMessages layTempo sr chan = proc (notes, ctrl, raw) -> do
31 notes' <- concat <<< map (noteToMessages layTempo sr chan) -< notes
32 ctrl' <- map (BF.second controllerToMessages) -< ctrl
33 rawNotes <- map (BF.second toRawMessage) -< notes'
34 rawCtrl <- map (BF.second toRawMessage) -< ctrl'
35 returnA -< rawNotes ++ rawCtrl ++ raw