]> Git — Sourcephile - tmp/julm/arpeggigon.git/blob - src/RMCA/Layer/LayerConf.hs
Hlint suggestions.
[tmp/julm/arpeggigon.git] / src / RMCA / Layer / LayerConf.hs
1 {-# LANGUAGE TupleSections #-}
2
3 module RMCA.Layer.LayerConf where
4
5 import Data.Ratio
6 import Data.ReactiveValue
7 import RMCA.Auxiliary
8 import RMCA.Semantics
9 import RMCA.Translator.Message
10
11 -- | Datatype representing dynamically modifiable characteristics for a layer.
12 data DynLayerConf = DynLayerConf { layerBeat :: Rational
13 , relPitch :: RelPitch
14 , strength :: Strength
15 , keepHeads :: Bool
16 } deriving (Show, Read, Eq)
17
18 -- | Datatype representing statically modifiable characteristics for a layer.
19 data StaticLayerConf = StaticLayerConf { beatsPerBar :: BeatsPerBar
20 , repeatCount :: Maybe Int
21 } deriving (Show, Read, Eq)
22
23 -- | Datatype containing informations useful for the synthetizer.
24 data SynthConf = SynthConf { volume :: Int
25 , instrument :: InstrumentNo
26 } deriving (Show, Read, Eq)
27
28 synthMessage :: Int -> SynthConf -> [Message]
29 synthMessage chan SynthConf { volume = v
30 , instrument = i
31 } = [ Volume (mkChannel chan) v
32 , Instrument (mkChannel chan) (mkProgram i)
33 ]
34
35 type LayerConf = (StaticLayerConf, DynLayerConf, SynthConf)
36
37 dynConf :: LayerConf -> DynLayerConf
38 dynConf (_,d,_) = d
39
40 staticConf :: LayerConf -> StaticLayerConf
41 staticConf (s,_,_) = s
42
43 synthConf :: LayerConf -> SynthConf
44 synthConf (_,_,s) = s
45
46 getDefaultLayerConfRV :: IO (ReactiveFieldReadWrite IO LayerConf)
47 getDefaultLayerConfRV = newCBMVarRW defaultLayerConf
48
49 defaultLayerConf :: LayerConf
50 defaultLayerConf = (defaultStaticLayerConf,defaultDynLayerConf,defaultSynthConf)
51
52 defaultStaticLayerConf :: StaticLayerConf
53 defaultStaticLayerConf = StaticLayerConf { beatsPerBar = 4
54 , repeatCount = Nothing
55 }
56 defaultDynLayerConf :: DynLayerConf
57 defaultDynLayerConf = DynLayerConf { layerBeat = 1 % 4
58 , relPitch = 0
59 , strength = 1
60 , keepHeads = False
61 }
62 defaultSynthConf :: SynthConf
63 defaultSynthConf = SynthConf { volume = 127
64 , instrument = 0
65 }