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

« back to all changes in this revision

Viewing changes to examples/effects/05_fuzz_disto.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
Fuzz distortion. High gain followed by, asymmetrical clipping, 
 
5
hard clip on top, soft compression on bottom.
 
6
 
 
7
"""
 
8
from pyo import *
 
9
 
 
10
s = Server().boot()
 
11
 
 
12
SOURCE = "../snds/flute.aif"
 
13
BP_CENTER_FREQ = 250
 
14
BP_Q = 2
 
15
BOOST = 5
 
16
LP_CUTOFF_FREQ = 3500
 
17
BALANCE = 0.8
 
18
 
 
19
src = SfPlayer(SOURCE, loop=True).mix(2)
 
20
 
 
21
# Transfert function for signal lower than 0
 
22
low_table = ExpTable([(0,-.25),(4096,0),(8192,0)], exp=10)
 
23
# Transfert function for signal higher than 0
 
24
high_table = CosTable([(0,0),(4096,0),(4598,1),(8192,1)])
 
25
 
 
26
# Bandpass filter and boost gain applied on input signal
 
27
bp = Biquad(src, freq=BP_CENTER_FREQ, q=BP_Q, type=2)
 
28
boost = Sig(bp, mul=BOOST)
 
29
 
 
30
# Split signal into positive and negative part
 
31
sign = Compare(boost, comp=0, mode=">=")
 
32
sw = Switch(boost, outs=2, voice=sign)
 
33
 
 
34
# Apply transfert function
 
35
lowsig = Lookup(low_table, sw[0])
 
36
highsig = Lookup(high_table, sw[1])
 
37
 
 
38
# Lowpass filter on distorted signal
 
39
lp = Tone(lowsig+highsig, freq=LP_CUTOFF_FREQ, mul=.3)
 
40
 
 
41
# Balance between dry and wet signals
 
42
out = Interp(src, lp, interp=BALANCE).out()
 
43
 
 
44
s.gui(locals())
 
 
b'\\ No newline at end of file'