Add source files, commit before reverting pictures to lists
This commit is contained in:
@@ -0,0 +1,137 @@
|
||||
module Dodge.LoadSound where
|
||||
-- imports {{{
|
||||
import Dodge.Data
|
||||
|
||||
import Data.Maybe
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import qualified Data.Map as M
|
||||
|
||||
import Control.Monad
|
||||
import Control.Lens
|
||||
|
||||
import qualified SDL.Mixer as Mix
|
||||
|
||||
-- }}}
|
||||
loadSounds :: IO (IM.IntMap Mix.Chunk)
|
||||
loadSounds = do
|
||||
-- pFireSound <- Mix.load "./data/sound/tap3.wav"
|
||||
pFireSound <- Mix.load "./data/sound/tap3.wav"
|
||||
click <- Mix.load "./data/sound/click1.wav"
|
||||
reloadSound' <- Mix.load "./data/sound/reload1.wav"
|
||||
tone440 <- Mix.load "./data/sound/tone440.wav"
|
||||
pickupSound' <- Mix.load "./data/sound/pickUp.wav"
|
||||
putdownSound' <- Mix.load "./data/sound/whiteNoiseFadeOut.wav"
|
||||
fireSound' <- Mix.load "./data/sound/fire1.wav"
|
||||
grenadeBang' <- Mix.load "./data/sound/grenade.wav"
|
||||
tapQuiet' <- Mix.load "./data/sound/tapQuiet.wav"
|
||||
twoStep' <- Mix.load "./data/sound/twoStep.wav"
|
||||
healSound' <- Mix.load "./data/sound/heal.wav"
|
||||
doorSound' <- Mix.load "./data/sound/slideDoor.wav"
|
||||
twoStepSlow' <- Mix.load "./data/sound/twoStepSlow.wav"
|
||||
knifeSound' <- Mix.load "./data/sound/knife.wav"
|
||||
buzzSound' <- Mix.load "./data/sound/buzz.wav"
|
||||
hitSound' <- Mix.load "./data/sound/hit1.wav"
|
||||
autoGunSound' <- Mix.load "./data/sound/autoGun.wav"
|
||||
shotgunSound' <- Mix.load "./data/sound/shotgun.wav"
|
||||
teleSound' <- Mix.load "./data/sound/tele.wav"
|
||||
longGunSound' <- Mix.load "./data/sound/longTap.wav"
|
||||
launcherSound' <- Mix.load "./data/sound/tap4.wav"
|
||||
smokeTrailSound' <- Mix.load "./data/sound/missileLaunch.wav"
|
||||
foot1Sound' <- Mix.load "./data/sound/foot1.wav"
|
||||
foot2Sound' <- Mix.load "./data/sound/foot2.wav"
|
||||
lasSound' <- Mix.load "./data/sound/tone440sawtooth.wav"
|
||||
teslaSound' <- Mix.load "./data/sound/Electrical-Welding.wav"
|
||||
crankSlow' <- Mix.load "./data/sound/crankSlow.wav"
|
||||
autoB' <- Mix.load "./data/sound/autoB.wav"
|
||||
mini' <- Mix.load "./data/sound/mini1.wav"
|
||||
impactA' <- Mix.load "./data/sound/Impact-A.wav"
|
||||
impactB' <- Mix.load "./data/sound/Impact-B.wav"
|
||||
impactC' <- Mix.load "./data/sound/Impact-C.wav"
|
||||
impactD' <- Mix.load "./data/sound/Impact-D.wav"
|
||||
glassShat1' <- Mix.load "./data/sound/Glass-Bottle-Shattering-A1.wav"
|
||||
glassShat2' <- Mix.load "./data/sound/Glass-Bottle-Shattering-A2.wav"
|
||||
glassShat3' <- Mix.load "./data/sound/Glass-Bottle-Shattering-A3.wav"
|
||||
glassShat4' <- Mix.load "./data/sound/Glass-Bottle-Shattering-A4.wav"
|
||||
glass1' <- Mix.load "./data/sound/Small-Piece-Of-Glass-Shattering-A1.wav"
|
||||
glass2' <- Mix.load "./data/sound/Small-Piece-Of-Glass-Shattering-A2.wav"
|
||||
glass3' <- Mix.load "./data/sound/Small-Piece-Of-Glass-Shattering-A3.wav"
|
||||
glass4' <- Mix.load "./data/sound/Small-Piece-Of-Glass-Shattering-A4.wav"
|
||||
foamSpray' <- Mix.load "./data/sound/foamSprayLoop.wav"
|
||||
return $ IM.fromList $ zip [0..]
|
||||
$ [ pFireSound
|
||||
, click
|
||||
, reloadSound'
|
||||
, tone440
|
||||
, pickupSound'
|
||||
, putdownSound'
|
||||
, fireSound'
|
||||
, grenadeBang'
|
||||
, tapQuiet'
|
||||
, twoStep'
|
||||
, healSound'
|
||||
, doorSound'
|
||||
, twoStepSlow'
|
||||
, knifeSound'
|
||||
, buzzSound'
|
||||
, hitSound' --15
|
||||
, autoGunSound'
|
||||
, shotgunSound'
|
||||
, teleSound'
|
||||
, longGunSound'
|
||||
, launcherSound'
|
||||
, smokeTrailSound'
|
||||
, foot1Sound'
|
||||
, foot2Sound'
|
||||
, lasSound'
|
||||
, teslaSound' --25
|
||||
, crankSlow'
|
||||
, autoB'
|
||||
, mini'
|
||||
, impactA'
|
||||
, impactB' --30
|
||||
, impactC'
|
||||
, impactD'
|
||||
, glassShat1' --33
|
||||
, glassShat2'
|
||||
, glassShat3'
|
||||
, glassShat4'
|
||||
, glass1' --37
|
||||
, glass2'
|
||||
, glass3'
|
||||
, glass4' --40
|
||||
, foamSpray'
|
||||
]
|
||||
|
||||
-- updateSound :: World -> IO World
|
||||
-- updateSound w
|
||||
-- = do forM_ (_soundQueue w) (\n -> Mix.playOn (-1) 0 (_loadedSounds w IM.! n))
|
||||
-- fmap (set soundQueue creatureSounds) $ stepSoundTimers $ w
|
||||
-- -- = return $ set soundQueue creatureSounds w
|
||||
-- -- = do forM_ (_soundQueue w) (\n -> Mix.playOn (-1) (_loadedSounds w IM.! n) 0)
|
||||
-- -- fmap (set soundQueue creatureSounds) $ return w
|
||||
-- where creatureSounds = []
|
||||
|
||||
soundOnce :: Int -> World -> World
|
||||
soundOnce i = over soundQueue ((:) i)
|
||||
|
||||
--stepSoundTimers :: World -> IO World
|
||||
--stepSoundTimers w = M.foldrWithKey stepSoundTimer (return w) (_sounds w)
|
||||
|
||||
-- ok, this is hard to reason about-- bugs can occur because I am unsure when
|
||||
-- everything is evaluated
|
||||
--stepSoundTimer :: SoundOrigin -> Sound -> IO World -> IO World
|
||||
--stepSoundTimer so s w =
|
||||
-- case _soundChannel s of
|
||||
-- Nothing -> do w1 <- w
|
||||
-- let soundChunk = _loadedSounds w1 IM.! _soundType s
|
||||
---- n <- Mix.playingCount
|
||||
-- channel <- Mix.playOn (-1) (-1) soundChunk
|
||||
-- -- w2 <- w -- Note that using w2 instead of w1 in the
|
||||
-- -- final return breaks the sound sometimes, must be
|
||||
-- -- something to do with order of evaluation
|
||||
-- return $ set (sounds . ix so . soundChannel) (Just $ fromIntegral channel) w1
|
||||
-- Just channel -> case _soundTime s of
|
||||
-- x | x > 0 -> fmap (set (sounds . ix so . soundTime) (x-1)) w
|
||||
-- | x <= 0 -> do Mix.fadeOut channel (fromIntegral $ _soundFadeTime s+ 1)
|
||||
-- fmap (over sounds (M.delete so)) w
|
||||
-- the sound fade doesn't seem to like being 0
|
||||
Reference in New Issue
Block a user