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