The envelope generated is the range 0 to 1 and may need to be scaled further, depending on the amplitude required. If using 0dbfs = 1, scaling down will probably be required since playing more than one note might result in clipping. If not using 0dbfs, scaling to a large amplitude (e.g. 32000) might be required.
The envelope may be described as:
Picture of an ADSR envelope.
The length of the sustain is calculated from the length of the note. This means adsr is not suitable for use with MIDI events. The opcode madsr uses the linsegr mechanism, and so can be used in MIDI applications.
adsr is new in Csound version 3.49.
Examples
Here is an example of the adsr opcode. It uses the file adsr.csd.
<CsoundSynthesizer><CsOptions>; Select audio/midi flags here according to platform-odac ;;;RT audio out;-iadc ;;;uncomment -iadc if RT audio input is needed too; For Non-realtime ouput leave only the line below:; -o adsr.wav -W ;;; for file output any platform</CsOptions><CsInstruments>sr=44100ksmps=32nchnls=20dbfs=1instr1iatt=p5idec=p6islev=p7irel=p8kenvadsriatt,idec,islev,irelkcps=cpspch(p4);frequencyasigvco2kenv*0.8,kcpsoutsasig,asigendin</CsInstruments><CsScore>i1027.00.00011.5.001; short attacki1327.021.5.5.001; long attacki1626.09.00011.5.7; long releasee</CsScore></CsoundSynthesizer>
Here is an example for the adsr-group, comparing the different adsr opcodes. It uses the file adsr-group.csd.
<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 adsr-group.wav -W ;;; for file output any platform</CsOptions><CsInstruments>; by Menno Knevel - 2021sr=44100ksmps=32nchnls=20dbfs=1; both amplitude and filter use same ADSR curves instr1kenvadsr.01,.5,.5,p4; linear envelope asigvco2kenv,110; A+D+S+R = p3 asigrezzyasig,500+(kenv*1000),10; same curve but scaled outsasig,asigendininstr2; midi behavior kenvmadsr.01,.5,.5,p4; linear envelopeasigvco2kenv,110; A+D+S = p3, then go into Release stage asigrezzyasig,500+(kenv*1000),10; same curve but scaled outsasig,asigendininstr3kenvxadsr.01,.5,.5,p4; exponential envelopeasigvco2kenv,110; A+D+S+R = p3 asigrezzyasig,500+(kenv*1000),10; same curve but scaled outsasig,asigendininstr4; midi behavior kenvmxadsr.01,.5,.5,p4; exponential envelopeasigvco2kenv,110; A+D+S = p3, then go into Release stage asigrezzyasig,500+(kenv*1000),10; same curve but scaled outsasig,asigendin</CsInstruments><CsScore>si112.01; same notes for everyone!i15..5i19.1.5si212.01i25..5i29.1.5si312.01i35..5i39.1.5si412.01i45..5i49.1.5e</CsScore></CsoundSynthesizer>