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

« back to all changes in this revision

Viewing changes to examples/utilities/06_separated_threads.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
Launch the audio processing in a separated thread and send events.
 
5
See play_snd.py for subprocess sound player.
 
6
 
 
7
"""
 
8
import subprocess, time, random
 
9
 
 
10
pipe = subprocess.Popen(["python -i play_snd.py"], shell=True, stdin=subprocess.PIPE).stdin
 
11
 
 
12
# Wait for the Server to be ready
 
13
time.sleep(2)
 
14
 
 
15
# send events to the sub process
 
16
for i in range(20):
 
17
    snd = "../snds/snd_%d.aif" % random.randrange(1,7)
 
18
    pipe.write("sf.path = '%s'\ndump = sf.play()\n" % snd)
 
19
    time.sleep(random.uniform(.2, .5))
 
20
 
 
21
# Stop the audio Server before exiting
 
22
pipe.write("s.stop()\ntime.sleep(0.25)\n")
 
23
pipe.close()
 
24
 
 
25