| 1 | |
| 2 | <refentry id="opnot"> |
| 3 | <indexterm id="IndexLogNot"><primary>!</primary></indexterm> |
| 4 | <refentryinfo><title>Mathematical Operations:Arithmetic and Logic Operations</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>!</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | |
| 10 | |
| 11 | <refnamediv> |
| 12 | <refname>!</refname> |
| 13 | |
| 14 | <refpurpose> |
| 15 | Logical NOT operator. |
| 16 | </refpurpose> |
| 17 | </refnamediv> |
| 18 | |
| 19 | <refsect1> |
| 20 | <title>Description</title> |
| 21 | <para> |
| 22 | Arithmetic operators perform operations of change-sign (negate), don't-change-sign, logical AND logical OR, add, subtract, multiply and divide. Note that a value or an expression may fall between two of these operators, either of which could take it as its left or right argument, as in |
| 23 | <literallayout>a + b * c.</literallayout> |
| 24 | </para> |
| 25 | |
| 26 | <para> |
| 27 | In such cases three rules apply: |
| 28 | </para> |
| 29 | |
| 30 | <para> |
| 31 | 1. * and <emphasis>/</emphasis> bind to their neighbors more strongly than + and −. Thus the above expression is taken as |
| 32 | <literallayout>a + (b * c)</literallayout> |
| 33 | with * taking b and c and then + taking a and b * c. |
| 34 | </para> |
| 35 | |
| 36 | <para> |
| 37 | 2. <emphasis>+</emphasis> and <emphasis>−</emphasis> bind more strongly than &&, which in turn is stronger than ||: |
| 38 | <literallayout>a && b - c || d</literallayout> |
| 39 | is taken as |
| 40 | <literallayout>(a && (b - c)) || d</literallayout> |
| 41 | </para> |
| 42 | |
| 43 | <para> |
| 44 | 3. When both operators bind equally strongly, the operations are done left to right: |
| 45 | <literallayout>a - b - c</literallayout> |
| 46 | is taken as |
| 47 | <literallayout>(a - b) - c</literallayout> |
| 48 | </para> |
| 49 | |
| 50 | <para> |
| 51 | Parentheses may be used as above to force particular groupings. |
| 52 | </para> |
| 53 | </refsect1> |
| 54 | |
| 55 | <refsect1> |
| 56 | <title>Syntax</title> |
| 57 | <synopsis><command>!</command> a (logical NOT; not audio-rate)</synopsis> |
| 58 | |
| 59 | <para> |
| 60 | where the argument <emphasis>a</emphasis> may be further expressions. |
| 61 | </para> |
| 62 | </refsect1> |
| 63 | |
| 64 | <refsect1> |
| 65 | <title>Examples</title> |
| 66 | <para> |
| 67 | Here is an example of the Logical NOT operator. It uses the file <ulink url="examples/opnot.csd"><citetitle>opnot.csd</citetitle></ulink>. |
| 68 | <example> |
| 69 | <title>Example of the opnot opcode.</title> |
| 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/opnot.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 72 | </example> |
| 73 | Its output should include lines like these: |
| 74 | <screen> |
| 75 | i1 1.00000 |
| 76 | i1 2.00000 |
| 77 | i1 1.00000 |
| 78 | i1 2.00000 |
| 79 | i1 1.00000 |
| 80 | i1 2.00000 |
| 81 | i1 1.00000 |
| 82 | ..... |
| 83 | </screen> |
| 84 | </para> |
| 85 | </refsect1> |
| 86 | |
| 87 | <refsect1> |
| 88 | <title>See also</title> |
| 89 | <para><link linkend="MathArtLogic"><citetitle>Arithmetic and Logic Operations</citetitle></link></para> |
| 90 | </refsect1> |
| 91 | |
| 92 | </refentry> |