Debian Codegraph @

pyo/examples/x10-tables/07-moving-points.py

raw symbols SCIP
1 """
2 07-moving-points.py - Periodically rewrite a break-point function table.
3
4 This example shows how we can dynamically modify a function table to create a
5 curve that varies over time.
6
7 Note: Rewriting a large table can produce xruns in the audio output. Usually,
8 for this kind of processes, we want to keep the table size relatively small.
9
10 """
11 from pyo import *
12
13 s = Server().boot()
14
15 # Initialize an empty table.
16 table = LinTable([(0, 0), (255, 0)], size=256)
17 table.view()
18
19 # Two LFOs whose values will change the center points in the table.
20 lfo1 = Sine(0.1, phase=0.75, mul=0.5, add=0.5)
21 lfo2 = Sine(0.15, phase=0.75, mul=0.5, add=0.5)
22
23
24 def create_line():
25 "Function to create a new line."
26 lst = [(0, 0)] # First point of the table at value 0.
27 lst.append((8, lfo1.get())) # Second point, from first LFO.
28 lst.append((128, lfo2.get())) # Third point, from second LFO.
29 lst.append((255, 0)) # Last point of the table at value 0.
30
31 # Replace the table content with the new list of points.
32 table.replace(lst)
33
34
35 # Call the function "create_line" every 50 ms.
36 pat = Pattern(function=create_line, time=0.05).play()
37
38 # Little test case...
39 amp = Osc(table, freq=4, mul=0.4)
40 synth = RCOsc(freq=[99.5, 100], sharp=0.3, mul=amp).out()
41
42 s.gui(locals())