home/ atoms/ sc-stream-is-consumable

Calling .asStream.next consumes a SuperCollider pattern's stream, which cannot be rewound

In SuperCollider a pattern is a reusable recipe, but the stream produced by .asStream is a consumable instance: each .next call yields the next item and advances the stream, and a spent stream cannot be rewound. Handing the same stream reference around therefore yields no items after it is exhausted. The discipline is to re-.play the pattern (making a fresh stream) rather than sharing a partially-consumed stream reference. Confusing the recipe (pattern) with the instance (stream) is a subtle source of silent voices.

Examples

p = Pseq([0,2,4], inf); q = p.asStream; q.next; q.next; // advances/consumes q p.asStream; // a fresh, independent stream — the recipe is reusable

Assessment

Explain the difference between an SC pattern and the stream from .asStream, and why sharing a spent stream produces no further notes.

“`.asStream.next` consumes a pattern** — patterns are recipes, streams are the consumable instances. Re-`.play` a pattern; don't hand a spent stream around.”
context/ · L1-instruments/supercollider/gotchas.md · chunk 1