Fold the noise removal toggle into one Off/6/12/18/21 dB slider

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-09 18:16:06 +00:00
co-authored by Claude Opus 5.5
parent cbe92e84ff
commit ad7bb4fc6e
@@ -20,13 +20,14 @@ import java.util.function.Supplier;
*/ */
final class CapturePanel extends FormPanel { final class CapturePanel extends FormPanel {
private static final String[] DENOISE_STEPS = {"Off", "6 dB", "12 dB", "18 dB", "21 dB"};
private final VoiceInput liveMic; private final VoiceInput liveMic;
private final VoiceActivationSection activation; private final VoiceActivationSection activation;
private final JComboBox<AudioDevice> inputCombo; private final JComboBox<AudioDevice> inputCombo;
private final JSlider inputGain; private final JSlider inputGain;
private final JCheckBox denoiseCheck; private final JSlider denoise;
private final JSlider denoiseLevel;
private final JCheckBox typingCheck; private final JCheckBox typingCheck;
private final JCheckBox agcCheck; private final JCheckBox agcCheck;
private final JSlider agcBoost; private final JSlider agcBoost;
@@ -48,13 +49,13 @@ final class CapturePanel extends FormPanel {
applyLive(m -> m.setInputGain(inputGain.getValue() / 100.0)); applyLive(m -> m.setInputGain(inputGain.getValue() / 100.0));
}); });
denoiseCheck = new JCheckBox("Remove background noise", settings.denoise); // Off, then TS3's four denoiser_level steps.
// TS3's four steps, 6/12/18/21 dB of suppression. denoise = new JSlider(0, DENOISE_STEPS.length - 1,
denoiseLevel = new JSlider(0, 3, Math.max(0, Math.min(3, settings.denoiserLevel))); settings.denoise ? Math.max(0, Math.min(3, settings.denoiserLevel)) + 1 : 0);
denoiseLevel.setMajorTickSpacing(1); denoise.setMajorTickSpacing(1);
denoiseLevel.setPaintTicks(true); denoise.setPaintTicks(true);
limitWidth(denoiseLevel, SLIDER_WIDTH); denoise.setSnapToTicks(true);
denoiseLevel.setToolTipText("6, 12, 18 or 21 dB"); JLabel denoiseLabel = new JLabel(DENOISE_STEPS[denoise.getValue()]);
typingCheck = new JCheckBox("Typing attenuation", settings.typingAttenuation); typingCheck = new JCheckBox("Typing attenuation", settings.typingAttenuation);
agcCheck = new JCheckBox("Automatic gain control", settings.agc); agcCheck = new JCheckBox("Automatic gain control", settings.agc);
agcBoost = new JSlider(0, Settings.MAX_AGC_BOOST_DB, settings.agcBoostDb); agcBoost = new JSlider(0, Settings.MAX_AGC_BOOST_DB, settings.agcBoostDb);
@@ -71,27 +72,26 @@ final class CapturePanel extends FormPanel {
addSection(this, c, row++, "Activation"); addSection(this, c, row++, "Activation");
row = activation.layOut(this, c, row); row = activation.layOut(this, c, row);
addSection(this, c, row++, "Digital Signal Processing"); addSection(this, c, row++, "Digital Signal Processing");
addWide(this, c, row++, denoiseCheck); addRow(this, c, row++, new JLabel("Remove background noise:"), sliderWithLabel(denoise, denoiseLabel));
addRow(this, c, row++, new JLabel("Noise removal level:"), denoiseLevel);
addWide(this, c, row++, typingCheck); addWide(this, c, row++, typingCheck);
addWide(this, c, row++, agcCheck); addWide(this, c, row++, agcCheck);
addRow(this, c, row++, new JLabel("Boost quiet speech:"), agcBoost); addRow(this, c, row++, new JLabel("Boost quiet speech:"), agcBoost);
addFiller(this, c, row); addFiller(this, c, row);
Runnable syncProcessing = () -> { Runnable syncProcessing = () -> {
denoiseLevel.setEnabled(denoiseCheck.isSelected());
agcBoost.setEnabled(agcCheck.isSelected()); agcBoost.setEnabled(agcCheck.isSelected());
applyLive(m -> { applyLive(m -> {
m.setNoiseSuppression(denoiseCheck.isSelected()); applyDenoise(m);
m.setDenoiserLevel(denoiseLevel.getValue());
m.setTypingAttenuation(typingCheck.isSelected()); m.setTypingAttenuation(typingCheck.isSelected());
m.setAgc(agcCheck.isSelected()); m.setAgc(agcCheck.isSelected());
}); });
}; };
denoiseCheck.addActionListener(e -> syncProcessing.run());
typingCheck.addActionListener(e -> syncProcessing.run()); typingCheck.addActionListener(e -> syncProcessing.run());
agcCheck.addActionListener(e -> syncProcessing.run()); agcCheck.addActionListener(e -> syncProcessing.run());
denoiseLevel.addChangeListener(e -> applyLive(m -> m.setDenoiserLevel(denoiseLevel.getValue()))); denoise.addChangeListener(e -> {
denoiseLabel.setText(DENOISE_STEPS[denoise.getValue()]);
applyLive(this::applyDenoise);
});
agcBoost.addChangeListener(e -> applyLive(m -> m.setAgcBoost(agcBoost.getValue()))); agcBoost.addChangeListener(e -> applyLive(m -> m.setAgcBoost(agcBoost.getValue())));
syncProcessing.run(); syncProcessing.run();
} }
@@ -100,14 +100,19 @@ final class CapturePanel extends FormPanel {
void writeInto(Settings target) { void writeInto(Settings target) {
target.inputDevice = AudioDevices.selectedId(inputCombo); target.inputDevice = AudioDevices.selectedId(inputCombo);
target.inputVolume = inputGain.getValue() / 100.0; target.inputVolume = inputGain.getValue() / 100.0;
target.denoise = denoiseCheck.isSelected(); target.denoise = denoise.getValue() > 0;
target.denoiserLevel = denoiseLevel.getValue(); if (target.denoise) target.denoiserLevel = denoise.getValue() - 1;
target.typingAttenuation = typingCheck.isSelected(); target.typingAttenuation = typingCheck.isSelected();
target.agc = agcCheck.isSelected(); target.agc = agcCheck.isSelected();
target.agcBoostDb = agcBoost.getValue(); target.agcBoostDb = agcBoost.getValue();
activation.writeInto(target); activation.writeInto(target);
} }
private void applyDenoise(VoiceInput mic) {
mic.setNoiseSuppression(denoise.getValue() > 0);
if (denoise.getValue() > 0) mic.setDenoiserLevel(denoise.getValue() - 1);
}
/** Applies a live change to the connected microphone and to the microphone test alike. */ /** Applies a live change to the connected microphone and to the microphone test alike. */
void applyLive(Consumer<VoiceInput> change) { void applyLive(Consumer<VoiceInput> change) {
if (liveMic != null) change.accept(liveMic); if (liveMic != null) change.accept(liveMic);