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 +}