| 1 |
14-post-processing.py - Accessing Events's audio output for post-processing. |
| 2 |
============================================================================================================================================ |
| 3 |
|
| 4 |
|
| 5 |
The Events framework is essentially an audio material generator. The user will |
| 6 |
generally want to have access to the result for future treatments, as in passing |
| 7 |
through some reverb or delay. |
| 8 |
|
| 9 |
There are two built-in arguments that help the user to configure the audio output |
| 10 |
of the Events object. |
| 11 |
|
| 12 |
- `signal`: A string indicating which attribute of the instrument is its final |
| 13 |
audio output. The Events objects will automatically sum this attribute |
| 14 |
signal from all active instrument instances. |
| 15 |
- `outs`: Determine how many channels the Events object output signal will contain. |
| 16 |
This value should match the number of audio streams produced by the |
| 17 |
instrument. |
| 18 |
|
| 19 |
Once these two arguments are defined, the sig() method returns an audio signal that |
| 20 |
is the sum of the active instance output signals. |
| 21 |
|
| 22 |
.. code-block:: python |
| 23 |
|
| 24 |
from pyo import * |
| 25 |
|
| 26 |
s = Server().boot() |
| 27 |
|
| 28 |
# A simple custom instrument. Note that the out() method is not called! |
| 29 |
class MyInstrument(EventInstrument): |
| 30 |
def __init__(self, **args): |
| 31 |
EventInstrument.__init__(self, **args) |
| 32 |
self.output = LFO(freq=self.freq, sharp=[0.5, 0.6], type=2, mul=self.env) |
| 33 |
|
| 34 |
|
| 35 |
# Some notes... |
| 36 |
scl = EventScale("C", "aeolian", 3, 3, type=2) |
| 37 |
|
| 38 |
# ... then the sequence of events. We are looking for a 2 streams (`outs`) |
| 39 |
# signal in the self.output attribute (`signal`) of the instrument. |
| 40 |
e = Events( |
| 41 |
instr=MyInstrument, |
| 42 |
degree=EventSlide(scl, segment=3, step=1), |
| 43 |
beat=1 / 4.0, |
| 44 |
db=-12, |
| 45 |
signal="output", |
| 46 |
outs=2, |
| 47 |
attack=0.001, |
| 48 |
decay=0.05, |
| 49 |
sustain=0.7, |
| 50 |
release=0.05, |
| 51 |
).play() |
| 52 |
|
| 53 |
# We use the sig() method to add post-processing to the events's sound. |
| 54 |
chorus = Chorus(e.sig(), depth=1, feedback=0.25) |
| 55 |
delay = Delay(chorus, delay=1, feedback=0.5) |
| 56 |
reverb = WGVerb(chorus + delay, feedback=0.8, cutoff=5000, bal=0.25).out() |
| 57 |
|
| 58 |
s.gui(locals()) |
| 59 |
|