| 1 | |
| 2 | <section id="OrchMacros"> |
| 3 | <title>Orchestra Macros</title> |
| 4 | |
| 5 | <para> |
| 6 | Orchestra macros work like C preprocessor macros, and replace the content of the macro in the orchestra before it is compiled. The opcodes one can use to create, call, or undefine orchestra macros are: |
| 7 | <itemizedlist> |
| 8 | <listitem><para><link linkend="define"><citetitle>#define</citetitle></link></para></listitem> |
| 9 | <listitem><para><link linkend="dollar"><citetitle>$NAME</citetitle></link></para></listitem> |
| 10 | <listitem><para><link linkend="ifdef"><citetitle>#ifdef</citetitle></link></para></listitem> |
| 11 | <listitem><para><link linkend="ifndef"><citetitle>#ifndef</citetitle></link></para></listitem> |
| 12 | <listitem><para><link linkend="ifdef"><citetitle>#end</citetitle></link></para></listitem> |
| 13 | <listitem><para><link linkend="ifdef"><citetitle>#else</citetitle></link></para></listitem> |
| 14 | <listitem><para><link linkend="include"><citetitle>#include</citetitle></link></para></listitem> |
| 15 | <listitem><para><link linkend="include"><citetitle>#includestr</citetitle></link></para></listitem> |
| 16 | <listitem><para><link linkend="undef"><citetitle>#undef</citetitle></link></para></listitem> |
| 17 | </itemizedlist> |
| 18 | </para> |
| 19 | <para> |
| 20 | Orchestra macros can also be defined using the command line flag <link linkend="FlagsCatMinusOmacro"><citetitle>--omacro:</citetitle></link>. |
| 21 | </para> |
| 22 | <para> |
| 23 | More information and examples on the usage of orchestra macros can be found in the entry for <link linkend="define"><citetitle>#define</citetitle></link>. |
| 24 | </para> |
| 25 | <para> |
| 26 | These opcodes refer to orchestra macros; for score macros, refer to <link linkend="ScoreMacros"><citetitle>Score Macros</citetitle></link>. |
| 27 | </para> |
| 28 | |
| 29 | <refsect1 id="opcodesOrchMathConstMacros"> |
| 30 | <title>Predefined Math Constant Macros</title> |
| 31 | <para>New in Csound 5.04 are predefined Math Constant Macros. The values |
| 32 | defined are those found in the C header math.h, and are automatically |
| 33 | defined when Csound starts and available for use in orchestras.</para> |
| 34 | |
| 35 | <informaltable frame="all"> |
| 36 | <tgroup cols="3" colsep="1" rowsep="1"> |
| 37 | <thead> |
| 38 | <row> |
| 39 | <entry>Macro</entry> |
| 40 | <entry>Value</entry> |
| 41 | <entry>Equivalent to</entry> |
| 42 | </row> |
| 43 | </thead> |
| 44 | |
| 45 | <tbody> |
| 46 | |
| 47 | <row> |
| 48 | <entry>$M_E</entry> |
| 49 | <entry>2.7182818284590452354</entry> |
| 50 | <entry>e</entry> |
| 51 | </row> |
| 52 | <row> |
| 53 | <entry>$M_LOG2E</entry> |
| 54 | <entry>1.4426950408889634074</entry> |
| 55 | <entry>log_2(e)</entry> |
| 56 | </row> |
| 57 | <row> |
| 58 | <entry>$M_LOG10E</entry> |
| 59 | <entry>0.43429448190325182765</entry> |
| 60 | <entry>log_10(e)</entry> |
| 61 | </row> |
| 62 | <row> |
| 63 | <entry>$M_LN2</entry> |
| 64 | <entry>0.69314718055994530942</entry> |
| 65 | <entry>log_e(2)</entry> |
| 66 | </row> |
| 67 | <row> |
| 68 | <entry>$M_LN10</entry> |
| 69 | <entry>2.30258509299404568402</entry> |
| 70 | <entry>log_e(10)</entry> |
| 71 | </row> |
| 72 | <row> |
| 73 | <entry>$M_PI</entry> |
| 74 | <entry>3.14159265358979323846</entry> |
| 75 | <entry>pi</entry> |
| 76 | </row> |
| 77 | <row> |
| 78 | <entry>$M_PI_2</entry> |
| 79 | <entry>1.57079632679489661923</entry> |
| 80 | <entry>pi/2</entry> |
| 81 | </row> |
| 82 | <row> |
| 83 | <entry>$M_PI_4</entry> |
| 84 | <entry>0.78539816339744830962</entry> |
| 85 | <entry>pi/4</entry> |
| 86 | </row> |
| 87 | <row> |
| 88 | <entry>$M_1_PI</entry> |
| 89 | <entry>0.31830988618379067154</entry> |
| 90 | <entry>1/pi</entry> |
| 91 | </row> |
| 92 | <row> |
| 93 | <entry>$M_2_PI</entry> |
| 94 | <entry>0.63661977236758134308</entry> |
| 95 | <entry>2/pi</entry> |
| 96 | </row> |
| 97 | <row> |
| 98 | <entry>$M_2_SQRTPI</entry> |
| 99 | <entry>1.12837916709551257390</entry> |
| 100 | <entry>2/sqrt(pi)</entry> |
| 101 | </row> |
| 102 | <row> |
| 103 | <entry>$M_SQRT2</entry> |
| 104 | <entry>1.41421356237309504880</entry> |
| 105 | <entry>sqrt(2)</entry> |
| 106 | </row> |
| 107 | <row> |
| 108 | <entry>$M_SQRT1_2</entry> |
| 109 | <entry>0.70710678118654752440</entry> |
| 110 | <entry>1/sqrt(2)</entry> |
| 111 | </row> |
| 112 | |
| 113 | </tbody> |
| 114 | </tgroup> |
| 115 | </informaltable> |
| 116 | |
| 117 | |
| 118 | </refsect1> |
| 119 | |
| 120 | |
| 121 | </section> |