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:

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!