diff --git a/config/config.go b/config/config.go index e83a58b..f0b2e6d 100644 --- a/config/config.go +++ b/config/config.go @@ -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 diff --git a/main.go b/main.go index 963645c..841122c 100644 --- a/main.go +++ b/main.go @@ -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)