Further implementation of poitional sound

This commit is contained in:
2021-04-06 19:19:23 +02:00
parent 48ef0c0088
commit 47ac104520
9 changed files with 44 additions and 26 deletions
+36
View File
@@ -0,0 +1,36 @@
{-# LANGUAGE TemplateHaskell #-}
module Sound.Data
where
import qualified SDL.Mixer as Mix
import qualified Data.IntMap as IM
import qualified Data.Map as M
import Control.Lens
import Geometry
import Data.Word (Word8)
import Data.Int (Int16)
data SoundStatus
= Playing
| FadingOut
| ToStart
deriving (Eq,Ord,Show)
data SoundData a = SoundData
{_loadedChunks :: IM.IntMap Mix.Chunk
,_playingSounds :: M.Map a Sound
}
data Sound = Sound
{ _soundTime :: Maybe Int
, _soundFadeTime :: Int
, _soundStatus :: SoundStatus
, _soundChannel :: Maybe Mix.Channel
, _soundPos :: Maybe (Int16,Word8)
, _soundChunkID :: Int
}
deriving (Eq,Ord,Show)
makeLenses ''SoundData
makeLenses ''Sound
cleanUpSoundPreload :: SoundData a -> IO ()
cleanUpSoundPreload sd = Mix.closeAudio