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
ff40ee8f63
commit
921803d066
@ -37,6 +37,7 @@ type ConfigS struct {
|
|||||||
ParticleAcceleration float32
|
ParticleAcceleration float32
|
||||||
ParticleDrag float32
|
ParticleDrag float32
|
||||||
DefaultToSingleChannel bool
|
DefaultToSingleChannel bool
|
||||||
|
PeakDetectSeparator int
|
||||||
}
|
}
|
||||||
|
|
||||||
var DefaultConfig = ConfigS{
|
var DefaultConfig = ConfigS{
|
||||||
@ -63,6 +64,7 @@ var DefaultConfig = ConfigS{
|
|||||||
ParticleAcceleration: 0.015,
|
ParticleAcceleration: 0.015,
|
||||||
ParticleDrag: 5.0,
|
ParticleDrag: 5.0,
|
||||||
DefaultToSingleChannel: false,
|
DefaultToSingleChannel: false,
|
||||||
|
PeakDetectSeparator: 1000,
|
||||||
}
|
}
|
||||||
|
|
||||||
var Config ConfigS
|
var Config ConfigS
|
||||||
|
11
main.go
11
main.go
@ -98,17 +98,8 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
|||||||
binary.Read(audio.SampleRingBuffer, binary.NativeEndian, &AY)
|
binary.Read(audio.SampleRingBuffer, binary.NativeEndian, &AY)
|
||||||
}
|
}
|
||||||
|
|
||||||
separator := 1000
|
indices := peaks.Get(FFTBuffer, config.Config.PeakDetectSeparator)
|
||||||
indices := peaks.Get(FFTBuffer, int(separator))
|
|
||||||
offset := uint32(indices[0])
|
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++ {
|
for i := uint32(0); i < numSamples-1; i++ {
|
||||||
fAX := float32(FFTBuffer[(i+offset)%numSamples]) * config.Config.Gain * float32(scale)
|
fAX := float32(FFTBuffer[(i+offset)%numSamples]) * config.Config.Gain * float32(scale)
|
||||||
fBX := float32(FFTBuffer[(i+1+offset)%numSamples]) * config.Config.Gain * float32(scale)
|
fBX := float32(FFTBuffer[(i+1+offset)%numSamples]) * config.Config.Gain * float32(scale)
|
||||||
|
Loading…
Reference in New Issue
Block a user