Skip to content

Commit c19ab04

Browse files
author
Niels van de Weem
committed
Set VoiceMeeter Gain between -60 and 12 instead of -inf and 12
1 parent 5de9540 commit c19ab04

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/main/java/com/getpcpanel/voicemeeter/Voicemeeter.java

+13-13
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.util.HashMap;
77
import java.util.List;
88
import java.util.Map;
9+
import java.util.Objects;
910

1011
import javax.annotation.Nonnull;
1112
import javax.annotation.Nullable;
@@ -61,6 +62,7 @@ public enum DialControlMode {
6162
NEG_12_TO_12("-12 to 12"),
6263
ZERO_TO_10("0 to 12"),
6364
NEG_40_TO_12("-40 to 12"),
65+
NEG_60_TO_12("-60 to 12"),
6466
NEG_INF_TO_12("-Inf to 12"),
6567
NEG_INF_TO_ZERO("-Inf to 0");
6668

@@ -145,7 +147,7 @@ public static List<ButtonType> stateButtonsFor(ControlType type, VoicemeeterVers
145147
}
146148

147149
public enum DialType {
148-
GAIN("Gain", "Gain", DialControlMode.NEG_INF_TO_12),
150+
GAIN("Gain", "Gain", DialControlMode.NEG_60_TO_12),
149151
AUDIBILITY("Audibility", "Audibility", DialControlMode.ZERO_TO_10),
150152
COMP("Comp", "Comp", DialControlMode.ZERO_TO_10),
151153
GATE("Gate", "Gate", DialControlMode.ZERO_TO_10),
@@ -350,18 +352,16 @@ public String makeParameterString(ControlType ct, int index, String parameter) {
350352
return ct.name() + "[" + index + "]." + parameter;
351353
}
352354

353-
private float convertLevel(DialControlMode ct, int level) {
354-
if (ct == DialControlMode.NEG_12_TO_12)
355-
return map(level, 0.0F, 100.0F, -12.0F, 12.0F);
356-
if (ct == DialControlMode.ZERO_TO_10)
357-
return map(level, 0.0F, 100.0F, 0.0F, 10.0F);
358-
if (ct == DialControlMode.NEG_40_TO_12)
359-
return map(level, 0.0F, 100.0F, -40.0F, 12.0F);
360-
if (ct == DialControlMode.NEG_INF_TO_12)
361-
return (level == 0) ? Float.NEGATIVE_INFINITY : map(level, 0.0F, 100.0F, -60.0F, 12.0F);
362-
if (ct == DialControlMode.NEG_INF_TO_ZERO)
363-
return (level == 0) ? Float.NEGATIVE_INFINITY : map(level, 0.0F, 100.0F, -60.0F, 0.0F);
364-
throw new IllegalArgumentException("Invalid conversiontype in voicemeeter");
355+
private float convertLevel(@Nonnull DialControlMode ct, int level) {
356+
Objects.requireNonNull(ct);
357+
return switch (ct) {
358+
case NEG_12_TO_12 -> map(level, 0.0F, 100.0F, -12.0F, 12.0F);
359+
case ZERO_TO_10 -> map(level, 0.0F, 100.0F, 0.0F, 10.0F);
360+
case NEG_40_TO_12 -> map(level, 0.0F, 100.0F, -40.0F, 12.0F);
361+
case NEG_60_TO_12 -> map(level, 0.0F, 100.0F, -60.0F, 12.0F);
362+
case NEG_INF_TO_12 -> (level == 0) ? Float.NEGATIVE_INFINITY : map(level, 0.0F, 100.0F, -60.0F, 12.0F);
363+
case NEG_INF_TO_ZERO -> (level == 0) ? Float.NEGATIVE_INFINITY : map(level, 0.0F, 100.0F, -60.0F, 0.0F);
364+
};
365365
}
366366

367367
private interface VoiceMeeterExceptionThrowingSupplier<T> {

0 commit comments

Comments
 (0)