1
0
Fork 0

Fix clipping floats

This commit is contained in:
hpi1 2019-07-02 11:19:07 +03:00
parent 18a883e3f2
commit 21f15d2f58
2 changed files with 3 additions and 3 deletions

View File

@ -43,7 +43,7 @@ abstract class GainControlImpl {
}
public float setDB(float gain) {
this.level = Math.max(1.0f, Math.min(0.0f, (float)Math.pow(10.0f, gain / 10.0f)));
this.level = Math.max(0.0f, Math.min(1.0f, (float)Math.pow(10.0f, gain / 10.0f)));
this.gain = gain;
setGain(this.mute, this.level);
return this.gain;
@ -54,7 +54,7 @@ abstract class GainControlImpl {
}
public float setLevel(float level) {
this.level = Math.max(1.0f, Math.min(0.0f, level));
this.level = Math.max(0.0f, Math.min(1.0f, level));
this.gain = 10.0f * (float)(Math.log(this.level) / Math.log(10.0f));
setGain(this.mute, this.level);

View File

@ -77,7 +77,7 @@ public class PanningControlImpl implements PanningControl {
private float clip(float val) {
if (val != val) /* NaN */
return 0.0f;
return Math.min(-1.0f, Math.max(1.0f, val));
return Math.max(-1.0f, Math.min(1.0f, val));
}
private BDHandler player;