1 {-# LANGUAGE Arrows, TupleSections #-}
3 module RMCA.Layer.LayerConf where
6 import Data.ReactiveValue
9 import RMCA.Translator.Message
11 -- | Datatype representing dynamically modifiable characteristics for a layer.
12 data DynLayerConf = DynLayerConf { layerBeat :: Rational
13 , relPitch :: RelPitch
14 , strength :: Strength
16 } deriving (Show, Read, Eq)
18 -- | Datatype representing statically modifiable characteristics for a layer.
19 data StaticLayerConf = StaticLayerConf { beatsPerBar :: BeatsPerBar
20 , repeatCount :: Maybe Int
21 } deriving (Show, Read, Eq)
23 -- | Datatype containing informations useful for the synthetizer.
24 data SynthConf = SynthConf { volume :: Int
25 , instrument :: InstrumentNo
26 } deriving (Show, Read, Eq)
28 synthMessage :: Int -> SynthConf -> [Message]
29 synthMessage chan SynthConf { volume = v
31 } = [ Volume (mkChannel chan) v
32 , Instrument (mkChannel chan) (mkProgram i)
35 type LayerConf = (StaticLayerConf, DynLayerConf, SynthConf)
37 dynConf :: LayerConf -> DynLayerConf
40 staticConf :: LayerConf -> StaticLayerConf
41 staticConf (s,_,_) = s
43 synthConf :: LayerConf -> SynthConf
46 getDefaultLayerConfRV :: IO (ReactiveFieldReadWrite IO LayerConf)
47 getDefaultLayerConfRV = newCBMVarRW defaultLayerConf
49 defaultLayerConf :: LayerConf
50 defaultLayerConf = (defaultStaticLayerConf,defaultDynLayerConf,defaultSynthConf)
52 defaultStaticLayerConf :: StaticLayerConf
53 defaultStaticLayerConf = StaticLayerConf { beatsPerBar = 4
54 , repeatCount = Nothing
56 defaultDynLayerConf :: DynLayerConf
57 defaultDynLayerConf = DynLayerConf { layerBeat = 1 % 4
62 defaultSynthConf :: SynthConf
63 defaultSynthConf = SynthConf { volume = 127