envlpx
Prev | Orchestra Opcodes and Operators | Next

## envlpx

envlpx — Applies an envelope consisting of 3 segments.

## Description

envlpx -- apply an envelope consisting of 3 segments:

1. stored function rise shape

2. modified exponential pseudo steady state

3. exponential decay

## Syntax

    ares envlpx xamp, irise, idur, idec, ifn, iatss, iatdec [, ixmod]

    kres envlpx kamp, irise, idur, idec, ifn, iatss, iatdec [, ixmod]

## Initialization

irise -- rise time in seconds. A zero or negative value signifies no rise modification.

idur -- overall duration in seconds. A zero or negative value will cause initialization to be skipped.

idec -- decay time in seconds. Zero means no decay. An idec > idur will cause a truncated decay.

ifn -- function table number of stored rise shape with extended guard point.

iatss -- attenuation factor, by which the last value of the envlpx rise is modified during the note's pseudo steady state. A factor greater than 1 causes an exponential growth and a factor less than 1 creates an exponential decay. A factor of 1 will maintain a true steady state at the last rise value. Note that this attenuation is not by fixed rate (as in a piano), but is sensitive to a note's duration. However, if iatss is negative (or if steady state < 4 k-periods) a fixed attenuation rate of abs(iatss) per second will be used. 0 is illegal.

iatdec -- attenuation factor by which the closing steady state value is reduced exponentially over the decay period. This value must be positive and is normally of the order of .01. A large or excessively small value is apt to produce a cutoff which is audible. A zero or negative value is illegal.

ixmod (optional, between +- .9 or so) -- exponential curve modifier, influencing the steepness of the exponential trajectory during the steady state. Values less than zero will cause an accelerated growth or decay towards the target (e.g. subito piano). Values greater than zero will cause a retarded growth or decay. The default value is zero (unmodified exponential).

## Performance

kamp, xamp -- input amplitude signal.

Rise modifications are applied for the first irise seconds, and decay from time idur - idec. If these periods are separated in time there will be a steady state during which amp will be modified by the first exponential pattern. If rise and decay periods overlap then both modifications will be in effect for that time. If the overall duration idur is exceeded in performance, the final decay will continue on in the same direction, tending asymptotically to zero.

## Examples

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

Example 207. Example of the envlpx 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 envlpx.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

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

    instr 1

    irise = 0.2
    idec  = 0.5
    idur  = p3 - idec

    ifn = 1
    iatss = p5
    iatdec = 0.01

    kenv envlpx .6, irise, idur, idec, ifn, iatss, iatdec
    kcps = cpspch(p4)
    asig vco2 kenv, kcps
    ;apply envlpx to the filter cut-off frequency
    asig moogvcf asig, kcps + (kenv * 8 * kcps) , .5 ;the higher the pitch, the higher the filter cut-off frequency
         outs asig, asig

    endin
    </CsInstruments>
    <CsScore>
    ; a linear rising envelope
    f 1 0 129 -7 0 128 1

    i 1 0 2 7.00 .1
    i 1 + 2 7.02  1
    i 1 + 2 7.03  2
    i 1 + 2 7.05  3
    e
    </CsScore>
    </CsoundSynthesizer>

## See Also

envlpxr, linen, linenr

## Credits

Thanks goes to Luis Jure for pointing out a mistake with iatss.

Prev | Up | Next
endop | Home | envlpxr