| 1 | |
| 2 | <refentry id="include"> |
| 3 | <indexterm id="IndexMultiFileOrch"><primary>multiple file orchestras</primary></indexterm> |
| 4 | |
| 5 | <indexterm id="IndexIncludeOrch"><primary>#include</primary><secondary>orchestra</secondary></indexterm> |
| 6 | <refentryinfo><title>Orchestra Syntax:Macros</title></refentryinfo> |
| 7 | <refmeta> |
| 8 | <refentrytitle>#include</refentrytitle> |
| 9 | </refmeta> |
| 10 | |
| 11 | |
| 12 | |
| 13 | <refnamediv> |
| 14 | <refname>#include</refname> |
| 15 | |
| 16 | <refpurpose> |
| 17 | Includes an external file for processing. |
| 18 | </refpurpose> |
| 19 | </refnamediv> |
| 20 | |
| 21 | <refsect1> |
| 22 | <title>Description</title> |
| 23 | <para> |
| 24 | 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>. |
| 25 | </para> |
| 26 | |
| 27 | <para> |
| 28 | Includes an external file for processing. |
| 29 | </para> |
| 30 | </refsect1> |
| 31 | |
| 32 | <refsect1> |
| 33 | <title>Syntax</title> |
| 34 | <synopsis><command>#include</command> <quote>filename</quote></synopsis> |
| 35 | <synopsis><command>#includestr</command> <quote>filename</quote></synopsis> |
| 36 | </refsect1> |
| 37 | |
| 38 | <refsect1> |
| 39 | <title>Performance</title> |
| 40 | <para>#includestr is similar to #include except that the file |
| 41 | name must be delimited by a double quote character and the file |
| 42 | name is subjected to macro expansion. |
| 43 | </para> |
| 44 | <para> |
| 45 | It is sometimes convenient to have the orchestra arranged in a |
| 46 | number of files, for example with each instrument in a separate |
| 47 | file. This style is supported by the |
| 48 | <emphasis>#include</emphasis> facility which is part of the |
| 49 | macro system. A line containing the text |
| 50 | |
| 51 | <informalexample> |
| 52 | <programlisting> |
| 53 | <emphasis role="omacro">#include</emphasis> "filename"</programlisting> |
| 54 | </informalexample> |
| 55 | |
| 56 | where the character " can be replaced by any suitable |
| 57 | character in #include (but not in #includestr). For |
| 58 | most uses the double quote symbol will probably be the most |
| 59 | convenient. The file name can include a full path. |
| 60 | </para> |
| 61 | |
| 62 | <para> |
| 63 | This takes input from the named file until it ends, when input |
| 64 | reverts to the previous input. |
| 65 | <emphasis>Note: </emphasis>Csound versions prior to 4.19 had a limit of 20 on the depth of included files and macros. |
| 66 | </para> |
| 67 | |
| 68 | <para> |
| 69 | Another suggested use of <emphasis>#include</emphasis> would be to define a set of macros which are part of the composer's style. |
| 70 | </para> |
| 71 | |
| 72 | <para> |
| 73 | An extreme form would be to have each instrument defines as a macro, with the instrument number as a parameter. Then an entire orchestra could be constructed from a number of <emphasis>#include</emphasis> statements followed by macro calls. |
| 74 | |
| 75 | <informalexample> |
| 76 | <programlisting> |
| 77 | <emphasis role="omacro">#include</emphasis> "clarinet" |
| 78 | <emphasis role="omacro">#include</emphasis> "flute" |
| 79 | <emphasis role="omacro">#include</emphasis> "bassoon" |
| 80 | $CLARINET(1) |
| 81 | $FLUTE(2) |
| 82 | $BASSOON(3)</programlisting> |
| 83 | </informalexample> |
| 84 | |
| 85 | It must be stressed that these changes are at the textual level and so take no cognizance of any meaning. |
| 86 | </para> |
| 87 | <para> |
| 88 | If the version of Csound is built with the CURL library the |
| 89 | filename in an <emphasis>#include</emphasis> statement can |
| 90 | be an URL, recognised by including the substring "://" in the |
| 91 | name. This will include text via protocols such as http, https, |
| 92 | and ftp. |
| 93 | </para> |
| 94 | </refsect1> |
| 95 | |
| 96 | <refsect1> |
| 97 | <title>Examples</title> |
| 98 | <para> |
| 99 | Here is an example of the include opcode. It uses the file <ulink url="examples/include.csd"><citetitle>include.csd</citetitle></ulink>, and <ulink url="examples/table1.inc"><citetitle>table1.inc</citetitle></ulink>. |
| 100 | |
| 101 | <example> |
| 102 | <title>Example of the include opcode.</title> |
| 103 | |
| 104 | <xi:include href="examples-xml/table1.inc.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 105 | |
| 106 | <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> |
| 107 | <xi:include href="examples-xml/include.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 108 | </example> |
| 109 | </para> |
| 110 | </refsect1> |
| 111 | |
| 112 | <refsect1> |
| 113 | <title>See also</title> |
| 114 | <para><link linkend="OrchMacros"><citetitle>Orchestra Macros</citetitle></link></para> |
| 115 | </refsect1> |
| 116 | |
| 117 | <refsect1> |
| 118 | <title>Credits</title> |
| 119 | <para> |
| 120 | <simplelist> |
| 121 | <member>Author: &namejohn;</member> |
| 122 | <member>University of Bath/Codemist Ltd.</member> |
| 123 | <member>Bath, UK</member> |
| 124 | <member>April 1998</member> |
| 125 | </simplelist> |
| 126 | <para> #includestr new in version 6.12</para> |
| 127 | </para> |
| 128 | <para>Example written by &namekevin;.</para> |
| 129 | |
| 130 | <para>New in Csound version 3.48</para> |
| 131 | <para>URLs available from Csound 6.02</para> |
| 132 | </refsect1> |
| 133 | </refentry> |