Files
loop/src/Sound/Data.hs
T

64 lines
1.7 KiB
Haskell

{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TemplateHaskell #-}
module Sound.Data where
import Control.Lens
import Data.Aeson
import Data.Aeson.TH
import Data.Int (Int16)
import Data.Word (Word8)
import Geometry.Data
import qualified SDL.Mixer as Mix
data SoundStatus = SoundStatus
{ _playStatus :: PlayStatus
, _soundIsLooping :: Bool
}
deriving (Eq, Ord, Show)
-- TODO make this more sensible (use product rather than union in some cases)
data PlayStatus
= JustStartedPlaying
| Playing
| ToStart
| ToContinueStart
| ToStop
| ToStartMenu
deriving (Eq, Ord, Show, Read) --, Generic)
newtype SoundID = SoundID {_getSoundID :: Int}
deriving (Eq, Ord, Show, Read) --Generic, Flat)
data ToPlaySound = ToPlaySound
{ _toPlaySoundTime :: Maybe Int
, _toPlaySoundStatus :: SoundStatus
, _toPlaySoundPos :: Point2 -- these exist?
, _toPlaySoundVolume :: Float
, _toPlaySoundVolumeFraction :: Float -- this needs cleaning up/combining
, _toPlaySoundChunkID :: SoundID
}
deriving (Eq, Show)
data Sound = Sound
{ _soundTime :: Maybe Int
, _soundStatus :: SoundStatus
, _soundChannel :: Maybe Mix.Channel
, _soundAngDist :: Maybe (Int16, Word8)
, _soundPos :: Point2
, _soundVolume :: Float
, _soundVolumeFraction :: Float -- this needs cleaning up/combining
, _soundChunkID :: SoundID
}
deriving (Eq, Ord, Show)
makeLenses ''Sound
makeLenses ''SoundID
makeLenses ''SoundStatus
deriveJSON defaultOptions ''PlayStatus
deriveJSON defaultOptions ''SoundID
deriveJSON defaultOptions ''SoundStatus
deriveJSON defaultOptions ''ToPlaySound