vco2
Implementation of a band-limited oscillator using pre-calculated tables.
vco2 is similar to vco. But the implementation uses pre-calculated tables of band-limited waveforms (see also GEN30) rather than integrating impulses. This opcode can be faster than vco (especially if a low control-rate is used) and also allows better sound quality. Additionally, there are more waveforms and oscillator phase can be modulated at k-rate. The disadvantage is increased memory usage. For more details about vco2 tables, see also vco2init and vco2ft.
Syntax
Initialization
imode (optional, default=0) -- a sum of values representing the waveform and its control values.
One may use any of the following values for imode:
- 16: enable k-rate phase control (if set, kphs is a required k-rate parameter that allows phase modulation)
- 1: skip initialization
One may use exactly one of these imode values to select the waveform to be generated:
- 14: user defined waveform -1 (requires using the vco2init opcode)
- 12: triangle (no ramp, faster)
- 10: square wave (no PWM, faster)
- 8: 4 * x * (1 - x) (i.e. integrated sawtooth)
- 6: pulse (not normalized)
- 4: sawtooth / triangle / ramp
- 2: square / PWM
- 0: sawtooth
The default value for imode is zero, which means a sawtooth wave with no k-rate phase control.
inyx (optional, default=0.5) -- bandwidth of the generated waveform, as percentage (0 to 1) of the sample rate. The expected range is 0 to 0.5 (i.e. up to sr/2), other values are limited to the allowed range.
Setting inyx to 0.25 (sr/4), or 0.3333 (sr/3) can produce a “fatter” sound in some cases, although it is more likely to reduce quality.
Performance
ares -- the output audio signal.
kamp -- amplitude scale. In the case of a imode waveform value of 6 (a pulse waveform), the actual output level can be a lot higher than this value.
kcps -- frequency in Hz (should be in the range -sr/2 to sr/2).
kpw (optional) -- the pulse width of the square wave (imode waveform=2) or the ramp characteristics of the triangle wave (imode waveform=4). It is required only by these waveforms and ignored in all other cases. The expected range is 0 to 1, any other value is wrapped to the allowed range.
Warning
kpw must not be an exact integer value (e.g. 0 or 1) if a sawtooth / triangle / ramp (imode waveform=4) is generated. In this case, the recommended range is about 0.01 to 0.99. There is no such limitation for a square/PWM waveform.
kphs (optional) -- oscillator phase (depending on imode, this can be either an optional i-rate parameter that defaults to zero or required k-rate). Similarly to kpw, the expected range is 0 to 1.
Note
When a low control-rate is used, pulse width (kpw) and phase (kphs) modulation is internally converted to frequency modulation. This allows for faster processing and reduced artifacts. But in the case of very long notes and continuous fast changes in kpw or kphs, the phase may drift away from the requested value. In most cases, the phase error is at most 0.037 per hour (assuming a sample rate of 44100 Hz).
This is a problem mainly in the case of pulse width (kpw), where it may result in various artifacts. While future releases of vco2 may fix such errors, the following work-arounds may also be of some help:
- Use kpw values only in the range 0.05 to 0.95. (There are more artifacts around integer values)
- Try to avoid modulating kpw by asymmetrical waveforms like a sawtooth wave. Relatively slow (<= 20 Hz) symmetrical modulation (e.g. sine or triangle), random splines (also slow), or a fixed pulse width is a lot less likely to cause synchronization problems.
- In some cases, adding random jitter (for example: random splines with an amplitude of about 0.01) to kpw may also fix the problem.
Examples
Here is an example of the vco2 opcode. It uses the file vco2.csd.
See Also
Credits
Author: Istvan Varga
New in version 4.22