1 {-# LANGUAGE Arrows, TupleSections #-}
3 module RMCA.Layer.LayerConf where
6 import Data.ReactiveValue
9 import RMCA.Global.Clock
11 import RMCA.Translator.Message
13 -- | Datatype representing dynamically modifiable characteristics for a layer.
14 data DynLayerConf = DynLayerConf { layerBeat :: Rational
15 , relPitch :: RelPitch
16 , strength :: Strength
17 } deriving (Show, Read, Eq)
19 -- | Datatype representing statically modifiable characteristics for a layer.
20 data StaticLayerConf = StaticLayerConf { beatsPerBar :: BeatsPerBar
21 , repeatCount :: Maybe Int
22 } deriving (Show, Read, Eq)
24 -- | Datatype containing informations useful for the synthetizer.
25 data SynthConf = SynthConf { volume :: Int
26 , instrument :: InstrumentNo
27 } deriving (Show, Read, Eq)
29 synthMessage :: Int -> SynthConf -> [Message]
30 synthMessage chan SynthConf { volume = v
32 } = [ Volume (mkChannel chan) v
33 , Instrument (mkChannel chan) (mkProgram i)
36 type LayerConf = (StaticLayerConf, DynLayerConf, SynthConf)
38 dynConf :: LayerConf -> DynLayerConf
41 staticConf :: LayerConf -> StaticLayerConf
42 staticConf (s,_,_) = s
44 synthConf :: LayerConf -> SynthConf
47 getDefaultLayerConfRV :: IO (ReactiveFieldReadWrite IO LayerConf)
48 getDefaultLayerConfRV = newCBMVarRW defaultLayerConf
50 defaultLayerConf :: LayerConf
51 defaultLayerConf = (defaultStaticLayerConf,defaultDynLayerConf,defaultSynthConf)
53 defaultStaticLayerConf :: StaticLayerConf
54 defaultStaticLayerConf = StaticLayerConf { beatsPerBar = 4
55 , repeatCount = Nothing
57 defaultDynLayerConf :: DynLayerConf
58 defaultDynLayerConf = DynLayerConf { layerBeat = 1 % 4
62 defaultSynthConf :: SynthConf
63 defaultSynthConf = SynthConf { volume = 127