File: 05-strange-attractors.py

package info (click to toggle)
python-pyo 1.0.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 52,332 kB
  • sloc: python: 135,133; ansic: 127,822; javascript: 16,116; sh: 395; makefile: 388; cpp: 242
file content (58 lines) | stat: -rw-r--r-- 1,656 bytes parent folder | download | duplicates (7)
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
58
"""
05-strange-attractors.py - Non-linear ordinary differential equations.

Oscilloscope part of the tutorial
---------------------------------

A strange attractor is a system of three non-linear ordinary
differential equations. These differential equations define a
continuous-time dynamical system that exhibits chaotic dynamics
associated with the fractal properties of the attractor.

There is three strange attractors in the library, the Rossler,
the Lorenz and the ChenLee objects. Each one can output stereo
signal if the `stereo` argument is set to True.

Use the "voice" slider of the window "Input interpolator" to
interpolate between the three sources.

Audio part of the tutorial
--------------------------

It's possible to create very interesting LFO with strange
attractors. The last part of this tutorial shows the use of
Lorenz's output to drive the frequency of two sine wave oscillators.

"""
from pyo import *

s = Server().boot()

### Oscilloscope ###

# LFO applied to the `chaos` attribute
lfo = Sine(0.2).range(0, 1)

# Rossler attractor
n1 = Rossler(pitch=0.5, chaos=lfo, stereo=True)

# Lorenz attractor
n2 = Lorenz(pitch=0.5, chaos=lfo, stereo=True)

# ChenLee attractor
n3 = ChenLee(pitch=0.5, chaos=lfo, stereo=True)

# Interpolates between input objects to produce a single output
sel = Selector([n1, n2, n3])
sel.ctrl(title="Input interpolator (0=Rossler, 1=Lorenz, 2=ChenLee)")

# Displays the waveform of the chosen attractor
sc = Scope(sel)

### Audio ###

# Lorenz with very low pitch value that acts as a LFO
freq = Lorenz(0.005, chaos=0.7, stereo=True, mul=250, add=500)
a = Sine(freq, mul=0.3).out()

s.gui(locals())