At its core, SuperCollider works in a strictly object oriented way. Although SynthDefs already allow to work with multiple instances of a definition, actual classes can help in many ways. This includes the typical OOP paradigms, such as member variables and methods for quick access to properties and actions.
While SynthDefs can be sent to a server during run time, classes are compiled when booting the interpreter or recompiling the class library. Some possible errors in class definitions are detected and reported by the compiler.
This is just a brief overview, introducing the basic principles. Read the SC documentation on writing classes for a detailed explanation.
Where to put SC Classes
SuperCollider classes are defined in .sc files with a specific structure. For compiling a class when booting the interpreter, it needs to be located in a directory which is scanned by SC. For this reason, an installation of SC creates a directory for user-defined content. Inside sclang, this directory can be shown with the following command:
On Linux systems, this is usually:
For more information, read the SC documentation on extensions.
Structure of SC Classes
The following explanations are based on the example in the repository. A class is defined inside brackets, with the class name:
Member variables are declared in the standard way for local variables. They can be accessed anywhere inside the class.
Constructor and Init
The constructor calls the init() function in the following way for initializing values and other tasks on object creations:
Creating Help Files
In SC, help files are integrated into the SCIde for quick access. Help files for classes are also created during compilation. They need to be placed in a directory relative to the .sc file with the extension .schelp:
Read the SC documentation on help files for more information.