From c54495260328083b4dfbd59cf6df7c1bf08612b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20Veres-Szentkir=C3=A1lyi?= Date: Mon, 15 Jul 2013 16:33:06 +0200 Subject: [PATCH] added get_freq_bits example --- pysstv/examples/get_freq_bits.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 pysstv/examples/get_freq_bits.py diff --git a/pysstv/examples/get_freq_bits.py b/pysstv/examples/get_freq_bits.py new file mode 100644 index 0000000..f34de84 --- /dev/null +++ b/pysstv/examples/get_freq_bits.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +""" +This example streams the raw floating point (freq, msec) tuples to stdout +in 4-byte single precision format (8 bytes per tuple), so that it can be +processed outside PySSTV. + +Usage example using unixsstv/gen_values: +get_freq_bits.py | gen_values 44100 | play -r 44100 -t f32 -c 1 --norm - +""" + +from pysstv.sstv import SSTV +from PIL import Image +from pysstv.color import MartinM1 +import struct, sys + +def main(): + img = Image.open("320x256rgb.png") + sstv = MartinM1(img, 44100, 16) + for freq, msec in sstv.gen_freq_bits(): + sys.stdout.write(struct.pack('ff', freq, msec)) + +if __name__ == '__main__': + main()