oscils — A simple, fast sine oscillator


Simple, fast sine oscillator, that uses only one multiply, and two add operations to generate one sample of output, and does not require a function table.


ares oscils iamp, icps, iphs [, iflg]


iamp -- output amplitude.

icps -- frequency in Hz (may be zero or negative, however the absolute value must be less than sr/2).

iphs -- start phase between 0 and 1.

iflg -- sum of the following values:

  • 2: use double precision even if Csound was compiled to use floats. This improves quality (especially in the case of long performance time), but may be up to twice as slow.

  • 1: skip initialization.


ares -- audio output


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

Example 709. Example of the oscils opcode.

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

; 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 oscils.wav -W ;;; for file output any platform

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

instr 1

iflg = p4
asig oscils .7, 220, 0, iflg
     outs asig, asig


i 1 0 2 0
i 1 3 2 2	;double precision

See also

Basic Oscillators


Author: Istvan Varga
January 2002

New in version 4.18