| 1 |
""" |
| 2 |
07-hand-made-harmonizer.py - Hand-written harmonizer effect. |
| 3 |
|
| 4 |
A harmonizer is a type of pitch shifter that combines the "shifted" pitch |
| 5 |
with the original pitch to create a two or more note harmony. |
| 6 |
|
| 7 |
The implementation consists of two overlapping delay lines for which the |
| 8 |
reading head speed is tuned to transpose the signal by an amount specified |
| 9 |
in semitones. |
| 10 |
|
| 11 |
The Harmonizer object (from pyo) implements an pitch shifter and should |
| 12 |
use less CPU than the hand-written version. this example's purpose is only |
| 13 |
to show how it works or to be used as a starting point to build an extended |
| 14 |
version. |
| 15 |
|
| 16 |
""" |
| 17 |
from pyo import * |
| 18 |
|
| 19 |
s = Server(duplex=0).boot() |
| 20 |
|
| 21 |
|
| 22 |
sf = SfPlayer("../snds/flute.aif", speed=1, loop=True, mul=0.5).out() |
| 23 |
|
| 24 |
|
| 25 |
env = WinTable(8) |
| 26 |
|
| 27 |
|
| 28 |
wsize = 0.1 |
| 29 |
|
| 30 |
|
| 31 |
trans = -7 |
| 32 |
|
| 33 |
|
| 34 |
ratio = pow(2.0, trans / 12.0) |
| 35 |
|
| 36 |
|
| 37 |
rate = -(ratio - 1) / wsize |
| 38 |
|
| 39 |
|
| 40 |
ind = Phasor(freq=rate, phase=[0, 0.5]) |
| 41 |
|
| 42 |
|
| 43 |
win = Pointer(table=env, index=ind, mul=0.7) |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
snd = Delay(sf, delay=ind * wsize, mul=win).mix(1) |
| 48 |
|
| 49 |
|
| 50 |
snd.out(1) |
| 51 |
|
| 52 |
s.gui(locals()) |