|
@@ -3,27 +3,39 @@
|
|
module Hypsibius.Data where
|
|
module Hypsibius.Data where
|
|
|
|
|
|
import Data.Sequence (Seq)
|
|
import Data.Sequence (Seq)
|
|
-import qualified Data.Sequence as S
|
|
|
|
import Data.Text (Text)
|
|
import Data.Text (Text)
|
|
import Data.Word (Word8)
|
|
import Data.Word (Word8)
|
|
import Lens.Family2.TH
|
|
import Lens.Family2.TH
|
|
|
|
|
|
|
|
+-- | XXX: This is a temporary definition of 'Oscillator' for early
|
|
|
|
+-- prototyping purposes.
|
|
data Oscillator
|
|
data Oscillator
|
|
= OscSine
|
|
= OscSine
|
|
| OscSquare
|
|
| OscSquare
|
|
deriving (Eq, Show)
|
|
deriving (Eq, Show)
|
|
|
|
|
|
|
|
+-- | XXX: This is a temporary definition of 'Instrument' for early
|
|
|
|
+-- prototyping purposes.
|
|
data Instrument = Instrument
|
|
data Instrument = Instrument
|
|
{ _instrSource :: Oscillator
|
|
{ _instrSource :: Oscillator
|
|
} deriving (Eq, Show)
|
|
} deriving (Eq, Show)
|
|
|
|
|
|
$(makeLenses ''Instrument)
|
|
$(makeLenses ''Instrument)
|
|
|
|
|
|
|
|
+
|
|
|
|
+-- | We'll maintain a list of instruments and refer to them using
|
|
|
|
+-- indices. For type safety, here is a wrapper around those
|
|
|
|
+-- indices.
|
|
newtype InstrRef = InstrRef { _fromInstrRef :: Int }
|
|
newtype InstrRef = InstrRef { _fromInstrRef :: Int }
|
|
deriving (Eq, Show)
|
|
deriving (Eq, Show)
|
|
|
|
|
|
$(makeLenses ''InstrRef)
|
|
$(makeLenses ''InstrRef)
|
|
|
|
|
|
|
|
+-- | A 'Note' here is an individual element of a scale, which we'll
|
|
|
|
+-- maintain a unique list of on a per-song basis, and most of the time
|
|
|
|
+-- we'll use indices into that list. A 'Note' has a frequency represented
|
|
|
|
+-- in cents and an appearance that the user will see when running the
|
|
|
|
+-- program, which should be no more than a few characters long.
|
|
data Note = Note
|
|
data Note = Note
|
|
{ _noteCents :: Double
|
|
{ _noteCents :: Double
|
|
, _noteAppearance :: Text
|
|
, _noteAppearance :: Text
|
|
@@ -31,11 +43,15 @@ data Note = Note
|
|
|
|
|
|
$(makeLenses ''Note)
|
|
$(makeLenses ''Note)
|
|
|
|
|
|
|
|
+-- | We'll maintain a list of notes and refer to them using indices. For type
|
|
|
|
+-- safety, here is a wrapper around those indices.
|
|
newtype NoteRef = NoteRef { _fromNoteRef :: Int }
|
|
newtype NoteRef = NoteRef { _fromNoteRef :: Int }
|
|
deriving (Eq, Show)
|
|
deriving (Eq, Show)
|
|
|
|
|
|
$(makeLenses ''NoteRef)
|
|
$(makeLenses ''NoteRef)
|
|
|
|
|
|
|
|
+-- | A 'Scale' has a name, a total number of cents (which will almost always be
|
|
|
|
+-- 1200 for traditional scales) and a list of notes associated with it.
|
|
data Scale = Scale
|
|
data Scale = Scale
|
|
{ _scaleName :: Text
|
|
{ _scaleName :: Text
|
|
, _scaleTotalCents :: Double
|
|
, _scaleTotalCents :: Double
|
|
@@ -44,13 +60,10 @@ data Scale = Scale
|
|
|
|
|
|
$(makeLenses ''Scale)
|
|
$(makeLenses ''Scale)
|
|
|
|
|
|
|
|
+-- | An 'Event' is a typical event associated with a song.
|
|
data Event = Event
|
|
data Event = Event
|
|
deriving (Eq, Show)
|
|
deriving (Eq, Show)
|
|
|
|
|
|
-data Track = Track
|
|
|
|
- {
|
|
|
|
- } deriving (Eq, Show)
|
|
|
|
-
|
|
|
|
data Beats
|
|
data Beats
|
|
= BeatsSimple Word8
|
|
= BeatsSimple Word8
|
|
| BeatsAdditive [Word8]
|
|
| BeatsAdditive [Word8]
|
|
@@ -59,6 +72,7 @@ data Beats
|
|
|
|
|
|
$(makeTraversals ''Beats)
|
|
$(makeTraversals ''Beats)
|
|
|
|
|
|
|
|
+
|
|
data Signature = Signature
|
|
data Signature = Signature
|
|
{ _sigPerBar :: Beats
|
|
{ _sigPerBar :: Beats
|
|
, _sigBeatUnit :: Word8
|
|
, _sigBeatUnit :: Word8
|
|
@@ -66,6 +80,18 @@ data Signature = Signature
|
|
|
|
|
|
$(makeLenses ''Signature)
|
|
$(makeLenses ''Signature)
|
|
|
|
|
|
|
|
+
|
|
|
|
+data TrackChunk = TrackChunk
|
|
|
|
+ { _tcSignature :: Signature
|
|
|
|
+ } deriving (Eq, Show)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+data Track = Track
|
|
|
|
+ {
|
|
|
|
+ } deriving (Eq, Show)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
data Song = Song
|
|
data Song = Song
|
|
{ _songScale :: Scale
|
|
{ _songScale :: Scale
|
|
, _songTracks :: Seq Track
|
|
, _songTracks :: Seq Track
|