Skip to content

Commit 386398d

Browse files
committed
change position of gainNode arg
1 parent 569d6ab commit 386398d

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/sound.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,20 @@ export default class Sound {
3939

4040
/**
4141
* play sound
42-
* @param {GainNode} gainNode - output mixer
4342
* @param {AudioBuffer} audioBuffer - sound data
4443
* @param {number} time - length to play, or 0 to play to the end
4544
* @param {boolean} loop - play the sound in loop if true
45+
* @param {GainNode} gainNode - output mixer
4646
* @example
4747
* import Sound from './sound.js';
48-
* Sound.play(soundMixer, jumpSound);
48+
* Sound.play(jumpSound);
4949
*/
50-
static play(gainNode, audioBuffer, time = 0, loop = false) {
50+
static play(audioBuffer, time = 0, loop = false, gainNode = getSoundMixer()) {
5151
const audioCtx = getAudioCtx();
5252

5353
const source = audioCtx.createBufferSource();
5454
source.buffer = audioBuffer;
55-
source.connect(gainNode || getSoundMixer());
55+
source.connect(gainNode);
5656
source.loop = loop;
5757
source.start(time);
5858

@@ -65,13 +65,13 @@ export default class Sound {
6565

6666
/**
6767
* set the output volume
68-
* @param {GainNode} gainNode - output mixer
6968
* @param {number} v - volume
69+
* @param {GainNode} gainNode - output mixer
7070
* @example
71-
* setVolume(soundMixer, .5);
71+
* setVolume(.5);
7272
*/
73-
static setVolume(gainNode, v) {
74-
(gainNode || getSoundMixer()).gain.value = v;
73+
static setVolume(v, gainNode = getSoundMixer()) {
74+
gainNode.gain.value = v;
7575
}
7676

7777
}

0 commit comments

Comments
 (0)