Skip to content

Commit 5a924de

Browse files
committed
fix: clamp sound effect volume to range [0, 1]
libGDX only supports values between 0 and 1 and values above 1 actually caused the sound to not be played on certain Android devices.
1 parent 62677a4 commit 5a924de

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

engine/src/main/java/org/destinationsol/assets/sound/OggSoundManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ private float getVolume(SolGame game, Vector2 position, float volumeMultiplier,
227227
float distance = position.dst(cameraPosition) - soundRadius;
228228
float distanceMultiplier = SolMath.clamp(1 - distance / maxSoundDist);
229229

230-
return sound.getBaseVolume() * volumeMultiplier * distanceMultiplier * globalVolumeMultiplier;
230+
return SolMath.clamp(sound.getBaseVolume() * volumeMultiplier * distanceMultiplier * globalVolumeMultiplier);
231231
}
232232

233233
/**

0 commit comments

Comments
 (0)