| 1 | |
| 2 | <refentry id="dollar"> |
| 3 | <indexterm id="IndexDollarMacros"><primary>macros</primary><secondary>orchestra</secondary></indexterm> |
| 4 | |
| 5 | <indexterm id="IndexDollarOrch"><primary>$NAME</primary><secondary>orchestra</secondary></indexterm> |
| 6 | |
| 7 | <indexterm id="IndexDollar"><primary>$NAME</primary></indexterm> |
| 8 | <refentryinfo><title>Orchestra Syntax:Macros</title></refentryinfo> |
| 9 | <refmeta> |
| 10 | <refentrytitle>$NAME</refentrytitle> |
| 11 | </refmeta> |
| 12 | |
| 13 | |
| 14 | |
| 15 | <refnamediv> |
| 16 | <refname>$NAME</refname> |
| 17 | |
| 18 | <refpurpose> |
| 19 | Calls a defined macro. |
| 20 | </refpurpose> |
| 21 | </refnamediv> |
| 22 | |
| 23 | <refsect1> |
| 24 | <title>Description</title> |
| 25 | <para> |
| 26 | Macros are textual replacements which are made in the orchestra as it is being read. The <link linkend="OrchMacros"><citetitle>orchestra macro system</citetitle></link> in Csound is a very simple one, and uses the characters # and $ to define and call macros. This can save typing, and can lead to a coherent structure and consistent style. This is similar to, but independent of, the <link linkend="ScoreMacros"><citetitle>macro system in the score language</citetitle></link>. |
| 27 | </para> |
| 28 | |
| 29 | <para> |
| 30 | <emphasis>$NAME</emphasis> |
| 31 | <emphasis>$NAME.</emphasis> -- calls a defined macro. To |
| 32 | use a macro, the name is used following a $ |
| 33 | character. The name is terminated by the first character which |
| 34 | is neither a letter nor a number. If it is necessary for the |
| 35 | name to be followed by a letter or number, a period, which will be |
| 36 | ignored, can be used to terminate the name. The string, |
| 37 | <emphasis>$NAME</emphasis>., is replaced by the |
| 38 | replacement text from the definition. The replacement text can |
| 39 | also include macro calls. |
| 40 | </para> |
| 41 | </refsect1> |
| 42 | |
| 43 | <refsect1> |
| 44 | <title>Syntax</title> |
| 45 | <synopsis><command>$NAME</command> </synopsis> |
| 46 | </refsect1> |
| 47 | |
| 48 | <refsect1> |
| 49 | <title>Initialization</title> |
| 50 | <para> |
| 51 | <emphasis># replacement text #</emphasis> -- The replacement text is any character string (not containing a #) and can extend over multiple lines. The replacement text is enclosed within the # characters, which ensure that additional characters are not inadvertently captured. |
| 52 | </para> |
| 53 | </refsect1> |
| 54 | |
| 55 | <refsect1> |
| 56 | <title>Performance</title> |
| 57 | <para> |
| 58 | Some care is needed with textual replacement macros, as they can sometimes do strange things. They take no notice of any meaning, so spaces are significant. This is why, unlike the C programming language, the definition has the replacement text surrounded by # characters. Used carefully, this simple macro system is a powerful concept, but it can be abused. |
| 59 | </para> |
| 60 | </refsect1> |
| 61 | |
| 62 | <refsect1> |
| 63 | <title>Examples</title> |
| 64 | <para> |
| 65 | Here is an example of the calling a macro. It uses the file <ulink url="examples/define.csd"><citetitle>define.csd</citetitle></ulink>. |
| 66 | |
| 67 | <example> |
| 68 | <title>An example of the calling a macro.</title> |
| 69 | |
| 70 | <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> |
| 71 | <xi:include href="examples-xml/define.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 72 | </example> |
| 73 | |
| 74 | Its output should include lines like this: |
| 75 | <screen> |
| 76 | Macro definition for VOLUME |
| 77 | Macro definition for CPS |
| 78 | Macro definition for TABLE</screen> |
| 79 | </para> |
| 80 | |
| 81 | <para> |
| 82 | Here is an example of the calling a macro with arguments. It uses the file <ulink url="examples/define_args.csd"><citetitle>define_args.csd</citetitle></ulink>. |
| 83 | |
| 84 | <example> |
| 85 | <title>An example of the calling a macro with arguments.</title> |
| 86 | |
| 87 | <xi:include href="examples-xml/define_args.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 88 | </example> |
| 89 | |
| 90 | Its output should include a line like this: |
| 91 | <screen> |
| 92 | Macro definition for OSCMACRO</screen> |
| 93 | </para> |
| 94 | </refsect1> |
| 95 | |
| 96 | <refsect1> |
| 97 | <title>See also</title> |
| 98 | <para><link linkend="OrchMacros"><citetitle>Orchestra Macros</citetitle></link></para> |
| 99 | </refsect1> |
| 100 | |
| 101 | <refsect1> |
| 102 | <title>Credits</title> |
| 103 | <para> |
| 104 | <simplelist> |
| 105 | <member>Author: &namejohn;</member> |
| 106 | <member>University of Bath/Codemist Ltd.</member> |
| 107 | <member>Bath, UK</member> |
| 108 | <member>April, 1998</member> |
| 109 | </simplelist> |
| 110 | </para> |
| 111 | <para>Examples written by &namekevin;.</para> |
| 112 | |
| 113 | <para>New in Csound version 3.48</para> |
| 114 | </refsect1> |
| 115 | </refentry> |