feature/high-low-pass-filter (#2)
Co-authored-by: Bastian Bührig <bastian.buehrig@2bconsult.eu> Reviewed-on: #2
This commit was merged in pull request #2.
This commit is contained in:
33
main.go
33
main.go
@@ -65,6 +65,19 @@ func main() {
|
||||
Usage: "Fade-out duration in milliseconds to apply at the end of the IR (default 5)",
|
||||
Value: 5.0,
|
||||
},
|
||||
&cli.Float64Flag{
|
||||
Name: "highcut",
|
||||
Usage: "High-cut filter (low-pass) cutoff frequency in Hz (applied to recorded sweep, optional)",
|
||||
},
|
||||
&cli.Float64Flag{
|
||||
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
|
||||
@@ -82,8 +95,26 @@ func main() {
|
||||
log.Printf("Sweep: %d samples, %d channels", len(sweepData.PCMData), sweepData.Channels)
|
||||
log.Printf("Recorded: %d samples, %d channels", len(recordedData.PCMData), recordedData.Channels)
|
||||
|
||||
// Optionally filter the recorded sweep
|
||||
recordedFiltered := recordedData.PCMData
|
||||
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, 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, slope: %d dB/oct", highcutHz, cutSlope)
|
||||
recordedFiltered = convolve.CascadeHighcut(recordedFiltered, recSampleRate, highcutHz, cutSlope)
|
||||
}
|
||||
|
||||
log.Println("Performing deconvolution...")
|
||||
ir := convolve.Deconvolve(sweepData.PCMData, recordedData.PCMData)
|
||||
ir := convolve.Deconvolve(sweepData.PCMData, recordedFiltered)
|
||||
log.Printf("Deconvolution result: %d samples", len(ir))
|
||||
|
||||
log.Println("Trimming silence...")
|
||||
|
||||
Reference in New Issue
Block a user