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