Debian Codegraph @

pyo/examples/x05-envelopes/01-data-signal-conversion.py

raw symbols SCIP
1 """
2 01-data-signal-conversion.py - Conversion from number to audio stream.
3
4 The Stream object is a new type introduced by pyo to represent an
5 audio signal as a vector of floats. It is sometimes useful to be
6 able to convert simple numbers (python's floats or integers) to
7 audio signal or to extract numbers from an audio stream.
8
9 The Sig object converts a number to an audio stream.
10
11 The PyoObject.get() method extracts a float from an audio stream.
12
13 """
14 from pyo import *
15
16 s = Server().boot()
17
18 # A python integer (or float).
19 anumber = 100
20
21 # Conversion from number to an audio stream (vector of floats).
22 astream = Sig(anumber)
23
24 # Use a Print (capital "P") object to print an audio stream.
25 pp = Print(astream, interval=0.1, message="Audio stream value")
26
27 # Use the get() method to extract a float from an audio stream.
28 print("Float from audio stream : ", astream.get())
29
30 s.gui(locals())