| 1 |
class Module(BaseModule): |
| 2 |
""" |
| 3 |
"Synthesis where the waveform is a small portion extracted from an audio signal" |
| 4 |
|
| 5 |
Description |
| 6 |
|
| 7 |
This module uses a small portion of an audio signal (between 64 and 8192 samples) as |
| 8 |
the waveform for an oscillator. By sliding the position of the portion in the signal, |
| 9 |
one can produce continuous complex variations of the waveform, which can give very |
| 10 |
rich sonorities. |
| 11 |
|
| 12 |
Sliders |
| 13 |
|
| 14 |
# Base Frequency : |
| 15 |
Fundamental frequency of the oscillator. |
| 16 |
# Position : |
| 17 |
Position in the signal where to extract the waveform. |
| 18 |
# Window Size : |
| 19 |
Lentgh, in samples, of the waveform. |
| 20 |
# LFO Frequency : |
| 21 |
Frequency of an LFO applied to the position in the signal. |
| 22 |
# LFO Depth : |
| 23 |
Depth of the LFO applied to the position in the signal. |
| 24 |
# Lowpass Freq : |
| 25 |
Frequency of a lowpass filter used to attenuate the higher components |
| 26 |
in the spectrum of the resulting signal. |
| 27 |
|
| 28 |
Graph Only |
| 29 |
|
| 30 |
# Overall Amplitude : |
| 31 |
The amplitude curve applied on the total duration of the performance |
| 32 |
|
| 33 |
Popups & Toggles |
| 34 |
|
| 35 |
# Polyphony Voices : |
| 36 |
Number of voices played simultaneously (polyphony), |
| 37 |
only available at initialization time |
| 38 |
# Polyphony Spread : |
| 39 |
Pitch variation between voices (chorus), |
| 40 |
only available at initialization time |
| 41 |
|
| 42 |
""" |
| 43 |
def __init__(self): |
| 44 |
BaseModule.__init__(self) |
| 45 |
self.table = self.addFilein("table") |
| 46 |
|
| 47 |
self.phase = Phasor(freq=self.frequency * self.polyphony_spread) |
| 48 |
self.triangle = Min(self.phase, comp=self.phase* -1 + 1, mul=2) |
| 49 |
self.winsizePort = Port(self.winsize / self.polyphony_spread, risetime=0.5, falltime=0.5, init=self.winsize.get(), |
| 50 |
mul=1. / self.table.getSize(False)) |
| 51 |
self.window = self.triangle * self.winsizePort |
| 52 |
self.lfodepthPort = Port(self.lfodepth, risetime=0.5, falltime=0.5, init=self.lfodepth.get(), mul=0.1) |
| 53 |
self.lfo = Sine(self.lfofreq, mul=self.lfodepthPort) |
| 54 |
self.positionPort = Port(self.position, risetime=0.25, falltime=0.25, init=self.position.get()) |
| 55 |
|
| 56 |
self.pointerPos = self.positionPort + self.window + self.lfo |
| 57 |
|
| 58 |
self.reader = Pointer2(self.table, index=self.pointerPos, mul=0.7) |
| 59 |
self.readerBL = IRWinSinc(self.reader, freq=0, order=16) |
| 60 |
self.filter = Biquadx(self.readerBL, freq=self.lowfreq, q=0.7, stages=2) |
| 61 |
|
| 62 |
self.out = Mix(self.filter, voices=self.nchnls, mul=self.env * self.polyphony_scaling) |
| 63 |
|
| 64 |
|
| 65 |
Interface = [ |
| 66 |
cfilein(name="table"), |
| 67 |
cgraph(name="env", label="Overall Amplitude", func=[(0,1),(1,1)], col="blue"), |
| 68 |
cslider(name="frequency", label="Base Frequency", min=1, max=1000, init=100, rel="log", unit="Hz", col="red"), |
| 69 |
cslider(name="position", label="Position", min=0, max=1, init=0.5, rel="lin", unit="x", col="orange"), |
| 70 |
cslider(name="winsize", label="Window Size", min=64, max=8192, init=512, rel="lin", res="int", unit="spl", col="orange2"), |
| 71 |
cslider(name="lfofreq", label="LFO Frequency", min=0.001, max=100, init=0.1, rel="log", unit="Hz", col="purple"), |
| 72 |
cslider(name="lfodepth", label="LFO Depth", min=0, max=1, init=0.1, rel="lin", unit="x", col="purple2"), |
| 73 |
cslider(name="lowfreq", label="Lowpass Freq", min=50, max=15000, init=2500, rel="log", unit="Hz", col="green"), |
| 74 |
cpoly() |
| 75 |
] |