Reading a section of an Array with Pseq() || How to?

Hi everyone,
I’m trying to read just a section of an array with a pseq, but I don’t know the proper method or pattern to use.
Could you help me please?

In this way I can read 1 value , how to read more adjacent values?

~rytmval = [ 0.2, 1, 0.2, 0.2, 0.2, 1, 0.2, 0.2, 0.2, 0.2, 0.2, 1];
Pbind(\instrument, \default, \dur, Pseq([],inf) ).play;

Really thanks in advance !!

I would probably use slice

Pbind(\instrument, \default, \dur, Pseq(~rytmval[0..2],inf) ).play;

Similar you can use collect with a pattern of indices

	\instrument, \default, 
	\dur, Pseq([0, 1, 2, 1, 0], inf).collect(~rytmval[_])
	// partial application, short for .collect { |i| ~rytmval[i] }

If the section needs to change as the pattern is playing, you should probably be using Pindex or Pwalk instead.

// basic usage of Pindex, fixed sub-sequence
Pbind(\instrument, \default, \dur, Pindex(~rytmval, Pseq((0..2)), inf)).play;

// changing subsequence
Pbind(\instrument, \default, \dur, Pindex(~rytmval, Plazy { Pseq((0 .. rrand(2, ~rytmval.size))) }, inf)).play;

One more: Pser(array, number_of_elements, start_index).


1 Like