From 3a10ec83f0c182d58fdf03d0f96dac5d963c6812 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20Veres-Szentkir=C3=A1lyi?= Date: Thu, 23 May 2013 14:03:25 +0200 Subject: [PATCH] corrected antialiasing algorithm --- sstv.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sstv.py b/sstv.py index 7655ee0..21ff0c9 100644 --- a/sstv.py +++ b/sstv.py @@ -57,7 +57,7 @@ class SSTV(object): lowest = -amp highest = amp - 1 for value in self.gen_values(): - sample = int(round(value * amp + alias * random())) + sample = int(round(value * amp + alias * (random() - 0.5))) yield max(min(highest, sample), lowest) def gen_values(self): @@ -66,7 +66,7 @@ class SSTV(object): param = 0 for freq, msec in self.gen_freq_bits(): offset = param - for sample in xrange(int(round(spms * msec + random()))): + for sample in xrange(int(round(spms * msec + random() - 0.5))): t = sample / self.samples_per_sec param = t * freq * 2 * pi + offset yield sin(param)