Use Non-Frames Version Previous Page Next Page
Signal Generators: Phasors

phasorbnk

  kr      phasorbnk  kcps, kndx, icnt[, iphs]
  ar      phasorbnk  xcps, kndx, icnt[, iphs]

Description

Produce an arbitrary number of normalized moving phase values, accessable by an index.

Initialization

icnt – maximum number of phasors to be used.

iphs – initial phase, expressed as a fraction of a cycle (0 to 1). If -1 initialization is skipped. If iphas>1 each phasor will be initialized with a random value.

Performance

kndx – index value to access individual phasors

For each independent phasor, an internal phase is successively accumulated in accordance with the kcps or xcps frequency to produce a moving phase value, normalized to lie in the range 0 <= phs < 1. Each individual phasor is accessed by index kndx.

This phasor bank can be used inside a k-rate loop to generate multiple independent voices, or together with the adsynt opcode to change parameters in the tables used by adsynt.

Example

Generate multiple voices with independent partials. This example is better with adsynt. See also the example under adsynt, for k-rate use of phasorbnk.

  giwave  ftgen     1, 0, 1024, 10, 1       ; generate a sinewave table

          instr 1
  icnt    =         10                      ; generate 10 voices
  asum    =         0                       ; empty output buffer
  kindex  =         0                       ; reset loop index

loop:                                       ; loop executed every k-cycle

  kcps    =         (kindex+1)*100 + 30     ; non-harmonic partials
  aphas   phasorbnk kcps, kindex, icnt      ; get phase for each voice
  asig    table     aphas, giwave, 1        ; and read wave from table
  asum    =         asum + asig             ; accumulate output

  kindex  =         kindex + 1
  if (kindex < icnt) kgoto loop             ; do loop

          out       asum*3000
          endin

Author

Peter Neubäcker
Munich, Germany
August, 1999
New in Csound version 3.58


Use Non-Frames Version Previous Page Next Page
Signal Generators: Phasors