| 1 |
""" |
| 2 |
01-envelopes.py - Using break-point function to control an FM synthesis. |
| 3 |
|
| 4 |
This example shows how break-point tables can be used to control synthesis/effect |
| 5 |
parameters at audio rate. Pyo offers many objects to generate break-point function: |
| 6 |
|
| 7 |
- LinTable: Construct a table from segments of straight lines. |
| 8 |
- CosTable: Construct a table from cosine interpolated segments. |
| 9 |
- ExpTable: Construct a table from exponential interpolated segments. |
| 10 |
- CurveTable: Construct a table from curve, with tension and bias, interpolated segments. |
| 11 |
- LogTable: Construct a table from logarithmic segments. |
| 12 |
- CosLogTable: Construct a table from logarithmic-cosine segments. |
| 13 |
|
| 14 |
These objects implement a `graph()` method (as well as Linseg and Expseg) which show |
| 15 |
a graph window with which the user can set the shape of the trajectory. |
| 16 |
|
| 17 |
With the focus on the graph window, the copy menu item (Ctrl+C) saves to the |
| 18 |
clipboard the list of points in a format well suited to be paste in the code. |
| 19 |
Useful to experiment graphically and then copy/paste the result in the script. |
| 20 |
|
| 21 |
To play more notes, in the Interpreter field of the Server GUI, call the `note(freq, dur)` |
| 22 |
function with the desired frequency and duration. |
| 23 |
|
| 24 |
Note: The wxPython Phoenix graphical library must be installed to use the graph. Infos at: |
| 25 |
|
| 26 |
http://www.wxpython.org/ |
| 27 |
|
| 28 |
""" |
| 29 |
from pyo import * |
| 30 |
|
| 31 |
s = Server().boot() |
| 32 |
|
| 33 |
|
| 34 |
amp_table = CosTable([(0, 0), (100, 1), (1024, 0.5), (7000, 0.5), (8192, 0)]) |
| 35 |
rat_table = ExpTable( |
| 36 |
[(0, 0.5), (1500, 0.5), (2000, 0.25), (3500, 0.25), (4000, 1), (5500, 1), (6000, 0.5), (8192, 0.5),] |
| 37 |
) |
| 38 |
ind_table = LinTable([(0, 20), (512, 10), (8192, 0)]) |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
amp_table.graph(title="Amplitude envelope") |
| 43 |
rat_table.graph(title="Ratio envelope") |
| 44 |
ind_table.graph(yrange=(0, 20), title="Modulation index envelope") |
| 45 |
|
| 46 |
|
| 47 |
amp = TableRead(table=amp_table, freq=1, loop=False, mul=0.3) |
| 48 |
rat = TableRead(table=rat_table, freq=1, loop=False) |
| 49 |
ind = TableRead(table=ind_table, freq=1, loop=False) |
| 50 |
|
| 51 |
|
| 52 |
fm = FM(carrier=[100, 100], ratio=rat, index=ind, mul=amp).out() |
| 53 |
|
| 54 |
|
| 55 |
def note(freq=100, dur=1): |
| 56 |
fm.carrier = [freq, freq * 1.005] |
| 57 |
amp.freq = 1.0 / dur |
| 58 |
rat.freq = 1.0 / dur |
| 59 |
ind.freq = 1.0 / dur |
| 60 |
amp.play() |
| 61 |
rat.play() |
| 62 |
ind.play() |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
note(200, 2) |
| 67 |
|
| 68 |
s.gui(locals()) |