Synthdefs folder inaccessible

Hello!

The store method on SynthDef doesn’t work anymore, the scsyndef files are written and saved in the right folder (as verified with SynthDef.synthDefDir), but I can’t play any synth for these registered Synthdefs… (Maximum amount of Synthdefs (1024) is not reached either…)
Any idea on what’s happening?
Thx!

Can you give a minimal example? Can’t quite guess the steps you’re taking based on the description. Also, exact error messages would help.

hjh

SynthDef(\trigseq, {
	var env = Env.asr(0.02, \vol.kr(1), 0.1).ar(2, \gate.kr(1));
	var trig = Decay2.ar(Env.perc(0.01, 0.001).ar(0), 0.001, 0.01);
	Out.ar(\outbus.ar(0), trig*env);
}).store;

Evaluating this code will write a scsyndef file in the right folder, but after quitting and restarting SC, the Synthdef is unknown…

→ Synth(‘trigseq’ : 1019)
*** ERROR: SynthDef trigseq not found
FAILURE IN SERVER /s_new SynthDef not found

I checked with SynthDef.synthDefDir and it’s pointing to the right folder (where my startup file is, which is successfully loaded when SC starts)…

I really don’t get this…
Many thanks

As far as I can see, it is not necessarily correct that the synthdefs/ directory is in the same place as the startup file.

In Linux at least:

File.exists(Platform.userConfigDir +/+ "startup.scd")  // true
File.exists(Platform.userAppSupportDir +/+ "synthdefs")  // true

Now, you haven’t stated which OS, but the rule seems to be that synthdefs are in the user app support directory, and the startup file is in the user config directory.

If you’ve put synthdefs in the config directory, then this is probably a nonstandard path for synthdefs and the server doesn’t know about it. (Educated guess.)

You can check:

s.options.verbosity = 1;
s.reboot;

One of the server-boot messages is “Loading synthdefs from default path: /home/xxxxx/.local/share/SuperCollider/synthdefs” which is the app support directory. The server is not looking in the config directory.

hjh

1 Like

Also useful: ServerOptions help –

.loadDefs = value

A Boolean indicating whether or not to load the synth definitions in synthdefs/ (or anywhere set in the environment variable SC_SYNTHDEF_PATH) at startup. The default is true.

Or, in startup.scd:

ServerBoot.add { |server| server.sendMsg('/d_loadDir', "... put your custom path here...") }

hjh

1 Like

Hi again and sorry, I thought your explanations about directories would solve the problem, but actually my SynthDefs folder is located at the right place, as revealed by the server-boot message ‘Loading synthdefs from default path: …’

I tried and removed the content of the synthdefs folder (except for the default synthdef) to start afresh. I then tried to store new defs.
It seems to be working normally when I create nodes manually with x = Synth(…), but when using streams/patterns (I tried Pbind and Pbindef), the synths are triggered but all the arguments remain unresponsive. The only way is to re-store the exact same Synthdef (or add it) without quitting the application, then it works normally.
I don’t get any error message in the process…

SuperCollider version 3.13.0-rc1 running on a Macbook pro (M1 Max), OS Ventura 13.0.

I hope it will give a better idea of the situation.
Many thx.

… Since I wrote the previous message 15min ago, the situation has changed, some SynthDefs don’t exist anymore (*** ERROR: SynthDef add0 not found) and their file has disappeared from the synthdefs folder!
Seems completely random and erratic…

Hm, I thought that wasn’t the case before.

For the pattern issue, you probably need to SynthDescLib.read in your startup file. This isn’t done automatically, and this requirement is probably not well documented.

This, I don’t know how to explain. In general, only temporary SynthDefs should be deleted. This is very likely to be hard to troubleshoot. I’m certain I can’t reproduce this on demand, and to be honest, I haven’t the time to try very hard at it.

I wonder, do you need to use store at all? I suspect that most perceived advantages of binary SynthDef files would vanish under close inspection.

hjh

1 Like

Thanks again for your fast reply, James.
Regarding the need to store SynthDef, I don’t know how other users like to proceed, but on my side I just like to register them, and to have at least the most used and important of my defs available at all time, without having to ‘add’ Synthdefs before I work on every different project…
Am I misunderstanding something here?

If there are erratic problems with the default SynthDef directory, maybe it might help to maintain your own directory of core SynthDefs, and load them yourself in the startup file.

If something in SC is wiping out files from the default directory, then really there are only 3 ways to proceed: either find where this is happening and fix it, or isolate your stuff away from that directory, or don’t use SynthDef files. The first sounds hard; the second sounds easy; the third doesn’t appeal to you.

I .add SynthDefs in launch scripts, because of course there are a lot of things to load: mixing channels, reverbs, GUIs etc. Most of these can’t be archived in files – they can be initialized only in code. So, I have to run code at load time. Therefore building SynthDefs isn’t an extra step – it’s integrated into the other stuff that I have to load anyway. Because of this, tbh, I haven’t used store in… 15 years? And never missed it.

hjh

1 Like

Oh, and a last detail I forgot: SynthDescLib sends all .added SynthDefs when a server boots. So you could .add defs during language startup, long before booting a server, and they will be transmitted later – no need to run a SynthDef script after server boot.

// Server not booted

(
SynthDef(\boop, { |out, freq = 220, amp = 0.1, decay = 0.15|
	var eg = EnvGen.kr(Env.perc(0.01, decay), doneAction: 2);
	var sig = SinOsc.ar(freq);
	Out.ar(out, (sig * amp * eg).dup);
}).add;
)

s.boot;

(instrument: \boop).play;  // OK!

So I have some classes that use SynthDefs, which .add those in *initClass. Other SynthDefs get built during the load script for my live setup.

hjh