]> Git — Sourcephile - tmp/julm/arpeggigon.git/blob - Reactogon/Translator/SortMessage.hs
Message sorting nearly finished.
[tmp/julm/arpeggigon.git] / Reactogon / Translator / SortMessage.hs
1 -- The idea is that the stream of data coming from the MIDI input port
2 -- will be sorted in three categories: note on events, controller
3 -- events and other events. The latter will be transmitted as is
4 -- through the whole systems.
5
6 module Reactogon.Translator.SortMessage where
7
8 import qualified Data.Bifunctor as BF
9 import Data.Maybe
10 import Reactogon.Semantics
11 import Reactogon.Translator.Message
12
13 -- TEMPORARY
14 data Control
15 --
16
17 sortRawMessages :: [RawMessage] -> ([Message], [RawMessage])
18 sortRawMessages = sortRawMessages' ([],[])
19 where sortRawMessages' r [] = r
20 sortRawMessages' (m, rm) (x:xs)
21 | isNothing nm = sortRawMessages' (m, x:rm) xs
22 | otherwise = sortRawMessages' ((fromJust nm) :m, rm) xs
23 where nm = fromRawMessage x
24
25 sortNotes :: [Message] -> ([Note], [Control])
26 sortNotes = undefined
27
28 sortMessages :: [RawMessage] -> ([Note], [Control], [RawMessage])
29 sortMessages = (\((a,b),c) -> (a,b,c)) . BF.first sortNotes . sortRawMessages
30
31 gatherMessages :: ([Note], [Control], [RawMessage]) -> [Message]
32 gatherMessages ([], [], []) = []
33 gatherMessages _ = undefined