home/ atoms/ sc-writing-methods-extensions

SuperCollider allows adding new methods to existing classes via extension files placed in the Extensions folder

Custom methods in SuperCollider are defined in .sc files outside the main application. A method extension uses + ClassName { methodName { ... } } syntax, which opens the class and adds a new method. These files must be saved in one of SuperCollider’s extension folders (e.g., ~/Library/Application Support/SuperCollider/Extensions). After saving, the class library must be recompiled. An extension method on SimpleNumber, for instance, can add a convenience conversion like 144.tempodur (beats-per-minute to seconds-per-beat). This approach avoids modifying the SC source while extending its vocabulary for a project.

Examples

+ SimpleNumber { tempodur { ^(60/this) } durtempo { ^(60/this) } } — saved as a .sc file in Extensions, adds 144.tempodur → 0.4167

Assessment

Where must a method extension file be saved for SuperCollider to find it? What must you do after saving the file before 60.tempodur will work?

“The first step to writing a new class or method, is to have some idea of the functionality you want to add”
corpus · supercollider-tutorials-full-transcripts-and-code-eli-fields · chunk 102