1 {-# LANGUAGE Arrows #-}
3 module RMCA.Translator.Note where
7 import RMCA.Global.Clock
8 import RMCA.Layer.Layer
10 import RMCA.Translator.Message
12 messageToNote :: Message -> Note
13 messageToNote (NoteOn _ p s) = Note { notePch = p
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 noteToMessages :: LTempo
23 -> Int -- Channel number
24 -> (Frames,Note) -- Note to convert
26 noteToMessages layTempo sr chan =
27 proc (t,n@Note { notePch = p
31 nm <- noteOnToMessage chan -< n
32 let dt = fromRational (d * toRational (tempoToQNoteIvl layTempo))
33 dn = floor $ dt * fromIntegral sr
34 returnA -< [(t,nm),(t + dn,switchOnOff nm)]
36 noteOnToMessage :: Int -> Note -> Message
37 noteOnToMessage c Note { notePch = p
39 } = NoteOn (makeChannel c) p s