A pseudo-UGen that uses a wavetable file produced by WavetablePrep. It attempts to control aliasing somewhat using a frequency-mapping technique. It also supports phase distortion and "unison"-style detuning.
As is normal for wavetable oscillators, MultiWtOsc begins with a linear ramp for the phase: Phasor ramps between 0.0 and 1.0.
hardSync
is applied as a trigger input to Phasor: the phase will reset to 0 every time hardSync
crosses from non-positive to positive. (If hardSync == 0
, then there are no such transitions and the Phasor will run normally, disabling sync.)
Then phaseMod
is added to this. Note: When phase-modulating a SinOsc, the SinOsc expects phase in radians, 0.0 to 2pi. With this range, the spectral effect is the same between frequency modulation and phase modulation, for any modulation index: SinOsc.ar(0, Phasor.ar(0, freq * SampleDur.ir, 0, 2pi) + (phaseMod * modIndex))
should sound the same as SinOsc.ar(freq * (1 + (phaseMod * modIndex)))
. Because MultiWtOsc's internal phase is 0.0 to 1.0, the effect of the modulator will be 2pi times stronger than in SinOsc. MultiWtOsc does not scale the modulator in any way, so, for a compatible interpretation of the modulation index, you should scale the modulator down by 2pi: phaseMod * index * (1/2pi)
(written this way to avoid a division operator).
The squeeze
parameter applies phase distortion to this. squeeze > 0
means that the part of the wavetable at wtOffset
will be squeezed (and, halfway away from this will be stretched). squeeze < 0
means the opposite. (Note that wtOffset
is simply added after phase distortion -- so, it can be used for phase modulation also! There should be a difference in sound between modulating phase before phase distortion, vs after.)
Returns a single-channel wavetable-oscillator signal. Detuned oscillators are summed to mono.
freq |
Frequency in Hz. |
wtPos |
Wavetable position. It is up to you to know how many wavetables were provided in the source. |
squeeze |
A phase-distortion factor. 0 is no distortion. |
wtOffset |
An offset, 0-1, added to the distorted phase. This determines the position in the wavetable that is squeezed or stretched. Rapid modulation is likely to affect pitch. |
bufnum |
The buffer, containing a file produced by WavetablePrep. |
wtSize |
The number of samples for each waveform. |
numTables |
The number of frequency maps. |
ratio |
The ratio between frequency maps (2 = one octave). |
numOscs |
The number of oscillators to produce. This must be a fixed integer (cannot be modulated). |
detune |
The maximum frequency ratio for detuning. 1 = no detuning. |
interpolation |
Interpolation method, passed internally to BufRd. 1 means no interpolation, 2 is linear, 4 is cubic. |
hardSync |
Optional. An audio-rate signal serving as a hard sync source. The default, 0, disables sync. See examples below. |
phaseMod |
Optional. An audio-rate signal to modulate the phase prior to phase distortion. To handle modulation index, you should multiply the modulator by |
Similar to ar
, but it returns the detuned oscillators as an array, so that you can mix them according to any strategy you like (e.g. Splay).