Hi there, I’m trying to make an Event pattern (
Pbind), but where different Events may have different keys (i.e. different sets of data that “belong together”). You can do cool things with arrays of keys and arrays of values (or
Ptuples of Patterns), which gets close to what I’d like. But I’d like the keys not to be from a fixed set, but per-Event. What I’d like, would be a sequence where the keys and values come from the same place… (Hmm, sounds like…Events.
Arrays/tuples work great, when you have data where all the keys are the same for each Event:
( // degrees, amps and durations that "go together": var degreeAmpDurs = [[0,0.1,0.5], [2,0.4,1], [4,0.1,0.125], [3,0.4,0.125]]; Pbind(#[degree, amp, dur], Pseq(degreeAmpDurs)).trace.play; ) // ( 'degree': 0, 'dur': 0.5, 'amp': 0.1 ) // ( 'degree': 2, 'dur': 1, 'amp': 0.4 ) // ( 'degree': 4, 'dur': 0.125, 'amp': 0.1 ) // ( 'degree': 3, 'dur': 0.125, 'amp': 0.4 )
But what about if you want a mix of “heterogeneous” Events that go together, where each could have a distinct set of keys? Is it “okay” to just use a
Pseq (for example) that holds the Events? I guess my question is: Is a
Pseq of Events different in any important way, compared to a
Pbind (e.g. for composing, chaining, etc.)? As far as I can tell so far with the tests I’ve done, it seems to work pretty well…
( var variedEvents = [(note: 2, amp: 0.1), (midinote: 67, amp: 0.3, detune: 0.1), (freq: 300, lag: 0.1, dur: 0.75), (degree: 2, scale: Scale.minor)]; (Pseq(variedEvents) <> (dur: 0.25)).trace.play ) // ( 'dur': 0.25, 'amp': 0.1, 'note': 2 ) // ( 'dur': 0.25, 'amp': 0.3, 'midinote': 67, 'detune': 0.1 ) // ( 'dur': 0.75, 'lag': 0.1, 'freq': 300 ) // ( 'degree': 2, 'dur': 0.25, 'scale': Scale([ 0, 2, 3, 5, 7, 8, 10 ], ...) )
I am possibly overthinking it. But I just want to know if I might run into any problems, where
Pbind would do something extra, compared to a literal sequence of Events. (One obvious difference might be if you wanted some of your parameters to be pattern-based – say you wanted some of the
amp values to use
Pexprand – but I think you can solve quite a bit with chaining).