Debian Codegraph @

docs/_sources/examples/02-controls/05-math-ops.rst.txt

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