EventStreamCleanup:
Filter:

EventStreamCleanup : Object

Helper class that collects information about internal state of streams that needs to be released

Description

Event streams created by objects like Pmono or Pfx are special: when they start, they create some state (like a new synth) that is present over the whole period of the stream, or at least over several events. When such a stream ends, it releases this state. There are other streams, however, that may stop their input stream at any time (e.g. Pfindur or Pdef). Them the state of any stream buried in the hierarchy of input streams must be released by them. EventStreamCleanup collects the cleanup functions and can run them when the stream is cut.

NOTE: So all event patterns that can end a subpattern (and streams respectively) have to use an EventStreamCleanup.

Some examples of patterns that may stop an input stream and update an EventStreamCleanup:

Some examples of patterns that create state that lasts over several events. They also release the state via EventStreamCleanup:

Class Methods

EventStreamCleanup.new

Create a new instance.

Inherited class methods

Instance Methods

.addFunction(event, function)

Add a new cleanup function which will be called when the stream is made to end somewhere downstreams. This is called only in patterns that create resources that need to be released (e.g. Pmono or Pfx).

Arguments:

event

The outevent that is passed on downstreams and which communicates to any stream-ending pattern what needs to be done to release the resources. It must be yielded after update!

function

The function that is called for cleanup. E.g. { group.free }.

Returns:

a CallOnce that executes the cleanup function at most once. Should it be necessary to execute the cleanup outside of the control of EventStreamCleanup, the CallOnce returned should be used instead of the original function, so that other referents are informed of the execution of the cleanup.

.update(event)

For every new event, the cleanup must be updated to receive information from any input stream further up. This method is called from all streams that may stop early (e.g. Pmono or Pfindur).

Arguments:

event

The outevent from the input stream. It must be yielded after update!

.exit(event, freeNodes: true)

Run all functions that have been collected over time, adding appropriate information to the event, in case it is passed on as an inevent.

Arguments:

event

The inevent that is passed through to the outer stream

freeNodes

Used internally.

Returns:

An event. In embedInStream, this event must be returned (^cleanup.exit(inevent))

.functions

.functions = value

A collections of cleanup functions.

.clear

Empty the cleanup functions, without evaluating them.

.terminate(freeNodes: true)

Run all functions that have been collected over time without adding information to an event.

Arguments:

freeNodes

Used internally.

Inherited instance methods

Undocumented instance methods

.addNodeCleanup(event, function)

.copy

Examples