home/ atoms/ sc-pchain-ppar-composition

Pchain and Ppar compose event patterns by layering key sources or running multiple patterns in parallel

Pchain(a, b) creates a new Event Pattern where each event inherits keys from pattern b first, then overlays keys from pattern a. It is the functional equivalent of inheritance at the event level. Ppar([a, b]) runs multiple Pbinds simultaneously on the same clock, ending when the longest pattern finishes. These combinators let you build complex musical textures from simple independent layers: one Pbind controls pitch, another controls timing, a third adds volume contour, and Pchain assembles them. This is the compositional equivalent of mixing buses in audio.

Examples

a = Pbind(\scale, Pn(Pstep([[0,2,4,5,7,9,11]], 5))); b = Pbind(\degree, Pbrown(0, 6, 1), \dur, 0.2, \octave, 6); c = Pbind(\degree, [0,2,4], \dur, 0.4); Pchain(Ppar([b, c]), a).play

Assessment

Write a Ppar with three independent rhythm patterns (kick, hi-hat, snare) that share a common scale pattern via Pchain. Modify only the scale pattern to change the tonality of all three layers.

“a = Pbind(*[ scale: Pn( Pstep([[0,2,4,5,7,9,11], [0,1,3,5,6,8,11] ], 5 ) ), db: Pn(Pseg([-20, -30, -25, -30], 0.4)) ]);”
corpus · the-supercollider-book-official-code-examples-scbookcode-gpl · chunk 145