2 // How to emulate Faust's seq, par, sum.
3 // x(k) is assumed to yield the kth signal.
6 xseq(n,x) = xseq(n-1,x) : x(n-1);
9 xpar(n,x) = xpar(n-1,x) , x(n-1);
12 xsum(n,x) = xsum(n-1,x) + x(n-1);
14 // These are all very similar. Abstracting
15 // on the binary "accumulator" function, we
16 // get the familiar fold(-left) function:
19 fold(n,f,x) = f(fold(n-1,f,x),x(n-1));
21 // Now seq, par, sum can be defined as:
23 fseq(n) = fold(n,\(x,y).(x:y));
24 fpar(n) = fold(n,\(x,y).(x,y));
28 // Often it is more convenient to specify
29 // parameters as a Faust tuple. We can match
30 // against the (xs,x) pattern to decompose
33 vfold(f,(xs,x)) = f(vfold(f,xs),x);
36 // Tuple version of seq, par, sum:
38 vseq = vfold(\(x,y).(x:y));
39 vpar = vfold(\(x,y).(x,y));
50 h(i) = a(i)*osc((i+1)*f0);
53 //process = xsum(3,h);
54 //process = fsum(3,h);
55 //process = vsum((h(0),h(1),h(2)));
57 reverse (x:y) = reverse(y):reverse(x);
60 // sequences from tuples (parallel -> serial)
61 process = reverse(vseq((sin,cos,tan)));