Pdefn holds a named pattern value that can be derived and reused across multiple running streams in SuperCollider
Pdefn (Pattern definition, value level) holds a named pattern that returns scalar values (as opposed to Pdef which plays Events). Multiple pattern proxies can reference the same Pdefn: Pdefn(\y, Pdefn(\x) + 2) creates a transposition that updates automatically when \x is rewritten. This enables a web of derived patterns that all react when the source changes — like live spreadsheet cells. When Pdefn(\x) is rewritten, all streams derived from it pick up the change at their next poll. Pdefn.clear resets all definitions.
Examples
Pdefn(\x, Pseq([0, 2, 0, 7, 6, 5, 4, 3], inf)); Pdefn(\y, Pdefn(\x) + 2); // derived transposition Pdefn(\z, Pdefn(\x) + Pseq([0, 5, 0, 7, 2], inf)); // Rewrite source — all derived patterns change: Pdefn(\x, Pseq([0, 11], inf));
Assessment
Create a Pdefn melody and derive a canon (same melody delayed by 4 beats) and a harmony (melody + 4 semitones) from it. Change the source melody mid-performance and confirm all three parts update simultaneously.