mirror of
https://github.com/make-42/xyosc
synced 2025-01-18 10:47:10 +01:00
might be more efficient
This commit is contained in:
parent
bc5597c436
commit
5d3a570c29
15
main.go
15
main.go
@ -23,7 +23,7 @@ import (
|
||||
"github.com/hajimehoshi/ebiten/v2/text/v2"
|
||||
"github.com/hajimehoshi/ebiten/v2/vector"
|
||||
|
||||
"github.com/MicahParks/peakdetect"
|
||||
"github.com/goccmack/godsp/peaks"
|
||||
)
|
||||
|
||||
type Game struct {
|
||||
@ -97,15 +97,10 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
binary.Read(audio.SampleRingBuffer, binary.NativeEndian, &AX)
|
||||
binary.Read(audio.SampleRingBuffer, binary.NativeEndian, &AY)
|
||||
}
|
||||
const (
|
||||
lag = 200
|
||||
threshold = 5
|
||||
influence = 0
|
||||
)
|
||||
detector := peakdetect.NewPeakDetector()
|
||||
detector.Initialize(influence, threshold, FFTBuffer[:lag])
|
||||
nextDataPoints := FFTBuffer[lag:]
|
||||
offset := uint32(0)
|
||||
|
||||
separator := 1000
|
||||
indices := peaks.Get(FFTBuffer, int(separator))
|
||||
offset := uint32(indices[0])
|
||||
for i, newPoint := range nextDataPoints {
|
||||
signal := detector.Next(newPoint)
|
||||
switch signal {
|
||||
|
Loading…
Reference in New Issue
Block a user