Local Classes/Functions for a Project?

Good afternoon SuperCollider Community,

I’m currently working on developing a some code for a self-contained project that includes code in some other languages as well. What I would like to do is be able to do something like an #include to include local Supercollider functions, and, if possible, have classes local to my project that I read and then compile when starting up.

I’m sure there’s a preferred way of doing this, so I’m asking the community - what’s the most canonical way of handling this and ensuring that code is local and reusable ?


Here are my thoughts, from my experience:

  1. “include” a SuperCollider file at runtime using path.load(), or path.loadRelative(). This works for variables, functions and notably for object prototypes, and it’s the way I currently use the most to modularize my code.
    EDIT: I initially wrote those functions wrong, sorry. Here is the related documentation

  2. But that doesn’t work with Classes, which need the class library to be recompiled in order to be included. Here are some ideas about how to achieve that:

Then you can install that Quark/Extension, publish it, share it, reuse it. But then, if you have a Quark or Extension installed, it wouldn’t be so local anymore (i.e. it would be always included)

  1. At this point it depends on if you want to use scide or to launch sclang directly, but you could craft a project-specific library configuration file that would list all your includePaths for that project, and load it when you launch sclang:
$ sclang -l /path/to/config/file.yaml
  1. Or, last option for me, would be to add includePaths to config at runtime, but since you need a store and recompile every time you modify them, it’s not that flexible as it sounds (I admit I have never ever used this):
LanguageConfig.store; // here you are saving to your default config file
1 Like

This is super duper helpful - thank you!

1 Like