33 * @copyright 2018 Photon Storm Ltd.
44 * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License }
55 */
6-
76var Class = require ( '../utils/Class' ) ;
87var EventEmitter = require ( 'eventemitter3' ) ;
98var Extend = require ( '../utils/object/Extend' ) ;
@@ -25,12 +24,8 @@ var NOOP = require('../utils/NOOP');
2524 * @param {SoundConfig } [config] - An optional config object containing default sound settings.
2625 */
2726var BaseSound = new Class ( {
28-
2927 Extends : EventEmitter ,
30-
31- initialize :
32-
33- function BaseSound ( manager , key , config )
28+ initialize : function BaseSound ( manager , key , config )
3429 {
3530 EventEmitter . call ( this ) ;
3631
@@ -259,14 +254,12 @@ var BaseSound = new Class({
259254 {
260255 return false ;
261256 }
262-
263257 if ( this . markers [ marker . name ] )
264258 {
265259 // eslint-disable-next-line no-console
266260 console . error ( 'addMarker - Marker with name \'' + marker . name + '\' already exists for sound \'' + this . key + '\'!' ) ;
267261 return false ;
268262 }
269-
270263 marker = Extend ( true , {
271264 name : '' ,
272265 start : 0 ,
@@ -281,9 +274,7 @@ var BaseSound = new Class({
281274 delay : 0
282275 }
283276 } , marker ) ;
284-
285277 this . markers [ marker . name ] = marker ;
286-
287278 return true ;
288279 } ,
289280
@@ -303,16 +294,13 @@ var BaseSound = new Class({
303294 {
304295 return false ;
305296 }
306-
307297 if ( ! this . markers [ marker . name ] )
308298 {
309299 // eslint-disable-next-line no-console
310300 console . error ( 'updateMarker - Marker with name \'' + marker . name + '\' does not exist for sound \'' + this . key + '\'!' ) ;
311301 return false ;
312302 }
313-
314303 this . markers [ marker . name ] = Extend ( true , this . markers [ marker . name ] , marker ) ;
315-
316304 return true ;
317305 } ,
318306
@@ -329,14 +317,11 @@ var BaseSound = new Class({
329317 removeMarker : function ( markerName )
330318 {
331319 var marker = this . markers [ markerName ] ;
332-
333320 if ( ! marker )
334321 {
335322 return null ;
336323 }
337-
338324 this . markers [ markerName ] = null ;
339-
340325 return marker ;
341326 } ,
342327
@@ -356,20 +341,17 @@ var BaseSound = new Class({
356341 play : function ( markerName , config )
357342 {
358343 if ( markerName === void 0 ) { markerName = '' ; }
359-
360344 if ( typeof markerName === 'object' )
361345 {
362346 config = markerName ;
363347 markerName = '' ;
364348 }
365-
366349 if ( typeof markerName !== 'string' )
367350 {
368351 // eslint-disable-next-line no-console
369352 console . error ( 'Sound marker name has to be a string!' ) ;
370353 return false ;
371354 }
372-
373355 if ( ! markerName )
374356 {
375357 this . currentMarker = null ;
@@ -384,17 +366,14 @@ var BaseSound = new Class({
384366 console . error ( 'No marker with name \'' + markerName + '\' found for sound \'' + this . key + '\'!' ) ;
385367 return false ;
386368 }
387-
388369 this . currentMarker = this . markers [ markerName ] ;
389370 this . currentConfig = this . currentMarker . config ;
390371 this . duration = this . currentMarker . duration ;
391372 }
392-
393373 this . resetConfig ( ) ;
394374 this . currentConfig = Extend ( this . currentConfig , config ) ;
395375 this . isPlaying = true ;
396376 this . isPaused = false ;
397-
398377 return true ;
399378 } ,
400379
@@ -412,10 +391,8 @@ var BaseSound = new Class({
412391 {
413392 return false ;
414393 }
415-
416394 this . isPlaying = false ;
417395 this . isPaused = true ;
418-
419396 return true ;
420397 } ,
421398
@@ -433,10 +410,8 @@ var BaseSound = new Class({
433410 {
434411 return false ;
435412 }
436-
437413 this . isPlaying = true ;
438414 this . isPaused = false ;
439-
440415 return true ;
441416 } ,
442417
@@ -514,7 +489,6 @@ var BaseSound = new Class({
514489 {
515490 return ;
516491 }
517-
518492 this . pendingRemove = true ;
519493 this . manager = null ;
520494 this . key = '' ;
@@ -539,17 +513,14 @@ var BaseSound = new Class({
539513 var cent = 1.0005777895065548 ; // Math.pow(2, 1/1200);
540514 var totalDetune = this . currentConfig . detune + this . manager . detune ;
541515 var detuneRate = Math . pow ( cent , totalDetune ) ;
542-
543516 this . totalRate = this . currentConfig . rate * this . manager . rate * detuneRate ;
544517 }
545518} ) ;
546519Object . defineProperty ( BaseSound . prototype , 'rate' , {
547-
548520 get : function ( )
549521 {
550522 return this . currentConfig . rate ;
551523 } ,
552-
553524 set : function ( value )
554525 {
555526 this . currentConfig . rate = value ;
@@ -564,12 +535,10 @@ Object.defineProperty(BaseSound.prototype, 'rate', {
564535 }
565536} ) ;
566537Object . defineProperty ( BaseSound . prototype , 'detune' , {
567-
568538 get : function ( )
569539 {
570540 return this . currentConfig . detune ;
571541 } ,
572-
573542 set : function ( value )
574543 {
575544 this . currentConfig . detune = value ;
@@ -583,5 +552,4 @@ Object.defineProperty(BaseSound.prototype, 'detune', {
583552 this . emit ( 'detune' , this , value ) ;
584553 }
585554} ) ;
586-
587555module . exports = BaseSound ;
0 commit comments