Debian Codegraph @

pyo/examples/x02-controls/05-math-ops.py

raw symbols SCIP
1 """
2 05-math-ops.py - Audio objects and arithmetic expresssions.
3
4 This script shows how a PyoObject reacts when used inside an
5 arithmetic expression.
6
7 Multiplication, addition, division and substraction can be applied
8 between pyo objects or between pyo objects and numbers. Doing so
9 returns a Dummy object that outputs the result of the operation.
10
11 A Dummy object is only a place holder to keep track of arithmetic
12 operations on audio objects.
13
14 PyoObject can also be used in expression with the exponent (**),
15 modulo (%) and unary negative (-) operators.
16
17 """
18 from pyo import *
19
20 s = Server().boot()
21 s.amp = 0.1
22
23 # Full scale sine wave
24 a = Sine()
25
26 # Creates a Dummy object `b` with `mul` attribute
27 # set to 0.5 and leaves `a` unchanged.
28 b = a * 0.5
29 b.out()
30
31 # Instance of Dummy class
32 print(b)
33
34 # Computes a ring modulation between two PyoObjects
35 # and scales the amplitude of the resulting signal.
36 c = Sine(300)
37 d = a * c * 0.3
38 d.out()
39
40 # PyoObject can be used with Exponent operator.
41 e = c ** 10 * 0.4
42 e.out(1)
43
44 # Displays the ringmod and the rectified signals.
45 sp = Spectrum([d, e])
46 sc = Scope([d, e])
47
48 s.gui(locals())