|
6 | 6 | import java.util.HashMap;
|
7 | 7 | import java.util.List;
|
8 | 8 | import java.util.Map;
|
| 9 | +import java.util.Objects; |
9 | 10 |
|
10 | 11 | import javax.annotation.Nonnull;
|
11 | 12 | import javax.annotation.Nullable;
|
@@ -61,6 +62,7 @@ public enum DialControlMode {
|
61 | 62 | NEG_12_TO_12("-12 to 12"),
|
62 | 63 | ZERO_TO_10("0 to 12"),
|
63 | 64 | NEG_40_TO_12("-40 to 12"),
|
| 65 | + NEG_60_TO_12("-60 to 12"), |
64 | 66 | NEG_INF_TO_12("-Inf to 12"),
|
65 | 67 | NEG_INF_TO_ZERO("-Inf to 0");
|
66 | 68 |
|
@@ -145,7 +147,7 @@ public static List<ButtonType> stateButtonsFor(ControlType type, VoicemeeterVers
|
145 | 147 | }
|
146 | 148 |
|
147 | 149 | public enum DialType {
|
148 |
| - GAIN("Gain", "Gain", DialControlMode.NEG_INF_TO_12), |
| 150 | + GAIN("Gain", "Gain", DialControlMode.NEG_60_TO_12), |
149 | 151 | AUDIBILITY("Audibility", "Audibility", DialControlMode.ZERO_TO_10),
|
150 | 152 | COMP("Comp", "Comp", DialControlMode.ZERO_TO_10),
|
151 | 153 | GATE("Gate", "Gate", DialControlMode.ZERO_TO_10),
|
@@ -350,18 +352,16 @@ public String makeParameterString(ControlType ct, int index, String parameter) {
|
350 | 352 | return ct.name() + "[" + index + "]." + parameter;
|
351 | 353 | }
|
352 | 354 |
|
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 | + }; |
365 | 365 | }
|
366 | 366 |
|
367 | 367 | private interface VoiceMeeterExceptionThrowingSupplier<T> {
|
|
0 commit comments