Skip to content

Commit 0a73500

Browse files
authored
Update all references of pc.AudioManager to pc.SoundManager (playcanvas#1999)
1 parent 78d7cb9 commit 0a73500

File tree

6 files changed

+28
-29
lines changed

6 files changed

+28
-29
lines changed

src/audio/channel.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ Object.assign(pc, function () {
33

44
var Channel;
55

6-
if (pc.AudioManager.hasAudioContext()) {
6+
if (pc.SoundManager.hasAudioContext()) {
77
/**
88
* @private
99
* @class
1010
* @name pc.Channel
11-
* @classdesc A channel is created when the pc.AudioManager begins playback of a pc.Sound. Usually created internally by
12-
* pc.AudioManager#playSound or pc.AudioManager#playSound3d. Developers usually won't have to create Channels manually.
13-
* @param {pc.AudioManager} manager - The AudioManager instance.
14-
* @param {pc.Sound} sound - The sound to playback.
15-
* @param {object} [options] - Optional options object.
16-
* @param {number} [options.volume=1] - The playback volume, between 0 and 1.
17-
* @param {number} [options.pitch=1] - The relative pitch, default of 1, plays at normal pitch.
18-
* @param {boolean} [options.loop=false] - Whether the sound should loop when it reaches the end or not.
11+
* @classdesc A channel is created when the pc.SoundManager begins playback of a pc.Sound. Usually created internally by
12+
* pc.SoundManager#playSound or pc.SoundManager#playSound3d. Developers usually won't have to create Channels manually.
13+
* @param {pc.SoundManager} manager - The SoundManager instance.
14+
* @param {pc.Sound} sound - The sound to playback.
15+
* @param {object} [options] - Optional options object.
16+
* @param {number} [options.volume=1] - The playback volume, between 0 and 1.
17+
* @param {number} [options.pitch=1] - The relative pitch, default of 1, plays at normal pitch.
18+
* @param {boolean} [options.loop=false] - Whether the sound should loop when it reaches the end or not.
1919
*/
2020
Channel = function (manager, sound, options) {
2121
options = options || {};
@@ -139,7 +139,7 @@ Object.assign(pc, function () {
139139
* @function
140140
* @name pc.Channel#setLoop
141141
* @description Enable/disable the loop property to make the sound restart from the beginning when it reaches the end.
142-
* @param {boolean} loop - True to loop the sound, false otherwise.
142+
* @param {boolean} loop - True to loop the sound, false otherwise.
143143
*/
144144
setLoop: function (loop) {
145145
this.loop = loop;
@@ -153,7 +153,7 @@ Object.assign(pc, function () {
153153
* @function
154154
* @name pc.Channel#setVolume
155155
* @description Set the volume of playback between 0 and 1.
156-
* @param {number} volume - The volume of the sound. Will be clamped between 0 and 1.
156+
* @param {number} volume - The volume of the sound. Will be clamped between 0 and 1.
157157
*/
158158
setVolume: function (volume) {
159159
volume = pc.math.clamp(volume, 0, 1);
@@ -196,7 +196,7 @@ Object.assign(pc, function () {
196196
}
197197
}
198198
});
199-
} else if (pc.AudioManager.hasAudio()) {
199+
} else if (pc.SoundManager.hasAudio()) {
200200
Channel = function (manager, sound, options) {
201201
this.volume = options.volume || 1;
202202
this.loop = options.loop || false;

src/audio/channel3d.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Object.assign(pc, function () {
66

77
var Channel3d;
88

9-
if (pc.AudioManager.hasAudioContext()) {
9+
if (pc.SoundManager.hasAudioContext()) {
1010
Channel3d = function (manager, sound, options) {
1111
pc.Channel.call(this, manager, sound, options);
1212

@@ -93,7 +93,7 @@ Object.assign(pc, function () {
9393
}
9494
}
9595
});
96-
} else if (pc.AudioManager.hasAudio()) {
96+
} else if (pc.SoundManager.hasAudio()) {
9797
// temp vector storage
9898
var offset = new pc.Vec3();
9999

src/backwards-compatibility.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,8 @@ pc.AssetRegistry.prototype.getAssetById = function (id) {
345345
return this.get(id);
346346
};
347347

348+
pc.AudioManager = pc.SoundManager;
349+
348350
pc.GraphNode.prototype._dirtify = function (local) {
349351
// #ifdef DEBUG
350352
console.warn('DEPRECATED: pc.GraphNode#_dirtify is deprecated. Use pc.GraphNode#_dirtifyLocal or _dirtifyWorld respectively instead.');

src/framework/application.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ Object.assign(pc, function () {
290290

291291
this.graphicsDevice = new pc.GraphicsDevice(canvas, options.graphicsDeviceOptions);
292292
this.stats = new pc.ApplicationStats(this.graphicsDevice);
293-
this._audioManager = new pc.SoundManager(options);
293+
this._soundManager = new pc.SoundManager(options);
294294
this.loader = new pc.ResourceLoader(this);
295295

296296
// stores all entities that have been created
@@ -582,7 +582,7 @@ Object.assign(pc, function () {
582582
this.loader.addHandler("texture", new pc.TextureHandler(this.graphicsDevice, this.assets, this.loader));
583583
this.loader.addHandler("text", new pc.TextHandler());
584584
this.loader.addHandler("json", new pc.JsonHandler());
585-
this.loader.addHandler("audio", new pc.AudioHandler(this._audioManager));
585+
this.loader.addHandler("audio", new pc.AudioHandler(this._soundManager));
586586
this.loader.addHandler("script", new pc.ScriptHandler(this));
587587
this.loader.addHandler("scene", new pc.SceneHandler(this));
588588
this.loader.addHandler("cubemap", new pc.CubemapHandler(this.graphicsDevice, this.assets, this.loader));
@@ -611,9 +611,9 @@ Object.assign(pc, function () {
611611
} else {
612612
this.systems.add(new pc.ScriptComponentSystem(this));
613613
}
614-
this.systems.add(new pc.AudioSourceComponentSystem(this, this._audioManager));
615-
this.systems.add(new pc.SoundComponentSystem(this, this._audioManager));
616-
this.systems.add(new pc.AudioListenerComponentSystem(this, this._audioManager));
614+
this.systems.add(new pc.AudioSourceComponentSystem(this, this._soundManager));
615+
this.systems.add(new pc.SoundComponentSystem(this, this._soundManager));
616+
this.systems.add(new pc.AudioListenerComponentSystem(this, this._soundManager));
617617
this.systems.add(new pc.ParticleSystemComponentSystem(this));
618618
this.systems.add(new pc.ScreenComponentSystem(this));
619619
this.systems.add(new pc.ElementComponentSystem(this));
@@ -1440,9 +1440,9 @@ Object.assign(pc, function () {
14401440
*/
14411441
onVisibilityChange: function () {
14421442
if (this.isHidden()) {
1443-
this._audioManager.suspend();
1443+
this._soundManager.suspend();
14441444
} else {
1445-
this._audioManager.resume();
1445+
this._soundManager.resume();
14461446
}
14471447
},
14481448

@@ -1841,9 +1841,9 @@ Object.assign(pc, function () {
18411841

18421842
this.off(); // remove all events
18431843

1844-
if (this._audioManager) {
1845-
this._audioManager.destroy();
1846-
this._audioManager = null;
1844+
if (this._soundManager) {
1845+
this._soundManager.destroy();
1846+
this._soundManager = null;
18471847
}
18481848

18491849
pc.http = new pc.Http();

src/sound/listener.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ Object.assign(pc, function () {
66
* @class
77
* @name pc.Listener
88
* @classdesc Represents an audio listener - used internally.
9-
* @param {pc.SoundManager} manager - The sound manager.
9+
* @param {pc.SoundManager} manager - The sound manager.
1010
*/
1111
var Listener = function (manager) {
1212
this.position = new pc.Vec3();
1313
this.velocity = new pc.Vec3();
1414
this.orientation = new pc.Mat4();
1515

16-
if (pc.AudioManager.hasAudioContext()) {
16+
if (pc.SoundManager.hasAudioContext()) {
1717
this.listener = manager.context.listener;
1818
}
1919
};

src/sound/manager.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,6 @@ Object.assign(pc, function () {
192192
}
193193
});
194194

195-
// backwards compatibility
196-
pc.AudioManager = SoundManager;
197-
198195
return {
199196
SoundManager: SoundManager
200197
};

0 commit comments

Comments
 (0)