Add --cut-slope option for filter steepness (default 12 dB/oct); cascade biquads for steeper slopes; update docs
This commit is contained in:
17
main.go
17
main.go
@@ -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...")
|
||||
|
||||
Reference in New Issue
Block a user