From cd917dc81f43b3914ad4ba3b50b89ce3399c9da7 Mon Sep 17 00:00:00 2001 From: Louis Dalibard Date: Thu, 16 Jan 2025 23:02:10 +0100 Subject: [PATCH] might be more efficient --- main.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main.go b/main.go index 841122c..17f7ad5 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import ( "image/color" "log" "math/rand/v2" + "sort" "xyosc/audio" "xyosc/config" "xyosc/fastsqrt" @@ -99,6 +100,7 @@ func (g *Game) Draw(screen *ebiten.Image) { } indices := peaks.Get(FFTBuffer, config.Config.PeakDetectSeparator) + sort.Ints(indices) offset := uint32(indices[0]) for i := uint32(0); i < numSamples-1; i++ { fAX := float32(FFTBuffer[(i+offset)%numSamples]) * config.Config.Gain * float32(scale)