vco
Prev | Orchestra Opcodes and Operators | Next

## vco

vco — Implementation of a band limited, analog modeled oscillator.

## Description

Implementation of a band limited, analog modeled oscillator, based on integration of band limited impulses. vco can be used to simulate a variety of analog wave forms.

## Syntax

    ares vco xamp, xcps, iwave, kpw [, ifn] [, imaxd] [, ileak] [, inyx] \
          [, iphs] [, iskip]

## Initialization

iwave -- determines the waveform:

- iwave = 1 - sawtooth

- iwave = 2 - square/PWM

- iwave = 3 - triangle/saw/ramp

ifn (optional, default = 1) -- Must point to a valid table which contains a sine wave. Csound will report an error if this parameter is not set and table 1 does not exist.

imaxd (optional, default = 1) -- is the maximum delay time. A time of 1/ifqc may be required for the PWM and triangle waveform. To bend the pitch down this value must be as large as 1/(minimum frequency).

ileak (optional, default = 0) -- if ileak is between zero and one (0 < ileak < 1) then ileak is used as the leaky integrator value. Otherwise a leaky integrator value of .999 is used for the saw and square waves and .995 is used for the triangle wave. This can be used to “flatten” the square wave or “straighten” the saw wave at low frequencies by setting ileak to .99999 or a similar value. This should give a hollower sounding square wave.

inyx (optional, default = .5) -- this is used to determine the number of harmonics in the band limited pulse. All overtones up to sr * inyx will be used. The default gives sr * .5 (sr/2). For sr/4 use inyx = .25. This can generate a “fatter” sound in some cases.

iphs (optional, default = 0) -- this is a phase value. There is an artifact (bug-like feature) in vco which occurs during the first half cycle of the square wave which causes the waveform to be greater in magnitude than all others. The value of iphs has an effect on this artifact. In particular setting iphs to .5 will cause the first half cycle of the square wave to resemble a small triangle wave. This may be more desirable than the large wave artifact which is the current default.

iskip (optional, default = 0) -- if non zero skip the initialisation of the filter. (New in Csound version 4.23f13 and 5.0)

## Performance

kpw -- determines either the pulse width (if iwave is 2) or the saw/ramp character (if iwave is 3) The value of kpw should be greater than 0 and less than 1. A value of 0.5 will generate either a square wave (if iwave is 2) or a triangle wave (if iwave is 3).

xamp -- determines the amplitude

xcps -- is the frequency of the wave in cycles per second.

## Examples

Here is an example of the vco opcode. It uses the file vco.csd.

Example 1167. Example of the vco opcode.

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

    <CsoundSynthesizer>
    <CsOptions>
    ; Select audio/midi flags here according to platform
    -odac    ;;;realtime audio out
    ;-iadc    ;;;uncomment -iadc if realtime audio input is needed too
    ; For Non-realtime ouput leave only the line below:
    ;-o vco.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

    sr = 44100
    ksmps = 32
    nchnls = 2
    0dbfs  = 1

    instr 1

    kamp  = .4
    kcps  = cpspch(p4)
    iwave = p5                              ; Select the wave form
    kpw init 0.5                            ; Set the pulse-width/saw-ramp character.
    ifn = 1
    asig vco kamp, kcps, iwave, kpw, ifn
    outs asig, asig
    endin

    </CsInstruments>
    <CsScore>
    f 1 0 65536 10 1    ; a sine wave.

    ;           pitch-class waveform
    i 1 00 02       05.00       1   ; saw
    i 1 02 02       05.00       2   ; square
    i 1 04 02       05.00       3   ; tri/saw/ramp

    i 1 06 02       07.00       1
    i 1 08 02       07.00       2
    i 1 10 02       07.00       3

    i 1 12 02       09.00       1
    i 1 14 02       09.00       2
    i 1 16 02       09.00       3

    i 1 18 02       11.00       1
    i 1 20 02       11.00       2
    i 1 22 02       11.00       3
    e
    </CsScore>
    </CsoundSynthesizer>

## See Also

Dynamic Spectrum Oscillators

## Credits

Author: Hans Mikelson
December 1998

New in Csound version 3.50

November 2002. Corrected the documentation for the kpw parameter thanks to Luis Jure and Hans Mikelson.

Prev | Up | Next
vclpf | Home | vco2