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

View File

@@ -425,3 +425,31 @@ func ApplyHighpassButterworth(data []float64, sampleRate int, cutoffHz float64)
}
return out
}
// CascadeLowcut applies the low-cut (high-pass) filter multiple times for steeper slopes.
// slopeDb: 12, 24, 36, ... (dB/octave)
func CascadeLowcut(data []float64, sampleRate int, cutoffHz float64, slopeDb int) []float64 {
if slopeDb < 12 {
slopeDb = 12
}
n := slopeDb / 12
out := data
for i := 0; i < n; i++ {
out = ApplyHighpassButterworth(out, sampleRate, cutoffHz)
}
return out
}
// CascadeHighcut applies the high-cut (low-pass) filter multiple times for steeper slopes.
// slopeDb: 12, 24, 36, ... (dB/octave)
func CascadeHighcut(data []float64, sampleRate int, cutoffHz float64, slopeDb int) []float64 {
if slopeDb < 12 {
slopeDb = 12
}
n := slopeDb / 12
out := data
for i := 0; i < n; i++ {
out = ApplyLowpassButterworth(out, sampleRate, cutoffHz)
}
return out
}