«Scgraph sound and vision» by codepool

on 27 Apr'17 22:02 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*
These are simple attempts to make sound and visual patches that use similar parameters which are set in one single command.

First boot scgraph from the terminal:

./bin/scgraph

then...
*/

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

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

////////////////////////// CUBE 1
(

SynthDef(\cube, {|freq = 0.5, amp = 1, offset = 0.6|
    var src = GCube.gr(SinOsc.kr(freq, 0, amp * 0.6, offset * 0.6));
    GGLRenderer.gr(src);
}).send(h);



SynthDef(\cube, {|freq = 0.5, amp = 1, offset = 0.6|
    var src = SinOsc.ar(220 * SinOsc.kr(freq, 0, amp, offset), 0, 0.5);
    Out.ar(0, [src, src]);
}).send(s);


~start = { |freq = 0.4, amp = 1, offset = 3|
	
	~graphics = Synth.new(\cube, [\freq, freq, \amp, amp, \offset, offset], target: h);
	~sound = Synth.new(\cube, [\freq, freq, \amp, amp, \offset, offset], target: s);

};

~setParams = { |freq = 0.4, amp = 1, offset = 3|
	
	~graphics.set([\freq, freq, \amp, amp, \offset, offset]);
	~sound.set([\freq, freq, \amp, amp, \offset, offset]);

};

~free = { ~graphics.free; ~sound.free };

)

~start.value;
~setParams.value(0.2, 1, 2);
~setParams.value(1, 3, 4);
~free.value;

////////////////////////// RECT 1



(

SynthDef(\rect, {|freq = 0.5, modFreq = 0.8, amp = 1, offset = 0.6|

    var src = GRectangle.gr(SinOsc.kr(freq, 0, amp, offset), SinOsc.kr(modFreq, 0, amp, offset));
    
    GGLRenderer.gr(src);
    
}).send(h);



SynthDef(\rect, {|freq = 0.5, modFreq = 0.8, amp = 1, offset = 0.6|
    var src = SinOsc.ar(220 * SinOsc.kr(freq, 0, amp, offset) * SinOsc.kr(modFreq, 0, 0.5, 1), 0, 0.5);
    Out.ar(0, [src, src]);
}).send(s);


~start = { |freq = 0.4, modFreq = 1.2, amp = 1, offset = 3|
	
	~graphics = Synth.new(\rect, [\freq, freq, \modFreq, modFreq, \amp, amp, \offset, offset], target: h);
	~sound = Synth.new(\rect, [\freq, freq, \modFreq, modFreq, \amp, amp, \offset, offset], target: s);

};

~setParams = { |freq = 0.4, modFreq = 1.2, amp = 1, offset = 3|
	
	~graphics.set([\freq, freq, \modFreq, modFreq, \amp, amp, \offset, offset]);
	~sound.set([\freq, freq, \modFreq, modFreq, \amp, amp, \offset, offset]);

};

~free = { ~graphics.free; ~sound.free };

)


~start.value;
~setParams.value(0.2, 0.7, 1, 2);
~setParams.value(1, 2, 3, 4);
~free.value;



////////////////////////// LINE 1



(

SynthDef(\line, {|freq1 = 0.5, freq2 = 0.8, amp = 1, offset = 0.6|

    var src = GLine.gr(10, [SinOsc.kr(freq1, 0, amp, offset), -2, -2], [SinOsc.kr(freq2, 0, amp, offset), 4, 4]);
    
    GGLRenderer.gr(src);
    
}).send(h);



SynthDef(\line, {|freq1 = 0.5, freq2 = 0.8, amp = 1, offset = 0.6|
    var src = 
    	Mix.ar([SinOsc.ar(220 * SinOsc.kr(freq1, 0, amp, offset), 0, 0.5),
    		SinOsc.ar(200 * SinOsc.kr(freq2, 0, amp, offset), 0, 0.5)
    	]);
    Out.ar(0, [src, src]);
}).send(s);


~start = { |freq1 = 0.4, freq2 = 1.2, amp = 1, offset = 3|
	
	~graphics = Synth.new(\line, [\freq1, freq1, \freq2, freq2, \amp, amp, \offset, offset], target: h);
	~sound = Synth.new(\line, [\freq1, freq1, \freq2, freq2, \amp, amp, \offset, offset], target: s);

};

~setParams = { |freq1 = 0.4, freq2 = 1.2, amp = 1, offset = 3|
	
	~graphics.set([\freq1, freq1, \freq2, freq2, \amp, amp, \offset, offset]);
	~sound.set([\freq1, freq1, \freq2, freq2, \amp, amp, \offset, offset]);

};

~free = { ~graphics.free; ~sound.free };

)


~start.value;
~setParams.value(0.2, 3, 7, 0);
~setParams.value(1, 2, 5, -2);
~free.value;
raw 3627 chars (focus & ctrl+a+c to copy)
reception
comments