From 649a4b21408a40fb39e0f019c7c622ae5aa8a503 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20Veres-Szentkir=C3=A1lyi?= Date: Tue, 2 Jul 2013 11:55:16 +0200 Subject: [PATCH] simplified and optimized offset calculation --- pysstv/sstv.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pysstv/sstv.py b/pysstv/sstv.py index 6c80a63..dcb05db 100644 --- a/pysstv/sstv.py +++ b/pysstv/sstv.py @@ -73,16 +73,15 @@ class SSTV(object): the samples per second value given during construction """ spms = self.samples_per_sec / 1000 - param = 0 + offset = 0 samples = 0 factor = 2 * pi / self.samples_per_sec for freq, msec in self.gen_freq_bits(): - offset = param samples += spms * msec tx = floor(samples) for sample in xrange(int(tx)): - param = sample * freq * factor + offset - yield sin(param) + yield sin(sample * freq * factor + offset) + offset = sample * freq * factor + offset samples -= tx def gen_freq_bits(self):