1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8">
5 <meta http-equiv=
"Content-Style-Type" content=
"text/css">
7 <meta name=
"Generator" content=
"Cocoa HTML Writer">
8 <meta name=
"CocoaVersion" content=
"824.48">
9 <style type=
"text/css">
10 p
.p1
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
}
11 p
.p2
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; min-height: 14.0px}
12 p
.p3
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
}
13 p
.p4
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; color: #0000ff}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; color: #0021e7}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; min-height: 12.0px}
16 p
.p7
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #ad140d}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #ad140d; min-height: 12.0px}
18 p
.p9
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco
; min-height: 16.0px}
19 span
.s1
{font: 18.0px Helvetica
}
20 span
.s2
{color: #001bb9}
21 span
.s3
{color: #0024f8}
22 span
.s4
{color: #000000}
23 span
.s5
{text-decoration: underline
}
24 span
.s6
{color: #0000ff}
25 span
.s7
{color: #ad140d}
26 span
.s8
{color: #606060}
27 span
.s9
{color: #8b2719}
28 span
.s10
{color: #2c7014}
29 span
.Apple-tab-span
{white-space:pre
}
33 <p class=
"p1"><span class=
"s1"><b>BinaryOpUgen
</b></span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>apply a binary operation to the values of an input ugen
</b></p>
34 <p class=
"p2"><br></p>
35 <p class=
"p1">BinaryOpUGens are created as the result of a binary operator applied to a UGen.
<span class=
"Apple-converted-space"> </span></p>
36 <p class=
"p2"><br></p>
37 <p class=
"p3"><span class=
"Apple-tab-span"> </span>(
<span class=
"s2">SinOsc
</span>.ar(
200) *
<span class=
"s2">ClipNoise
</span>.ar).dump;
</p>
38 <p class=
"p3"><span class=
"Apple-tab-span"> </span>(
<span class=
"s2">SinOsc
</span>.ar(
200).thresh(
0.5)).dump;
</p>
39 <p class=
"p2"><br></p>
40 <p class=
"p1">The use of the binary operators
<b>*
</b> and
<b>thresh
</b> above each instantiate a BinaryOpUGen. The operators themselves
<span class=
"Apple-converted-space"> </span>(which are methods) are not to be confused with the resulting BinaryOpUGen (which is an object).
<span class=
"Apple-converted-space"> </span></p>
41 <p class=
"p1">When operating on UGens instead of numbers, what results is not a result of the calculation, but a structure that represents that calculation. For the immediate operations on numbers, see for example
<a href=
"../../Math/SimpleNumber.html"><span class=
"s3">SimpleNumber
</span></a>.
</p>
42 <p class=
"p2"><br></p>
43 <p class=
"p1">There are helpfiles for each the different operators, listed below. Examples for unary operations on UGens are to be found in UGen's superclass
<a href=
"../../Core/Kernel/AbstractFunction.html"><span class=
"s3">AbstractFunction
</span></a>.
</p>
44 <p class=
"p2"><br></p>
45 <p class=
"p1">The following operators have their own helpfiles:
</p>
46 <p class=
"p2"><br></p>
47 <p class=
"p4"><a href=
"../../BinaryOps/addition.html"><b>+
</b></a><span class=
"s4"><b> </b><a href=
"../../BinaryOps/subtraction.html"><b>-
</b></a><b> </b><a href=
"../../BinaryOps/multiplication.html"><b>*
</b></a><b> </b><a href=
"../../BinaryOps/division.html"><b>/
</b></a><b> </b><a href=
"../../BinaryOps/exponentiation.html"><b>**
</b></a><b> </b><a href=
"../../BinaryOps/absdif.html"><b>absdif
</b></a><b> </b><a href=
"../../BinaryOps/amclip.html"><b>amclip
</b></a><b> </b><a href=
"../../BinaryOps/atan2.html"><b>atan2
</b></a><b> </b><a href=
"../../BinaryOps/clip2.html"><b>clip2
</b></a><b> </b><a href=
"../../BinaryOps/difsqr.html"><b>difsqr
</b></a><b> </b><a href=
"../../BinaryOps/excess.html"><b>excess
</b></a><b> </b><a href=
"../../BinaryOps/fold2.html"><b>fold2
</b></a><b> </b><a href=
"../../BinaryOps/hypot.html"><b>hypot
</b></a><b> </b><a href=
"../../BinaryOps/hypotApx.html"><b>hypotApx
</b></a><b> </b><a href=
"../../BinaryOps/max.html"><b>max
</b></a><b> </b><a href=
"../../BinaryOps/min.html"><b>min
</b></a><b> </b><a href=
"../../BinaryOps/ring1.html"><b>ring1
</b></a><b> </b><a href=
"../../BinaryOps/ring2.html"><b>ring2
</b></a><b> </b><a href=
"../../BinaryOps/ring3.html"><b>ring3
</b></a><b> </b><a href=
"../../BinaryOps/ring4.html"><b>ring4
</b></a><b> </b><a href=
"../../BinaryOps/round.html"><b>round
</b></a><b> </b><a href=
"../../BinaryOps/scaleneg.html"><b>scaleneg
</b></a><b> </b><a href=
"../../BinaryOps/sqrdif.html"><b>sqrdif
</b></a><b> </b><a href=
"../../BinaryOps/sqrsum.html"><b>sqrsum
</b></a><b> </b><a href=
"../../BinaryOps/sumsqr.html"><b>sumsqr
</b></a><b> </b><a href=
"../../BinaryOps/thresh.html"><b>thresh
</b></a><b> </b><a href=
"../../BinaryOps/trunc.html"><b>trunc
</b></a><b> </b><a href=
"../../BinaryOps/wrap2.html"><b>wrap2
</b></a></span></p>
48 <p class=
"p2"><br></p>
49 <p class=
"p1"><span class=
"Apple-tab-span"> </span><b>*new(selector, a, b)
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>return a new instance that applies the operator (
<b>selector
</b>)
<span class=
"Apple-converted-space"> </span></p>
50 <p class=
"p1"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>to the ugens (
<b>a and b
</b>)
</p>
51 <p class=
"p1"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>normally, this is implicitly called when applying a unary operator to a UGen.
</p>
52 <p class=
"p2"><br></p>
53 <p class=
"p5"><span class=
"s4"><b>See also:
</b> <a href=
"UnaryOpUGen.html"><span class=
"s5">UnaryOpUGen
</span></a></span></p>
54 <p class=
"p1"><b>Structually related:
</b> <a href=
"../../Core/BinaryOpFunction.html"><span class=
"s6">BinaryOpFunction
</span></a>,
<a href=
"../../Streams-Patterns-Events/Patterns/Pbinop.html"><span class=
"s6">Pbinop
</span></a></p>
55 <p class=
"p2"><br></p>
56 <p class=
"p1"><b>Examples
</b></p>
57 <p class=
"p6"><span class=
"Apple-tab-span"> </span></p>
58 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span>a =
</span><span class=
"s2">WhiteNoise
</span><span class=
"s4">.ar;
</span>// a WhiteNoise
</p>
59 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span>b = a +
2;
</span>// a BinaryOpUGen.
</p>
60 <p class=
"p3"><span class=
"Apple-tab-span"> </span>b.operator;
<span class=
"s7">// +
</span></p>
61 <p class=
"p8"><br></p>
62 <p class=
"p7"><span class=
"Apple-tab-span"> </span>// sound example
</p>
63 <p class=
"p3"><span class=
"Apple-tab-span"> </span>(
</p>
64 <p class=
"p3"><span class=
"Apple-tab-span"> </span>{
<span class=
"Apple-converted-space"> </span></p>
65 <p class=
"p3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s2">var
</span> a =
<span class=
"s2">LFSaw
</span>.ar(
300);
</p>
66 <p class=
"p3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s2">var
</span> b =
<span class=
"s2">LFSaw
</span>.ar(
329.1);
</p>
67 <p class=
"p3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>a % b *
0.1<span class=
"Apple-converted-space"> </span></p>
68 <p class=
"p3"><span class=
"Apple-tab-span"> </span>}.play;
</p>
69 <p class=
"p3"><span class=
"Apple-tab-span"> </span>)
<span class=
"s7"><span class=
"Apple-tab-span"> </span></span></p>
70 <p class=
"p2"><br></p>
71 <p class=
"p1"><b>The comparison operators
</b></p>
72 <p class=
"p2"><br></p>
73 <p class=
"p1">The operators
>,
>=,
<, and
<= are particularly useful for triggering. They should not be confused with their use in conditionals. Compare
</p>
74 <p class=
"p9"><br></p>
75 <p class=
"p3">if(
1 > 0) {
<span class=
"s8">"1 is greater than 0"</span>.postln };
<span class=
"s9">//
> returns a boolean
</span></p>
76 <p class=
"p9"><br></p>
77 <p class=
"p1">with
</p>
78 <p class=
"p9"><br></p>
79 <p class=
"p7">// trigger an envelope
</p>
82 <p class=
"p3"><span class=
"Apple-tab-span"> </span><span class=
"s2">var
</span> trig;
</p>
83 <p class=
"p3"><span class=
"Apple-tab-span"> </span>trig =
<span class=
"s2">SinOsc
</span>.ar(
1)
> 0.1;
</p>
84 <p class=
"p3"><span class=
"Apple-tab-span"> </span><span class=
"s2">EnvGen
</span>.kr(
<span class=
"s2">Env
</span>.perc, trig, doneAction:
0) *
<span class=
"s2">SinOsc
</span>.ar(
440,
0,
0.1)
</p>
85 <p class=
"p3">}.play
</p>
86 <p class=
"p7"><span class=
"s4">)
</span>//
> outputs
0 or
1</p>
87 <p class=
"p9"><br></p>
88 <p class=
"p1">See the individual helpfiles (
<a href=
"../../BinaryOps/greaterthan.html"><span class=
"s3">></span></a>,
<a href=
"../../BinaryOps/greaterorequalthan.html"><span class=
"s3">>=
</span></a>,
<a href=
"../../BinaryOps/lessthan.html"><span class=
"s3"><</span></a>,
<a href=
"../../BinaryOps/lessorequalthan.html"><span class=
"s3"><=
</span></a><span class=
"s3"> </span>) for more detail.
</p>
89 <p class=
"p6"><br></p>
90 <p class=
"p1">Since the equality operator (
<b>==
</b>) is used to distingush objects including UGens, it cannot be used to create a BinaryOpUGen by application. Instead, to get a trigger value each time two signals are the same (instead of just finding out whether two UGens are the same), one can instantiate a BinaryOpUGen directly:
</p>
91 <p class=
"p6"><br></p>
92 <p class=
"p3"><span class=
"Apple-tab-span"> </span>(
</p>
93 <p class=
"p3"><span class=
"Apple-tab-span"> </span>{
</p>
94 <p class=
"p3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s2">var
</span> a =
<span class=
"s2">SinOsc
</span>.ar(
1).round(
0.1);
</p>
95 <p class=
"p3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s2">var
</span> b =
<span class=
"s2">SinOsc
</span>.ar(
1.2).round(
0.1);
</p>
96 <p class=
"p3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s2">BinaryOpUGen
</span>(
<span class=
"s10">'=='
</span>, a, b) *
0.1</p>
97 <p class=
"p3"><span class=
"Apple-tab-span"> </span>}.play;
</p>
98 <p class=
"p3"><span class=
"Apple-tab-span"> </span>)
</p>
99 <p class=
"p6"><span class=
"Apple-tab-span"> </span></p>
100 <p class=
"p6"><span class=
"Apple-tab-span"> </span></p>
101 <p class=
"p6"><span class=
"Apple-tab-span"> </span></p>