Resetting Pbind from event values pairs

Hi,
For a project that sets Pbindefs while they are playing with messages outside of SC, I would like to be able to reset the Pbindefs back to their original definition. I don’t want to use PatternProxies oder Pdefns since I like the way you can change Pbindefs.
So I defined a reset-event with key-value pairs and defined a function to overwrite the currently playing Pbindef. I tried to use the \set type to set all the values of the Pbindef. But this does not work unless I explicitly type all the values. Since I have multiple Synths that need to be reset, I was hoping to use a function instead of typing it all in manually.
Is the \type, \set approach the right way? Or do you know another way?

thank you

As an example
A SynthDef

SynthDef('praise', {
		|gate=1|
		var amp1, amp2, freq1, freq2, sig1, sig2, env1, env2;
		amp1 = LFPulse.kr(\ampHz.kr(0.2), 0, \pulWidth.kr(0.9)) * \ampScale.kr(0.75);
		amp2 = LFPulse.kr(\ampHz.kr(0.2), 0, \pulWidth.kr(0.9)) * \ampScale.kr(0.75);
		env1 = EnvGen.kr(Env.adsr(\atk.kr(1.5), 0.2, 0.7, \rls.kr(2.9)), gate, doneAction:2);
		env2 = EnvGen.kr(Env.adsr(\atk.kr(1.5), 0.1, 0.7, \rls.kr(2.9)), gate, doneAction:2);
		freq1 = LFNoise0.kr(\fRate.kr(0.2)).exprange(\freq.kr(40), \freq.kr(40) * \fMul.kr(4)).round(\freq.kr(40) * \rnd.kr(1.0));
		freq2 = LFNoise0.kr(\fRate.kr(0.2)).exprange(\freq.kr(40), \freq.kr(40) * \fMul.kr(4)).round(\freq.kr(40) * \rnd.kr(1.0));
		freq1 = freq1 * LFPulse.kr(\pulRate.kr(0.2));
		freq2 = freq2 * LFPulse.kr(\pulRate.kr(0.2));
		sig1 = RHPF.ar(Pulse.ar(freq1, \width.kr(0.2)), \ffreq.kr(300),  \rq.kr(1.0)) * amp1 * env1 * \amp.kr(0.1) ;
		sig2 = RHPF.ar(Pulse.ar(freq2, \width.kr(0.2)), \ffreq.kr(300), \rq.kr(1.0)) * amp2 * env2 * \amp.kr(0.1);
		sig1 = BPF.ar(sig1, \bpf.kr(120));
		sig2 = BPF.ar(sig2, \bpf.kr(120)) ;
		Out.ar(~out, [sig1, sig2]);
		Out.ar(\outfx.kr(~fx1Bus), [sig1, sig2] * \send.kr(-30).dbamp);
	}).add;

this is the reset-event

~reset = (
	praise: (
			instrument:'praise',
			ampHz: 0.2,
			pulWidth: 0.9,
			ampScale: 0.75,
			atk: 1.5,
			rls: 2.9,
			fRate: 0.2,
			freq: 40,
			fMul: 4,
			rnd: 1.0,
			pulRate: 0.2,
			width: 0.2,
			ffreq: 300,
			rq: 1.0,
			bpf: 120,
			send: -30

		))

the Pbindef

Pbindef(\praise,
	\instrument, \praise,
	\degree, Pseq([[0, 4, 7], [2, 8, 11], [4, 2, 5]], inf),
	\dur, t.tempo *5,
	\amp, 0.15
);

and the reset Function

	~resetPattern = {
		|name|
		var params, synth;
		params = List.new;
		~reset[name].keys.do({
			|k|
			params.addAll([k, ~reset[name][k]])
		});
		params.postln;
		synth = Synth(name, params.asArray);
		Pbindef(name, \type, \set, \id, synth, \args, #[]);
	};

Good question! A few comments:

A rule of thumb, whenever you are duplicating code and using variable names like sig1 and sig2 etc, and the two versions do not differ in details, you should probably be using an array instead. So you could simplify your SynthDef:

SynthDef('praise', {
	|gate=1, out|
	var channels = {
		var amp1, amp2, freq1, freq2, sig1, sig2, env1, env2;
		amp1 = LFPulse.kr(\ampHz.kr(0.2), 0, \pulWidth.kr(0.9)) * \ampScale.kr(0.75);
		env1 = EnvGen.kr(Env.adsr(\atk.kr(1.5), 0.2, 0.7, \rls.kr(2.9)), gate, doneAction:2);
		freq1 = LFNoise0.kr(\fRate.kr(0.2)).exprange(\freq.kr(40), \freq.kr(40) * \fMul.kr(4)).round(\freq.kr(40) * \rnd.kr(1.0));
		freq1 = freq1 * LFPulse.kr(\pulRate.kr(0.2));
		sig1 = RHPF.ar(Pulse.ar(freq1, \width.kr(0.2)), \ffreq.kr(300),  \rq.kr(1.0)) * amp1 * env1 * \amp.kr(0.1) ;
		sig1 = BPF.ar(sig1, \bpf.kr(120));
	} ! 2;
	Out.ar(out, channels);
	Out.ar(\outfx.kr(~fx1Bus), channels * \send.kr(-30).dbamp);
}).add;

where { ... } ! 2 creates an Array of two elements from calling the function twice.
Also, I would recommend to pass the output bus to the synth and not hardcode it. Hardcoding it will make it not work with Ndefs for example.

Then, for the reset.

// asPairs creates an array of key value pairs
// the star embeds them into the message "new":

Pbindef(\praise, *~reset[\praise].asPairs);


awesome answer, and it works!
thanks also for the other suggestions!
boris