Shifting arrays as a means of time travel

I’ve been working on ways of making future events available in the present as a way of extending the capabilities of various conditional operations. This is what I’ve come up with.
What I think is nice about it is that it allows for a resonable degree of live coding and live experimentation.

It is kind of a lot of text though so I’m really just asking for input on ways of expressing the same functionality in a neater way?
Maybe methods or classes i’ve overlooked.

// Run this block first
t =;

// These can be evaluated line by line with shift+return after running the containing block.
// When evaluated these patterns will be embeded in the Routines-streams below when the previously embedded pattern ends.
~hhPattern1 = Pshufn(Bjorklund(5, 8), 1);
~hhPattern1 = Pseq([1, 0, 0, 0, 0, 0, 0, 0],1);
~hhPattern2 = Pseq([1, 0, 0, 0, 1, 0, 0, 0],1);

// These make it so that the ~hhAmpArrayGen and the patterns above can be 
//evaluated separetaly and still keep putting out numbers on time.
~hhPatternRoutine1 = Routine{

~hhPatternRoutine2 = Routine{

// This function does all the conditional operations.
// It also keeps a record of what is going to happen and what has happened with a shifting array.
// Then this block 
var array=0!9;
~hhAmpArrayGen= {
	var shiftedArray, pat1, pat2;
	shiftedArray=array.shift(-1, 0);
		{array.put(array.size-1, pat2)},
		{array.put(array.size-1, pat1)}

// Try running the function a few times to get an idea of what it's doing.

// When evaluated this function resets the "pattern routines" to make 
// sure the patterns start from the begining. 
		\instrument, \default,
		\dur, 0.25,
		//The \amp-key only gets paired with the element currently at index 5. 
		\amp, Pseq([~hhAmpArrayGen.value[4]], 1),
		\rell, 0.1,
		\freq, Pif(Pkey(\amp) > 0, 1, \rest)
}), inf).play(t, quant:[4, 1, 0.1]);