Swap method makes it easy to quickly change Pdefn to temporary alternative, for example to mute it after the first beat, with possibility to resume again
--- /dev/null
+GlobalDict {
+ classvar <>all;
+ *initClass {
+ all = IdentityDictionary.new;
+ }
+
+ *removeAll {
+ this.all.clear;
+ this.all.makeEmpty;
+ }
+
+ *at { arg key;
+ ^this.all.at(key)
+ }
+
+ *put { arg key, value;
+ ^this.all.put(key, value)
+ }
+}
\ No newline at end of file
--- /dev/null
++ Pdefn {
+ swap {|newPattern|
+ var tempSource, keyName;
+ keyName = (\Pdefn++this.key).asSymbol;
+ if(newPattern.isNil) {
+ tempSource = source;
+ this.source = GlobalDict.at(keyName);
+ GlobalDict.put(keyName, tempSource);
+ } {
+ switch (newPattern,
+ \fbs, { newPattern = Pseq([1, Pseq([Rest(1)], inf)]) },
+ \s, { newPattern = Rest(1) }
+ );
+ GlobalDict.put(keyName, source);
+ this.source = newPattern;
+ }
+ ^this
+ }
+}
])).quant_(4).play;
TempoClock.tempo = 2;
-Pdefn(\durtest, Pseq([1, Pseq([Rest(1)], inf)], inf)).quant_(4);
+Pdefn(\durtest, 1).quant_(4);
+//Pdefn(\durtest, Rest(1)).quant_(4);
+//Pdefn(\durtest, Pseq([1], 1)).quant_(4).play;
+Pdefn(\durtest).swap;
+Pdefn(\durtest).swap(\fb);
Pdef(\temp, Pbind(*[
instrument: \dyti,
db: -19,