summaryrefslogtreecommitdiff
path: root/lib/Clipper.ck
blob: c11d3c2ef87a74168c154dc4f77f7d076d80004a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*
 * clip signal within -1 to 1 with simple UGens
 */
public class Clipper {
	Gain input; // chuck input signal to this
	Gain output; // chuck this out to have the result

	Step one; 1 => one.next;
	input => HalfRect a;
	one => a; // calculate a from HalfRect(input + 1)
	one => Gain two; 2 => two.gain;
	-1 => a.gain;
	a => HalfRect b;
	two => b; // calculate b from HalfRect(2 - HalfRect(input + 1))
	-1 => b.gain;
	one => output;
	b => output; // the result we want: 1 - HalfRect(2 - HalfRect(input + 1))
}