all repos — captcha @ 436e363f8439b0ac604f152748e2e13bbe575b53

Go package captcha implements generation and verification of image and audio CAPTCHAs.

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
commit

436e363f8439b0ac604f152748e2e13bbe575b53

parent

b9845ccf32c801cd41486d4ae298b60dfc68fee5

1 files changed, 2 insertions(+), 3 deletions(-)

jump to
M audio.goaudio.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 }