]> Git — Sourcephile - tmp/julm/arpeggigon.git/blob - RCMA/Translator/Translator.hs
Translation from high to low level progressing. Should be finished soon.
[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.Semantics
8 import RCMA.Translator.Message
9 import RCMA.Translator.SortMessage
10
11 -- Uses function defined in SortMessage. This is a pure function and
12 -- it might not need to be a signal function.
13 readMessages :: [(Frames,RawMessage)]
14 -> ([(Frames,Note)], [(Frames,Controller)], [(Frames,RawMessage)])
15 readMessages = proc r -> do
16 (mes, raw) <- sortRawMessages -< r
17 (notes, ctrl) <- convertMessages <<< sortNotes -< mes
18 returnA -< (notes, ctrl, raw)
19
20 gatherMessages :: ([(Frames,Note)], [(Frames,Controller)], [(Frames,RawMessage)])
21 -> [(Frames, RawMessage)]
22 gatherMessages = proc (notes, ctrl, raw) -> do
23 rawNotes <- map (BF.second toRawMessage) -< notes
24 rawCtrl <- map (BF.second toRawMessage) -< ctrl
25 returnA -< rawNotes ++ rawCtrl ++ raw