1class:: MulAdd
2categories:: UGens>Maths
3summary:: Multiply and add to a signal
4
5description::
6Multiplies the signal by mul and adds add. This UGen is very efficient (it performs various optimisation checks, for example). It is used very heavily throughout SuperCollider to perform multiply and add operations on the server; in fact it is  what "really" performs the mul and add arguments found in many UGens.
7
8See also the discussion of mul and add arguments in the link::Classes/UGen:: help file.
9
10classmethods::
11private:: new1
12
13method:: new
14argument:: in
15input signal
16argument:: mul
17multiply with this value
18argument:: add
19add this value
20
21discussion::
22Same as:
23code::
24in.madd(mul, add)
25::
26
27instancemethods::
28private:: init
29
30Examples::
31code::
32s.boot;
33
34// The mul and add arguments of SinOsc themselves use MulAdd!
35// These two examples will create precisely the same synth graph:
36x = { SinOsc.ar(440, 0, 0.1, 0.05) }.play(s);
37x.trace; // You should see a "MulAdd" in the trace
38x.free;
39
40x = { MulAdd(SinOsc.ar(440, 0), 0.1, 0.05) }.play(s);
41x.trace;
42x.free;
43
44// In fact this will produce the same graph too - the separate multiply and add are optimised into one MulAdd
45x = { SinOsc.ar(440, 0) * 0.1 + 0.05 }.play(s);
46x.trace;
47x.free;
48::
49(Note: the "trace" message is described in the helpfile for link::Classes/Node::.)
50