Debian Codegraph @

pyo/examples/x10-tables/03-looping.py

raw symbols SCIP
1 """
2 03-looper.py - High quality crossfading multimode sound looper.
3
4 The Looper object reads audio from a PyoTableObject and plays it back in
5 a loop with user-defined pitch, start time, duration and crossfade time.
6
7 Looper will send a trigger signal every time a new playback starts, which
8 means at the object activation and at the beginning of the crossfade when
9 looping. User can retrieve the trigger streams with obj['trig'].
10
11 Looper also outputs a time stream, given the current position of the
12 reading pointer, normalized between 0.0 and 1.0 (1.0 means the beginning
13 of the crossfade), inside the loop. User can retrieve the trigger stream
14 with obj['time'].
15
16 Some methods let change the behaviour of the loop:
17
18 - Looper.appendFadeTime(boolean):
19 If True, the crossfade starts after the loop duration.
20 - Looper.fadeInSeconds(boolean):
21 If True, the crossfade duration (`xfade` attribute) is set in seconds.
22
23 """
24 from pyo import *
25
26 s = Server().boot()
27
28 table = SndTable("../snds/baseballmajeur_m.aif")
29 table.view()
30
31 looper = Looper(
32 table=table, # The table to read.
33 pitch=1.0, # Speed factor, 0.5 means an octave lower,
34 # 2 means an octave higher.
35 start=0, # Start time of the loop, in seconds.
36 dur=table.getDur(), # Duration of the loop, in seconds.
37 xfade=25, # Duration of the crossfade, in % of the loop length.
38 mode=1, # Looping mode: 0 = no loop, 1 = forward,
39 # 2 = backward, 3 = back-and-forth.
40 xfadeshape=0, # Shape of the crossfade envelope: 0 = linear
41 # 1 = equal power, 2 = sigmoid.
42 startfromloop=False, # If True, the playback starts from the loop start
43 # point. If False, the playback starts from the
44 # beginning and enters the loop mode when crossing
45 # the loop start point.
46 interp=4, # Interpolation method (used when speed != 1):
47 # 1 = none, 2 = linear, 3 = cosine, 4 = cubic.
48 autosmooth=True, # If True, a lowpass filter, following the pitch,
49 # is applied on the output signal to reduce the
50 # quantization noise produced by very low transpositions.
51 # interp = 4 and autosmooth = True give a very high
52 # quality reader for playing sound at low rates.
53 mul=0.5,
54 )
55 looper.ctrl()
56
57 stlooper = looper.mix(2).out()
58
59 s.gui(locals())