File: 06-vocoder.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 (35 lines) | stat: -rw-r--r-- 1,154 bytes parent folder | download | duplicates (3)
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
31
32
33
34
35
"""
06-vocoder.py - Analysis/resynthesis vocoder effect.

A vocoder is an analysis/resynthesis process that
uses the spectral envelope of a first sound to shape
the spectrum of a second sound. Usually (for the best
results) the first sound should present a dynamic
spectrum (for both frequencies and amplitudes) and the
second sound should contain a rich and stable spectrum.

In this example, LFOs are applied to every dynamic argument
of the Vocoder object to show the range of sound effects
the user can get with a vocoder.

"""
from pyo import *
from random import random

s = Server().boot()

# First sound - dynamic spectrum.
spktrm = SfPlayer("../snds/baseballmajeur_m.aif", speed=[1, 1.001], loop=True)

# Second sound - rich and stable spectrum.
excite = Noise(0.2)

# LFOs to modulate every parameters of the Vocoder object.
lf1 = Sine(freq=0.1, phase=random()).range(60, 100)
lf2 = Sine(freq=0.11, phase=random()).range(1.05, 1.5)
lf3 = Sine(freq=0.07, phase=random()).range(1, 20)
lf4 = Sine(freq=0.06, phase=random()).range(0.01, 0.99)

voc = Vocoder(spktrm, excite, freq=lf1, spread=lf2, q=lf3, slope=lf4, stages=32).out()

s.gui(locals())