Hi everyone. I’m still experimenting a lot with SuperCollider, trying to setup my personal live-coding system. In most live-coding environments, patterns can be updated on the fly without restarting each time a particular line is reevaluated. However, the current default behavior of Ndef → Pbind is to swap the old and the new instance each time the line is evaluated:
// Reevaluating the line is restarting the pattern to first index.
Ndef(\restart)[0] = Pbind(\legato, 0.1, \dur, 0.25, \note, Pseq([0,2,4,5,7], inf));
Ndef(\restart).play;
I understand that this is how Ndef works. There is a transition and crossfading, fadeTime long, between the old Pbind and the new Pbind.
What are your techniques to live-update a pattern that is already playing? How do you build patterns incrementally over time by adding / updating keys and values?
EventPatternProxy is the class you’ll need to swap out the definition of a Pattern while it’s playing. More specifically, you probably want to use Pdef, which is an corollary to Ndef but for Patterns, and is built on top of EventPatternProxy.
Pdef is for replacing the whole Pbind, for replacing key streams see its subclass Pbindef. For replacing single key streams you can use Pdefn, but for replacing more than one, Pbindef is more practical. See Psym for working with Symbols.
I use Pbindef via my wrapper class PLbindef. It can also be used with Chars and Strings to shorten syntax as described in the tutorial “PLx and live coding with Strings”.
Thanks @semiquaver and @dkmayer. I think I know precisely what I am aiming for. I would like the quant value to be automatically deduced from the length of one of the streams. For a melodic pattern, it would mean that the size of key \freq or \note would be the quant value for the pattern.
Pseq([1,2,3], inf) representing an infinite stream, I don’t know if there is a way to extract the information that the pattern is in fact a repetition of three elements.