[sc-users] how to use initClass with synthdefs?

chris chris at oedo.net
Fri Dec 1 08:42:14 PST 2006


Dan Stowell wrote:
> The thing to bear in mind is that the initClass methods run when the
> lang is (re)compiled - i.e. typically when the server is not yet
> booted. So "send(s)" will do nothing, it will send to a basically
> nonexistent server. The only way is to use a disk-writing method like
> .writeDefFile or .writeOnce.

right, i suspected as much, thanks for clarifying it :)

> You've said you don't want to save the SynthDef - why? If you're
> really sure you don't, then there's no point using initClass at all.

just to keep things tidy, more than anything. i figured a class could 
use synths that really have no use in other classes, and it wouldn't 
make sense to store these on the actual disk, if the class could make 
them 'as required'...

> You should instead do something like:
> 
> * define an instance variable in the class like synthdefssent=false
> * when the class is called to do its stuff, if(synthdefssent.not, {
> send the synthdefs; synthdefssent=true})
> 
> (that works assuming an instance of the class only deals with one
> server, which is very often true)

...or, i guess, it wouldn't do any harm if i simply send the sythdefs 
through when i instantiate the class - if they're already on the server, 
they'll just be over-written with themselves, which shouldn't cause too 
many problems, i think?

thanks for the reply anyway, dan :)

>> can anyone point me in the direction to go regarding *initClass and
>> synthdefs?
>>
>> I've tried this
>>
>> Bob {
>>         *initClass {
>>                 var s = Server.default;
>>
>>                 SynthDef(\etc,{ ........ }).send(s);
>>
>>         }
>> }
>>
>> and it doesn't seem to work (i get FAILURE /s_new SynthDef not found). i
>> don't really want to load these synthdefs and save them, i'd rather this
>> class compiled them when it needed them.


More information about the sc-users mailing list