When not only scrambling one would also want to define the number of choices.
I'd rewrite Prandc with a length arg:
Prandc : ListPattern {
var <>length;
*new { arg list, repeats = inf, length;
^super.new(list, repeats).length_(length ?? { list.size })
}
embedInStream { arg inval;
var item, stream;
var localList = { list.choose } ! length;
repeats.value(inval).do({ arg j;
item = localList.wrapAt(i);
inval = item.embedInStream(inval);
});
});
^inval;
}
}
// the wrapper has to be adapted
+ ArrayedCollection {
prandc {|repeats=inf, length|
^Prandc(this, repeats, length);
}
}
After recompile:
Pbindef(\a, \note, (0..7).prandc(2, 4).repeat, \dur, 0.15).play
Pbindef(\a, \note, (0..7).prandc(3, 4).repeat, \dur, 0.15).play
Pbindef(\a, \note, (0..7).prandc(2, 3).repeat, \dur, 0.15).play
// with no length passed the array length is taken
Pbindef(\a, \note, (0..7).prandc(2).repeat, \dur, 0.15).play
Greetings
Daniel
-----------------------------