Skip to content

Commit

Permalink
(volume) Correctly clamp lower values at -32768 (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
devoxin committed Apr 28, 2024
1 parent 3e90c61 commit 20f37df
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
}

Expand All @@ -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)));
}
}
}

0 comments on commit 20f37df

Please sign in to comment.