Add --cut-slope option for filter steepness (default 12 dB/oct); cascade biquads for steeper slopes; update docs

This commit is contained in:
Bastian Bührig
2025-07-11 10:31:48 +02:00
parent 0cb60d884c
commit 8d9afb4fc6
4 changed files with 53 additions and 6 deletions

17
main.go
View File

@@ -73,6 +73,11 @@ func main() {
Name: "lowcut",
Usage: "Low-cut filter (high-pass) cutoff frequency in Hz (applied to recorded sweep, optional)",
},
&cli.IntFlag{
Name: "cut-slope",
Usage: "Cut filter slope in dB/octave (12, 24, 36, 48, ...; default 12)",
Value: 12,
},
},
Action: func(c *cli.Context) error {
// Read sweep WAV file
@@ -95,13 +100,17 @@ func main() {
recSampleRate := recordedData.SampleRate
highcutHz := c.Float64("highcut")
lowcutHz := c.Float64("lowcut")
cutSlope := c.Int("cut-slope")
if cutSlope < 12 || cutSlope%12 != 0 {
return fmt.Errorf("cut-slope must be a positive multiple of 12 (got %d)", cutSlope)
}
if lowcutHz > 0 {
log.Printf("Applying low-cut (high-pass) filter to recorded sweep: %.2f Hz", lowcutHz)
recordedFiltered = convolve.ApplyHighpassButterworth(recordedFiltered, recSampleRate, lowcutHz)
log.Printf("Applying low-cut (high-pass) filter to recorded sweep: %.2f Hz, slope: %d dB/oct", lowcutHz, cutSlope)
recordedFiltered = convolve.CascadeLowcut(recordedFiltered, recSampleRate, lowcutHz, cutSlope)
}
if highcutHz > 0 {
log.Printf("Applying high-cut (low-pass) filter to recorded sweep: %.2f Hz", highcutHz)
recordedFiltered = convolve.ApplyLowpassButterworth(recordedFiltered, recSampleRate, highcutHz)
log.Printf("Applying high-cut (low-pass) filter to recorded sweep: %.2f Hz, slope: %d dB/oct", highcutHz, cutSlope)
recordedFiltered = convolve.CascadeHighcut(recordedFiltered, recSampleRate, highcutHz, cutSlope)
}
log.Println("Performing deconvolution...")