1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
|
class::Main
categories::Core>Kernel
summary:: The concrete instance of Process
related:: Classes/StartUp
description::
Main is the concrete instance of link::Classes/Process:: (the runtime environment for the virtual machine and interpreter).
Main overrides some methods of Process. There are two methods of interest. One is named startup and is
called after the class library has been compiled. The other is called shutdown which gets called when the library gets re-compiled.
method:: thisProcess
The singleton instance of Main is available through the special keyword thisProcess.
For example, to find out what platform you're on:
code::
thisProcess.platform; // --> e.g. "an OSXPlatform", "a LinuxPlatform", ...
::
classMethods::
subsection:: SuperCollider version
These class methods tell you which version of SuperCollider you are running and whether that version complies to your required minimum / maximum settings:
method::version
returns:: the current version as a human readable string
method::versionAtLeast
Returns code::true:: if we are running version maj.min.patch or newer, false otherwise. If code::min:: and/or
code::patch:: are code::nil::, they will be treated as wildcards. The tweak part of the version is completely ignored.
argument::maj
Major version number as Integer.
argument::min
Minor version number as Integer, or code::nil::.
argument::patch
Patch version number as Integer, or code::nil::.
code::
Main.versionAtLeast(3, 10, 4);
::
method::versionAtMost
Returns code::true:: if we are running version maj.min.patch or older, false otherwise. If code::min:: and/or
code::patch:: are code::nil::, they will be treated as wildcards. The tweak part of the version is completely ignored.
argument::maj
Major version number as Integer.
argument::min
Minor version number as Integer, or code::nil::.
argument::patch
Patch version number as Integer, or code::nil::.
code::
Main.versionAtMost(3, 13, 9);
::
method::scVersionMajor
returns:: major version number as Integer
method::scVersionMinor
returns:: minor version number as Integer
method::scVersionPatch
returns:: patch version number as Integer
method::scVersionTweak
The "tweak" version is typically only used to distinguish pre-release versions of SC from proper releases. It may be
empty.
returns:: tweak version as a String
method::scVersionPostfix
Deprecated. Use code::scVersionPatch:: and code::scVersionTweak:: instead.
instanceMethods::
private::prArgv, prOpenUDPPort
method::startup
Called after the class library has been compiled.
discussion::
This calls the superclass' startup, which among other things initializes the link::Classes/AppClock:: and the top-level link::Classes/Environment::.
Main's startup then stores Server.default in the interpreter variable s, sets the platform default's link::Classes/GUI:: kit, calls a link::Classes/Platform:: specific startup method (for example, OSXPlatform's startup opens the server windows), and finally invokes StartUp.run.
To add your own startup functionalities, you could either edit the special startup-file (discussed in link::Reference/StartupFile::), or use StartUp.add as discussed in the link::Classes/StartUp:: help file.
method::shutdown
Called after SuperCollider is quit or the class library is about to be re-compiled.
discussion::
This will quit all audio link::Classes/Server:: instances, perform a platform specific shutdown (e.g. the HID subsystem is released), finally Process' shutdown method is called, resulting in successive calls to UI.shutdown, NetAddr.disconnectAll, File.closeAll, and Archive.write. To register your own shutdown code, use a call like this:
code::
ShutDown.add({ "Good bye!!".postln });
::
method::run
Override this to do whatever you want, e. g. add a class extension file like this to the class library:
code::
+ Main {
run { "myPatch.rtf".load }
}
::
argument::newFunc
A link::Classes/Function:: or similar object to be set. When evaluated, this function will be passed the arguments time, replyAddr, and message, corresponding to the time the message was sent, the link::Classes/NetAddr:: of the sender, and the message itself as an link::Classes/Array::.
method::addOSCRecvFunc
Register a link::Classes/Function:: to be evaluated whenever SuperCollider language (the client) receives an OSC message. This will not overwrite any previously registered functions.
argument::func
A link::Classes/Function:: or similar object to be added. When evaluated, this function will be passed the arguments msg, time, replyAddr, and recvPort, corresponding to the message itself as an link::Classes/Array::, the time the message was sent, the link::Classes/NetAddr:: of the sender, and the port on which the message was received. Note that this order differs from that used by the deprecated method link::#-recvOSCfunc::.
code::
// post all incoming traffic except the server status messages
// basically the same as OSCFunc.trace
(
f = { |msg, time, replyAddr, recvPort|
if(msg[0] != '/status.reply') {
"At time %s received message % from % on port%\n".postf( time, msg, replyAddr, recvPort )
}
};
thisProcess.addOSCRecvFunc(f);
);
// stop posting.
thisProcess.removeOSCRecvFunc(f);
::
method::removeOSCRecvFunc
Remove a link::Classes/Function:: from the list of those evaluated whenever SuperCollider language (the client) receives an OSC message. This will leave any other registered functions in place.
argument::func
A link::Classes/Function:: or similar object to be removed.
method::replaceOSCRecvFunc
Replace a link::Classes/Function:: in the list of those evaluated whenever SuperCollider language (the client) receives an OSC message with a different one. This will leave any other registered functions in place.
argument::func
The link::Classes/Function:: or similar object to be replaced.
argument::newFunc
A link::Classes/Function:: or similar object to be replace the one being removed. When evaluated, this function will be passed the arguments time, replyAddr, recvPort, and message, corresponding to the time the message was sent, the link::Classes/NetAddr:: of the sender, the port on which the message was received, and the message itself as an link::Classes/Array::.
method::openUDPPort
Attempt to open a new UDP port for receiving OSC traffic. If another application has already bound to the requested port this will fail. Once opened, ports remain bound until SC is recompiled.
If the port was already opened by SC it will return true directly without trying to open the port again.
argument::portNum
An link::Classes/Integer:: indicating the port to attempt to bind.
returns::A link::Classes/Boolean:: indicating whether the attempt was successful.
code::
thisProcess.openUDPPort(3000); // will return true or false.
thisProcess.openPorts; // returns all open ports
::
method::openPorts
Get a collection of all active UDP ports, including the main sclang port code::NetAddr.langPort::.
returns::A link::Classes/Set::.
method::pid
Returns:: The operating system's pid (process ID) for the process.
method::recompile
Recompiles the class library.
method::platform
Get the current link::Classes/Platform::
method::argv
Get the command-line arguments passed to sclang.
|