envlpxr — The envlpx opcode with a final release segment.
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.
ares envlpxr xamp, irise, idec, ifn, iatss, iatdec [, ixmod] [,irind]
kres envlpxr kamp, irise, idec, ifn, iatss, iatdec [, ixmod] [,irind]
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 determining the exponential change in value over time during the pseudo steady state period between the end of the rise and the beginning of the decay (at the note's release). 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; 0 is illegal. The value will change by abs(iatss) per second.
iatdec -- the ratio of the value at the end of the decay period to the value at its beginning (when the note is released). It 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.
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 do not need to use xtratim if you are using envlpxr, since the time is extended automatically.
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.
Here is an example of the envlpxr opcode. It uses the file envlpxr.csd.
Example 267. 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>