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

ar vco xamp, xcps, iwave, kpw [, ifn] [, imaxd] [, ileak] [, inyx] [, iphs]

Initialization

iwave -- determines the waveform:

ifn (optional, default = 1) -- should be the table number of a of a stored sine wave.

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.

Performance

kpw -- determines the pulse width when iwave is set to 2, and determines Saw/Ramp character when iwave is set to 3. The value of kpw should be between 0 and 1. A value of .5 will generate a square wave or a triangle wave depending on iwave.

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 files vco.orc and vco.sco.

Example 1. Example of the vco opcode.

/* vco.orc */
; 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
/* vco.orc */
        
/* vco.sco */
; 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
/* vco.sco */
        

Credits

Author: Hans Mikelson

December, 1998 (New in Csound version 3.50)