Pay attention to cache behavior, resulting in fast_scale_y being about
[xiph/unicode.git] / vorbisfile-python / test_float.py
blob253fa37fedf7fe5e616d09b0a898841168a36858
1 import struct
2 import ossaudiodev
3 from vorbisfile import *
5 adev = ossaudiodev.open('w')
6 adev.setfmt(ossaudiodev.AFMT_S16_BE)
7 adev.channels(2)
8 adev.speed(44100)
10 vf = VorbisFile()
11 vf.open('/home/jack/test.ogg')
14 data, cs = vf.read(8192, format=FORMAT_FLOAT)
15 while len(data) > 0:
16 buffer = ''
17 for j in range(len(data[0])):
18 l = int(data[0][j]*32768)
19 r = int(data[1][j]*32768)
20 if l > 32767: l = 32767
21 if r > 32767: r = 32767
22 if l < -32768: l = -32768
23 if r < -32768: r = -32768
24 buffer += struct.pack("hh", l, r)
26 adev.write(buffer)
27 data, cs = vf.read(8192, format=FORMAT_FLOAT)