Pnshuf:
Filter:
ddwPatterns/Classes (extension) | Streams-Patterns-Events > Patterns > List

Pnshuf
ExtensionExtension

Partial-shuffle list pattern

Description

Like Pshuf, Pnshuf streams out the members of a list in random order.

The differences are:

"local" flag

Two behaviors are available:

Patterns are normally supposed to be stateless, so that they can be embedded into any stream, anywhere, and each stream exhibits independent behavior. The default, local = true, follows this principle.

Local = false, then, is safe only if you are sure that a particular Pnshuf instance will be embedded in only one stream at a time -- no parallel usage! If you need parallel usage and local = false, you should have a separate Pnshuf instance for each parallel stream.

Class Methods

.new

Create and return a new Pnshuf instance.

Arguments:

list

The list of items to be shuffled and streamed out.

repeats

How many of these items to stream out in one embedding.

local

If false (default), parallel-safe, but items may repeat before all the others are streamed out. If true, each ordering will be used in full, but the pattern object will not be safe for parallel streaming.

Instance Methods

.local

Get or set the local flag (Boolean).

Examples

Local = true: "3, 2, 1" vs "3, 4, 2" vs "4, 2, 1" etc. are all completely independent shuffles -- hence, starting at the beginning of this output, the value 3 appears a second time, before 4 had a chance to appear.

With local = false, the shuffled orderings are "2, 4, 1, 3" vs "1, 2, 4, 3" vs "1, 2, 3, 4" etc -- but the interspersed 100s interrupt these.

As a series of pitches (non-local streaming):