diff --git a/data/sound/autoB.wav b/data/sound/autoB.TATATA.100.wav similarity index 100% rename from data/sound/autoB.wav rename to data/sound/autoB.TATATA.100.wav diff --git a/data/sound/autoGun.wav b/data/sound/autoGun.BRAP.100.wav similarity index 100% rename from data/sound/autoGun.wav rename to data/sound/autoGun.BRAP.100.wav diff --git a/data/sound/grenade.wav b/data/sound/bang.BANG.150.wav similarity index 100% rename from data/sound/grenade.wav rename to data/sound/bang.BANG.150.wav diff --git a/data/sound/longTap.wav b/data/sound/bangEcho.BANGG.150.wav similarity index 100% rename from data/sound/longTap.wav rename to data/sound/bangEcho.BANGG.150.wav diff --git a/data/sound/buzz.wav b/data/sound/buzz.ZMM.80.wav similarity index 100% rename from data/sound/buzz.wav rename to data/sound/buzz.ZMM.80.wav diff --git a/data/sound/click1.wav b/data/sound/click1.CLICK.50.wav similarity index 100% rename from data/sound/click1.wav rename to data/sound/click1.CLICK.50.wav diff --git a/data/sound/crankSlow.wav b/data/sound/crankSlow.CHNKCHNKCHUNK.50.wav similarity index 100% rename from data/sound/crankSlow.wav rename to data/sound/crankSlow.CHNKCHNKCHUNK.50.wav diff --git a/data/sound/Electrical-Welding.wav b/data/sound/elecCrackle.CRAKLE.100.wav similarity index 100% rename from data/sound/Electrical-Welding.wav rename to data/sound/elecCrackle.CRAKLE.100.wav diff --git a/data/sound/endFootStep.wav b/data/sound/endFootStep.wav deleted file mode 100644 index b7b391208..000000000 Binary files a/data/sound/endFootStep.wav and /dev/null differ diff --git a/data/sound/explosion.wav b/data/sound/explosion.BOOM.200.wav similarity index 100% rename from data/sound/explosion.wav rename to data/sound/explosion.BOOM.200.wav diff --git a/data/sound/fire.wav b/data/sound/fire.WRR.50.wav similarity index 100% rename from data/sound/fire.wav rename to data/sound/fire.WRR.50.wav diff --git a/data/sound/fire1.wav b/data/sound/fireLoud.WRRR.100.wav similarity index 100% rename from data/sound/fire1.wav rename to data/sound/fireLoud.WRRR.100.wav diff --git a/data/sound/foamSprayFadeOut.wav b/data/sound/foamSprayFadeOut.HSS.50.wav similarity index 100% rename from data/sound/foamSprayFadeOut.wav rename to data/sound/foamSprayFadeOut.HSS.50.wav diff --git a/data/sound/foamSprayLoop.wav b/data/sound/foamSprayLoop.HSSS.50.wav similarity index 100% rename from data/sound/foamSprayLoop.wav rename to data/sound/foamSprayLoop.HSSS.50.wav diff --git a/data/sound/foot1.wav b/data/sound/foot1.TIP.30.wav similarity index 100% rename from data/sound/foot1.wav rename to data/sound/foot1.TIP.30.wav diff --git a/data/sound/foot2.wav b/data/sound/foot2.TAP.30.wav similarity index 100% rename from data/sound/foot2.wav rename to data/sound/foot2.TAP.30.wav diff --git a/data/sound/footStep.wav b/data/sound/foot3.TAPP.40.wav similarity index 100% rename from data/sound/footStep.wav rename to data/sound/foot3.TAPP.40.wav diff --git a/data/sound/Glass-Bottle-Shattering-A1.wav b/data/sound/glassShat1.CRSNK.80.wav similarity index 100% rename from data/sound/Glass-Bottle-Shattering-A1.wav rename to data/sound/glassShat1.CRSNK.80.wav diff --git a/data/sound/Glass-Bottle-Shattering-A2.wav b/data/sound/glassShat2.CRNKL.80.wav similarity index 100% rename from data/sound/Glass-Bottle-Shattering-A2.wav rename to data/sound/glassShat2.CRNKL.80.wav diff --git a/data/sound/Glass-Bottle-Shattering-A3.wav b/data/sound/glassShat3.CRNK.80.wav similarity index 100% rename from data/sound/Glass-Bottle-Shattering-A3.wav rename to data/sound/glassShat3.CRNK.80.wav diff --git a/data/sound/Glass-Bottle-Shattering-A4.wav b/data/sound/glassShat4.CRSK.80.wav similarity index 100% rename from data/sound/Glass-Bottle-Shattering-A4.wav rename to data/sound/glassShat4.CRSK.80.wav diff --git a/data/sound/grunt.wav b/data/sound/grunt.HNH.50.wav similarity index 100% rename from data/sound/grunt.wav rename to data/sound/grunt.HNH.50.wav diff --git a/data/sound/heal.wav b/data/sound/heal.BLIH.20.wav similarity index 100% rename from data/sound/heal.wav rename to data/sound/heal.BLIH.20.wav diff --git a/data/sound/hit.wav b/data/sound/hit.THUD.30.wav similarity index 100% rename from data/sound/hit.wav rename to data/sound/hit.THUD.30.wav diff --git a/data/sound/hit1.wav b/data/sound/hit1.SMACK.40.wav similarity index 100% rename from data/sound/hit1.wav rename to data/sound/hit1.SMACK.40.wav diff --git a/data/sound/Impact-A.wav b/data/sound/impact1.CRASH.80.wav similarity index 100% rename from data/sound/Impact-A.wav rename to data/sound/impact1.CRASH.80.wav diff --git a/data/sound/Impact-B.wav b/data/sound/impact2.CRUNK.80.wav similarity index 100% rename from data/sound/Impact-B.wav rename to data/sound/impact2.CRUNK.80.wav diff --git a/data/sound/Impact-C.wav b/data/sound/impact3.CRUMPLE.80.wav similarity index 100% rename from data/sound/Impact-C.wav rename to data/sound/impact3.CRUMPLE.80.wav diff --git a/data/sound/Impact-D.wav b/data/sound/impact4.CRISH.80.wav similarity index 100% rename from data/sound/Impact-D.wav rename to data/sound/impact4.CRISH.80.wav diff --git a/data/sound/knife.wav b/data/sound/knife.SWSH.20.wav similarity index 100% rename from data/sound/knife.wav rename to data/sound/knife.SWSH.20.wav diff --git a/data/sound/mini.wav b/data/sound/mini.BRPBRPBRP.120.wav similarity index 100% rename from data/sound/mini.wav rename to data/sound/mini.BRPBRPBRP.120.wav diff --git a/data/sound/mini1.wav b/data/sound/mini1.BRDBRDBRD.120.wav similarity index 100% rename from data/sound/mini1.wav rename to data/sound/mini1.BRDBRDBRD.120.wav diff --git a/data/sound/missileLaunch.wav b/data/sound/missileLaunch.WHSSH.100.wav similarity index 100% rename from data/sound/missileLaunch.wav rename to data/sound/missileLaunch.WHSSH.100.wav diff --git a/data/sound/Cranking-Gear--Faster--www.fesliyanstudios.com.mp3 b/data/sound/nondata/Cranking-Gear--Faster--www.fesliyanstudios.com.mp3 similarity index 100% rename from data/sound/Cranking-Gear--Faster--www.fesliyanstudios.com.mp3 rename to data/sound/nondata/Cranking-Gear--Faster--www.fesliyanstudios.com.mp3 diff --git a/data/sound/Cranking-Gears--Fast--www.fesliyanstudios.com.mp3 b/data/sound/nondata/Cranking-Gears--Fast--www.fesliyanstudios.com.mp3 similarity index 100% rename from data/sound/Cranking-Gears--Fast--www.fesliyanstudios.com.mp3 rename to data/sound/nondata/Cranking-Gears--Fast--www.fesliyanstudios.com.mp3 diff --git a/data/sound/Cranking-Gears--Medium--www.fesliyanstudios.com.mp3 b/data/sound/nondata/Cranking-Gears--Medium--www.fesliyanstudios.com.mp3 similarity index 100% rename from data/sound/Cranking-Gears--Medium--www.fesliyanstudios.com.mp3 rename to data/sound/nondata/Cranking-Gears--Medium--www.fesliyanstudios.com.mp3 diff --git a/data/sound/Cranking-Gears--Slow--www.fesliyanstudios.com.mp3 b/data/sound/nondata/Cranking-Gears--Slow--www.fesliyanstudios.com.mp3 similarity index 100% rename from data/sound/Cranking-Gears--Slow--www.fesliyanstudios.com.mp3 rename to data/sound/nondata/Cranking-Gears--Slow--www.fesliyanstudios.com.mp3 diff --git a/data/sound/Electrical-Welding-Metal-Long-A1-www.fesliyanstudios.com.mp3 b/data/sound/nondata/Electrical-Welding-Metal-Long-A1-www.fesliyanstudios.com.mp3 similarity index 100% rename from data/sound/Electrical-Welding-Metal-Long-A1-www.fesliyanstudios.com.mp3 rename to data/sound/nondata/Electrical-Welding-Metal-Long-A1-www.fesliyanstudios.com.mp3 diff --git a/data/sound/Electrical-Welding.mp3 b/data/sound/nondata/Electrical-Welding.mp3 similarity index 100% rename from data/sound/Electrical-Welding.mp3 rename to data/sound/nondata/Electrical-Welding.mp3 diff --git a/data/sound/Rifle-Automatic-Fire-B-www.fesliyanstudios.com.mp3 b/data/sound/nondata/Rifle-Automatic-Fire-B-www.fesliyanstudios.com.mp3 similarity index 100% rename from data/sound/Rifle-Automatic-Fire-B-www.fesliyanstudios.com.mp3 rename to data/sound/nondata/Rifle-Automatic-Fire-B-www.fesliyanstudios.com.mp3 diff --git a/data/sound/reload.aup b/data/sound/nondata/reload.aup similarity index 100% rename from data/sound/reload.aup rename to data/sound/nondata/reload.aup diff --git a/data/sound/tap.aup b/data/sound/nondata/tap.aup similarity index 100% rename from data/sound/tap.aup rename to data/sound/nondata/tap.aup diff --git a/data/sound/twoStep.aup b/data/sound/nondata/twoStep.aup similarity index 100% rename from data/sound/twoStep.aup rename to data/sound/nondata/twoStep.aup diff --git a/data/sound/pickUp.wav b/data/sound/pickUp.SHUHP.20.wav similarity index 100% rename from data/sound/pickUp.wav rename to data/sound/pickUp.SHUHP.20.wav diff --git a/data/sound/reload.wav b/data/sound/reload.TNKTNKTNK.30.wav similarity index 100% rename from data/sound/reload.wav rename to data/sound/reload.TNKTNKTNK.30.wav diff --git a/data/sound/reload1.wav b/data/sound/reload1.CHPCHPCHP.30.wav similarity index 100% rename from data/sound/reload1.wav rename to data/sound/reload1.CHPCHPCHP.30.wav diff --git a/data/sound/reload2.wav b/data/sound/reload2.wav deleted file mode 100644 index 66bc749f4..000000000 Binary files a/data/sound/reload2.wav and /dev/null differ diff --git a/data/sound/shotgun.wav b/data/sound/shotgun.BRAHCHCH.100.wav similarity index 100% rename from data/sound/shotgun.wav rename to data/sound/shotgun.BRAHCHCH.100.wav diff --git a/data/sound/sineRaisePitchOneSec.wav b/data/sound/sineRaisePitchOneSec.BWAH.30.wav similarity index 100% rename from data/sound/sineRaisePitchOneSec.wav rename to data/sound/sineRaisePitchOneSec.BWAH.30.wav diff --git a/data/sound/sineRaisePitchTwoSec.wav b/data/sound/sineRaisePitchTwoSec.BWAAH.30.wav similarity index 100% rename from data/sound/sineRaisePitchTwoSec.wav rename to data/sound/sineRaisePitchTwoSec.BWAAH.30.wav diff --git a/data/sound/skwareFadeTwoSec.wav b/data/sound/skwareFadeTwoSec.DWAAH.30.wav similarity index 100% rename from data/sound/skwareFadeTwoSec.wav rename to data/sound/skwareFadeTwoSec.DWAAH.30.wav diff --git a/data/sound/slideDoor.wav b/data/sound/slideDoor.DRR.30.wav similarity index 100% rename from data/sound/slideDoor.wav rename to data/sound/slideDoor.DRR.30.wav diff --git a/data/sound/Small-Piece-Of-Glass-Shattering-A2.wav b/data/sound/smallGlass1.TRINKL.50.wav similarity index 100% rename from data/sound/Small-Piece-Of-Glass-Shattering-A2.wav rename to data/sound/smallGlass1.TRINKL.50.wav diff --git a/data/sound/Small-Piece-Of-Glass-Shattering-A4.wav b/data/sound/smallGlass2.KRTNKL.50.wav similarity index 100% rename from data/sound/Small-Piece-Of-Glass-Shattering-A4.wav rename to data/sound/smallGlass2.KRTNKL.50.wav diff --git a/data/sound/Small-Piece-Of-Glass-Shattering-A3.wav b/data/sound/smallGlass3.CRTINK.50.wav similarity index 100% rename from data/sound/Small-Piece-Of-Glass-Shattering-A3.wav rename to data/sound/smallGlass3.CRTINK.50.wav diff --git a/data/sound/Small-Piece-Of-Glass-Shattering-A1.wav b/data/sound/smallGlass4.TINKLE.50.wav similarity index 100% rename from data/sound/Small-Piece-Of-Glass-Shattering-A1.wav rename to data/sound/smallGlass4.TINKLE.50.wav diff --git a/data/sound/tap1.wav b/data/sound/tap1.TAK.80.wav similarity index 100% rename from data/sound/tap1.wav rename to data/sound/tap1.TAK.80.wav diff --git a/data/sound/tap2.wav b/data/sound/tap2.TAKH.80.wav similarity index 100% rename from data/sound/tap2.wav rename to data/sound/tap2.TAKH.80.wav diff --git a/data/sound/tap3.wav b/data/sound/tap3.BRAP.80.wav similarity index 100% rename from data/sound/tap3.wav rename to data/sound/tap3.BRAP.80.wav diff --git a/data/sound/tap4.wav b/data/sound/tap4.THUD.50.wav similarity index 100% rename from data/sound/tap4.wav rename to data/sound/tap4.THUD.50.wav diff --git a/data/sound/tapQuiet.wav b/data/sound/tapQuiet.BRAP.40.wav similarity index 100% rename from data/sound/tapQuiet.wav rename to data/sound/tapQuiet.BRAP.40.wav diff --git a/data/sound/tele.wav b/data/sound/tele.ZHM.100.wav similarity index 100% rename from data/sound/tele.wav rename to data/sound/tele.ZHM.100.wav diff --git a/data/sound/tinitus.wav b/data/sound/tinitus.RINGGG.80.wav similarity index 100% rename from data/sound/tinitus.wav rename to data/sound/tinitus.RINGGG.80.wav diff --git a/data/sound/tone440.wav b/data/sound/tone440.BEP.80.wav similarity index 100% rename from data/sound/tone440.wav rename to data/sound/tone440.BEP.80.wav diff --git a/data/sound/tone440sawtooth.wav b/data/sound/tone440sawtooth.SCREE.100.wav similarity index 100% rename from data/sound/tone440sawtooth.wav rename to data/sound/tone440sawtooth.SCREE.100.wav diff --git a/data/sound/twoStep.wav b/data/sound/twoStep.TIPTAP.40.wav similarity index 100% rename from data/sound/twoStep.wav rename to data/sound/twoStep.TIPTAP.40.wav diff --git a/data/sound/twoStep1.wav b/data/sound/twoStep1.TAPTIP.60.wav similarity index 100% rename from data/sound/twoStep1.wav rename to data/sound/twoStep1.TAPTIP.60.wav diff --git a/data/sound/twoStepSlow.wav b/data/sound/twoStepSlow.TIPTOP.40.wav similarity index 100% rename from data/sound/twoStepSlow.wav rename to data/sound/twoStepSlow.TIPTOP.40.wav diff --git a/data/sound/whiteNoiseFadeIn.wav b/data/sound/whiteNoiseFadeIn.FHP.20.wav similarity index 100% rename from data/sound/whiteNoiseFadeIn.wav rename to data/sound/whiteNoiseFadeIn.FHP.20.wav diff --git a/data/sound/whiteNoiseFadeOut.wav b/data/sound/whiteNoiseFadeOut.PHF.20.wav similarity index 100% rename from data/sound/whiteNoiseFadeOut.wav rename to data/sound/whiteNoiseFadeOut.PHF.20.wav diff --git a/src/Dodge/Creature/Action.hs b/src/Dodge/Creature/Action.hs index 49a8d2ed5..d547362d3 100644 --- a/src/Dodge/Creature/Action.hs +++ b/src/Dodge/Creature/Action.hs @@ -19,7 +19,7 @@ import Dodge.Base import Dodge.Zone import Dodge.Base.Collide import Dodge.SoundLogic -import Dodge.SoundLogic.Synonyms +import Dodge.SoundLogic.LoadSound --import Dodge.WorldEvent import Dodge.Inventory --import Dodge.LightSources @@ -167,7 +167,7 @@ blinkAction -> World -> World blinkAction cr w - = soundMultiFrom [TeleSound 0,TeleSound 1] p3 teleSound Nothing + = soundMultiFrom [TeleSound 0,TeleSound 1] p3 teleS Nothing . over radDistortion (distortionBulge ++) . set (creatures . ix cid . crPos) p3 . blinkShockwave cid p3 @@ -198,7 +198,7 @@ youDropItem w = case yourItem w of NoItem -> w _ -> rmSelectedInvItem (_yourID w) . copyItemToFloor (you w) (_crInvSel cr) - $ soundFrom (CrSound (_crID cr)) (_crPos cr) putDownSound Nothing + $ soundFrom (CrSound (_crID cr)) (_crPos cr) whiteNoiseFadeOutS Nothing w where cr = you w @@ -233,7 +233,7 @@ pickUpItem pickUpItem cid flit w = case maybeInvSlot of Nothing -> w Just i -> w - & soundFrom (CrSound cid) (_flItPos flit) pickUpSound Nothing + & soundFrom (CrSound cid) (_flItPos flit) pickUpS Nothing & updateItLocation i & floorItems %~ IM.delete (_flItID flit) & creatures . ix cid . crInv . ix i %~ addItem it diff --git a/src/Dodge/Creature/Impulse.hs b/src/Dodge/Creature/Impulse.hs index cc525ec87..e6d7b036c 100644 --- a/src/Dodge/Creature/Impulse.hs +++ b/src/Dodge/Creature/Impulse.hs @@ -11,7 +11,7 @@ import Dodge.Data.DamageType import Dodge.Creature.State.Data import Dodge.Creature.Stance.Data import Dodge.SoundLogic -import Dodge.SoundLogic.Synonyms +import Dodge.SoundLogic.LoadSound import Geometry import qualified Data.IntMap.Strict as IM @@ -84,5 +84,5 @@ followImpulse cr w imp = case imp of posFromID cid' = _crPos $ _creatures w IM.! cid' rr a = fst $ randomR (-a,a) $ _randGen w hitCr i = over (creatures . ix i . crState . crDamage) (addDam i) - . soundFrom (CrSound cid) cpos hitSound Nothing + . soundFrom (CrSound cid) cpos hitS Nothing addDam i dams = Blunt 100 cpos (posFromID i) (posFromID i) : dams diff --git a/src/Dodge/Creature/State.hs b/src/Dodge/Creature/State.hs index 54730e5cd..55a1d0343 100644 --- a/src/Dodge/Creature/State.hs +++ b/src/Dodge/Creature/State.hs @@ -9,7 +9,7 @@ import Dodge.Creature.Stance.Data --import Dodge.Creature.Test --import Dodge.Base import Dodge.SoundLogic -import Dodge.SoundLogic.Synonyms +import Dodge.SoundLogic.LoadSound import Dodge.RandomHelp import Dodge.WorldEvent --import Dodge.WallCreatureCollisions @@ -141,7 +141,7 @@ weaponReloadSounds cr w = case _crInv cr IM.!? _crInvSel cr of | otherwise -> w Just Weapon{_wpReloadState = 0} -> w Just Weapon{_wpReloadState = 1} -> stopSoundFrom (CrReloadSound cid) w - Just Weapon{} -> soundFrom (CrReloadSound cid) (_crPos cr) reloadSound (Just 1) w + Just Weapon{} -> soundFrom (CrReloadSound cid) (_crPos cr) reloadS (Just 1) w _ -> w where cid = _crID cr @@ -223,7 +223,7 @@ updateExpBarrel cr w applyFuseDamage cr' = cr' & crHP %~ subtract (length . _piercedPoints . _crSpState $ _crState cr') hiss | null poss = id - | otherwise = soundMultiFrom [BarrelHiss 0,BarrelHiss 1] (_crPos cr) 41 (Just 1) + | otherwise = soundMultiFrom [BarrelHiss 0,BarrelHiss 1] (_crPos cr) foamSprayLoopS (Just 1) stopSounds = stopSoundFrom (BarrelHiss 0) . stopSoundFrom (BarrelHiss 1) damToExpBarrel :: [DamageType] -> Creature -> Creature diff --git a/src/Dodge/Creature/State/WalkCycle.hs b/src/Dodge/Creature/State/WalkCycle.hs index 522491aec..adf6fa354 100644 --- a/src/Dodge/Creature/State/WalkCycle.hs +++ b/src/Dodge/Creature/State/WalkCycle.hs @@ -4,7 +4,9 @@ import Dodge.Data import Dodge.Data.SoundOrigin import Dodge.Creature.Stance.Data import Dodge.SoundLogic +import Dodge.SoundLogic.LoadSound import Geometry.Data +import Sound.Data import Control.Lens @@ -36,6 +38,6 @@ makeFootstepSound currentStride maxStride ff p where footor = [FootstepSound 0,FootstepSound 1] -chooseFootSound :: FootForward -> Int -chooseFootSound LeftForward = 22 -chooseFootSound _ = 23 +chooseFootSound :: FootForward -> SoundID +chooseFootSound LeftForward = foot1S +chooseFootSound _ = foot2S diff --git a/src/Dodge/Creature/Volition.hs b/src/Dodge/Creature/Volition.hs index 80da0d64f..3d586a3a6 100644 --- a/src/Dodge/Creature/Volition.hs +++ b/src/Dodge/Creature/Volition.hs @@ -5,12 +5,12 @@ import Dodge.Data import Dodge.Base.Collide import Dodge.Creature.Test import Dodge.Creature.Stance.Data -import Dodge.SoundLogic.Synonyms +import Dodge.SoundLogic.LoadSound import Geometry holsterWeapon, drawWeapon :: Action -holsterWeapon = DoImpulses [ChangePosture AtEase, MakeSound putDownSound] -drawWeapon = DoImpulses [ChangePosture Aiming, MakeSound pickUpSound] +holsterWeapon = DoImpulses [ChangePosture AtEase, MakeSound whiteNoiseFadeOutS] +drawWeapon = DoImpulses [ChangePosture Aiming, MakeSound whiteNoiseFadeInS] fleeFrom :: Creature -> Maybe Creature -> Action fleeFrom cr mtcr = case mtcr of diff --git a/src/Dodge/Data.hs b/src/Dodge/Data.hs index d0f66e0bd..7f079c5ff 100644 --- a/src/Dodge/Data.hs +++ b/src/Dodge/Data.hs @@ -378,7 +378,7 @@ data Item } | NoItem -data ReloadType = ActiveReload | PassiveReload Int +data ReloadType = ActiveReload | PassiveReload SoundID data ItEffect = NoItEffect | ItInvEffect @@ -581,7 +581,7 @@ data Impulse -- | UseIntrinsicAbility | Melee Int | ChangePosture Posture - | MakeSound Int + | MakeSound SoundID | ChangeStrategy Strategy | AddGoal Goal | ArbitraryImpulseFunction (World -> Creature -> Creature) diff --git a/src/Dodge/Default.hs b/src/Dodge/Default.hs index ac127e3ab..388726e9a 100644 --- a/src/Dodge/Default.hs +++ b/src/Dodge/Default.hs @@ -15,6 +15,7 @@ import Dodge.Creature.State.Data import Dodge.Creature.Perception.Data import Dodge.Creature.Memory.Data import Dodge.SoundLogic +import Dodge.SoundLogic.LoadSound import Dodge.Picture.Layer import Geometry import Picture @@ -214,7 +215,7 @@ defaultButton = Button , _btEvent = \b w -> set (buttons . ix (_btID b) . btPict) (onLayer WlLayer $ color red $ polygon $ rectNSEW (-4) (-5) 10 (-10)) . set (buttons . ix (_btID b) . btState) BtNoLabel - . soundFrom (LeverSound 0) (_btPos b) 1 Nothing $ w + . soundFrom (LeverSound 0) (_btPos b) click1S Nothing $ w , _btID = 0 , _btText = "Button" , _btState = BtOff diff --git a/src/Dodge/Initialisation.hs b/src/Dodge/Initialisation.hs index 81514442a..f85430a9e 100644 --- a/src/Dodge/Initialisation.hs +++ b/src/Dodge/Initialisation.hs @@ -9,7 +9,7 @@ import Dodge.Layout import Dodge.Story import Dodge.WorldEvent.Cloud import Dodge.SoundLogic -import Dodge.SoundLogic.Synonyms +import Dodge.SoundLogic.LoadSound --import Dodge.Creature.Perception import Geometry.Data --import Picture @@ -47,7 +47,7 @@ initialWorld = defaultWorld , _mousePos = V2 0 0 , _testString = testStringInit , _yourID = 0 - , _worldEvents = soundFrom BackgroundSound (V2 0 0) foamSprayFadeOutSound Nothing + , _worldEvents = soundFrom BackgroundSound (V2 0 0) foamSprayFadeOutS Nothing . foldr ((.) . makeStartCloudAt) id [V3 x y 5 | x <- [-5,-3..5] , y <- [-5,-3..5]] , _pressPlates = IM.empty , _buttons = IM.empty diff --git a/src/Dodge/Item/Consumable.hs b/src/Dodge/Item/Consumable.hs index f01d0f8c1..51883a211 100644 --- a/src/Dodge/Item/Consumable.hs +++ b/src/Dodge/Item/Consumable.hs @@ -6,7 +6,7 @@ import Dodge.Item.Data import Dodge.Picture.Layer import Dodge.Default import Dodge.SoundLogic -import Dodge.SoundLogic.Synonyms +import Dodge.SoundLogic.LoadSound import Dodge.Item.Draw @@ -32,7 +32,7 @@ heal25 :: Int -> World -> Maybe World heal25 = heal 25 heal :: Int -> Int -> World -> Maybe World heal hp n w | _crHP (_creatures w IM.! n) >= 10000 = Nothing - | otherwise = Just $ soundFrom (CrSound $ _crID cr) (_crPos cr) healSound Nothing w + | otherwise = Just $ soundFrom (CrSound $ _crID cr) (_crPos cr) healS Nothing w & creatures . ix n . crHP %~ min 10000 . (+ hp) where cr = _creatures w IM.! n diff --git a/src/Dodge/Item/Weapon.hs b/src/Dodge/Item/Weapon.hs index e565e7dbb..59231572d 100644 --- a/src/Dodge/Item/Weapon.hs +++ b/src/Dodge/Item/Weapon.hs @@ -8,7 +8,7 @@ import Dodge.Base import Dodge.Zone import Dodge.Picture.Layer import Dodge.SoundLogic -import Dodge.SoundLogic.Synonyms +import Dodge.SoundLogic.LoadSound import Dodge.Creature.Action import Dodge.RandomHelp import Dodge.WorldEvent @@ -66,7 +66,7 @@ pistol = defaultGun [ ammoCheckI , hammerCheckI , useTimeCheckI - , withSoundI 0 + , withSoundI tap3S , useAmmo 1 , randSpreadDir , withMuzFlareI @@ -145,7 +145,7 @@ teslaGun = defaultGun [ ammoCheckI , useTimeCheckI , withTempLight 1 100 (V3 0 0 1) - , withSoundForI 25 1 + , withSoundForI elecCrackleS 1 , useAmmo 1 ] , _wpSpread = 0.001 @@ -180,7 +180,7 @@ lasGun = defaultAutoGun [ ammoCheckI , useTimeCheckI , withTempLight 1 100 (V3 1 1 0) - , withSoundForI 24 1 + , withSoundForI tone440sawtoothS 1 , useAmmo 1 ] , _wpSpread = 0.001 @@ -296,7 +296,7 @@ hvAutoGun = defaultAutoGun , _itUseModifiers = [ ammoCheckI , rateIncABI 24 7 (torqueBeforeAtLeast 0.1 0.1) (torqueAfterI 0.2) - , withSoundI longGunSound + , withSoundI bangEchoS , withThinSmokeI , withMuzFlareI ] @@ -323,7 +323,7 @@ ltAutoGun = defaultAutoGun , _itUseModifiers = [ ammoCheckI , useTimeCheckI - , withSoundI 0 + , withSoundI tap1S , useAmmo 1 , withRandomDirI 0.1 , torqueAfterI 0.2 @@ -359,10 +359,10 @@ miniGun = defaultAutoGun , _itUse = useAmmoParamsVelMod vm4 , _itUseModifiers = [ ammoCheckI - , withWarmUpI 26 + , withWarmUpI crankSlowS , useTimeCheckI --, afterRecoil recoilAmount - , withSoundForI 28 2 + , withSoundForI mini1S 2 --, withThinSmokeI , torqueAfterI 0.05 , withSidePushI 53 @@ -429,7 +429,7 @@ spreadGun = defaultGun [ ammoCheckI , hammerCheckI , useTimeCheckI - , withSoundI shotgunSound + , withSoundI shotgunS , useAmmo 1 , withRecoilI 100 , withMuzFlareI @@ -461,7 +461,7 @@ multGun = defaultGun [ ammoCheckI , hammerCheckI , useTimeCheckI - , withSoundI shotgunSound + , withSoundI shotgunS , useAmmo 1 , withRecoilI 200 , withMuzFlareI @@ -499,7 +499,7 @@ longGun = defaultGun , _wpLoadedAmmo = 1 , _wpReloadTime = 100 , _wpReloadState = 0 - , _wpReloadType = PassiveReload skwareFadeTwoSecSound + , _wpReloadType = PassiveReload skwareFadeTwoSecS , _itUseRate = 100 , _itUseTime = 0 , _itUse = useAmmoParams @@ -507,7 +507,7 @@ longGun = defaultGun [ ammoCheckI , hammerCheckI , useTimeCheckI - , withSoundI longGunSound + , withSoundI bangEchoS , useAmmo 1 , withThickSmokeI , torqueAfterI 0.05 @@ -553,7 +553,7 @@ poisonSprayer = defaultAutoGun , _itUseModifiers = [ ammoCheckI , useTimeCheckI - , withSoundForI foamSpray 5 + , withSoundForI foamSprayLoopS 5 , useAmmo 1 , spreadNumI ] @@ -752,10 +752,10 @@ moveRemoteBomb itid time pID w $ set (projectiles .ix pID.pjUpdate) (\_ -> moveRemoteBomb itid (f time) pID) w | time < 2 = case hitWl of - Just (p,_) -> soundFrom (Tap 0) p tapQuiet Nothing $ halfV updatedWorld + Just (p,_) -> soundFrom (Tap 0) p tapQuietS Nothing $ halfV updatedWorld _ -> halfV updatedWorld | otherwise = case hitWl of - Just (p,_) -> soundFrom (Tap 0) p tapQuiet Nothing updatedWorld + Just (p,_) -> soundFrom (Tap 0) p tapQuietS Nothing updatedWorld _ -> updatedWorld where updatedWorld @@ -875,7 +875,7 @@ fireRemoteLauncher :: Creature -> World -> World fireRemoteLauncher cr w = setLocation $ resetFire $ resetName - $ soundFrom (CrWeaponSound cid) pos launcherSound Nothing + $ soundFrom (CrWeaponSound cid) pos tap4S Nothing $ over projectiles addRemRocket w where i = IM.newKey $ _projectiles w @@ -923,7 +923,7 @@ moveRemoteShell cid itid pj w ( ( pjVel %~ ( (accel +.+) . (frict *.*) ) ) . ( pjDir .~ newdir ) ) - & soundFrom (ShellSound i) newPos smokeTrailSound (Just 1) + & soundFrom (ShellSound i) newPos missileLaunchS (Just 1) & smokeGen & makeFlameletTimed oldPos 20 (0.5 *.* rotateV (pi+sparkD) accel) Nothing 3 10 | time > -200 = case thingHit of diff --git a/src/Dodge/Item/Weapon/AutoGun.hs b/src/Dodge/Item/Weapon/AutoGun.hs index 153ac65bc..6a0f24c5c 100644 --- a/src/Dodge/Item/Weapon/AutoGun.hs +++ b/src/Dodge/Item/Weapon/AutoGun.hs @@ -13,7 +13,7 @@ import Dodge.Picture.Layer import Dodge.Item.Draw import Dodge.Item.Weapon.Bullet import Dodge.Item.Weapon.TriggerType -import Dodge.SoundLogic.Synonyms +import Dodge.SoundLogic.LoadSound import Picture import Geometry @@ -40,7 +40,7 @@ autoGun = defaultAutoGun [('M', torqueBefore 0.08) ,('S', torqueBefore 0.05) ] - , withSoundI autoGunSound + , withSoundForI autoBS 5 , useAmmo 1 , withRandomDirI (autogunSpread/2) , withMuzFlareI diff --git a/src/Dodge/Item/Weapon/Bezier.hs b/src/Dodge/Item/Weapon/Bezier.hs index b6f7e3056..d7e217e3a 100644 --- a/src/Dodge/Item/Weapon/Bezier.hs +++ b/src/Dodge/Item/Weapon/Bezier.hs @@ -15,6 +15,7 @@ import Dodge.Particle.Bullet.HitEffect import Dodge.WorldEvent.HitEffect import Dodge.RandomHelp import Dodge.Picture.Layer +import Dodge.SoundLogic.LoadSound import Picture import Geometry @@ -28,7 +29,7 @@ bezierGun = defaultGun , _itUse = \_ -> useTargetPos $ \p -> shootBezier $ fromJust p -- <- the start point , _itUseModifiers = [ useTimeCheckI - , withSoundI 0 + , withSoundI tap2S , useAmmo 1 , withMuzFlareI . withRecoilI 40 diff --git a/src/Dodge/Item/Weapon/Grenade.hs b/src/Dodge/Item/Weapon/Grenade.hs index d2645b180..b876916a8 100644 --- a/src/Dodge/Item/Weapon/Grenade.hs +++ b/src/Dodge/Item/Weapon/Grenade.hs @@ -7,7 +7,7 @@ import Dodge.Base import Dodge.Zone import Dodge.Picture.Layer import Dodge.SoundLogic -import Dodge.SoundLogic.Synonyms +import Dodge.SoundLogic.LoadSound import Dodge.Item.Attachment.Data import Dodge.Item.Draw import Dodge.Default.Shell @@ -32,7 +32,7 @@ moveGrenade 0 _ pID w = over projectiles (IM.delete pID) pj = _projectiles w IM.! pID explosion = _pjPayload pj moveGrenade time dir pID w = case hitWl of - Just (p,_) -> soundFrom (Tap 0) p tapQuiet Nothing updatedWorld + Just (p,_) -> soundFrom (Tap 0) p tapQuietS Nothing updatedWorld _ -> updatedWorld where updatedWorld = updateV $ set (projectiles . ix pID . pjPos) finalPos diff --git a/src/Dodge/Item/Weapon/Launcher.hs b/src/Dodge/Item/Weapon/Launcher.hs index c1481f366..675be0b29 100644 --- a/src/Dodge/Item/Weapon/Launcher.hs +++ b/src/Dodge/Item/Weapon/Launcher.hs @@ -4,7 +4,7 @@ import Dodge.Data import Dodge.Data.SoundOrigin import Dodge.Default.Weapon import Dodge.Default.Shell -import Dodge.SoundLogic.Synonyms +import Dodge.SoundLogic.LoadSound import Dodge.WorldEvent.Explosion import Dodge.Picture.Layer import Dodge.Item.Data @@ -43,7 +43,7 @@ launcher = defaultGun , _itUseModifiers = [ ammoCheckI , useTimeCheckI - , withSoundI launcherSound + , withSoundI tap4S , useAmmo 1 ] , _wpSpread = 0.02 @@ -107,7 +107,7 @@ doThrust :: Projectile -> World -> World doThrust pj w = w & randGen .~ g & projectiles . ix i . pjVel %~ (\v -> accel +.+ frict *.* v) - & soundFrom (ShellSound i) newPos smokeTrailSound (Just 1) + & soundFrom (ShellSound i) newPos missileLaunchS (Just 1) & makeFlameletTimed (oldPos -.- vel) 0 (vel +.+ rotateV (pi+sparkD) accel) Nothing 3 10 & smokeGen where diff --git a/src/Dodge/Item/Weapon/TriggerType.hs b/src/Dodge/Item/Weapon/TriggerType.hs index 0e4aa36db..70087f1f6 100644 --- a/src/Dodge/Item/Weapon/TriggerType.hs +++ b/src/Dodge/Item/Weapon/TriggerType.hs @@ -44,6 +44,7 @@ import Dodge.RandomHelp import Dodge.Item.Attachment.Data import Dodge.Item.Data import Dodge.Default +import Sound.Data import Geometry import Geometry.Vector3D @@ -121,7 +122,7 @@ rateIncABI startRate fastRate exeffFirst exeffCont eff item cr w && _itUseTime item == 0 {- | Apply effect after a warm up. -} withWarmUpI - :: Int -- ^ warm up sound id + :: SoundID -- ^ warm up sound id -> ChainEffect withWarmUpI soundID f item cr w | _wpReloadState item /= 0 = w @@ -140,7 +141,7 @@ withWarmUpI soundID f item cr w {- | Adds a sound to a creature based world effect. The sound is emitted from the creature's position. -} withSoundI - :: Int -- ^ Sound id + :: SoundID -- ^ Sound id -> ChainEffect withSoundI soundid f item cr = soundFrom (CrWeaponSound cid) (_crPos cr) soundid Nothing @@ -151,7 +152,7 @@ withSoundI soundid f item cr {- | Adds a sound to a creature based world effect. The sound is emitted from the creature's position. -} withSoundForI - :: Int -- ^ Sound id + :: SoundID -- ^ Sound id -> Int -- ^ Frames to play -> ChainEffect withSoundForI soundid playTime f item cr diff --git a/src/Dodge/LevelGen/Block.hs b/src/Dodge/LevelGen/Block.hs index 46b8f9bc8..792330b92 100644 --- a/src/Dodge/LevelGen/Block.hs +++ b/src/Dodge/LevelGen/Block.hs @@ -6,8 +6,10 @@ import Dodge.Base import Dodge.Zone import Dodge.Zone.Data import Dodge.SoundLogic +import Dodge.SoundLogic.LoadSound import Dodge.WorldEvent.Sound import Dodge.LevelGen.Pathing +import Dodge.RandomHelp import Geometry import Picture.Data import qualified IntMapHelp as IM @@ -46,12 +48,12 @@ killBlock bl w = f bl . flip (foldr unshadow) (_blShadows bl) $ w pos = fst $ _wlLine bl breakHitSound bl' | _wlIsSeeThrough bl' = mkSoundBreakGlass pos - | otherwise = soundMultiFrom sos (fst $ _wlLine bl') (soundid + 4) Nothing + | otherwise = soundMultiFrom sos (fst $ _wlLine bl') impactSound Nothing hitSound' bl' | _wlIsSeeThrough bl' = mkSoundSplinterGlass pos - | otherwise = soundMultiFrom sos (fst $ _wlLine bl') soundid Nothing + | otherwise = soundMultiFrom sos (fst $ _wlLine bl') impactSound Nothing sos = [BlockDegradeSound 0,BlockDegradeSound 1] - (soundid,_) = randomR (29,32) $ _randGen w + impactSound = evalState (takeOne [impact1S,impact2S,impact3S,impact4S]) $ _randGen w unshadow :: Int -> World -> World unshadow bid w' = case w' ^? walls . ix bid of Just b -> diff --git a/src/Dodge/LevelGen/MoveDoor.hs b/src/Dodge/LevelGen/MoveDoor.hs index 5a7296e2e..299adbf15 100644 --- a/src/Dodge/LevelGen/MoveDoor.hs +++ b/src/Dodge/LevelGen/MoveDoor.hs @@ -11,7 +11,7 @@ import Dodge.Base import Dodge.Zone import Dodge.Zone.Data import Dodge.SoundLogic -import Dodge.SoundLogic.Synonyms +import Dodge.SoundLogic.LoadSound import Geometry import qualified Data.IntMap.Strict as IM @@ -70,7 +70,7 @@ addSoundToDoor i pld hwd (x:ys) = f x : ys where g dm w | dist wp pld > 2 && dist wp hwd > 2 - = soundFrom (WallSound i) wp doorSound (Just 1) $ dm w + = soundFrom (WallSound i) wp slideDoorS (Just 1) $ dm w | otherwise = dm w where wp = fst $ _wlLine (_walls w IM.! i) diff --git a/src/Dodge/LevelGen/Switch.hs b/src/Dodge/LevelGen/Switch.hs index da35c8ccb..ea2cfbeb9 100644 --- a/src/Dodge/LevelGen/Switch.hs +++ b/src/Dodge/LevelGen/Switch.hs @@ -3,6 +3,7 @@ module Dodge.LevelGen.Switch import Dodge.Data import Dodge.Data.SoundOrigin import Dodge.SoundLogic +import Dodge.SoundLogic.LoadSound import Dodge.Picture.Layer import Picture import Geometry @@ -19,7 +20,7 @@ makeButton c eff = Button , _btPos = V2 0 0 , _btRot = 0 , _btEvent = \b w -> eff . over buttons (IM.adjust turnOn (_btID b)) - . soundFromGeneral (LeverSound 0) (btpos b) 1 Nothing $ w + . soundFromGeneral (LeverSound 0) (btpos b) click1S Nothing $ w , _btID = 0 , _btText = "Button" --, _btText = "Button" @@ -45,7 +46,7 @@ makeSwitch c effOn effOff = Button , _btState = BtOff } where - flipSwitch b w = switchEffect b . soundFromGeneral (LeverSound 0) (bpos b) 1 Nothing $ w + flipSwitch b w = switchEffect b . soundFromGeneral (LeverSound 0) (bpos b) click1S Nothing $ w bpos b w = _btPos $ _buttons w IM.! _btID b switchEffect b = case _btState b of BtOff -> effOn . over buttons (IM.adjust turnOn (_btID b)) diff --git a/src/Dodge/Particle/Bullet/HitEffect.hs b/src/Dodge/Particle/Bullet/HitEffect.hs index 8fa2920a9..e17859f7c 100644 --- a/src/Dodge/Particle/Bullet/HitEffect.hs +++ b/src/Dodge/Particle/Bullet/HitEffect.hs @@ -11,6 +11,7 @@ import Dodge.WorldEvent import Dodge.Particle.Bullet.Spawn import Dodge.WorldEvent.DamageBlock import Dodge.SoundLogic +import Dodge.SoundLogic.LoadSound import Dodge.RandomHelp import Dodge.WorldEvent.Shockwave import Dodge.Creature.State.Data @@ -37,7 +38,7 @@ bulHitCr bt p cr w mvDams = [ PushDam 1 $ 2 *.* bulVel ] addDamage = creatures . ix cid . crState . crDamage %~ ((Piercing 100 sp p ep : mvDams) ++ ) addDamageArmoured = creatures . ix cid . crState . crDamage %~ (mvDams ++) - makeHitSound = soundMultiFrom [CrHitSound 0] p 15 (Just 10) + makeHitSound = soundMultiFrom [CrHitSound 0] p hit1S (Just 10) flashEff = over worldEvents (bloodFlashAt p . ) cid = _crID cr (d1,_) = randomR (-0.7,0.7) $ _randGen w @@ -55,7 +56,7 @@ bulBounceArmCr' bt p cr w mvDams = [ PushDam 1 $ 2 *.* bulVel ] addDamage = creatures . ix cid . crState . crDamage %~ ((Piercing 100 sp p ep : mvDams) ++ ) addDamageArmoured = creatures . ix cid . crState . crDamage %~ (mvDams ++) - makeHitSound = soundMultiFrom [CrHitSound 0] p 15 (Just 10) + makeHitSound = soundMultiFrom [CrHitSound 0] p hit1S (Just 10) flashEff = over worldEvents ((.) $ bloodFlashAt p) cid = _crID cr newDir = safeNormalizeV (p -.- _crPos cr) @@ -76,7 +77,7 @@ bulPenCr' bt p cr w ] ++ ) - $ soundMultiFrom [CrHitSound 0] ep 15 (Just 10) + $ soundMultiFrom [CrHitSound 0] ep hit1S (Just 10) $ over worldEvents (addPiercer . ) w where @@ -100,7 +101,7 @@ hvBulHitCr bt p cr w ] ++ ) - $ soundMultiFrom [CrHitSound 0] ep 15 (Just 10) + $ soundMultiFrom [CrHitSound 0] ep hit1S (Just 10) w where (d1,_) = randomR (-0.7,0.7) $ _randGen w @@ -112,7 +113,7 @@ bulIncCr' :: Particle -> Point2 -> Creature -> World -> World bulIncCr' bt p cr w = over (creatures . ix cid . crState . crDamage) ( Piercing 60 sp p ep : ) - . soundMultiFrom [CrHitSound 0] p 15 (Just 10) + . soundMultiFrom [CrHitSound 0] p hit1S (Just 10) $ incFlamelets w where @@ -126,7 +127,7 @@ bulConCr' :: Particle -> Point2 -> Creature -> World -> World bulConCr' bt p cr w = over (creatures . ix cid . crState . crDamage) ( Piercing 60 sp p ep : ) - . soundMultiFrom [CrHitSound 0] p 15 (Just 10) + . soundMultiFrom [CrHitSound 0] p hit1S (Just 10) $ mkwave w where diff --git a/src/Dodge/Render/Picture.hs b/src/Dodge/Render/Picture.hs index 8580acd14..a00bec1a3 100644 --- a/src/Dodge/Render/Picture.hs +++ b/src/Dodge/Render/Picture.hs @@ -10,6 +10,7 @@ import Dodge.Picture.SizeInvariant import Dodge.Picture.Layer import Dodge.Render.HUD import Dodge.Render.MenuScreen +import Dodge.SoundLogic.LoadSound import Sound.Data import Geometry import Picture @@ -77,7 +78,7 @@ soundPic :: World -> Sound -> Picture soundPic w s = fixedSizePicClampArrow 50 50 thePic p w where p = _soundPos s - thePic = scale 0.15 0.15 $ text "SOUND" + thePic = scale 0.15 0.15 $ text $ soundToOnomato $ _soundChunkID s crDraw :: World -> Creature -> Picture crDraw w c = _crPict c c w diff --git a/src/Dodge/SoundLogic.hs b/src/Dodge/SoundLogic.hs index 3c2e5a97e..db20eff70 100644 --- a/src/Dodge/SoundLogic.hs +++ b/src/Dodge/SoundLogic.hs @@ -23,6 +23,7 @@ import Sound.Data import Geometry.Data import Geometry.Vector import Dodge.SoundLogic.Synonyms +import Dodge.SoundLogic.LoadSound import Control.Lens import qualified Data.Map as M @@ -44,7 +45,7 @@ resumeSound w = w For each origin only one sound will play at a time. -} soundOnceOrigin - :: Int -- ^ ID of the sound to be played + :: SoundID -- ^ ID of the sound to be played -> SoundOrigin -- ^ The \"creator\" of the sound -> Point2 -- ^ The position of the sound in the world -> World @@ -58,14 +59,14 @@ soundOnceOrigin sType so p w = w & sounds %~ M.insertWith (\ _ x -> x) so theSou , _soundChannel = Nothing , _soundAngDist = Just (a,0) , _soundPos = p - , _soundVolume = soundVolID sType + , _soundVolume = soundToVol sType } a = soundAngle p w soundFrom :: SoundOrigin -- ^ \"Creator\" of sound -> Point2 -- ^ Position of sound - -> Int -- ^ ID of sound to be played + -> SoundID -- ^ ID of sound to be played -> Maybe Int -- ^ Frames to play sound for, Nothing for until finished -> World -> World @@ -78,7 +79,7 @@ soundFrom so pos sType mtime w = over sounds (M.insertWith f so sound) w , _soundChannel = Nothing , _soundAngDist = Just (a,0) , _soundPos = pos - , _soundVolume = soundVolID sType + , _soundVolume = soundToVol sType } f _ s = s {_soundTime = mtime } a = soundAngle pos w @@ -86,7 +87,7 @@ soundFrom so pos sType mtime w = over sounds (M.insertWith f so sound) w soundFromGeneral :: SoundOrigin -- ^ \"Creator\" of sound -> (World -> Point2) -- ^ Position of sound - -> Int -- ^ ID of sound to be played + -> SoundID -- ^ ID of sound to be played -> Maybe Int -- ^ Frames to play sound for, Nothing for until finished -> World -> World @@ -99,7 +100,7 @@ soundFromGeneral so fpos sType mtime w = over sounds (M.insertWith f so sound) w , _soundChannel = Nothing , _soundAngDist = Just (a,0) , _soundPos = fpos w - , _soundVolume = soundVolID sType + , _soundVolume = soundToVol sType } f _ s = s {_soundTime = mtime } a = soundAngle (fpos w) w @@ -124,7 +125,7 @@ Does nothing if all origins are already creating sounds. -} soundMultiFrom :: [SoundOrigin] -> Point2 -- ^ Position - -> Int -- ^ Sound ID + -> SoundID -- ^ Sound ID -> Maybe Int -- ^ Frames to play for, Nothing for full length -> World -> World @@ -140,7 +141,7 @@ soundMultiFrom (so:sos) pos sType mtime w , _soundChannel = Nothing , _soundAngDist = Just (a,0) , _soundPos = pos - , _soundVolume = soundVolID sType + , _soundVolume = soundToVol sType } a = soundAngle pos w {- | Sets '_soundTime' to 0. -} diff --git a/src/Dodge/SoundLogic/LoadSound.hs b/src/Dodge/SoundLogic/LoadSound.hs index 6db55cf26..6f2e27d45 100644 --- a/src/Dodge/SoundLogic/LoadSound.hs +++ b/src/Dodge/SoundLogic/LoadSound.hs @@ -1,104 +1,318 @@ module Dodge.SoundLogic.LoadSound where +import Sound.Data + import qualified Data.IntMap.Strict as IM import qualified SDL.Mixer as Mix +loadSound :: (Int,String) -> IO (Int, Mix.Chunk) +loadSound (i,s) = do + chnk <- Mix.load $ "./data/sound/" ++ s + return (i,chnk) + loadSounds :: IO (IM.IntMap Mix.Chunk) loadSounds = do Mix.openAudio Mix.defaultAudio 128 - 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" - foamSprayFadeOut <- Mix.load "./data/sound/foamSprayFadeOut.wav" - sineRaisePitchOneSec <- Mix.load "./data/sound/sineRaisePitchOneSec.wav" - sineRaisePitchTwoSec <- Mix.load "./data/sound/sineRaisePitchTwoSec.wav" - skwareFadeTwoSec <- Mix.load "./data/sound/skwareFadeTwoSec.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 - , foamSprayFadeOut - , sineRaisePitchOneSec - , sineRaisePitchTwoSec - , skwareFadeTwoSec - ] + fmap IM.fromList $ mapM loadSound $ zip [0..] soundPathList + +soundToVol :: SoundID -> Float +soundToVol v = case _getSoundID v of + 0 -> 20 + 1 -> 80 + 2 -> 40 + 3 -> 30 + 4 -> 30 + 5 -> 100 + 6 -> 50 + 7 -> 20 + 8 -> 200 + 9 -> 100 + 10 -> 50 + 11 -> 80 + 12 -> 30 + 13 -> 80 + 14 -> 120 + 15 -> 50 + 16 -> 30 + 17 -> 100 + 18 -> 80 + 19 -> 50 + 20 -> 100 + 21 -> 120 + 22 -> 20 + 23 -> 20 + 24 -> 80 + 25 -> 30 + 26 -> 80 + 27 -> 80 + 28 -> 80 + 29 -> 50 + 30 -> 30 + 31 -> 40 + 32 -> 50 + 33 -> 50 + 34 -> 80 + 35 -> 80 + 36 -> 60 + 37 -> 40 + 38 -> 150 + 39 -> 40 + 40 -> 50 + 41 -> 40 + 42 -> 30 + 43 -> 80 + 44 -> 80 + 45 -> 20 + 46 -> 80 + 47 -> 50 + 48 -> 50 + 49 -> 30 + 50 -> 100 + 51 -> 50 + 52 -> 150 + 53 -> 100 + 54 -> 80 + 55 -> 30 + 56 -> 100 + 57 -> 100 + _ -> 50 +soundToOnomato :: SoundID -> String +soundToOnomato v = case _getSoundID v of + 0 -> "BLIH" + 1 -> "CRNK" + 2 -> "BRAP" + 3 -> "TIP" + 4 -> "THUD" + 5 -> "BRAP" + 6 -> "CRTINK" + 7 -> "SHUHP" + 8 -> "BOOM" + 9 -> "WHSSH" + 10 -> "KRTNKL" + 11 -> "CRUMPLE" + 12 -> "TAP" + 13 -> "CRUNK" + 14 -> "BRDBRDBRD" + 15 -> "WRR" + 16 -> "DRR" + 17 -> "TATATA" + 18 -> "TAK" + 19 -> "TRINKL" + 20 -> "SCREE" + 21 -> "BRPBRPBRP" + 22 -> "PHF" + 23 -> "FHP" + 24 -> "CRSNK" + 25 -> "BWAAH" + 26 -> "RINGGG" + 27 -> "ZMM" + 28 -> "BRAP" + 29 -> "HNH" + 30 -> "CHPCHPCHP" + 31 -> "SMACK" + 32 -> "HSSS" + 33 -> "HSS" + 34 -> "CRSK" + 35 -> "CRASH" + 36 -> "TAPTIP" + 37 -> "TIPTOP" + 38 -> "BANG" + 39 -> "TIPTAP" + 40 -> "THUD" + 41 -> "TAPP" + 42 -> "DWAAH" + 43 -> "TAKH" + 44 -> "BEP" + 45 -> "SWSH" + 46 -> "CRNKL" + 47 -> "CHNKCHNKCHUNK" + 48 -> "TINKLE" + 49 -> "TNKTNKTNK" + 50 -> "BRAHCHCH" + 51 -> "CLICK" + 52 -> "BANGG" + 53 -> "WRRR" + 54 -> "CRISH" + 55 -> "BWAH" + 56 -> "CRAKLE" + 57 -> "ZHM" + _ -> error "unitialised sound" +soundPathList :: [String] +soundPathList = + [ "heal.BLIH.20.wav" + , "glassShat3.CRNK.80.wav" + , "tapQuiet.BRAP.40.wav" + , "foot1.TIP.30.wav" + , "hit.THUD.30.wav" + , "autoGun.BRAP.100.wav" + , "smallGlass3.CRTINK.50.wav" + , "pickUp.SHUHP.20.wav" + , "explosion.BOOM.200.wav" + , "missileLaunch.WHSSH.100.wav" + , "smallGlass2.KRTNKL.50.wav" + , "impact3.CRUMPLE.80.wav" + , "foot2.TAP.30.wav" + , "impact2.CRUNK.80.wav" + , "mini1.BRDBRDBRD.120.wav" + , "fire.WRR.50.wav" + , "slideDoor.DRR.30.wav" + , "autoB.TATATA.100.wav" + , "tap1.TAK.80.wav" + , "smallGlass1.TRINKL.50.wav" + , "tone440sawtooth.SCREE.100.wav" + , "mini.BRPBRPBRP.120.wav" + , "whiteNoiseFadeOut.PHF.20.wav" + , "whiteNoiseFadeIn.FHP.20.wav" + , "glassShat1.CRSNK.80.wav" + , "sineRaisePitchTwoSec.BWAAH.30.wav" + , "tinitus.RINGGG.80.wav" + , "buzz.ZMM.80.wav" + , "tap3.BRAP.80.wav" + , "grunt.HNH.50.wav" + , "reload1.CHPCHPCHP.30.wav" + , "hit1.SMACK.40.wav" + , "foamSprayLoop.HSSS.50.wav" + , "foamSprayFadeOut.HSS.50.wav" + , "glassShat4.CRSK.80.wav" + , "impact1.CRASH.80.wav" + , "twoStep1.TAPTIP.60.wav" + , "twoStepSlow.TIPTOP.40.wav" + , "bang.BANG.150.wav" + , "twoStep.TIPTAP.40.wav" + , "tap4.THUD.50.wav" + , "foot3.TAPP.40.wav" + , "skwareFadeTwoSec.DWAAH.30.wav" + , "tap2.TAKH.80.wav" + , "tone440.BEP.80.wav" + , "knife.SWSH.20.wav" + , "glassShat2.CRNKL.80.wav" + , "crankSlow.CHNKCHNKCHUNK.50.wav" + , "smallGlass4.TINKLE.50.wav" + , "reload.TNKTNKTNK.30.wav" + , "shotgun.BRAHCHCH.100.wav" + , "click1.CLICK.50.wav" + , "bangEcho.BANGG.150.wav" + , "fireLoud.WRRR.100.wav" + , "impact4.CRISH.80.wav" + , "sineRaisePitchOneSec.BWAH.30.wav" + , "elecCrackle.CRAKLE.100.wav" + , "tele.ZHM.100.wav" + ] +healS :: SoundID +healS = SoundID 0 +glassShat3S :: SoundID +glassShat3S = SoundID 1 +tapQuietS :: SoundID +tapQuietS = SoundID 2 +foot1S :: SoundID +foot1S = SoundID 3 +hitS :: SoundID +hitS = SoundID 4 +autoGunS :: SoundID +autoGunS = SoundID 5 +smallGlass3S :: SoundID +smallGlass3S = SoundID 6 +pickUpS :: SoundID +pickUpS = SoundID 7 +explosionS :: SoundID +explosionS = SoundID 8 +missileLaunchS :: SoundID +missileLaunchS = SoundID 9 +smallGlass2S :: SoundID +smallGlass2S = SoundID 10 +impact3S :: SoundID +impact3S = SoundID 11 +foot2S :: SoundID +foot2S = SoundID 12 +impact2S :: SoundID +impact2S = SoundID 13 +mini1S :: SoundID +mini1S = SoundID 14 +fireS :: SoundID +fireS = SoundID 15 +slideDoorS :: SoundID +slideDoorS = SoundID 16 +autoBS :: SoundID +autoBS = SoundID 17 +tap1S :: SoundID +tap1S = SoundID 18 +smallGlass1S :: SoundID +smallGlass1S = SoundID 19 +tone440sawtoothS :: SoundID +tone440sawtoothS = SoundID 20 +miniS :: SoundID +miniS = SoundID 21 +whiteNoiseFadeOutS :: SoundID +whiteNoiseFadeOutS = SoundID 22 +whiteNoiseFadeInS :: SoundID +whiteNoiseFadeInS = SoundID 23 +glassShat1S :: SoundID +glassShat1S = SoundID 24 +sineRaisePitchTwoSecS :: SoundID +sineRaisePitchTwoSecS = SoundID 25 +tinitusS :: SoundID +tinitusS = SoundID 26 +buzzS :: SoundID +buzzS = SoundID 27 +tap3S :: SoundID +tap3S = SoundID 28 +gruntS :: SoundID +gruntS = SoundID 29 +reload1S :: SoundID +reload1S = SoundID 30 +hit1S :: SoundID +hit1S = SoundID 31 +foamSprayLoopS :: SoundID +foamSprayLoopS = SoundID 32 +foamSprayFadeOutS :: SoundID +foamSprayFadeOutS = SoundID 33 +glassShat4S :: SoundID +glassShat4S = SoundID 34 +impact1S :: SoundID +impact1S = SoundID 35 +twoStep1S :: SoundID +twoStep1S = SoundID 36 +twoStepSlowS :: SoundID +twoStepSlowS = SoundID 37 +bangS :: SoundID +bangS = SoundID 38 +twoStepS :: SoundID +twoStepS = SoundID 39 +tap4S :: SoundID +tap4S = SoundID 40 +foot3S :: SoundID +foot3S = SoundID 41 +skwareFadeTwoSecS :: SoundID +skwareFadeTwoSecS = SoundID 42 +tap2S :: SoundID +tap2S = SoundID 43 +tone440S :: SoundID +tone440S = SoundID 44 +knifeS :: SoundID +knifeS = SoundID 45 +glassShat2S :: SoundID +glassShat2S = SoundID 46 +crankSlowS :: SoundID +crankSlowS = SoundID 47 +smallGlass4S :: SoundID +smallGlass4S = SoundID 48 +reloadS :: SoundID +reloadS = SoundID 49 +shotgunS :: SoundID +shotgunS = SoundID 50 +click1S :: SoundID +click1S = SoundID 51 +bangEchoS :: SoundID +bangEchoS = SoundID 52 +fireLoudS :: SoundID +fireLoudS = SoundID 53 +impact4S :: SoundID +impact4S = SoundID 54 +sineRaisePitchOneSecS :: SoundID +sineRaisePitchOneSecS = SoundID 55 +elecCrackleS :: SoundID +elecCrackleS = SoundID 56 +teleS :: SoundID +teleS = SoundID 57 loadMusic :: IO (IM.IntMap Mix.Music) loadMusic = do diff --git a/src/Dodge/WorldEvent/Explosion.hs b/src/Dodge/WorldEvent/Explosion.hs index bedc1dae0..a503adbb6 100644 --- a/src/Dodge/WorldEvent/Explosion.hs +++ b/src/Dodge/WorldEvent/Explosion.hs @@ -12,7 +12,7 @@ import Dodge.WorldEvent.SpawnParticle --import Dodge.WorldEvent.Flash import Dodge.RandomHelp import Dodge.SoundLogic -import Dodge.SoundLogic.Synonyms +import Dodge.SoundLogic.LoadSound import Dodge.WorldEvent.Shockwave import Geometry import Geometry.Vector3D @@ -30,7 +30,7 @@ makePoisonExplosionAt -> World -> World makePoisonExplosionAt p w - = soundMultiFrom [Explosion 0,Explosion 1] p grenadeBang Nothing + = soundMultiFrom [Explosion 0,Explosion 1] p bangS Nothing $ foldr (makeGasCloud p) w vels where vels = replicateM 25 (randInCirc 2) & evalState $ _randGen w @@ -58,7 +58,7 @@ makeFlameExplosionAt -> World -> World makeFlameExplosionAt p w - = soundMultiFrom [Explosion 0,Explosion 1] p grenadeBang Nothing + = soundMultiFrom [Explosion 0,Explosion 1] p bangS Nothing $ over particles (newFlames ++ ) w where newFlames = zipWith makeFlameWithVelAndTime velocities timers @@ -73,7 +73,7 @@ makeExplosionAt -> World -> World makeExplosionAt p w - = soundMultiFrom [Explosion 0,Explosion 1] p grenadeBang Nothing + = soundMultiFrom [Explosion 0,Explosion 1] p bangS Nothing . addFlames -- . explosionFlashAt p . over tempLightSources (theTLS :) diff --git a/src/Dodge/WorldEvent/Sound.hs b/src/Dodge/WorldEvent/Sound.hs index 53acf8bf7..8a6a2238a 100644 --- a/src/Dodge/WorldEvent/Sound.hs +++ b/src/Dodge/WorldEvent/Sound.hs @@ -3,17 +3,21 @@ module Dodge.WorldEvent.Sound import Dodge.Data import Dodge.Data.SoundOrigin import Dodge.SoundLogic -import System.Random +import Dodge.SoundLogic.LoadSound import Geometry.Data +import Dodge.RandomHelp +import System.Random import Control.Lens +import Control.Monad.State.Lazy + mkSoundBreakGlass :: Point2 -> World -> World mkSoundBreakGlass p w = soundOnceOrigin soundid (GlassBreakSound 0) p $ set randGen g w where - (soundid,g) = _randGen w & randomR (37,40) + (soundid,g) = _randGen w & runState (takeOne [glassShat1S,glassShat2S,glassShat3S,glassShat4S]) mkSoundSplinterGlass :: Point2 -> World -> World mkSoundSplinterGlass p w = soundOnceOrigin soundid (GlassBreakSound 1) p $ set randGen g w where - (soundid,g) = _randGen w & randomR (33,36) + (soundid,g) = _randGen w & runState (takeOne [smallGlass1S,smallGlass2S,smallGlass3S,smallGlass4S]) diff --git a/src/Dodge/WorldEvent/SpawnParticle.hs b/src/Dodge/WorldEvent/SpawnParticle.hs index 2deb37db4..894ea8fe0 100644 --- a/src/Dodge/WorldEvent/SpawnParticle.hs +++ b/src/Dodge/WorldEvent/SpawnParticle.hs @@ -20,7 +20,7 @@ import Dodge.WorldEvent.Cloud import Dodge.Particle.Bullet.Draw import Dodge.Particle.Bullet.Update import Dodge.SoundLogic -import Dodge.SoundLogic.Synonyms +import Dodge.SoundLogic.LoadSound import Dodge.RandomHelp --import Dodge.Debug import Picture @@ -99,7 +99,7 @@ moveFlame rotd w pt _ -> (glare $ doSound damcrs , mvPt) where time = _btTimer' pt - doSound = soundFrom Flame (V2 x y) fireSound (Just 2) -- . over worldEvents ((.) $ flameGlareAt ep) + doSound = soundFrom Flame (V2 x y) fireS (Just 2) -- . over worldEvents ((.) $ flameGlareAt ep) glare | time `mod` 5 == 0 = tempLightSources %~ (theTLS :) diff --git a/src/Sound.hs b/src/Sound.hs index 9d8690f82..aa66fad10 100644 --- a/src/Sound.hs +++ b/src/Sound.hs @@ -82,7 +82,7 @@ tryPlay sd s = do i <- tryGetChannel s _ <- liftIO $ do Mix.halt i - Mix.playOn i Mix.Once (sd IM.! _soundChunkID s) + Mix.playOn i Mix.Once (sd IM.! (_getSoundID $ _soundChunkID s)) return $ s & soundChannel ?~ i & soundStatus .~ JustStartedPlaying diff --git a/src/Sound/Data.hs b/src/Sound/Data.hs index 3b9fd70d3..461367f80 100644 --- a/src/Sound/Data.hs +++ b/src/Sound/Data.hs @@ -15,6 +15,9 @@ data SoundStatus | ToStart deriving (Eq,Ord,Show) +newtype SoundID = SoundID { _getSoundID :: Int } + deriving (Eq,Ord,Show) + newtype SoundData = SoundData {_loadedChunks :: IM.IntMap Mix.Chunk } @@ -25,7 +28,7 @@ data Sound = Sound , _soundAngDist :: Maybe (Int16,Word8) , _soundPos :: Point2 , _soundVolume :: Float - , _soundChunkID :: Int + , _soundChunkID :: SoundID } deriving (Eq,Ord,Show)