The Tooba
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Macros
Pages
nextstage
hack.py
Go to the documentation of this file.
1
import
math
2
import
os
3
import
sys
4
5
6
CMD = (
"g++ -Wall -g -D__ARDUINO=0 -Iteensy -o foo instr.cpp teensy/common.cpp teensy/key.cpp"
)
7
8
assert
os.system(CMD) == 0, CMD
9
assert
os.system(
"./foo"
) == 0,
"./foo"
10
11
if
'gnuplot'
in
sys.argv[1:]:
12
os.system(
"echo \"set term png; set output 'output.png';"
13
" plot 'foo.gp' using 1:3 with lines, 'foo.gp' using 1:2 with lines\" | gnuplot"
)
14
sys.exit(0)
15
else
:
16
assert
sys.platform ==
'darwin'
,
'Sound only works on the Mac'
17
18
import
aifc
19
20
import
foo
21
S = foo.samples
22
23
try
:
24
os.unlink(
"quux.aiff"
)
25
except
:
26
pass
27
28
q = aifc.open(
"quux.aiff"
,
"wb"
)
29
q.setnchannels(1)
30
q.setsampwidth(2)
31
q.setframerate(foo.sampfreq)
32
q.setnframes(len(S))
33
34
def
f
(x):
35
xhi = (x >> 8) & 0xff
36
xlo = x & 0xff
37
return
chr(xhi) + chr(xlo)
38
39
q.writeframes(
""
.join(map(f, S)))
40
q.close()
41
42
os.system(
"afplay quux.aiff"
)
hack.f
def f
Definition:
hack.py:34
Generated on Sat Aug 15 2015 21:01:51 for The Tooba by
1.8.8