Pattern that lets you retrigger a pattern from another pattern

Thanks @jamshark70! Most of this is beyond my understanding. It will take some time for me to digest I can see that it works and that is great!
I tried to apply this concept to @hemiketal great post on My Pdef workflow
where he uses an added \isRest key to the default keys in order to get a nice sequencer going.
So I thought I could apply ~trigger koncept to the \isRest. But that doesn’t seem to work. Maybe I am asking to much. Nevertheless I am extremely thankful for your help and giving me useful solutions to what I wanted to accomplish!

  var addisRest = Event.parentEvents.default;
         addisRest[\play] = addisRest[\play] <> { ~isRest.notNil.if { ~isRest.if { ~type = \rest } } };

~c = TempoClock.new(120/60).permanent_(true);
~c.tempo_(120/4/60);


(
~trigger = false;
Pdef(\part, Pdef(\part1,
	Ppar([
	Pbind(
		\instrument, \default,
		\isRest, Pseq([
			1,0,1,0,
			1,0,0,0,
			1,0,0,0,
			1,0,1,1,
			1,0,1,1,
			1,0,1,0,
			1,0,1,0,
			1,0,0,1,
			].rotate(0),inf).coin.not,
		\octave,3,
		\dur, 1/16,
	   \amp,1,
		\legato, 0.005,
		).collect({ |ev|
			if(ev[\isRest]) {
				~trigger = false}
			{~trigger = true};
			ev  // return event
		}),



		Pchain(
			// add note data into timing data
			Pn(Pbind(
				// pattern that listens
				\ghoast, Pif(
					Pfunc({ ~trigger }),
					// here, we must un-do the trigger being set
					// otherwise Pn will infloop
					Pfunc({
						~trigger = false;
						nil  // return nil to stop the Pbind!
					}),
					\dummy
				),
				\degree, Pseq([1,5,7,9,12
			],1),  // changed `1` to `inf`
				\octave, 6
			), inf),

			Pbind(
				\instrument, \default,
				\timingOffset, Pseq([0, 0.009], 1),
				\dur, 1/16,
				\sus, 2,
				\amp, 0.1
			)
		),




	],inf)

)).play(~c);
)

1 Like