Add clap detection sensitivity settings (Tools menu)

Threshold and min-interval (the librosa delta/wait knobs) were only
ever tunable via the CLI's -t/-m flags. Added a Clap Detection
Settings dialog (Tools menu) with both as spin boxes, an explicit
Reset to Defaults button, and Cancel that leaves MainWindow's current
settings untouched.

Exposed DEFAULT_THRESHOLD=0.7/DEFAULT_MIN_INTERVAL=0.3 as named
constants in clap_detection.py so the CLI script, DetectWorker's
defaults, and the dialog's reset button all reference the same source
of truth instead of three copies of the same magic numbers that could
drift apart.
This commit is contained in:
ThePendulum
2026-07-26 05:56:50 +02:00
parent 97cbf38d97
commit ff127a8c21
4 changed files with 186 additions and 10 deletions
+8 -2
View File
@@ -19,6 +19,12 @@ class ClapDetectionUnavailable(RuntimeError):
pass
# Shared with the GUI's detection-settings dialog (main.py) so both the CLI
# and GUI default to, and can be reset to, the exact same values.
DEFAULT_THRESHOLD = 0.7
DEFAULT_MIN_INTERVAL = 0.3
@dataclass(frozen=True)
class ClapEvent:
time_sec: float
@@ -109,8 +115,8 @@ def _extract_audio_wav(input_path: str, audio_stream_index: Optional[int] = None
def detect_claps(
input_path: str,
start_offset: float = 0.0,
threshold: float = 0.7,
min_interval: float = 0.3,
threshold: float = DEFAULT_THRESHOLD,
min_interval: float = DEFAULT_MIN_INTERVAL,
max_results: Optional[int] = None,
audio_stream_index: Optional[int] = None,
) -> List[ClapEvent]: