Execute a .scd file from another

Hello everybody, this is probably an easy/beginner one, but i didn’t figure it out.
Lets say i defined some Pdefs, SynthDefs or just global ~variables in a supercollider file and saved it. How can i simply execute all those objects in this file, from another file?
I want to make it so i dont have to open every single file with synthdefs and execute them manually.
Thank you very much

See load (the String method) and Sclang Startup File

1 Like

PathName.filesDo{ |file| } will iterate over all files in all subfolders for a given path (pathname object)

loadPaths will iterate over all files that match a regular expression . if you’re good with those.

SynthDef has certain options / methods such as ‘write to disk’ … you may look into it… and there’s also a ‘SynthDefs’ folder located in your user support directory →

Platform.userAppSupportDir // also in the drop-down, next to save file, etc.

The synthdefs in that directory may get loaded everytime SC starts, or class library recompiled , someone else may know …

You can use Archive.global, it’s a namespace that automatically gets written to file, and loaded at startup… it gets saved as archive.scxtar in the same user support directory… it becomes very useful to always use single letter variables a or r, and point them to Archive.global

You can also use Object.readArchive(string_path), and ~an_object.writeArchive(string_path) , but you have to supply your own paths… the user app support dir is typically the most convenient , in my experiences

1 Like