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) -- should be the table number of a of a stored sine wave. 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 1149. 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
    ; Audio out   Audio in
    -odac           -iadc    ;;;RT audio I/O
    ; For Non-realtime ouput leave only the line below:
    ; -o vco.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

    ; Initialize the global variables.
    sr = 44100
    kr = 44100
    ksmps = 1
    nchnls = 1

    ; Instrument #1
    instr 1
      ; Set the amplitude.
      kamp = p4

      ; Set the frequency.
      kcps = cpspch(p5)

      ; Select the wave form.
      iwave = p6

      ; Set the pulse-width/saw-ramp character.
      kpw init 0.5

      ; Use Table #1.
      ifn = 1

      ; Generate the waveform.
      asig vco kamp, kcps, iwave, kpw, ifn

      ; Output and amplification.
      out asig
    endin

    </CsInstruments>
    <CsScore>

    ; Table #1, a sine wave.
    f 1 0 65536 10 1

    ; Define the score.
    ; p4 = raw amplitude (0-32767)
    ; p5 = frequency, in pitch-class notation.
    ; p6 = the waveform (1=Saw, 2=Square/PWM, 3=Tri/Saw-Ramp-Mod)
    i 1 00 02 20000 05.00 1
    i 1 02 02 20000 05.00 2
    i 1 04 02 20000 05.00 3

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

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

    i 1 18 02 20000 11.00 1
    i 1 20 02 20000 11.00 2
    i 1 22 02 20000 11.00 3
    e

    </CsScore>
    </CsoundSynthesizer>

## See Also

vco2

## 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