Main:
Filter:
Classes | Core > Kernel

Main : Process : Object

The concrete instance of Process
Source: Main.sc

Description

Main is the concrete instance of 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.

thisProcess

The singleton instance of Main is available through the special keyword thisProcess. For example, to find out what platform you're on:

Class Methods

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:

Main.version

Returns:

the current version as a human readable string

Main.versionAtLeast(maj, min, patch)

Returns true if we are running version maj.min.patch or newer, false otherwise. If min and/or patch are nil, they will be treated as wildcards. The tweak part of the version is completely ignored.

Arguments:

maj

Major version number as Integer.

min

Minor version number as Integer, or nil.

patch

Patch version number as Integer, or nil.

Main.versionAtMost(maj, min, patch)

Returns true if we are running version maj.min.patch or older, false otherwise. If min and/or patch are nil, they will be treated as wildcards. The tweak part of the version is completely ignored.

Arguments:

maj

Major version number as Integer.

min

Minor version number as Integer, or nil.

patch

Patch version number as Integer, or nil.

Main.scVersionMajor

Returns:

major version number as Integer

Main.scVersionMinor

Returns:

minor version number as Integer

Main.scVersionPatch

Returns:

patch version number as Integer

Main.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

Main.scVersionPostfix

From extension in /usr/local/share/SuperCollider/SCClassLibrary/deprecated/3.10/Main.sc

Deprecated. Use scVersionPatch and scVersionTweak instead.

Inherited class methods

Undocumented class methods

Main.overwriteMsg

Main.packages

From extension in /usr/local/share/SuperCollider/SCClassLibrary/Common/Quarks/packages.sc

Instance Methods

.startup

Called after the class library has been compiled.

Discussion:

This calls the superclass' startup, which among other things initializes the AppClock and the top-level Environment.

Main's startup then stores Server.default in the interpreter variable s, sets the platform default's GUI kit, calls a 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 Sclang Startup File), or use StartUp.add as discussed in the StartUp help file.

.shutdown

Called after SuperCollider is quit or the class library is about to be re-compiled.

Discussion:

This will quit all audio 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:

.run

Override this to do whatever you want, e. g. add a class extension file like this to the class library:

Arguments:

(newFunc)

A 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 NetAddr of the sender, and the message itself as an Array.

.addOSCRecvFunc(func)

Register a Function to be evaluated whenever SuperCollider language (the client) receives an OSC message. This will not overwrite any previously registered functions.

Arguments:

func

A 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 Array, the time the message was sent, the 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 -recvOSCfunc.

.removeOSCRecvFunc(func)

Remove a 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.

Arguments:

func

A Function or similar object to be removed.

.replaceOSCRecvFunc(func, newFunc)

Replace a 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.

Arguments:

func

The Function or similar object to be replaced.

newFunc

A 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 NetAddr of the sender, the port on which the message was received, and the message itself as an Array.

.openUDPPort(portNum)

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.

Arguments:

portNum

An Integer indicating the port to attempt to bind.

Returns:

A Boolean indicating whether the attempt was successful.

.openPorts

Get a collection of all active UDP ports, including the main sclang port NetAddr.langPort.

Returns:

A Set.

.pid

Returns:

The operating system's pid (process ID) for the process.

.recompile

Recompiles the class library.

.platform

Get the current Platform

.argv

Get the command-line arguments passed to sclang.

Inherited instance methods

Undocumented instance methods

.escapeWindow

.exitFullScreen

.hardStop

.platformClass

From extension in /usr/local/share/SuperCollider/SCClassLibrary/Platform/linux/extMain.sc

.recvOSCmessage(time, replyAddr, recvPort, msg)

.showClassBrowser

.showHelp

.showHelpBrowser

.showHelpSearch

.stop