MemoRoutine:
Filter:
miSCellaneous_lib/Classes (extension) | Libraries > miSCellaneous > PSx stream patterns | Streams-Patterns-Events > PSx stream patterns

MemoRoutine
ExtensionExtension

Routine-like object which stores last values

Description

A MemoRoutine behaves like a Routine, though it is not defined as a subclass of it. It stores last values, the maximum buffer size can be defined. MemoRoutine is internally used by PSx and related Pattern classes, which therefore also remember their last value(s).

Class Methods

.new

Creates a MemoRoutine instance with the given Function.

Arguments:

func

Function to instantiate the Routine with.

stackSize

Call stack depth, defaults to 512.

bufSize

Number of last values to store, defaults to 1.

copyItems

Determines if and how to copy items, which are returned by method next (run, value, resume) and which are either non-Sets or member of Sets, into the buffer. Takes Integer 0 (or false or Symbol \false), 1 (or true or Symbol \true) or 2 (or Symbol \deep). Other values are interpreted as 0. Defaults to 0.

0: storage of original item

1: storage of copied item

2: storage of deepCopied item

copySets

Determines if to copy Sets (and hence Events), which are returned by method next (run, value, resume), into the buffer. Takes Integer 0 (or false or Symbol \false), 1 (or true or Symbol \true). Other values are interpreted as 0. Defaults to 1.

0: storage of original Set

1: storage of copied Set

NOTE: The distinction of copying items and sets makes sense in the case of event streams. Per default Events are copied (copySets == 1), not their values (copyItems == 0). By playing Events those are used to store additional data (synth ids, msgFuncs …) which is mostly not of interest when refering to the event stream, e.g. with PSx patterns which use MemoRoutine - copied Events will not contain this additional data. If values of Events or values returned directly by the stream (being no kind of Sets) are unstructured then copying makes no sense, this is the normal case, so copyItems defaults to 0. When going to alter the ouput, you might want to set copyItems to 1 for a MemoRoutine returning simple arrays or 2 for nested arrays (deepCopy). For deepCopying Events you'd have to set copySets to 1 and copyItems to 2 (an option copySets == 2 doesn't exist as it would be contradictory in combination with copyItems < 2).

Instance Methods

.next

Arguments:

inval

Same conventions with method yield as with aRoutine.next.

.value

Same as next.

.resume

Same as next.

.run

Same as next.

.lastValue

Last value.

.lastValues

Instance variable getter method for array of stored last values.

.at

Returns ith item of array of last values (keep in mind reversed order: last value first).

.bufSize

Size of array of last values.

.reset

Resets the MemoRoutine by resetting its Routine.

.stop

Stops the MemoRoutine by stopping its Routine.

.count

Instance variable getter and setter methods. Counts each call of next / value / resume / run.

.copyItems

Instance variable getter and setter methods. If used directly the Integer copy code must be passed (see above).

.copySets

Instance variable getter and setter methods. If used directly the Integer copy code must be passed (see above).

.routine

Instance variable getter and setter methods.

Examples