From a59428ab19d05012491f1736d467ed83845fed9a Mon Sep 17 00:00:00 2001 From: Louis Dalibard Date: Thu, 16 Jan 2025 22:27:12 +0100 Subject: [PATCH] yes --- main.go | 2 +- signalprocessing/signalprocessing.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 309fe8f..bf348f0 100644 --- a/main.go +++ b/main.go @@ -101,7 +101,7 @@ func (g *Game) Draw(screen *ebiten.Image) { binary.Read(audio.SampleRingBuffer, binary.NativeEndian, &AX) binary.Read(audio.SampleRingBuffer, binary.NativeEndian, &AY) } - FFTBuffer = window.Apply(FFTBuffer, signalprocessing.HannWindow) + FFTBuffer = window.Apply(FFTBuffer, signalprocessing.CachedWindowFunction) X := fft.FFTReal(FFTBuffer) r, θ := cmplx.Polar(X[1]) maxR := r diff --git a/signalprocessing/signalprocessing.go b/signalprocessing/signalprocessing.go index 1c98bb1..5f171ac 100644 --- a/signalprocessing/signalprocessing.go +++ b/signalprocessing/signalprocessing.go @@ -12,3 +12,7 @@ var HannWindow []float64 func Init() { HannWindow = window.Hann(int(config.Config.ReadBufferSize / audio.SampleSizeInBytes / 2)) } + +func CachedWindowFunction(u int) []float64 { + return HannWindow +}