Debian Codegraph @

docs/_sources/examples/04-soundfiles/03-read-from-ram.rst.txt

raw
1 03-read-from-ram.py - Soundfile playback from RAM.
2 ============================================================================================================================================
3
4
5 Reading a sound file from the RAM gives the advantage of a very
6 fast access to every loaded samples. This is very useful for a
7 lot of processes, such as granulation, looping, creating envelopes
8 and waveforms and many others.
9
10 The simplest way of loading a sound in RAM is to use the SndTable
11 object. This example loads a sound file and reads it in loop.
12 We will see some more evolved processes later...
13
14 .. code-block:: python
15
16 from pyo import *
17
18 s = Server().boot()
19
20 path = SNDS_PATH + "/transparent.aif"
21
22 # Loads the sound file in RAM. Beginning and ending points
23 # can be controlled with "start" and "stop" arguments.
24 t = SndTable(path)
25
26 # Gets the frequency relative to the table length.
27 freq = t.getRate()
28
29 # Simple stereo looping playback (right channel is 180 degrees out-of-phase).
30 osc = Osc(table=t, freq=freq, phase=[0, 0.5], mul=0.4).out()
31
32 s.gui(locals())
33