added get_freq_bits example

ironpython
András Veres-Szentkirályi 2013-07-15 16:33:06 +02:00
rodzic 8262a72629
commit c544952603
1 zmienionych plików z 24 dodań i 0 usunięć

Wyświetl plik

@ -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()