git.haldean.org symrep / 5f5a139
add a readme Will Haldean Brown 6 years ago
4 changed file(s) with 72 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
00 __pycache__
11 *.pyc
2 *.dot
3 *.png
4 *.wav
2 /*.dot
3 /*.png
4 /*.wav
0 symrep
1 ===
2 `symrep` is an attempt to make a general-purpose, hierarchical, functional
3 representation for media using function composition. Graphs that represent some
4 creative entity are constructed from nested function calls, these graphs can
5 then be sampled at different parameter values with varying results. `symrep` is
6 written to be parameter-space agnostic, allowing for it to be used for
7 everything from 5.1-channel audio to functional representation of 3D models.
8
9 For example, this source code for audio synthesis (using the `symrep.audio`
10 package):
11
12 from symrep import *
13 import sys
14
15 n = sum(
16 product(
17 const(0.3),
18 product(
19 audio.sine(const(440), name="tuner"),
20 audio.sine(const(0.5)),
21 )
22 ),
23 product(
24 const(0.2),
25 audio.sine(
26 product(
27 const(400),
28 piecewise(
29 audio.sawtooth(const(1)),
30 const(1),
31 const(1),
32 ),
33 ),
34 name="riser",
35 )
36 ),
37 product(
38 const(0.3),
39 audio.sine(const(220), name="thing"),
40 ),
41 product(
42 audio.sine(const(140), name="kick1"),
43 audio.square(const(2), const(0.05)),
44 ),
45 product(
46 const(0.5),
47 audio.sine(const(100), name="kick2"),
48 shift(
49 audio.square(const(2), const(0.05)),
50 const(0.25),
51 )
52 ),
53 product(
54 const(0.2),
55 audio.sine(const(523), name="duty"),
56 audio.square(
57 const(2),
58 audio.sawtooth(const(1. / 60.)),
59 ),
60 )
61 )
62 audio.stream_pcm(n, 44100, sys.stdout)
63
64 Gives the following graph:
65
66 ![](examples/sound.png)
67
68 [...and this sound file](examples/sound.wav)
Binary diff not shown
Binary diff not shown