~ubuntu-branches/debian/sid/python-pyo/sid

« back to all changes in this revision

Viewing changes to examples/sequencing/02_random_score.py

  • Committer: Package Import Robot
  • Author(s): Tiago Bortoletto Vaz
  • Date: 2012-06-08 20:35:45 UTC
  • Revision ID: package-import@ubuntu.com-20120608203545-4z7kcf2lgvpsk18y
Tags: upstream-0.6.1
ImportĀ upstreamĀ versionĀ 0.6.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# encoding: utf-8
 
3
"""
 
4
Calling Python function from an audio stream with the Score object.
 
5
 
 
6
"""
 
7
from pyo import *
 
8
import random
 
9
 
 
10
s = Server(sr=44100, nchnls=2, buffersize=256, duplex=0).boot()
 
11
 
 
12
# Frequency of event generation in Hz
 
13
GEN_FREQ = .25
 
14
 
 
15
aamp = Linseg([(0,0),(1./GEN_FREQ,1),(2./GEN_FREQ,0)], mul=.5).stop()
 
16
asyn = Rossler(pitch=0.25, chaos=0.5, stereo=True, mul=aamp).out()
 
17
 
 
18
bamp = Linseg([(0,0),(1./GEN_FREQ,1),(2./GEN_FREQ,0)], mul=.25).stop()
 
19
bsyn = SineLoop(freq=[100,100], feedback=0.05, mul=bamp).out()
 
20
 
 
21
camp = Linseg([(0,0),(1./GEN_FREQ,1),(2./GEN_FREQ,0)], mul=.25).stop()
 
22
csyn = FM(carrier=[100,100], ratio=[.49,.5], index=6, mul=camp).out()
 
23
 
 
24
def event_0():
 
25
    print "playing chaotic attractor"
 
26
    asyn.pitch = random.uniform(0.25,0.75)
 
27
    asyn.chaos = random.uniform(0.2,0.8)
 
28
    aamp.play()
 
29
 
 
30
def event_1():
 
31
    print "playing looped oscillator"
 
32
    bsyn.freq = [random.choice(range(50,501,50))*random.uniform(0.99,1.01) for i in range(2)]
 
33
    bsyn.feedback = random.uniform(0.01, 0.1)
 
34
    bamp.play()
 
35
 
 
36
def event_2():
 
37
    print "playing frequency modulation"
 
38
    csyn.carrier = [random.choice([50,100,150,200,250])*random.uniform(0.99,1.01) for i in range(2)]
 
39
    csyn.ratio = [random.choice([.1251,.249,.502,.7501,1.003]) for i in range(2)]
 
40
    camp.play()
 
41
 
 
42
tr = RandInt(max=3, freq=GEN_FREQ)
 
43
sc = Score(input=tr, fname='event_')
 
44
 
 
45
s.gui(locals())
 
 
b'\\ No newline at end of file'