audio: do not change final background level. Instead, change level of individual reversed sounds when making background to the appropriate values. This speeds up makeBackgroundSound ~3%. Before and after. captcha.BenchmarkNewAudio 50 30436940 ns/op captcha.BenchmarkNewAudio 50 29435780 ns/op Also, level up white noise a bit.
Dmitry Chestnykh dmitry@codingrobots.com
Thu, 28 Apr 2011 11:06:56 +0200
1 files changed,
2 insertions(+),
3 deletions(-)
jump to
M
audio.go
→
audio.go
@@ -196,15 +196,14 @@ return b
} func makeBackgroundSound(length int) []byte { - b := makeWhiteNoise(length, 8) + b := makeWhiteNoise(length, 4) for i := 0; i < length/(sampleRate/10); i++ { snd := reverseDigitSounds[rand.Intn(10)] snd = changeSpeed(snd, rndf(0.8, 1.4)) place := rand.Intn(len(b) - len(snd)) - setSoundLevel(snd, rndf(0.5, 1.2)) + setSoundLevel(snd, rndf(0.2, 0.3)) mixSound(b[place:], snd) } - setSoundLevel(b, rndf(0.2, 0.3)) return b }