View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide

dynamic Synth creation example [SC3]

this example needs running server and audio. this is ineffective, but can be done.


.
(
	d = 0.04;
	r = Routine({
		var server;
		server = Server.default;	
		
		3.do({	
					
			0.5.postln.wait;
		
		
		
			SynthDef("test", { 	var f, zout;
				f = LFSaw.kr(0.4 + rrand(1.6, 0.0), 0, 24, 
[LFSaw, LFTri].choose.kr([8,8]+[0, 3.0.rand], 0, 3, 80 + (rrand(-30, 30)))).midicps; // glissando function
				zout = CombN.ar(LPF.ar(Pulse.ar(f, 0.4, [0.5, 0.1]), [400, 1900]), 0.2, 0.2, 4); 	
				Out.ar(0, zout);
			}).writeDefFile;

			1.wait;

			server.sendMsg("/d_load", "engine/synthdefs/test.scsyndef");
			server.sendBundle(d, ["/s_new", "test", 1000, 0]);
		
			3.wait;

			server.sendMsg("/n_free", 1000);
			
		
		});
		
						
	});
	SystemClock.play(r);
)
**
/*
authors so far:
jrh
*/
//SC 3











//here a SythDef gets written to file (directory:
engine/synthdefs)
some UGens and parameters are chosen at random



//wait a bit (writing is asynchronous).
//load it
//play it

//wait

//stop it