-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest.py
More file actions
57 lines (46 loc) · 1.2 KB
/
test.py
File metadata and controls
57 lines (46 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import math
import os
import sys
# Set __ARM = 0 so later it will be possible to disable assembly language.
CMD = ("g++ -Wall -g -D__ARM=0 -Iteensy -o foo test.cpp teensy/synth.cpp teensy/tune.cpp teensy/tests.cpp")
assert os.system(CMD) == 0, CMD
just_tests = False
if 'valgrind' in sys.argv[1:]:
CMD = "valgrind --tool=callgrind --dump-instr=yes --collect-jumps=yes ./foo"
elif 'tests' in sys.argv[1:]:
CMD = "./foo -t"
just_tests = True
else:
CMD = "./foo"
assert os.system(CMD) == 0, CMD
if just_tests:
sys.exit(0)
if 'gnuplot' in sys.argv[1:]:
os.system("echo \"set term png; set output 'output.png';"
" plot 'foo.gp' using 1:2 with lines\" | gnuplot")
sys.exit(0)
import aifc
fname = "quux.aiff"
if sys.platform == "darwin":
player = "afplay"
else:
assert sys.platform == "linux2"
player = "play" # apt-get install sox
def f(x):
xhi = (x >> 8) & 0xff
xlo = x & 0xff
return chr(xhi) + chr(xlo)
import foo
S = foo.samples
try:
os.unlink(fname)
except:
pass
q = aifc.open(fname, "wb")
q.setnchannels(1)
q.setsampwidth(2)
q.setframerate(foo.sampfreq)
q.setnframes(len(S))
q.writeframes("".join(map(f, S)))
q.close()
os.system(player + " " + fname)