File: 03-read-from-ram.py

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 (30 lines) | stat: -rw-r--r-- 904 bytes parent folder | download | duplicates (7)
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
"""
03-read-from-ram.py - Soundfile playback from RAM.

Reading a sound file from the RAM gives the advantage of a very
fast access to every loaded samples. This is very useful for a
lot of processes, such as granulation, looping, creating envelopes
and waveforms and many others.

The simplest way of loading a sound in RAM is to use the SndTable
object. This example loads a sound file and reads it in loop.
We will see some more evolved processes later...

"""
from pyo import *

s = Server().boot()

path = SNDS_PATH + "/transparent.aif"

# Loads the sound file in RAM. Beginning and ending points
# can be controlled with "start" and "stop" arguments.
t = SndTable(path)

# Gets the frequency relative to the table length.
freq = t.getRate()

# Simple stereo looping playback (right channel is 180 degrees out-of-phase).
osc = Osc(table=t, freq=freq, phase=[0, 0.5], mul=0.4).out()

s.gui(locals())