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 297. 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
; Audio out   Audio in    No messages
-odac           -iadc     -d     ;;;RT audio I/O
; For Non-realtime ouput leave only the line below:
; -o oscils.wav -W ;;; for file output any platform

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

; Instrument #1 - a fast sine oscillator.
instr 1
  iamp = 10000
  icps = 440
  iphs = 0

  a1 oscils iamp, icps, iphs
  out a1


; Play Instrument #1 for 2 seconds.
i 1 0 2



Author: Istvan Varga
January 2002

Example written by Kevin Conder.

New in version 4.18