«Scgraph sound and vision part 2» by codepool

on 27 Apr'17 16:01 in scgraph

Migration from the old SourceForge wiki.

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
Trying to get more concise style.

First boot scgraph from the terminal:

./bin/scgraph

then...
*/


// nonprivate after fredrik
(
s = Server.local;
s.boot;

h = Server("scgraph", NetAddr("localhost", 37291));
h.boot;
)

////////////////////////// POINTS 1
(

SynthDef(\points, {|iFreq = 110, modFreq = 0.5, freqDeviation = 1, amp = 1, offset = 0.6|

	var src, ctrlSines, ctrlMul;

	ctrlMul = SinOsc.kr(modFreq * 0.7);
	ctrlSines = Array.newClear(6);
		
	ctrlSines.do { |item, index| 
	
		ctrlSines[index] = SinOsc.kr(modFreq * 1.2 * (1 + (Rand(0, 0.5) * freqDeviation) ), 0, amp * 5);
	};
	    
	src = 
	     GPoints.gr(
	     	ctrlMul.range(2, 40), 
	     	[
	     	[ctrlSines[0], ctrlSines[1], 0], 
	     	[ctrlSines[2], ctrlSines[3], 0], 
	     	[ctrlSines[4], ctrlSines[5], 0]
	     	]
	     );
     
    GGLRenderer.gr(src);
    
}).send(h);

SynthDef(\points, {|iFreq = 110, modFreq = 0.5, freqDeviation = 1, amp = 1, offset = 0.6|

	var src, audioSines, ctrlSines, ctrlMul;

	ctrlMul = SinOsc.kr(modFreq * 0.7);
	ctrlSines = Array.newClear(6);
	audioSines = Array.newClear(3);
		
	ctrlSines.do { |item, index| 
	
		ctrlSines[index] = SinOsc.kr(modFreq * 1.2 * (1 + (Rand(0, 0.5) * freqDeviation) ), 0, amp * 4);
		
	};
	
	audioSines.do { |item, index|
		
		audioSines[index] = SinOsc.ar( (iFreq * index) * ctrlSines[(index * 2) + 1], 0, amp * ctrlMul.range(0.051, 0.2) );
		audioSines[index] = 
			Pan2.ar(audioSines[index], ctrlSines[index * 2]);
	
	};
	    
	src = Mix.new(audioSines);
     
    Out.ar(0, src);
    
}).send(s);


~start = { |iFreq = 110, modFreq = 0.5, freqDeviation = 1, amp = 1|

	~scg = Array.newClear(2);

	[h, s].do { |item, index|
	
		~scg[index] = Synth.new(\points, [\iFreq, iFreq, \modFreq, modFreq, \freqDeviation, freqDeviation, \amp, amp], target: item)
	};


};

~setParams = { |iFreq = 110, modFreq = 0.5, freqDeviation = 1, amp = 1|

	~scg.do { |item, index|
	
		item.set([\iFreq, iFreq, \modFreq, modFreq, \freqDeviation, freqDeviation, \amp, amp]);

	};

};

~free = { ~scg.do { |item, index| item.free } };

)

~start.value;
~setParams.value(80, 0.3, 2, 0.9);
~setParams.value(400, 0.8, 8, 0.3);
~setParams.value(297, 0.1, 2, 0.7);
~setParams.value(773, 0.8, 3, 0.7);
~free.value;
raw 2339 chars (focus & ctrl+a+c to copy)
reception
comments