File: 04-receive-list.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 (34 lines) | stat: -rw-r--r-- 1,371 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
Receiving OSC messages as list of audio streams
============================================================================================================================================


**04-receive-list.py**

OscListReceive receives list of values over a network via the Open Sound
Control protocol. It converts the values as audio streams that can be used
to control audio process.

.. code-block:: python

    from pyo import *
    
    s = Server().boot()
    
    source = SfPlayer("../snds/flute.aif", loop=True, mul=0.7)
    
    # Receives a list of two values from a TouchOSC's XY pad and converts
    # them as audio streams. All streams for a given address can be retrieve
    # with the syntax: rec[address]. One can access the individual streams
    # for an address with slicing: rec[address][0], rec[address][1], etc.
    rec = OscListReceive(port=9002, address="/4/xy", num=2)
    
    # Sets initial values for the OSC streams. This allow the program to run with
    # minimal behaviour even if no message have been sent on this address.
    rec.setValue("/4/xy", [0.5, 0.5])
    
    # Assign the value on the X axis to the drive parameter, and
    # the value on the Y axis to the slope (lowpass filter) parameter.
    disto = Disto(source, drive=Sqrt(rec["/4/xy"][0]), slope=Sqrt(rec["/4/xy"][1]), mul=0.5).mix(2).out()
    
    s.gui(locals())