trigphasor
Prev | Orchestra Opcodes and Operators | Next

## trigphasor

trigphasor — A resettable linear ramp between two levels

## Description

Plugin opcode in scugens.

A resettable linear ramp between two levels (port of Supercollider's Phasor). trigphasor is a linear ramp between kstart and kend values. When its trigger input crosses from non-positive to positive, trigphasor's output will jump to its reset position (or to kstartif no reset value was given). Upon reaching the end of its ramp, trigphasor will wrap back to its start.

## Syntax

    aindex trigphasor xtrig, xrate, kstart, kend [, kresetPos]

    kindex trigphasor xtrig, xrate, kstart, kend [, kresetPos]

## Performance

xtrig -- trigger, whenever this crosses from non-positive to possitive

xrate -- value added at each evaluation. When running at k-rate, this value is added at each cycle; at a-rate, this value is added per sample (ksmps per cycle).

kstart, kend -- start and end values of the phasor

xtrig -- trigger, whenever this crosses from non-positive to possitive

kresetPos -- if specified, this value will be used to jump to after a trigger. Otherwise, a trigger will set the position back to kstart

To generate a phasing signal from kstart to kend with a given period (duration of each cycle), the calculation would be:

rate = (end - start) / (period * sr)

In the case of phasor being used at k-rate, use kr instead of sr in the above formula.

## Examples

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

Example 907. Example of the trigphasor opcode.

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

    <CsoundSynthesizer>
    <CsOptions>
    -odac
    </CsOptions>
    <CsInstruments>

    sr = 44100
    ksmps = 64
    nchnls = 2
    0dbfs = 1.0

    gisnd ftgen 0, 0, 0, -1, "finneganswake1.flac", 0, 0, 0

    instr 1
      ; use trigphasor to read a soundfile
      inumsamps = nsamp(gisnd)
      irate = 1  ; play at original speed
      ktrig metro 0.25
      aphase trigphasor ktrig, irate, 0, inumsamps
      asig table3 aphase, gisnd
      asig *= linsegr:a(0, 0.01, 1, 0.01, 0)
      outch 1, asig
    endin

    </CsInstruments>
    <CsScore>
    i 1 0 20
    f0 3600

    </CsScore>
    </CsoundSynthesizer>

## See also

phasor

## Credits

By: Eduardo Moguillansky 2017

Prev | Up | Next
sc_phasor | Home | sc_trig