Arpeggiation and chords from one Pbind

Hello all,

I am trying to switch between playing an arpeggiation and playing chords in a Pbind. I would ideally like to specify a length of time to play both, and choose between the arpeggiator or playing a chord. If I was playing a chord, I would set the duration to be the overall length of time. If I was playing the arpeggiator, I would like to fill up the overall length of time with individual notes of a single duration. This is what I’m trying right now:

(

~one = [54, 66, 69, 73];

~two = [47, 66, 71, 74];

p = Pdef(

\patt,

Pbind(

\type, Prand([\arp, \chord], inf),

\length, 4,

\ch, Pseq([~one, ~two, ~one, ~two], 1),

\midinote, Pif(Pkey(\type) == \arp, Pseq(Pkey(\ch), Pkey(\length)), Pseq([Pkey(\ch)], 1)),

\dur, Pif(Pkey(\type) == \arp, Pseq([0.25], Pkey(\length)), Pseq([Pkey(\length)*0.25], 1)),

)).play;

)

p.stop;

The issue seems to be the Pkey inside the Pseq in the midinote key. If I add \test, Pkey(\ch).trace,

as a key in the pattern, I seem to get the list of notes I want. However, Pkey(\ch) does not seem to be retrieving the list that Pseq needs. I no longer get an error message when I add .asCollection to the Pkey(\ch), but playing the pattern with that addition doesn’t play any notes.

Is there a different architecture I should be using here? I was looking at Pspawn, but that doesn’t seem to allow me to define the overall length of the arpeggiator or chord player as I would like to. Sorry if this is vague, I seem to be missing some fundamental concepts needed to make this work. I’m on SC3.9 on Linux.

Thanks!

You could certainly do it with Pspawner, but there is a dedicated event key for this: \strum

http://doc.sccode.org/Tutorials/A-Practical-Guide/PG_08_Event_Types_and_Parameters.html

Concerning the Pif + ‘==’ issue see these recent threads

Thanks for the strum tip, and also the info about ==! Lots to look into here.