From 7c3700effa68fd6d21e14261aa2efc30ba8c7e7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Franusic?= Date: Mon, 17 Jun 2013 12:52:29 -0700 Subject: [PATCH] update comments in code based on README.md --- sstv.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sstv.py b/sstv.py index 6388e7d..d2a5920 100644 --- a/sstv.py +++ b/sstv.py @@ -26,6 +26,7 @@ class SSTV(object): BITS_TO_STRUCT = {8: 'b', 16: 'h'} def write_wav(self, filename): + """writes the whole image to a Microsoft WAV file""" fmt = '<' + self.BITS_TO_STRUCT[self.bits] data = ''.join(struct.pack(fmt, b) for b in self.gen_samples()) with closing(wave.open(filename, 'wb')) as wav: @@ -35,7 +36,8 @@ class SSTV(object): wav.writeframes(data) def gen_samples(self): - """generates bits from gen_values""" + """generates discrete samples from gen_values(), performing quantization according to the bits per sample value given during construction + """ max_value = 2 ** self.bits alias = 1 / max_value amp = max_value / 2 @@ -46,7 +48,8 @@ class SSTV(object): yield max(min(highest, sample), lowest) def gen_values(self): - """generates -1 .. +1 values from freq_bits""" + """generates samples between -1 and +1 from gen_freq_bits(), performing sampling according to the samples per second value given during construction + """ spms = self.samples_per_sec / 1000 param = 0 samples = 0 @@ -61,7 +64,8 @@ class SSTV(object): samples -= tx def gen_freq_bits(self): - """generates (freq, msec) tuples from image""" + """generates tuples (freq, msec) that describe a sine wave segment with frequency in Hz and duration in ms + """ yield FREQ_VIS_START, MSEC_VIS_START yield FREQ_SYNC, MSEC_VIS_SYNC yield FREQ_VIS_START, MSEC_VIS_START