Debian Codegraph @

pyo/examples/x22-events/14-post-processing.py

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