/*
modular software environment for SC3 with GUI:

http://www.ixi-software.net/content/software.html

http://ixi-audio.net/content/download/ixiquarks/index.html

*/

{ Out.ar(0, PanAz.ar(4, WhiteNoise.ar(0.5), LFSaw.kr(0.3))) }.play

{ SinOsc.ar( (Line.kr(48, 60, 10) + LFPulse.kr(1,0,0.5).range(-1,1) + [12, 17]).midicps,0 , 0.5) }.play

{ SinOsc.ar( (Line.kr(48, [60, 36], 10) + LFPulse.kr(1,0,0.5).range(-1,1) + 12).midicps,0 , 0.5) }.play

{ SinOsc.ar( LFNoise0.kr(3).range(200, 2000) ) }.play

{ LFNoise2.ar(300)}.scope  

(
SynthDef("test", {
	var resfreq, sig;
	resfreq = LFNoise1.kr(1).range(300, 1200);
	sig = Saw.ar(100);
	sig = Resonz.ar(sig, resfreq, 0.8);
	Out.ar(0, sig);
	}).store;
)

Synth("test")

(
SynthDef("test", { arg freq=100, rq=0.1, rate=1;
	var resfreq, sig;
	resfreq = LFNoise1.kr(rate).range(300, 1200);
	sig = Saw.ar(freq);
	sig = Resonz.ar(sig, resfreq, rq);
	Out.ar(0, sig);
	}).store;
)

Synth("test")

//  Symbols are written like \freq  or 'freq'

y = Synth("test", [\freq, 300, \rate, 15  ])

y.free
y

x = Synth("test", [\freq, 455, \rate, 40  ])
x.free

y.set(\freq, 40)
y.set(\freq, 1, \rate, 3, \rq, 0.3)

y.set(\freq, 1, \rate, 3, \rq, 0.3)

s.queryAllNodes

y.set(\freq, 4, \rate, 20, \rq, 0.1)

4.do { arg i; i.postln }

[40, 31, 56, 67, "hallo", \symbol, 3.2].do { arg element, n; element.postln }

// 20.do { arg i; Synth("blabla", [\freq, (i+1) * 300

rrand(300.0, 700.0) // functional notation
300.0.rrand(700.0)	// receiver.message notation
300.0 rrand: 700.0	// as binary operator

min
max
round

3.1.round(1)
round(3.1, 1)
3.1 round: 1

(
SynthDef("name", {
	var sig;
	sig = SinOsc.ar(rrand(300.0, 700.0));
	Out.ar(0, sig);
	}).store
)	
	
Synth("name")

(
SynthDef("name", {
	var sig;
	sig = SinOsc.ar(Rand(300.0, 700.0));
	Out.ar(0, sig);
	}).store
)	

Synth("name")

(
SynthDef("namedkufsdfk", {
	var sig;
	sig = SinOsc.ar(rrand(300.0, 700.0));
	Out.ar(0, sig);
	}).send(s);
)	
	
Synth("namedkufsdfk")

b = Buffer.read(s, "/Users/abart/Desktop/lisbon_SC3/sounds/mono/flute.wav")  // absolute path

b = Buffer.read(s, "sounds/a11wlk01.wav");
b = Buffer.read(s, "sounds/a11wlk01-44_1.aiff");
b.play

b = Buffer.read(s, "../../sounds/a11wlk01.wav");

b = Buffer.loadDialog(s);
b.play
b.query

Buffer.browse

b.bufnum
b.sampleRate
b.numChannels

b.free

44100 / 20000
20000 / 44100

(
SynthDef("wert", { arg buf=0, rate=1;
	var sig;
	sig = PlayBuf.ar(1, buf, BufRateScale.kr(buf) * rate, loop: 1);
	Out.ar(0, sig)
	}).store;
)

y = Synth("wert", [\buf, b.bufnum])	
y.set(\rate, 0.4)
y.set(\rate, 2.4)
y.set(\rate, rrand(0.1, 2.0))
y.set(\buf, c.bufnum)

b = Buffer.read(s, "/Users/abart/Desktop/lisbon_SC3/sounds/mono/flute.wav")  // absolute path
b.play
c = Buffer.read(s, "sounds/a11wlk01.wav");
c.play
c.query
b.query

(
SynthDef("wert", { arg buf=0, rate=1;
	var sig;
	sig = PlayBuf.ar(1, buf, BufRateScale.kr(buf) * rate, loop: 0);
	FreeSelfWhenDone.kr(sig);
	Out.ar(0, sig)
	}).store;
)

y = Synth("wert", [\buf, b.bufnum])
s.queryAllNodes

(
SynthDef("wert", { arg buf=0, rate=1;
	var sig, echo;
	sig = PlayBuf.ar(1, buf, BufRateScale.kr(buf) * rate, loop: 0);
	echo = CombN.ar(sig, 1.0, 0.3, 2);
	FreeSelfWhenDone.kr(sig);
	Out.ar(0, echo)
	}).store;
)

(
SynthDef("wert", { arg buf=0, rate=1;
	var sig;
	sig = PlayBuf.ar(1, buf, BufRateScale.kr(buf) * rate, loop: 0);
	FreeSelfWhenDone.kr(sig);
	sig = CombN.ar(sig, 1.0, 0.3, 2);
	Out.ar(0, sig)
	}).store;
)

(
SynthDef("wert", { arg buf=0, rate=1;
	var sig, pos;
	pos = BufFrames.kr(buf) * Rand(0, 1);
	sig = PlayBuf.ar(1, buf, BufRateScale.kr(buf) * rate, startPos: pos, loop: 1);
	FreeSelfWhenDone.kr(sig);
	Out.ar(0, sig)
	}).store;
)

y = Synth("wert", [\buf, b.bufnum])

18.do { Synth("wert", [\buf, b.bufnum]) }

(
SynthDef("wert", { arg buf=0, rate=1, out=0;
	var sig, pos;
	pos = BufFrames.kr(buf) * Rand(0, 1);
	sig = PlayBuf.ar(1, buf, BufRateScale.kr(buf) * rate, startPos: pos, loop: 1);
	FreeSelfWhenDone.kr(sig);
	Out.ar(out, sig)
	}).store;
)

18.do { Synth("wert", [\buf, b.bufnum, \out, rrand(0, 1)]) }

(
SynthDef("wert", { arg buf=0, rate=1;
	var sig, pos, n;
	n = 18;
	pos = BufFrames.kr(buf) * { Rand(0, 1) }.dup(n) ;
	sig = PlayBuf.ar(1, buf, BufRateScale.kr(buf) * rate, startPos: pos, loop: 1);
	FreeSelfWhenDone.kr(sig);
//	sig = Pan2.ar(sig, { Rand(-1, 1) }.dup(n) );
	sig = PanAz.ar(4, sig, { Rand(-1, 1) }.dup(n) );
	Out.ar(0, sig.sum * 0.2)
	}).store;
)

y = Synth("wert", [\buf, b.bufnum])

2 + (3 * 4) 
(3 * 4) + 2

{...}.value(n)

{ 3 + 4 }

ServerOptions

s.options.numOutputBusChannels = 20;
s.boot