File: 03-send-streams.rst.txt

package info (click to toggle)
python-pyo 1.0.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 52,332 kB
  • sloc: python: 135,133; ansic: 127,822; javascript: 16,116; sh: 395; makefile: 388; cpp: 242
file content (42 lines) | stat: -rw-r--r-- 1,312 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Sending audio streams as Open Sound Control messages
============================================================================================================================================


**03-send-streams.py**

This program does not generate any sound. All it does is to produce
audio streams that are then send on an open port as OSC messages in
order to control a granulation process created in the example 
*02-receive-streams.py*.

.. code-block:: python

    from pyo import *
    
    s = Server().boot()
    
    # Manual control of the density of grains per second.
    dens = Sig(0.5)
    dens.ctrl(title="Density of grains per second")
    
    # Generate a normalized random position in the sound with interpolation.
    pos = Randi(min=0.00, max=1.00, freq=0.1)
    
    # Manual control of the transposition per grain.
    pit = Sig(0)
    pit.ctrl(title="Transposition per grain")
    
    # Manual control of the grain's duration.
    dur = Sig(0.5)
    dur.ctrl(title="Grain duration")
    
    # Takes audio signals and sends their current value as OSC messages every buffer size.
    send = OscSend(
        input=[dens, pos, pit, dur],
        port=9000,
        address=["/density", "/position", "/pitch_rand", "/duration"],
        host="127.0.0.1",
    )
    
    s.gui(locals())