Added help for Pen and updated some other docs
[supercollider.git] / HelpSource / Classes / MantissaMask.schelp
blob4f2a12d010548e3fc70fde05af7edb4ae026f688
1 class:: MantissaMask
2 summary:: Reduce precision.
3 categories::  UGens>Filters>Nonlinear
6 Description::
8 Masks off bits in the mantissa of the floating point sample value.
9 This introduces a quantization noise, but is less severe than linearly
10 quantizing the signal.
13 classmethods::
15 method::ar, kr
17 argument::in
18 The input signal.
20 argument::bits
22 The number of mantissa bits to preserve. A number from 0 to 23.
25 argument::mul
26 Output will be multiplied by this value.
28 argument::add
29 This value will be added to the output.
31 Examples::
33 code::
35 // preserve only 3 bits of mantissa.
36 { MantissaMask.ar(SinOsc.ar(SinOsc.kr(0.2,0,400,500), 0, 0.4), 3) }.play
38 // the original
39 { SinOsc.ar(SinOsc.kr(0.2,0,400,500), 0, 0.4) }.play
41 // the difference.
44         var in;
45         in = SinOsc.ar(SinOsc.kr(0.2,0,400,500), 0, 0.4);
46         Out.ar(0, in - MantissaMask.ar(in, 3));
47 }.play
51 // preserve 7 bits of mantissa.
52 // This makes the lower 16 bits of the floating point number become zero.
53 { MantissaMask.ar(SinOsc.ar(SinOsc.kr(0.2,0,400,500), 0, 0.4), 7) }.play
55 // the original
56 { SinOsc.ar(SinOsc.kr(0.2,0,400,500), 0, 0.4) }.play
58 // the difference.
61         var in;
62         in = SinOsc.ar(SinOsc.kr(0.2,0,400,500), 0, 0.4);
63         Out.ar(0, in - MantissaMask.ar(in, 7));
64 }.play