[SOLVED] MIDI pattern to send multiple control values

You can simplify your code by using control “chords” and Pchain. Both save multiple typing.

(
Pdef(\m, Ppar([
	Pbind(\type, \midi, \midiout, m, \midicmd, \noteOn,
		\scale, Scale.harmonicMinor,
		\degree, [0, 2, 4],
		\octave, Pn(Pshuf((2..8),4)),
		\amp, Pwhite(0.1, 0.9) * 0.2,
	),
	Pbind(\type, \midi, \midiout, m, \midicmd, \control,
		\ctlNum, [41, 42, 45],
		\control, Ptuple([60, Pdefn(\ctlModulatorAttack), Pdefn(\ctlCarrierDecay)])
	)
])).play;
)


// in addition use Pchain

(
p = Pbind(\type, \midi, \midiout, m, \midicmd, \noteOn,
	\scale, Scale.harmonicMinor,
	\degree, [0, 2, 4],
	\octave, Pn(Pshuf((2..8),4)),
	\amp, Pwhite(0.1, 0.9) * 0.2,
);

q = Pbind(
	\midicmd, \control,
	\ctlNum, [41, 42, 45],
	\control, Ptuple([60, Pdefn(\ctlModulatorAttack), Pdefn(\ctlCarrierDecay)])
) <> p;

Ppar([p, q]).play;
)

Accidentially (or not) there have been 3 related threads recently.

If you like to have all in one I’d take James’ recommendation of a dedicated Event type. It can always do what you want and define.

Event.addEventType(\midiOnCtl, { |server|
	var original = currentEnvironment.copy.put(\type, \midi);
	~midicmd.do { |cmd|
		original.copy.put(\midicmd, cmd).play;
	};
});

(
p = Pbind(\type, \midiOnCtl, 
	\midiout, m, 
	\midicmd, [\noteOn, \control],
	\scale, Scale.harmonicMinor,
	\degree, [0, 2, 4],
	\octave, Pn(Pshuf((2..8),4)),
	\amp, Pwhite(0.1, 0.9) * 0.2,
	\ctlNum, [41, 42, 45],
	\control, Ptuple([60, Pdefn(\ctlModulatorAttack), Pdefn(\ctlCarrierDecay)])
);

p.play;
)