From 20f37dff305238a382557cb98b6b714516c23a99 Mon Sep 17 00:00:00 2001 From: devoxin <15076404+devoxin@users.noreply.github.com> Date: Sun, 28 Apr 2024 23:29:15 +0100 Subject: [PATCH] (volume) Correctly clamp lower values at -32768 (#106) --- .../discord/lavaplayer/filter/volume/PcmVolumeProcessor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/src/main/java/com/sedmelluq/discord/lavaplayer/filter/volume/PcmVolumeProcessor.java b/main/src/main/java/com/sedmelluq/discord/lavaplayer/filter/volume/PcmVolumeProcessor.java index d6887258..421dcb72 100644 --- a/main/src/main/java/com/sedmelluq/discord/lavaplayer/filter/volume/PcmVolumeProcessor.java +++ b/main/src/main/java/com/sedmelluq/discord/lavaplayer/filter/volume/PcmVolumeProcessor.java @@ -67,7 +67,7 @@ private void applyCurrentVolume(ShortBuffer buffer) { for (int i = buffer.position(); i < endOffset; i++) { int value = buffer.get(i) * integerMultiplier / 10000; - buffer.put(i, (short) Math.max(-32767, Math.min(32767, value))); + buffer.put(i, (short) Math.max(Short.MIN_VALUE, Math.min(Short.MAX_VALUE, value))); } } @@ -80,7 +80,7 @@ private void unapplyCurrentVolume(ShortBuffer buffer) { for (int i = buffer.position(); i < endOffset; i++) { int value = buffer.get(i) * 10000 / integerMultiplier; - buffer.put(i, (short) Math.max(-32767, Math.min(32767, value))); + buffer.put(i, (short) Math.max(Short.MIN_VALUE, Math.min(Short.MAX_VALUE, value))); } } }