cmake build system: visiblity support for clang
[supercollider.git] / SCClassLibrary / Common / Control / asDefName.sc
blobed9bde03d8b720f9e71bfb6b44891e5e8aba52e0
1 + SynthDef {
3         asSynthDef { ^this }
4         asDefName {     ^name   }
8 + Object {
10         asSynthDef {
11                 error("Cannot convert this object to a SynthDef:" + this);
12                 this.dump;
13                 ^nil
14         }
15         asDefName {
16                 ^this.asSynthDef.name
17         }
22 + String {
23         asDefName { ^this }
26 + Symbol {
27         asDefName { ^this.asString }
30 + Function {
31         /*
32                 this is mainly for  {}.play and Synth({ })
34                 Synth({
35                         SinOsc.ar
36                 })
37                 or:
38                 Synth({
39                         Out.ar(0,SinOsc.ar)
40                 })
42                 it inserts an Out only if it needs it
43         */
45         asDefName { // won't work immediately for Synth.new
46                 var def;
47                 def = this.asSynthDef;
48                 def.send(Server.default);
49                 ^def.name
50         }
52         asSynthDef { arg rates, prependArgs, outClass=\Out, fadeTime, name;
53                 ^GraphBuilder.wrapOut(name ?? { this.identityHash.abs.asString },
54                         this, rates, prependArgs, outClass, fadeTime
55                 );
56         }
58         play { arg target, outbus = 0, fadeTime = 0.02, addAction=\addToHead, args;
59                 var def, synth, server, bytes, synthMsg;
60                 target = target.asTarget;
61                 server = target.server;
62                 if(server.serverRunning.not) {
63                         ("server '" ++ server.name ++ "' not running.").warn; ^nil
64                 };
65                 def = this.asSynthDef(
66                         fadeTime:fadeTime,
67                         name: SystemSynthDefs.generateTempName
68                 );
69                 synth = Synth.basicNew(def.name, server);
70                         // if notifications are enabled on the server,
71                         // use the n_end signal to remove the temp synthdef
72                 if(server.notified) {
73                         OSCpathResponder(server.addr, ['/n_end', synth.nodeID], { |time, resp, msg|
74                                 server.sendMsg(\d_free, def.name);
75                                 resp.remove;
76                         }).add;
77                 };
78                 synthMsg = synth.newMsg(target, [\i_out, outbus, \out, outbus] ++ args, addAction);
79                 def.doSend(server, synthMsg);
80                 ^synth
81         }