@@ -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