3 import Prelude
hiding (lookup)
4 import Graphics
.UI
.SDL
.Mixer
10 sounds
:: IntMap Chunk
15 startAudio
:: IO Audio
17 openAudio defaultFrequency AudioS16LSB
2 2048
18 allocateChannels maxChan
21 return Audio
{ sounds
= empty }
27 whenJust
:: (Monad m
) => Maybe a
-> (a
-> m b
) -> m
()
28 whenJust Nothing _
= return ()
29 whenJust
(Just x
) f
= f x
>> return ()
31 playSound
:: Int -> Audio
-> IO ()
32 playSound
id audio
= do
33 let chunk
= lookup id (sounds audio
)
34 whenJust chunk
(\x
-> tryPlayChannel
(-1) x
0)
37 fadeAll
:: Audio
-> IO ()
39 fadeOutChannel
(-1) 200