git.haldean.org symrep / 3d6d225
move audio generation to examples Will Haldean Brown 6 years ago
2 changed file(s) with 20 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
0 import symrep
1 import sys
2
3 n1 = symrep.product(
4 symrep.const(0.5),
5 symrep.product(
6 symrep.audio.sine(symrep.const(440)),
7 symrep.audio.sine(symrep.const(0.5)),
8 )
9 )
10 n2 = symrep.product(
11 symrep.const(0.5),
12 symrep.product(
13 symrep.audio.sine(symrep.const(360)),
14 symrep.audio.sine(symrep.const(0.4)),
15 )
16 )
17 n = symrep.sum(n1, n2)
18
19 symrep.audio.to_wav(n, 44100, 10, sys.stdout)
4848 stream.write("data")
4949 stream.write(struct.pack("<I", 4 * len(data)))
5050 data.tofile(stream)
51
52 if __name__ == "__main__":
53 n = symrep.base.product(
54 sine(symrep.base.const(440)),
55 sine(symrep.base.const(0.2)),
56 )
57 with open("test.wav", "w") as f:
58 to_wav(n, 44100, 5, f)