Overview
These are my notes on the Event Class in SuperCollider, a very deep and complex Class which can be used in several ways.
The Event Class
The Event class is a deep-level subclass of Collection. Because of that, the Event class is designed to hold multiple pieces of information inside a single object. This is done via Key-Value-Pairs. These key-value pairs exist within the Event object’s own namespace, meaning they are specific to each Event instance.
// make a event
e = ();
// make a event with multiples key-value pairs
e = (foo: 7, faa: 3, fee: -12);
e.class; // check the class of the object 'e'
e.keys; // check the keys of the event
e[\foo]; // return the value at the key 'foo'
e.foo; // do the same as above
Event Types
The Event class has several predefined Event Types like note, rest and midi. The default type is note.
Event.eventTypes.keys.postln; // returns all predefined event typesWhen you play a empty event, e.g. with the method .play you actually play a event of the type note. This is done with a default instrument, which is part of the default event type ‘note’ and has the name default. You can look this up in the implementation of the Event class.
So playing a note generates a Synth of the SynthDef ‘default’
().play; // this plays the default event type 'note'
(type: \note).play; // do the same as above
(type: \note, instrument: \default).play; // do the same as above
(type: \note, instrument: \mySynthDef, amp: 0.1).play; // play a event with your own SynthDef and arguments
(type: \note, instrument: \mySynthDef).play; // play a event with your own SynthDef and the default arguments of the event type 'note'You can also interchange the instrument ‘default’ by your own SynthDef, which makes all of you arguments of this SynthDef avaiable. The event type ‘note’ has several default arguments like freq, amp and others with default values. These default values will overwrite the default argument values of your SynthDef, since the Synth is called with the default argument values of the Event Type ‘note’.
You can check the implemented default values via this command:
Event.parentEvents.default[\degree].postcs;\Event.parentEvents.default.keys.postcs;\ // return all standard-keys of the default Event Type 'note'Partial Events
Partial events are modular building blocks of an Event. Each partial event is a set of keys related to a specific aspect of an Event’s functionality (e.g., amplitude, duration, MIDI).
They allow complex Events to be composed by combining multiple partial events, making event definitions flexible and reusable.
Partial events are stored in the class variable `Event.partialEvents` as a dictionary mapping names to sets of keys.
// returns all partialEvents and for each of them the set of keys belonging to it
(
Event.partialEvents.keys.do{ |n|
n.postln;
Event.partialEvents[n].keys.postln;
\.postln;
};\
)