Scgraph sound and vision

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...

(back to Code Pool)

// 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;