envlpxr
Prev | Orchestra Opcodes and Operators | Next

## envlpxr

envlpxr — The envlpx opcode with a final release segment.

## Description

envlpxr is the same as envlpx except that the final segment is entered only on sensing a MIDI note release. The note is then extended by the decay time.

## Syntax

    ares envlpxr xamp, irise, idec, ifn, iatss, iatdec [, ixmod] [,irind]

    kres envlpxr kamp, irise, idec, ifn, iatss, iatdec [, ixmod] [,irind]

## Initialization

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

idec -- decay time in seconds. Zero means no decay.

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

iatss -- attenuation factor, by which the last value of the envlpxr 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).

irind (optional) -- independence flag. If left zero, the release time (idec) will influence the extended life of the current note following a note-off. If non-zero, the idec time is quite independent of the note extension (see below). The default value is 0.

## Performance

kamp, xamp -- input amplitude signal.

envlpxr is an example of the special Csound “r” units that contain a note-off sensor and release time extender. When each senses a score event termination or a MIDI noteoff, it will immediately extend the performance time of the current instrument by idec seconds unless it is made independent by irind. Then it will begin a decay from wherever it was at the time.

You can use other pre-made envelopes which start a release segment upon receiving a note off message, like linsegr and expsegr, or you can construct more complex envelopes using xtratim and release. Note that you don't need to use xtratim if you are using envlpxr, since the time is extended automatically.

These “r” units can also be modified by MIDI noteoff velocities (see veloffs). If the irind flag is on (non-zero), the overall performance time is unaffected by note-off and veloff data.

Multiple “r” units. When two or more “r” units occur in the same instrument it is usual to have only one of them influence the overall note duration. This is normally the master amplitude unit. Other units controlling, say, filter motion can still be sensitive to note-off commands while not affecting the duration by making them independent (irind non-zero). Depending on their own idec (release time) values, independent “r” units may or may not reach their final destinations before the instrument terminates. If they do, they will simply hold their target values until termination. If two or more “r” units are simultaneously master, note extension is by the greatest idec.

## Examples

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

Example 224. Example of the envlpxr opcode.

    <CsoundSynthesizer>
    <CsOptions>
    ; Select audio/midi flags here according to platform
    -odac  -+rtmidi=virtual -M0   ;;;realtime audio out and realtime midi in
    ;-iadc    ;;;uncomment -iadc if realtime audio input is needed too
    ; For Non-realtime ouput leave only the line below:
    ; -o envlpxr.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

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

    instr 1

    icps	cpsmidi
    iamp	ampmidi	.5

    kenv	envlpxr	iamp, 0.2, 1, 1, 1, 0.01
    asig	pluck	kenv, icps, 200, 2, 1
    	outs	asig, asig

    endin
    </CsInstruments>
    <CsScore>
    f 1 0 129 -7 0 128 1
    f 2 0 4096 10 1

    f0 30	;runs 30 seconds
    e
    </CsScore>
    </CsoundSynthesizer>

## See Also

envlpx, linen, linenr

## Credits

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

Prev | Up | Next
envlpx | Home | ephasor