Chucklib storage classes


Four types, categorized by index type and creation method:


Index

Creation type

Abstract class

Collection class

Integer

prNew

AbstractChuckArray

Array

Integer

Automatic

AbstractChuckNewArray

Array

Symbol

prNew

AbstractChuckDict

IdentityDictionary

Symbol

Automatic

AbstractChuckNewDict

IdentityDictionary


Automatic creation types are for objects which may have an unlimited number of instances (such as process prototypes or bound processes):


PR(\aiMel) => BP(\mel1); 


prNew types require you to create the instance explicitly using prNew before chucking something into it. Intended for objects and that require only a few instances that are reused over and over (like VP, VoicerProxy). The use of prNew prevents you from accidentally creating extra instances that might mess up a GUI, for instance.


VC(\buzz) => VP.prNew(0); 


For array prNew types, common usage is to create the arrayed instances during initialization:


6.do({ |i|

VoicerProxy.new => VP.prNew(i);

// here you can make a gui for the new VoicerProxy if you want

});

VC(\buzz) => VP(0); 



General methods


*all

*values

Returns all the instances of the given storage class.


PR.all;


*keys

Returns all the indexes (for array classes) or names (for dictionary classes) of the instances of this class.


PR.keys;


*exists(index) or *exists(name)

Answers whether an object exists at the index or name specified.


PR.exists(\thisDoesntExist); // returns false

PR.exists(\mel1); // this does exist, returns true


*freeAll

Release all of the objects in the storage class.


collIndex

When addressed to an instance of the storage class, responds with its index or name.


v

value

Responds with the object being stored in this storage object. If the passThru flag (see below) is true, it may not be necessary to access the object explicitly. v is included as a short form for convenience.


Note one exception: Func responds to .value by executing its function, rather than returning the function. If you need to get the function object itself, use v.


exists

A storage class instance may exist but not hold anything at this time. Check whether the storage object is active using this method. Answers with a Boolean.


free

Release the object held in this storage instance.


path

If the object was loaded from a file saved on disk, this method answers with the full path to that file.


openFile

If the path for this object exists, open the file in a document window.


*prNew(index) or *prNew(name)

Should be used only for classes that require explicit creation of instances, as described above.


VoicerProxy.new => VP.prNew(0);


*passThru

*passThru_(bool)

A flag that determines whether or not messages that storage classes do not respond to will be passed automatically to the object being stored. If this flag is false, you must explicitly access the value of the storage object before addressing messages to the target. The default is true, meaning that explicit access is often not required.


The flag applies to all storage classes simultaneously; it is not independent per class.


Note that because of the ways SuperCollider looks up messages, if the storage class implements a method, that method will "swallow" the call and the message will not be delegated to the target. Usually this is not problem, but watch out for methods defined in Object.



Convenience methods


*runFile

Present an open file dialog to the user. After the file is chosen, execute its contents.


*loadGui

Load the GUI definition saved in Prototypes/gui.txt.


*open

*openCodeDoc(path)

After the GUI definition is loaded, coordinates for a document window should be saved in Library.at(\codeBounds). These methods open a document and automatically move it to those coordinates. openCodeDoc takes the path as an argument; open lets the user choose the file from an open file dialog.




Subtypes


Related objects may be grouped together under a subType identifier. This allows you to access the objects as a group. I use it to categorize the built-in objects defined in the prototypes directory. During performance, they can keep all the objects belonging to a section/piece/track under the same subType; then, when that section is over, I can release all of its objects using the group identifier.


*defaultSubType

*defaultSubType_(symbol)

Get or set the default subType. From that point forward, new objects will be assigned this subType automatically. This applies globally to all storage classes; it cannot be set individually per class.


subType

subType_(symbol)

Get or set the subType for a given instance.


*subTypes

Responds with an array of the unique subTypes that exist in the storage class.


PR.subTypes;


*allOfType(symbol)

Responds with an array of the objects in this storage class that have the given subType.


PR.allOfType(\drumSequencer);


*freeType

Release all the objects in the storage class that have the given subType.


*freeTypeAll

Go through all storage classes and release all the objects that have the given subType. This is a very useful "seek and destroy" method to clean up at the end of a section of a larger performance.



The classes 


Process management


PR -- Process prototype

BP -- Bound Process


Voicer and Synth management


Fact -- factory -- automatic creation 

VC -- VoiCer -- automatic creation 

SY -- SYnth -- automatic creation


GUI management


VP -- VoicerProxy -- prNew 

MCG -- MixerChannel Gui -- prNew 

MT -- MIDI Trigger -- automatic


MIDI input management


MBM -- MIDIBufManager -- prNew 

MRS -- MIDIRecSocket 


Process component management


Func -- adaptation function -- automatic 

ProtoEvent -- automatic 

Mode -- automatic 


MicRh -- microrhythm -- automatic

MacRh -- macrorhythm -- automatic

ArpegPat -- arpeggiation pattern -- automatic