The first problem here is that port numbers are 16 bits, unsigned â maximum 65535. (Not a limitation in SC â every app is subject to this.)
If you try to boot the server with port number 77110, sclang will be unable to communicate with it. So your script will hang, waiting forever for boot.
Here, I think your troubleshooting efforts might have been flummoxed by jumping immediately to commandline use. If you had tested your block of code in the IDE first, you would have seen that the server status indicator goes yellow and freezes â valuable information!
Try port 62110 or such.
The second problem is that, by default, indeed SynthDef:add
sends only to the default server. (I was thinking of something else last night⌠my mistake.)
There are two ways to deal with that. One is documented: âA server can be added by SynthDescLib.global.addServer(server)
.â
(
~myServer = Server(\myServer, NetAddr("127.0.0.1", 62110));
SynthDescLib.global.addServer(~myServer);
~myServer.waitForBoot {
SynthDef(\sine, {
var snd;
snd = SinOsc.ar(\freq.kr(440));
snd = snd * Env.perc(0.01, 0.3).ar(Done.freeSelf);
// btw I'm on headphones now, so the example as written
// will blast full-scale audio into my left ear only.
// (the Synth call specifies amp: 0.1 but there's no amp arg!)
// so I'm gonna fix that here: proper amp scaling + L-R dup
Out.ar(0, (snd * \amp.kr(0.1)).dup);
}).add;
~myServer.sync;
Routine({
10.do {
Synth(\sine, [freq: exprand(100, 8000), amp: 0.1], ~myServer);
rrand(0.1, 0.5).yield;
};
0.exit;
}).play;
};
)
The other is⌠if you arenât using the original default server for anything, you can simply make your new server the default⌠and then donât worry about it. I think this is easier because, in the above case, you have to remember to tell the Synth() to go to ~myServer â you will forget this sometimes.
// this, at the beginning of Nathan's script
Server.default = s = Server(\myServer, NetAddr("127.0.0.1", 62110));
Or, just change the addr of the default server:
Server.default.addr = NetAddr("127.0.0.1", 62110);
hjh