gdritter repos hypsibius / 3b51335
Some refining of data types Getty Ritter 8 years ago
2 changed file(s) with 40 addition(s) and 8 deletion(s). Collapse all Expand all
2626 build-depends: base >=4.7 && <4.9
2727 , brick
2828 , lens-family-core
29 , lens-family-th
2930 , text
3031 , containers
3132 , vty
1 {-# LANGUAGE TemplateHaskell #-}
2
13 module Hypsibius.Data where
24
35 import Data.Sequence (Seq)
46 import qualified Data.Sequence as S
57 import Data.Text (Text)
6
7 data Instrument = Instrument
8 { _instrSource :: Oscillator
9 } deriving (Eq, Show)
10
11 newtype InstrRef = InstrRef { fromInstrRef :: Int }
12 deriving (Eq, Show)
8 import Data.Word (Word8)
9 import Lens.Family2.TH
1310
1411 data Oscillator
1512 = OscSine
1613 | OscSquare
1714 deriving (Eq, Show)
1815
16 data Instrument = Instrument
17 { _instrSource :: Oscillator
18 } deriving (Eq, Show)
19
20 $(makeLenses ''Instrument)
21
22 newtype InstrRef = InstrRef { _fromInstrRef :: Int }
23 deriving (Eq, Show)
24
25 $(makeLenses ''InstrRef)
26
1927 data Note = Note
2028 { _noteCents :: Double
2129 , _noteAppearance :: Text
2230 } deriving (Eq, Show)
2331
24 newtype NoteRef = NoteRef { fromNoteRef :: Int }
32 $(makeLenses ''Note)
33
34 newtype NoteRef = NoteRef { _fromNoteRef :: Int }
2535 deriving (Eq, Show)
36
37 $(makeLenses ''NoteRef)
2638
2739 data Scale = Scale
2840 { _scaleName :: Text
2941 , _scaleTotalCents :: Double
3042 , _scaleNotes :: Seq Note
3143 } deriving (Eq, Show)
44
45 $(makeLenses ''Scale)
3246
3347 data Event = Event
3448 deriving (Eq, Show)
3751 {
3852 } deriving (Eq, Show)
3953
54 data Beats
55 = BeatsSimple Word8
56 | BeatsAdditive [Word8]
57 | BeatsFractional Word8 Word8
58 deriving (Eq, Show)
59
60 $(makeTraversals ''Beats)
61
62 data Signature = Signature
63 { _sigPerBar :: Beats
64 , _sigBeatUnit :: Word8
65 } deriving (Eq, Show)
66
67 $(makeLenses ''Signature)
68
4069 data Song = Song
4170 { _songScale :: Scale
4271 , _songTracks :: Seq Track
4372 } deriving (Eq, Show)
73
74 $(makeLenses ''Song)