@@ -18,8 +18,13 @@ define () ->
1818 buzzObjectsPool : []
1919 soundFilesPaths : {}
2020 soundLoops : []
21+
22+ useBuzzPooled : false
23+ useBuzzFireAndForget : false
24+ useLowLag : false
25+ useSoundsJS : false
2126
22- constructor : (@eventRouter , @timeKeeper , @buzz , @lowLag , @Bowser , @samplebank ) ->
27+ constructor : (@eventRouter , @timeKeeper , @createjs , @ buzz , @lowLag , @Bowser , @samplebank ) ->
2328 @soundLoops .soundIDs = []
2429 @soundLoops .beatStrings = []
2530
@@ -33,7 +38,17 @@ define () ->
3338
3439 @timeKeeper .addListener (' beat' , (beat ) => @ soundLoop (beat) );
3540
36- @ playSound = (a ,b ,c ) => @ play_using_LOWLAGJS (a,b,c)
41+ if @Bowser .msie
42+ @useSoundsJS = true
43+ @ playSound = (a ,b ,c ) => @ play_using_SOUNDJS (a,b,c)
44+
45+ # @playSound = (a,b,c) => @play_using_BUZZ_JS_FIRE_AND_FORGET(a,b,c)
46+
47+ # @useBuzzPooled = true
48+ # @playSound = (a,b,c) => @play_using_BUZZJS_WITH_ONE_POOL_PER_SOUND(a,b,c)
49+
50+ else
51+ @ playSound = (a ,b ,c ) => @ play_using_LOWLAGJS (a,b,c)
3752
3853 addToScope : (scope ) ->
3954
@@ -94,6 +109,9 @@ define () ->
94109 availableBuzzObject = new @buzz .sound (soundFilePath)
95110 availableBuzzObject .play ()
96111
112+ play_using_SOUNDJS : (soundFilesPaths ,loopedSoundID ,@buzzObjectsPool ) ->
113+ @createjs .Sound .play (loopedSoundID)
114+
97115 play_using_DYNAMICALLY_CREATED_AUDIO_TAG : (soundFilesPaths ,loopedSoundID ,@buzzObjectsPool ) ->
98116 audioElement = undefined
99117 source1 = undefined
@@ -133,7 +151,7 @@ define () ->
133151 # create a new one
134152 # OR there are already too many, so simply put the sound system
135153 # is mangled.
136- if @totalCreatedSoundObjects > 31
154+ if @totalCreatedSoundObjects > 91
137155 @soundSystemIsMangled = true
138156 $ (" #soundSystemIsMangledMessage" ).modal ()
139157 $ (" #simplemodal-container" ).height 250
@@ -204,9 +222,22 @@ define () ->
204222 soundInfo = undefined
205223 preloadSounds = undefined
206224 soundDef = @samplebank
225+
226+ if @useSoundsJS
227+ loadHandler = (event , theSound ) ->
228+ # This is fired for each sound that is registered.
229+ instance = createjs .Sound .play (event .src ) # play using id. Could also use full source path or event.src.
230+ instance .volume = 0.001
231+ return
232+ createjs .Sound .addEventListener " fileload" , createjs .proxy (loadHandler, @ );
233+
207234 for cycleSoundDefs in [0 ... soundDef .sounds .length ]
235+
208236 soundInfo = soundDef .getByNumber (cycleSoundDefs)
209- # @buzzObjectsPool[soundInfo.name] = []
237+ if @useSoundsJS
238+ createjs .Sound .registerSound soundInfo .path , soundInfo .name , 30
239+ if @useBuzzPooled
240+ @buzzObjectsPool [soundInfo .name ] = []
210241 @soundFilesPaths [soundInfo .name ] = soundInfo .path
211242 @lowLag .load (soundInfo .path ,soundInfo .name )
212243
0 commit comments