You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Sound class exposes a method (setVolume()) which tweaks its gainNode.
It seems like the intent of the setVolume() method is to pre-configure the volume of the Sound instance so that subsequent calls to its play() method use the configured volume.
However, the play() method accepts its own volume param which is overwriting the existing gain value that was set during the setVolume() method call.
This is because setVolume is only really used to change the volume of a sound after it's been played for sounds where you only have one instance of it like music for example. Typically you control the volume by passing it into the play function.
I'm not sure how to make this work in a better way because you need to be able to set the volume when a sound is played but you also need to be able to change that volume afterwards sometimes like if the music volume is changed by the player.
I need to do some thinking on the sound object itself because it is kind of doing double duty by also allowing changes to the most recently played instance of that sound.
The
Sound
class exposes a method (setVolume()
) which tweaks itsgainNode
.It seems like the intent of the
setVolume()
method is to pre-configure the volume of theSound
instance so that subsequent calls to itsplay()
method use the configured volume.However, the
play()
method accepts its ownvolume
param which is overwriting the existing gain value that was set during thesetVolume()
method call.Here is where the value is being overwritten:
LittleJS/src/engineAudio.js
Line 331 in b0251c9
Example code:
Expected Outcome:
The sound should be played at a volume much lower than the default.
Actual Outcome:
The sound seems to be played at the default volume.
The text was updated successfully, but these errors were encountered: