// Last week we made our first sound (well, I did on your behalf) s = Server.local; //Create a local server s.boot; //Boot it // Create and send a Synth Definition file ( SynthDef("simplesine", { var osc1, osc2; osc1 = SinOsc.ar(220); osc2 = SinOsc.ar(440); Out.ar(0, [osc1, osc2]); }).writeDefFile; s.sendSynthDef("simplesine"); ) // Attach to a node on the server s.sendMsg("/s_new", "simplesine", 1000, 1, 0); // Free the node when you are finished s.sendMsg("/n_free", 1000); // Simple! But how do we change values once a synthdef has been sent to the server? // In our sine wave example, lets create an argument to control the frequency ( SynthDef("variablesine", { arg freq; var osc; osc = SinOsc.ar(freq); Out.ar(0, osc); }).writeDefFile; s.sendSynthDef("variablesine"); ) // Play a 440Hz sine wave, node 1000 s.sendMsg("/s_new", "variablesine", 1000, 1, 0, "freq", 440); // Stop it s.sendMsg("/n_free", 1000); // Play an octave higher s.sendMsg("/s_new", "variablesine", 1000, 1, 0, "freq", 880); // Stop it s.sendMsg("/n_free", 1000); // So, how would we play multiple notes at the same time? // // // // // Attach the synthdef to multiple nodes, with different values for the "freq" argument! ( s.sendMsg("/s_new", "variablesine", 1000, 1, 0, "freq", 200); s.sendMsg("/s_new", "variablesine", 1001, 1, 0, "freq", 300); s.sendMsg("/s_new", "variablesine", 1002, 1, 0, "freq", 400); ) // Free the nodes ( s.sendMsg("/n_free", 1000); s.sendMsg("/n_free", 1001); s.sendMsg("/n_free", 1002); ) // Kill the server when you are finished s.quit;