| 1 | |
| 2 | <refentry id="adsr"> |
| 3 | <indexterm id="IndexAdsr"><primary>adsr</primary></indexterm> |
| 4 | <refentryinfo><title>Signal Generators:Envelope Generators</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>adsr</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | |
| 10 | |
| 11 | <refnamediv> |
| 12 | <refname>adsr</refname> |
| 13 | <refpurpose> |
| 14 | Calculates the classical ADSR envelope using linear segments. |
| 15 | </refpurpose> |
| 16 | </refnamediv> |
| 17 | |
| 18 | <refsect1> |
| 19 | <title>Description</title> |
| 20 | <para> |
| 21 | Calculates the classical ADSR envelope using linear segments. |
| 22 | </para> |
| 23 | </refsect1> |
| 24 | |
| 25 | <refsect1> |
| 26 | <title>Syntax</title> |
| 27 | <synopsis>ares <command>adsr</command> iatt, idec, islev, irel [, idel]</synopsis> |
| 28 | |
| 29 | <synopsis>kres <command>adsr</command> iatt, idec, islev, irel [, idel]</synopsis> |
| 30 | </refsect1> |
| 31 | |
| 32 | <refsect1> |
| 33 | <title>Initialization</title> |
| 34 | <para> |
| 35 | <emphasis>iatt</emphasis> -- duration of attack phase |
| 36 | </para> |
| 37 | |
| 38 | <para> |
| 39 | <emphasis>idec</emphasis> -- duration of decay |
| 40 | </para> |
| 41 | |
| 42 | <para> |
| 43 | <emphasis>islev</emphasis> -- level for sustain phase |
| 44 | </para> |
| 45 | |
| 46 | <para> |
| 47 | <emphasis>irel</emphasis> -- duration of release phase |
| 48 | </para> |
| 49 | |
| 50 | <para> |
| 51 | <emphasis>idel</emphasis> -- period of zero before the envelope starts |
| 52 | </para> |
| 53 | </refsect1> |
| 54 | |
| 55 | <refsect1> |
| 56 | <title>Performance</title> |
| 57 | <para> |
| 58 | The envelope generated is the range 0 to 1 and may need to be scaled |
| 59 | further, depending on the amplitude required. If using |
| 60 | <link linkend="Zerodbfs"><citetitle>0dbfs</citetitle></link> = 1, scaling down |
| 61 | will probably be required since playing more than one note might result in clipping. |
| 62 | If not using <link linkend="Zerodbfs"><citetitle>0dbfs</citetitle></link>, scaling |
| 63 | to a large amplitude (e.g. 32000) might be required. |
| 64 | </para> |
| 65 | <para> |
| 66 | The envelope may be described as: |
| 67 | <mediaobject> |
| 68 | <imageobject> |
| 69 | <imagedata fileref="images/adsr.png" format="PNG"/> |
| 70 | </imageobject> |
| 71 | |
| 72 | <textobject> |
| 73 | <phrase>Picture of an ADSR envelope.</phrase> |
| 74 | </textobject> |
| 75 | |
| 76 | <caption> |
| 77 | <para>Picture of an ADSR envelope.</para> |
| 78 | </caption> |
| 79 | </mediaobject> |
| 80 | </para> |
| 81 | |
| 82 | <para> |
| 83 | The length of the sustain is calculated from the length of the note. This means <emphasis>adsr</emphasis> is not suitable for use with MIDI events. The opcode <link linkend="madsr"><citetitle>madsr</citetitle></link> uses the <link linkend="linsegr"><citetitle>linsegr</citetitle></link> mechanism, and so can be used in MIDI applications. |
| 84 | </para> |
| 85 | |
| 86 | <para> |
| 87 | <emphasis>adsr</emphasis> is new in Csound version 3.49. |
| 88 | </para> |
| 89 | </refsect1> |
| 90 | |
| 91 | <refsect1> |
| 92 | <title>Examples</title> |
| 93 | <para> |
| 94 | Here is an example of the adsr opcode. It uses the file <ulink url="examples/adsr.csd"><citetitle>adsr.csd</citetitle></ulink>. |
| 95 | |
| 96 | <example> |
| 97 | <title>Example of the adsr opcode.</title> |
| 98 | |
| 99 | |
| 100 | |
| 101 | <para>See the sections <link linkend="UsingRealTime"><citetitle>Real-time Audio</citetitle></link> and <link linkend="CommandFlags"><citetitle>Command Line Flags</citetitle></link> for more information on using command line flags.</para> |
| 102 | <xi:include href="examples-xml/adsr.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 103 | </example> |
| 104 | </para> |
| 105 | <para> |
| 106 | Here is an example for the adsr-group, comparing the different adsr opcodes. It uses the file <ulink url="examples/adsr-group.csd"><citetitle>adsr-group.csd</citetitle></ulink>. |
| 107 | <example> |
| 108 | <title>Example of the adsr group.</title> |
| 109 | <xi:include href="examples-xml/adsr-group.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 110 | </example> |
| 111 | </para> |
| 112 | </refsect1> |
| 113 | |
| 114 | <refsect1> |
| 115 | <title>See Also</title> |
| 116 | <para> |
| 117 | <link linkend="SiggenEnvelope"><citetitle>Envelope Generators</citetitle></link> |
| 118 | </para> |
| 119 | </refsect1> |
| 120 | |
| 121 | <refsect1> |
| 122 | <title>Credits</title> |
| 123 | <para>Author: &namejohn;</para> |
| 124 | <para>New in version 3.49</para> |
| 125 | </refsect1> |
| 126 | </refentry> |