poscil3
Prev | Orchestra Opcodes and Operators | Next

## poscil3

poscil3 — High precision oscillator with cubic interpolation.

## Description

High precision oscillator with cubic interpolation. poscil3 (precise oscillator) is the same as oscil3, but always employs floating-point table indexing, instead of integer math. It is only a bit slower than oscil3 when reading power-two size tables.

## Syntax

    ares poscil3 aamp, acps [, ifn, iphs]

    ares poscil3 aamp, kcps [, ifn, iphs]

    ares poscil3 kamp, acps [, ifn, iphs]

    ares poscil3 kamp, kcps [, ifn, iphs]

    ires poscil3 kamp, kcps [, ifn, iphs]

    kres poscil3 kamp, kcps [, ifn, iphs]

## Initialization

ifn -- (optional) function table number. This defaults to -1 which indicates a sinewave.

iphs (optional, default=0) -- initial phase (normalized table index 0-1). If a negative value is given initialisation of the phase is skipped.

## Performance

ares -- output signal

kamp, aamp -- the amplitude of the output signal.

kcps, acps -- the frequency of the output signal in cycles per second.

poscil3 works like poscil, but uses cubic interpolation.

## Examples

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

Example 780. Example of the poscil3 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 real audio input is needed too
    ; For Non-realtime ouput leave only the line below:
    ; -o poscil3.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

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

    giSine ftgen 0, 0, 2^10, 10, 1

    instr 1

    krnd  randomh 40, 440, 1	; produce random values
    ain   poscil3 .6, krnd, giSine
    kline line    1, p3, 0    	; straight line
    aL,aR pan2    ain, kline	; sent across image
          outs    aL, aR

    endin
    </CsInstruments>
    <CsScore>
    i1 0 10
    e
    </CsScore>
    </CsoundSynthesizer>

Here is another example of the poscil3 opcode, which uses a table filled from a sound file. It uses the file poscil3-file.csd .

Example 781. Another example of the poscil3 opcode.

    <CsoundSynthesizer>
    <CsOptions>
    ; 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 poscil3-file.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

    ; Example written by Joachim Heintz 07/2008

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

    ; non-normalized function table with a sample 1
    giFile	ftgen 1, 0, 0, -1, "fox.wav", 0, 0, 0

    ; Instrument #1 - uses poscil3 for playing samples from a function table
    instr 1
    kamp = p4
    kspeed	= p5
    ifn = 1
    iskip = p6
    kcps	= kspeed / (ftlen(ifn) / ftsr(ifn)); frequency of the oscillator
    iphs	= iskip / (ftlen(ifn) / ftsr(ifn)); calculates skiptime to phase values (0-1)

      a1 poscil3 kamp, kcps, ifn, iphs
      out a1
    endin
    </CsInstruments>
    <CsScore>
    i1 0 2.756 1 1 0
    i1 3 2.756 1 -1 0
    i1 6 1.378 1 .5 2.067
    e
    </CsScore>
    </CsoundSynthesizer>

## See also

Basic Oscillators

## Credits

Authors: John ffitch, Gabriel Maldonado
Italy

New in Csound version 3.52

variants with a-rate amplitude or frequency new in 5.16

Function table optional in Csound version 6.00

Skip of initialisation new in version 6.06

Prev | Up | Next
portk | Home | poscil