Debian Codegraph @

pyo/examples/x03-generators/05-strange-attractors.py

raw symbols SCIP
1 """
2 05-strange-attractors.py - Non-linear ordinary differential equations.
3
4 Oscilloscope part of the tutorial
5 ---------------------------------
6
7 A strange attractor is a system of three non-linear ordinary
8 differential equations. These differential equations define a
9 continuous-time dynamical system that exhibits chaotic dynamics
10 associated with the fractal properties of the attractor.
11
12 There is three strange attractors in the library, the Rossler,
13 the Lorenz and the ChenLee objects. Each one can output stereo
14 signal if the `stereo` argument is set to True.
15
16 Use the "voice" slider of the window "Input interpolator" to
17 interpolate between the three sources.
18
19 Audio part of the tutorial
20 --------------------------
21
22 It's possible to create very interesting LFO with strange
23 attractors. The last part of this tutorial shows the use of
24 Lorenz's output to drive the frequency of two sine wave oscillators.
25
26 """
27 from pyo import *
28
29 s = Server().boot()
30
31 ### Oscilloscope ###
32
33 # LFO applied to the `chaos` attribute
34 lfo = Sine(0.2).range(0, 1)
35
36 # Rossler attractor
37 n1 = Rossler(pitch=0.5, chaos=lfo, stereo=True)
38
39 # Lorenz attractor
40 n2 = Lorenz(pitch=0.5, chaos=lfo, stereo=True)
41
42 # ChenLee attractor
43 n3 = ChenLee(pitch=0.5, chaos=lfo, stereo=True)
44
45 # Interpolates between input objects to produce a single output
46 sel = Selector([n1, n2, n3])
47 sel.ctrl(title="Input interpolator (0=Rossler, 1=Lorenz, 2=ChenLee)")
48
49 # Displays the waveform of the chosen attractor
50 sc = Scope(sel)
51
52 ### Audio ###
53
54 # Lorenz with very low pitch value that acts as a LFO
55 freq = Lorenz(0.005, chaos=0.7, stereo=True, mul=250, add=500)
56 a = Sine(freq, mul=0.3).out()
57
58 s.gui(locals())