mirror of
https://github.com/make-42/xyosc
synced 2025-01-18 18:57: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/text/v2"
|
||||||
"github.com/hajimehoshi/ebiten/v2/vector"
|
"github.com/hajimehoshi/ebiten/v2/vector"
|
||||||
|
|
||||||
"github.com/MicahParks/peakdetect"
|
"github.com/goccmack/godsp/peaks"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Game struct {
|
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, &AX)
|
||||||
binary.Read(audio.SampleRingBuffer, binary.NativeEndian, &AY)
|
binary.Read(audio.SampleRingBuffer, binary.NativeEndian, &AY)
|
||||||
}
|
}
|
||||||
const (
|
|
||||||
lag = 200
|
separator := 1000
|
||||||
threshold = 5
|
indices := peaks.Get(FFTBuffer, int(separator))
|
||||||
influence = 0
|
offset := uint32(indices[0])
|
||||||
)
|
|
||||||
detector := peakdetect.NewPeakDetector()
|
|
||||||
detector.Initialize(influence, threshold, FFTBuffer[:lag])
|
|
||||||
nextDataPoints := FFTBuffer[lag:]
|
|
||||||
offset := uint32(0)
|
|
||||||
for i, newPoint := range nextDataPoints {
|
for i, newPoint := range nextDataPoints {
|
||||||
signal := detector.Next(newPoint)
|
signal := detector.Next(newPoint)
|
||||||
switch signal {
|
switch signal {
|
||||||
|
Loading…
Reference in New Issue
Block a user