oscils

oscils — A simple, fast sine oscillator

Description

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.

Syntax

ares oscils iamp, icps, iphs [, iflg]

Initialization

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.

Performance

ares -- audio output

Examples

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

Example 695. Example of the oscils 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
-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
</CsOptions>
<CsInstruments>

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

instr 1

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

endin
</CsInstruments>
<CsScore>

i 1 0 2 0
i 1 3 2 2	;double precision
e
</CsScore>
</CsoundSynthesizer>


See also

Basic Oscillators

Credits

Author: Istvan Varga
January 2002

New in version 4.18