pvsosc

pvsosc — PVS-based oscillator simulator.

Description

Generates periodic signal spectra in AMP-FREQ format, with the option of four wave types:

  1. sawtooth-like (harmonic weight 1/n, where n is partial number)
  2. square-like (similar to 1., but only odd partials)
  3. pulse (all harmonics with same weight)
  4. cosine

Complex waveforms (ie. all types except cosine) contain all harmonics up to the Nyquist. This makes pvsosc an option for generation of band-limited periodic waves. In addition, types can be changed using a k-rate variable.

Syntax

fsig pvsosc kamp, kfreq, ktype, isize [,ioverlap] [, iwinsize] [, iwintype] [, iformat]

Initialisation

fsig -- output pv stream set to zero.

isize -- size of analysis frame and window.

ioverlap -- (Optional) size of overlap, defaults to isize/4.

iwinsize -- (Optional) window size, defaults to isize.

iwintype -- (Optional) window type, defaults to Hanning. The choices are currently:

  • 0 = Hamming window

  • 1 = von Hann window

iformat -- (Optional) data format, defaults to 0 which produces AMP:FREQ data. That is currently the only option.

Performance

kamp -- signal amplitude. Note that the actual signal amplitude can, depending on wave type and frequency, vary slightly above or below this value. Generally the amplitude will tend to exceed kamp on higher frequencies (> 1000 Hz) and be reduced on lower ones. Also due to the overlap-add process, when resynthesing with pvsynth, frequency glides will cause the output amplitude to fluctuate above and below kamp.

kfreq -- fundamental frequency in Hz.

ktype -- wave type: 1. sawtooh-like, 2.square-like, 3.pulse and any other value for cosine.

Examples

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

Example 368. Example of the pvsosc 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 pvsosc.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

sr = 44100
kr = 4410
ksmps = 10
nchnls = 1

instr 1
; a band-limited sawtooth-wave oscillator		
fsig  pvsosc   10000, 440, 1, 1024 ; generate wave spectral signal
asig pvsynth fsig                       ; resynthesise it
out asig
endin

instr 2
; a band-limited square-wave oscillator		
fsig  pvsosc   10000, 440, 2, 1024 ; generate wave spectral signal
asig pvsynth fsig                       ; resynthesise it
out asig
endin


instr 3
; a pulse oscillator		
fsig  pvsosc   10000, 440, 3, 1024 ; generate wave spectral signal
asig pvsynth fsig                       ; resynthesise it
out asig
endin

instr 4
; a cosine-wave oscillator		
fsig  pvsosc   10000, 440, 4, 1024 ; generate wave spectral signal
asig pvsynth fsig                       ; resynthesise it
out asig
endin

</CsInstruments>
<CsScore>

i 1 0 1
i 2 2 1
i 3 4 1
i 4 6 1

e

</CsScore>
</CsoundSynthesizer>


Credits

Author: Victor Lazzarini;
August 2006