2 summary:: Mark Polishook tutorial
3 categories:: Tutorials>Mark_Polishook_tutorial
4 related:: Tutorials/Mark_Polishook_tutorial/00_Introductory_tutorial
6 section::Networks and client/server
8 SuperCollider 3 uses a client/server model to operate across a network. What this means is that users write client programs that ask a server to do something, that is, they request service. Such requests can occur locally on one computer or they can be distributed remotely among two or more computers. Whether the computers are in the same room or separated across the world makes no difference as long as they're connected on a network.
10 Client programs in SuperCollider typically specify synthesis definition (how a particular sound will be made) and synthesis scheduling (when a particular sound will be made). In turn, a SuperCollider server (or servers) synthesizes audio according to client instructions.
12 To summarize, clients request; servers respond.
14 section::Client/server examples
17 ////////////////////////////////////////////////////////////////////////////////////////////////////
18 // EX. 1 - execute each line, one at a time
19 // define a synthesis process and make a client request to a server
20 ////////////////////////////////////////////////////////////////////////////////////////////////////
22 // define a server with a name and an address
23 s = Server("aServer", NetAddr("127.0.0.1", 56789)); // "localhost" is a synonym for an ip of // "127.0.0.1"
27 // define a synthesis engine
28 SynthDef("sine", { Out.ar(0, SinOsc.ar(440, 0, 0.2)) }).send(s);
30 // schedule (run) synthesis
31 s.sendMsg("s_new", "sine", n = s.nextNodeID, 0, 1);
33 // stop the synth (delete it)
34 s.sendMsg("/n_free", n);
36 // (optionally) stop the server
41 ////////////////////////////////////////////////////////////////////////////////////////////////////
43 // the same as in above, except on 2 computers across a network
44 ////////////////////////////////////////////////////////////////////////////////////////////////////
46 // define a (remote) server; it represents a computer "somewhere" on the internet"
47 // the ip number has to be valid and the server, wherever it is, has to be running
48 // servers cannot be booted remotely, eg, a program on one machine can't boot a server on another
49 // this example assumes the server on the remote machine was booted from within
50 // supercollider and not from the terminal
51 s = Server("aServer", NetAddr("... an ip number ...", 56789));
53 // define a synthesis engine ... exactly as in the previous example
54 SynthDef("sine", { Out.ar(0, SinOsc.ar(440, 0, 0.2)) }).send(s);
56 // schedule synthesis ... exactly as in the previous example
57 s.sendMsg("s_new", "sine", n = s.nextNodeID, 0, 1);
59 // stop the synth (delete it)
60 s.sendMsg("/n_free", n);
64 ////////////////////////////////////////////////////////////////////////////////////////////////////
66 // client/server on one computer vs. client server on two computers
67 // the previous examples without comments
68 // they're identical except that
69 // the example that runs on one computer explicitly boots the server
70 // the example on 2 computers _assumes the server "somewhere" on the internet is booted
71 ////////////////////////////////////////////////////////////////////////////////////////////////////
74 s = Server("aServer", NetAddr("localhost", 56789));
76 SynthDef("sine", { Out.ar(0, SinOsc.ar(440, 0, 0.2)) }).send(s);
77 s.sendMsg("s_new", "sine", n = s.nextNodeID, 0, 1);
78 s.sendMsg("/n_free", n);
82 // on two computers ... the server has to have a valid ip address
83 s = Server("aServer", NetAddr("... an ip number ...", 56789));
84 SynthDef("sine", { Out.ar(0, SinOsc.ar(440, 0, 0.2)) }).send(s);
85 s.sendMsg("s_new", "sine", n = s.nextNodeID, 0, 1);
86 s.sendMsg("/n_free", n);
89 section::Localhost and internal servers
91 The previous examples define server objects. But, for the most part, this isn't necessary as SuperCollider defines two such objects, the localhost and internal servers, at startup. They're represented by windows at the bottom of the screen. Each of the windows has a boot button to start its respective server.
93 See the link::Guides/ClientVsServer::, link::Classes/Server::, and link::Classes/ServerOptions:: and link::Tutorials/Tutorial:: documents in the SuperCollider help system for further information.
95 ////////////////////////////////////////////////////////////////////////////////////////////////////
97 Go to link::Tutorials/Mark_Polishook_tutorial/06_Prerequisites::