From 8262a72629be738b1b7d8a85b56f6840e8289e86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20Veres-Szentkir=C3=A1lyi?= Date: Mon, 15 Jul 2013 15:38:03 +0200 Subject: [PATCH] added get_floats example --- pysstv/examples/get_floats.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 pysstv/examples/get_floats.py diff --git a/pysstv/examples/get_floats.py b/pysstv/examples/get_floats.py new file mode 100644 index 0000000..4cf47d9 --- /dev/null +++ b/pysstv/examples/get_floats.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +""" +This example streams the raw floating point samples to stdout in 4-byte +single precision format, so that it can be processed outside PySSTV. + +Usage example: get_floats.py | play -r 44100 -t f32 -c 1 --norm - +""" + +from pysstv.sstv import SSTV +from PIL import Image +from pysstv.grayscale import Robot8BW +import struct, sys + +def main(): + img = Image.open("160x120bw.png") + sstv = Robot8BW(img, 44100, 16) + sstv.vox_enabled = True + for value in sstv.gen_values(): + sys.stdout.write(struct.pack('f', value)) + +if __name__ == '__main__': + main()