2017-11-09 13:37:41 +00:00
|
|
|
var Class = require('../utils/Class');
|
2017-11-13 18:39:32 +00:00
|
|
|
var NOOP = require('../utils/NOOP');
|
|
|
|
var EventDispatcher = require('../events/EventDispatcher');
|
|
|
|
// Phaser.Sound.BaseSoundManager
|
2017-11-10 12:05:29 +00:00
|
|
|
var BaseSoundManager = new Class({
|
2017-11-13 18:39:32 +00:00
|
|
|
initialize: function BaseSoundManager(game) {
|
2017-11-10 18:05:26 +00:00
|
|
|
/**
|
2017-11-13 18:39:32 +00:00
|
|
|
* Local reference to game.
|
2017-11-16 14:23:35 +00:00
|
|
|
*
|
2017-11-13 18:39:32 +00:00
|
|
|
* @property {Phaser.Game} game
|
2017-11-10 18:05:26 +00:00
|
|
|
*/
|
|
|
|
this.game = game;
|
2017-11-16 15:04:07 +00:00
|
|
|
/**
|
|
|
|
* An array containing all added sounds.
|
|
|
|
*
|
|
|
|
* @property {Array} sounds
|
|
|
|
*/
|
|
|
|
this.sounds = [];
|
2017-11-13 18:39:32 +00:00
|
|
|
/**
|
|
|
|
* Global mute setting.
|
2017-11-16 14:23:35 +00:00
|
|
|
*
|
2017-11-13 18:39:32 +00:00
|
|
|
* @property {boolean} mute
|
|
|
|
*/
|
|
|
|
this.mute = false;
|
|
|
|
/**
|
|
|
|
* Global volume setting.
|
2017-11-16 14:23:35 +00:00
|
|
|
*
|
2017-11-13 18:39:32 +00:00
|
|
|
* @property {number} volume
|
|
|
|
*/
|
|
|
|
this.volume = 1;
|
|
|
|
/**
|
2017-11-16 14:23:35 +00:00
|
|
|
* Global playback rate at which all the audio assets will be played.
|
2017-11-13 18:39:32 +00:00
|
|
|
* Value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed
|
|
|
|
* and 2.0 doubles the audio's playback speed.
|
2017-11-16 14:23:35 +00:00
|
|
|
*
|
2017-11-13 18:39:32 +00:00
|
|
|
* @property {number} rate
|
|
|
|
*/
|
|
|
|
this.rate = 1;
|
2017-11-16 16:21:49 +00:00
|
|
|
/**
|
|
|
|
* Global detuning of all sounds in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29).
|
|
|
|
* The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent).
|
|
|
|
*
|
|
|
|
* @property {number} detune
|
|
|
|
*/
|
|
|
|
this.detune = 0;
|
2017-11-13 18:39:32 +00:00
|
|
|
/**
|
|
|
|
* Global amount of panning to apply.
|
|
|
|
* The value can range between -1 (full left pan) and 1 (full right pan).
|
|
|
|
* @property {number} pan
|
|
|
|
*/
|
|
|
|
this.pan = 0;
|
|
|
|
// TODO add fields for global spatialization options
|
|
|
|
/**
|
2017-11-21 17:02:24 +00:00
|
|
|
* Flag indicating if sounds should be paused when game looses focus,
|
|
|
|
* for instance when user switches tabs or to another program/app.
|
|
|
|
*
|
|
|
|
* @property {boolean} pauseOnBlur
|
2017-11-13 18:39:32 +00:00
|
|
|
*/
|
2017-11-21 17:02:24 +00:00
|
|
|
this.pauseOnBlur = true;
|
2017-11-13 18:39:32 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @property {Phaser.Events.EventDispatcher} events
|
|
|
|
*/
|
|
|
|
this.events = new EventDispatcher();
|
|
|
|
},
|
|
|
|
add: NOOP,
|
|
|
|
addAudioSprite: NOOP,
|
|
|
|
addOscillator: NOOP,
|
|
|
|
remove: NOOP,
|
|
|
|
removeByKey: NOOP,
|
|
|
|
pauseAll: NOOP,
|
|
|
|
resumeAll: NOOP,
|
|
|
|
stopAll: NOOP,
|
|
|
|
update: NOOP,
|
|
|
|
destroy: NOOP
|
2017-11-10 18:05:26 +00:00
|
|
|
});
|
2017-11-10 12:05:29 +00:00
|
|
|
module.exports = BaseSoundManager;
|