Add linear fade-out to IRs with --fade-ms option (default 5ms); update README and CLI
This commit is contained in:
19
main.go
19
main.go
@@ -60,6 +60,11 @@ func main() {
|
||||
Name: "length-ms",
|
||||
Usage: "Optional: Output IR length in milliseconds (will trim or zero-pad as needed)",
|
||||
},
|
||||
&cli.Float64Flag{
|
||||
Name: "fade-ms",
|
||||
Usage: "Fade-out duration in milliseconds to apply at the end of the IR (default 5)",
|
||||
Value: 5.0,
|
||||
},
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
// Read sweep WAV file
|
||||
@@ -135,6 +140,14 @@ func main() {
|
||||
ir = convolve.TrimOrPad(ir, targetSamples)
|
||||
}
|
||||
|
||||
// Apply fade-out
|
||||
fadeMs := c.Float64("fade-ms")
|
||||
fadeSamples := int(float64(targetSampleRate) * fadeMs / 1000.0)
|
||||
if fadeSamples > 0 {
|
||||
log.Printf("Applying linear fade-out: %d samples (%.2f ms)...", fadeSamples, fadeMs)
|
||||
ir = convolve.FadeOutLinear(ir, fadeSamples)
|
||||
}
|
||||
|
||||
// Write regular IR
|
||||
log.Printf("Writing IR to: %s (%dHz, %d-bit WAV)", c.String("output"), sampleRate, bitDepth)
|
||||
if err := wav.WriteWAVFileWithOptions(c.String("output"), ir, sampleRate, bitDepth); err != nil {
|
||||
@@ -165,6 +178,12 @@ func main() {
|
||||
mptIR = convolve.TrimOrPad(mptIR, targetSamples)
|
||||
}
|
||||
|
||||
// Apply fade-out to MPT IR
|
||||
if fadeSamples > 0 {
|
||||
log.Printf("Applying linear fade-out to MPT IR: %d samples (%.2f ms)...", fadeSamples, fadeMs)
|
||||
mptIR = convolve.FadeOutLinear(mptIR, fadeSamples)
|
||||
}
|
||||
|
||||
// Generate MPT output filename
|
||||
outputPath := c.String("output")
|
||||
if len(outputPath) > 4 && outputPath[len(outputPath)-4:] == ".wav" {
|
||||
|
||||
Reference in New Issue
Block a user