diff --git a/pkg/convolve/convolve.go b/pkg/convolve/convolve.go index 58e2a5f..120b517 100644 --- a/pkg/convolve/convolve.go +++ b/pkg/convolve/convolve.go @@ -6,6 +6,7 @@ import ( "math" "math/cmplx" "os" + "strings" "image/png" @@ -642,8 +643,13 @@ func PlotIR(ir []float64, sampleRate int, irFileName string) error { p2.Draw(canvases[1][0]) dc.DrawImage(vg.Rectangle{Min: vg.Point{X: 0, Y: 0}, Max: vg.Point{X: width, Y: height}}, imgPlots.Image()) - // Save as PNG - f, err = os.Create("ir_plot.png") + // Save as PNG in the same directory as the IR file + irDir := filepath.Dir(irFileName) + irBase := filepath.Base(irFileName) + irNameWithoutExt := strings.TrimSuffix(irBase, filepath.Ext(irBase)) + plotFileName := filepath.Join(irDir, irNameWithoutExt+".png") + + f, err = os.Create(plotFileName) if err != nil { return err }