]> Git — Sourcephile - tmp/julm/arpeggigon.git/blob - RCMA/Translator/Note.hs
Translation from high to low level progressing. Should be finished soon.
[tmp/julm/arpeggigon.git] / RCMA / Translator / Note.hs
1 {-# LANGUAGE Arrows #-}
2
3 module RCMA.Translator.Note where
4
5 import Data.Ratio
6 import FRP.Yampa
7 import RCMA.Global.Clock
8 import RCMA.Layer.Layer
9 import RCMA.Semantics
10 import RCMA.Translator.Message
11
12 messageToNote :: Message -> Note
13 messageToNote (NoteOn _ p s) = Note { notePch = p
14 , noteStr = s
15 , noteDur = 1 % 4
16 , noteOrn = noOrn
17 }
18
19 -- noteToMessage gives a pair of two time-stamped messages. The one on
20 -- the left is a note message, the other a note off.
21 --
22 -- For now this is only a tuple but a list will probably be necessary.
23 noteToMessages :: Tempo -> Layer -> Int -> (Time,Note)
24 -> ((Time,Message),(Time,Message))
25 noteToMessages tempo l@(Layer { relTempo = rt }) chan =
26 proc m@(t,n@Note { notePch = p
27 , noteStr = s
28 , noteDur = d
29 , noteOrn = noOrn
30 }) -> do
31 nm <- noteOnToMessage l chan -< n
32 t' <- returnA -< t + fromRational $ d * tempoToDTime $ rt * fromIntegral tempo
33 returnA -< ((t,nm),(t',switchOnOff nm))
34
35 noteOnToMessage :: Int -> Note -> Message
36 noteOnToMessage c (Note { notePch = p
37 , noteStr = s
38 }) = NoteOn (makeChannel c) p s
39
40 convertControl :: Message -> Controller
41 convertControl _ = Lol