File: array_ugens.ck

package info (click to toggle)
chuck 1.5.5.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 41,056 kB
  • sloc: cpp: 123,473; ansic: 35,893; javascript: 2,111; yacc: 609; makefile: 457; python: 174; perl: 86
file content (36 lines) | stat: -rw-r--r-- 1,351 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// connecting => with arrays of UGens
// (requires chuck-1.5.2.2 or higher)
// there are several possibilities...

// 1) LHS[X] => RHS: each elements in LHS => to RHS
Gain A[3] => Gain B;
for( UGen a : A ) <<< "1) connected:", a.isConnectedTo(B) >>>;

// 2) LHS[X] => RHS[X]: one to one mapping 
Gain C[3] => Gain D[3];
for( int i; i < C.size(); i++ )
    <<< "2) connected:", C[i].isConnectedTo(D[i]) >>>;

// 3) LHS[X] => RHS[Y]: one to one mapping up to min(X,Y), after
// which elements in the smaller array will modulo to the beginning
// and connect to remaining elements in larger array
Gain E[2] => Gain F[3];
Math.max(E.size(), F.size()) => int greater;
for( int i; i < greater; i++ )
    <<< "3) connected:", E[i%E.size()].isConnectedTo(F[i%F.size()]) >>>;

// 4) LHS => RHS[X]: LHS => to each element in RHS
Gain G => Gain H[3];
for( UGen h : H ) <<< "4) connected:", G.isConnectedTo(h) >>>;

// array of mono ugens => stereo ugen
Gain I[2] => Pan2 J;
// should be 1 0 0 1
<<< "5) connected:", I[0].isConnectedTo(J.left), I[0].isConnectedTo(J.right),
    I[1].isConnectedTo(J.left), I[1].isConnectedTo(J.right) >>>;

// stereo ugen => array of mono ugens
Pan2 K => Gain L[2];
// should be 1 0 0 1
<<< "6) connected:", K.left.isConnectedTo(L[0]), K.right.isConnectedTo(L[0]),
    K.left.isConnectedTo(L[1]), K.right.isConnectedTo(L[1]) >>>;