hey,
i have a function which creates fractals from an initial rhythm pattern and stores them as Pseqs
in a dictionary. i would then sequence different indices of this dictionary with Pdict
to access the different fractal rhythms likes this:
(
// fractals from initial rhythm: [ 3, 1, 2, 2, 1, 3 ] stored in ~durations
~durations = [
[ 12 ],
[ 6, 6 ],
[ 6, 3, 3 ],
[ 3, 3, 3, 3 ],
[ 3, 3, 2, 1, 3 ],
[ 3, 1, 2, 2, 1, 3 ], // initial rhythm at index 5
[ 2, 1, 1, 2, 2, 1, 3 ],
[ 2, 1, 1, 2, 2, 1, 2, 1 ],
[ 2, 1, 1, 2, 1, 1, 1, 2, 1 ],
[ 1, 1, 1, 1, 2, 1, 1, 1, 2, 1 ],
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1 ],
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
];
~getDict = { |durations|
var arrays, dictionary = ();
dictionary.clear;
durations.do { |array, key|
dictionary.put(key, Pseq(array, 1));
};
dictionary;
};
// store Pseqs with durations in a dictionary
~patDict = ~getDict.(~durations);
// sequence of indices
~index = Pseq([0, 4, 2, 1], 1);
)
// sequence different fractal patterns with Pdict
x = Pbind(\instrument, \default, \dur, 0.125 * Pdict(~patDict, ~index).trace).play;
x.stop;
lets say i would convert these arrays stored in ~durations
into binary form like this:
(
~binaryDurations = [
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
[ 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 ],
[ 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0 ],
[ 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0 ],
[ 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0 ],
[ 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0 ],
[ 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0 ],
[ 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1 ],
[ 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1 ],
[ 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1 ],
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1 ],
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
];
)
and would store them in a dictionary like this:
(
~getDict = { |durations|
var arrays, dictionary = ();
dictionary.clear;
durations.do { |array, key|
dictionary.put(key, array);
};
dictionary;
};
~patDict = ~getDict.(~binaryDurations);
)
how can i sequence different arrays in binary form stored in ~patDict
to use them as a trigger mask with the following SynthDef to create a rhythmic meso / macro structure? is it in anyway possible when using the .set method to access a different array of ~patDict
to sync these with the triggers from Impulse.ar
? how would you go about that?
(
var hanningWindow = { |phase|
(1 - (phase * 2pi).cos) / 2 * (phase < 1);
};
var triggerMask = { |trig, maskOn, sequence, mod|
var mask = Demand.ar(trig, 0, Dseq([Dser(sequence, mod)], inf));
mask.poll(trig, 'sequence');
trig * Select.ar(maskOn, [K2A.ar(1), mask]);
};
SynthDef(\pulsar, {
var tFreq = \tFreq.kr(10);
var trig = triggerMask.(Impulse.ar(tFreq), \maskOn.kr(1), \sequence.kr(Array.fill(16, 1)), \mod.kr(16));
var grainFreq = \freq.kr(400);
var phase = Sweep.ar(trig, grainFreq);
var grainWindow = hanningWindow.(phase);
var sig = sin(phase * 2pi);
sig = sig * grainWindow * \amp.kr(0.25);
sig = Pan2.ar(sig, \pan.kr(0));
OffsetOut.ar(\out.kr(0), sig);
}).add;
)
// masking sequence
~sequence = [1, 0, 1, 1, 0];
x = Synth(\pulsar, [\tFreq, 10, \freq, 800, \maskOn, 1, \sequence, ~sequence, \mod, 5]);
// use another sequence
x.set(\sequence, [1, 1, 0, 0, 1]);
// set mod
x.set(\mod, 3);
// disable trigger mask
x.set(\maskOn, 0);
x.free;