[SOLVED] MIDI pattern to send multiple control values

Is there a way to send several MIDI \control values at once from inside a single Pbind? I’m trying to use Pbind to control a Volca FM. I’ve made it work, but the syntax is a bit cumbersome, since I have to declare a Pbind for each control and then wrap everything inside a Ppar. I am aware of the limitation of Pbind on sending both \noteOn and \control MIDI commands (is there a way around this, by the way?). Is there a Pmidi somewhere? It would be great to have a pattern just for midi, like a Pbind but without all the hassle of declaring setup MIDI pairs for every single note player and control. Has anybody done such a thing? I’ve been thinking on doing it, but I’m just starting to create my first patterns and this is a bit overwhelming at this point.

Ideally, what I’m looking for is something like this:

Pmidi(\midiout, MIDIOut(0), 
        \degree, Pwhite(0,7),
	\ccVelocity, 60,
	\ccModulatorAttack, 10,
	...
);

Here is my actual code which is –needless to say– a pain even to read:

(
Pdef(\m, Ppar([
	Pbind(\type, \midi, \midiout, m, \midicmd, \noteOn,
		\scale, Scale.harmonicMinor,
		\degree, [0, 2, 4],
		\octave, Pn(Pshuf((2..8),4)),
		\amp, Pbjorklund(5,8) * 0.2,
	),
	Pbind(\type, \midi, \midiout, m, \midicmd, \control,
		\ctlNum, 41, //  velocity -- Pbind's \velocity doesn't work because VolcaFM's MIDI interface doesn't support it
		\control, 60,
	),
	Pbind(\type, \midi, \midiout, m, \midicmd, \control,
		\ctlNum, 42, // modulator attack
		\control, Pdefn(\ctlModulatorAttack),
	),
	Pbind(\type, \midi, \midiout, m, \midicmd, \control,
		\ctlNum, 45, // carrier decay
		\control, Pdefn(\ctlCarrierDecay),
])).play;
)

I’m pretty sure someone has already solved this. Are you out there?

Thanks!

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;
)

Wow, thanks.

You can simplify your code by using control “chords” and Pchain

I had tried “chords” but as plain arrays and didn’t work with patterns. I didn’t know they had to be inside Ptuple. I’m just a very basic Pattern user so far. Thank you so much for pointing it out!

I wasn’t aware of Pchain either. Thanks for that, too, very useful.

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

I had searched a lot for threads on the subject and didn’t find these. I may need to polish my searching skills…

If you like to have all in one I’d take James’ recommendation of a dedicated Event type.

That is certainly very intersting! Thanks a lot!