might be more efficient

This commit is contained in:
Louis Dalibard 2025-01-16 22:58:28 +01:00
parent ff40ee8f63
commit 921803d066
2 changed files with 3 additions and 10 deletions

View File

@ -37,6 +37,7 @@ type ConfigS struct {
ParticleAcceleration float32
ParticleDrag float32
DefaultToSingleChannel bool
PeakDetectSeparator int
}
var DefaultConfig = ConfigS{
@ -63,6 +64,7 @@ var DefaultConfig = ConfigS{
ParticleAcceleration: 0.015,
ParticleDrag: 5.0,
DefaultToSingleChannel: false,
PeakDetectSeparator: 1000,
}
var Config ConfigS

11
main.go
View File

@ -98,17 +98,8 @@ func (g *Game) Draw(screen *ebiten.Image) {
binary.Read(audio.SampleRingBuffer, binary.NativeEndian, &AY)
}
separator := 1000
indices := peaks.Get(FFTBuffer, int(separator))
indices := peaks.Get(FFTBuffer, config.Config.PeakDetectSeparator)
offset := uint32(indices[0])
for i, newPoint := range nextDataPoints {
signal := detector.Next(newPoint)
switch signal {
case peakdetect.SignalPositive:
offset = uint32(i + lag)
break
}
}
for i := uint32(0); i < numSamples-1; i++ {
fAX := float32(FFTBuffer[(i+offset)%numSamples]) * config.Config.Gain * float32(scale)
fBX := float32(FFTBuffer[(i+1+offset)%numSamples]) * config.Config.Gain * float32(scale)