Debian Codegraph @

opcodes/madsr.xml

raw symbols SCIP
1
2 <refentry id="madsr">
3 <indexterm id="IndexMadsr"><primary>madsr</primary></indexterm>
4 <refentryinfo><title>Signal Generators:Envelope Generators</title></refentryinfo>
5 <refmeta>
6 <refentrytitle>madsr</refentrytitle>
7 </refmeta>
8
9 <refnamediv>
10 <refname>madsr</refname>
11 <refpurpose>
12 Calculates the classical ADSR envelope using the <emphasis>linsegr</emphasis> mechanism.
13 </refpurpose>
14 </refnamediv>
15
16 <refsect1>
17 <title>Description</title>
18 <para>
19 Calculates the classical ADSR envelope using the <link linkend="linsegr"><citetitle>linsegr</citetitle></link> mechanism.
20 </para>
21 </refsect1>
22
23 <refsect1>
24 <title>Syntax</title>
25 <synopsis>ares <command>madsr</command> iatt, idec, islev, irel [, idel] [, ireltim]</synopsis>
26
27 <synopsis>kres <command>madsr</command> iatt, idec, islev, irel [, idel] [, ireltim]</synopsis>
28 </refsect1>
29
30 <refsect1>
31 <title>Initialization</title>
32 <para>
33 <emphasis>iatt</emphasis> -- duration of attack phase
34 </para>
35
36 <para>
37 <emphasis>idec</emphasis> -- duration of decay
38 </para>
39
40 <para>
41 <emphasis>islev</emphasis> -- level for sustain phase
42 </para>
43
44 <para>
45 <emphasis>irel</emphasis> -- duration of release phase.
46 </para>
47
48 <para>
49 <emphasis>idel</emphasis> -- period of zero before the envelope starts
50 </para>
51
52 <para>
53 <emphasis>ireltim</emphasis> (optional, default=-1) -- Control release time after receiving a MIDI noteoff event. If less than zero, the longest release time given in the current instrument is used. If zero or more, the given value will be used for release time. Its default value is -1. (New in Csound 3.59 - not yet properly tested)
54 </para>
55
56 <para>
57 Please note that the release time was restricted to 32767/<link
58 linkend="kr"><citetitle>kr</citetitle></link> seconds in
59 versions prior to 5.00; since then it has been
60 (2<superscript>31</superscript>-1)/kr.
61 </para>
62 </refsect1>
63
64 <refsect1>
65 <title>Performance</title>
66 <para>
67 The envelope is in the range 0 to 1 and may need to be scaled further. The envelope may be described as:
68
69 <mediaobject>
70 <imageobject>
71 <imagedata fileref="images/adsr.png" format="PNG"/>
72 </imageobject>
73
74 <textobject>
75 <phrase>Picture of an ADSR envelope.</phrase>
76 </textobject>
77 <caption>
78 <para>Picture of an ADSR envelope.</para>
79 </caption>
80 </mediaobject>
81 </para>
82
83 <para>
84 The length of the sustain is calculated from the length of the note. This means <link linkend="adsr"><citetitle>adsr</citetitle></link> is not suitable for use with MIDI events. The opcode <emphasis>madsr</emphasis> uses the <link linkend="linsegr"><citetitle>linsegr</citetitle></link> mechanism, and so can be used in MIDI applications.
85 </para>
86 <para>
87 You can use other pre-made envelopes which start a release
88 segment upon receiving a note off message, like <link
89 linkend="linsegr"><citetitle>linsegr</citetitle></link> and
90 <link linkend="expsegr"><citetitle>expsegr</citetitle></link>,
91 or you can construct more complex envelopes using <link
92 linkend="xtratim"><citetitle>xtratim</citetitle></link> and
93 <link
94 linkend="release"><citetitle>release</citetitle></link>. Note
95 that you do not need to use <link linkend="xtratim"><citetitle>xtratim</citetitle></link> if you are using <emphasis>madsr</emphasis>, since the time is extended automatically.
96 </para>
97 <note>
98 <para> Times for <emphasis>iatt</emphasis>, <emphasis>idec</emphasis> and <emphasis>irel</emphasis> cannot be 0. If 0 is used, no envelope is generated. Use a very small value like 0.0001 if you need an instantaneous attack, decay or release.
99 </para>
100 </note>
101 </refsect1>
102
103 <refsect1>
104 <title>Examples</title>
105 <para>
106 Here is an example of the madsr opcode. It uses the file <ulink url="examples/madsr.csd"><citetitle>madsr.csd</citetitle></ulink>.
107
108 <example>
109 <title>Example of the madsr opcode.</title>
110 <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>
111 <xi:include href="examples-xml/madsr.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
112 </example>
113
114 Here is another example of the madsr opcode, using midi input. It uses the file <ulink url="examples/madsr-2.csd"><citetitle>madsr-2.csd</citetitle></ulink>.
115
116 <example>
117 <title>second example of the madsr opcode.</title>
118 <xi:include href="examples-xml/madsr-2.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
119 </example>
120 </para>
121 <para>
122 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>.
123 <example>
124 <title>Example of the adsr group.</title>
125 <xi:include href="examples-xml/adsr-group.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
126 </example>
127 </para>
128 </refsect1>
129
130 <refsect1>
131 <title>See Also</title>
132 <para>
133 <link linkend="SiggenEnvelope"><citetitle>Envelope Generators</citetitle></link>
134 </para>
135 </refsect1>
136
137 <refsect1>
138 <title>Credits</title>
139 <para>Author: &namejohn;</para>
140 <para>November 2002. Thanks to &namerasmus;, added documentation for the <emphasis>ireltim</emphasis> parameter.</para>
141 <para>December 2002. Thanks to Iain McCurdy, added an example.</para>
142 <para>December 2002. Thanks to &nameistvan;, added documentation about the maximum release time.</para>
143 <para>New in Csound version 3.49.</para>
144 </refsect1>
145 </refentry>