Skip to content

Commit

Permalink
fix(client): fix distorted RNNoise output during mono capture (#400)
Browse files Browse the repository at this point in the history
see remjey/mumble@f16b47c for info on why this works
  • Loading branch information
codeHusky authored May 11, 2024
1 parent 66bb3ae commit 54f84a2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion api/common/src/main/java/su/plo/voice/api/util/AudioUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,15 @@ public static short[] floatsToShorts(float[] floats) {
short[] shorts = new short[floats.length];

for(int i = 0; i < floats.length; i++) {
shorts[i] = Float.valueOf(floats[i]).shortValue();
shorts[i] = Float.valueOf(
Math.min( // Clamp to prevent overdrive causing clipping (https://github.com/remjey/mumble/commit/f16b47c81aceaf0c8704b355d9316bf685cb3704)
Short.MAX_VALUE,
Math.max(
Short.MIN_VALUE,
floats[i]
)
)
).shortValue();
}

return shorts;
Expand Down

0 comments on commit 54f84a2

Please sign in to comment.