Saving Functions for future sessions

Is there a possibility to collect my functions somewhere so that supercollider always finds them at startup? I know I can write classes in the Extensions directory, I was wondering if the same is possible for stand-alone functions too?

Is it the supercollidic way to have a class MyFunctions with all my functions as methods of it?!

You can place your functions in the startup.scd file, perhaps as part of an IdentityDictionary. It works just fine,

BUT, since you asked, in the supercollider programming style, one might also consider writing a class for this. Some classes serve as a method to store objects associated with a key, which can be accessed globally. Observe how all the “def” classes are structured. You will notice that each of them has a classvar associated with a Dictionary. Once the class is instantiated anywhere, this dictionary (the key → object pairs) becomes available globally.

MyFuncs {
  classvar <>all;

 *initClass { all =; }

1 Like

using Classes has the added advantage that the signatures are displayed in the IDE etc…

its just annoying that we can’t define classes without recompiling!

Related to this, my quark ddwChucklib has a Func class for global storage of functions to reuse.

{ |a = 10| a.rand } => Func(\random);


\random.eval(10)  // same as Func(\random).value(10)

The “fake ChucK” assignment syntax irritates some – in which case you could also do Func(\random).value = { |a = 100| a.rand };.

You’d still need to load them via startup.scd (or another class’s *initClassTree method) but I find the .eval syntax to be pretty handy.


There are also .load and .loadRelative. For use in the startup.scd in the Platform.userAppSupportDir folder, the .load method is better.

You can organise your functions using environment variables in one or more SCD files.

~doThis = { |...| ... };
~doThat = { |...| ... };

Then add "FilePath".load to the startup.scd file. Each function can be called using the environment variable assigned to it.

I prefer not to write classes or additional methods for existing classes. They should be installed separately (and recompiled) for use. Functions are easier to use, at least for me, especially when working with other people or using many machines.

1 Like