Hi,
I’d like to control several patterns alternately, according to a midi note number, with a single midi controller. For example, when I play midi note 60, the values of controller 10 control a parameter of pattern A, and when I stop playing this note, my pattern A continues in automatic mode. When I play midi note 61, my cc 10 controls a Pattern B parameter, and so on.
I’m looking for the best way to code this kind of interaction. In fact, it’s a question of reconstructing a kind of aftertouch, for an interface (the Sylphyo) that doesn’t have one.
Here’s a simplified proposal, I have the feeling that it’s not a good way to realize this interaction, especially if I multiply the number of notes and make the pattern more complex. What’s more, I think it would be better to avoid the last loop (routine).
I’d be very grateful for your opinion and suggestions.
MIDIIn.connectAll;
(
//Get note on and off
(
MIDIdef.noteOn(\note60on, { |val, num, chan, src|
~note60 = true;
}, noteNum: 60);
MIDIdef.noteOff(\note60off, { |val, num, chan, src|
~note60 = false;
}, noteNum: 60);
);
////Get controller value
MIDIdef.cc(\ctlin, { |val|
~valCC10 = val.linlin(0, 127, 0, 1); // Conversion de la valeur CC
}, ccNum: 10);
// A Flow
Pbindef(\autoFlow,
//\instrument, \synthA, // Synthétiseur par défaut
\freq, Pwhite(440, 460, inf), // Exemple de séquence de fréquence
\dur, 0.1 // Durée de chaque note
).play;
// Conditionnal action
~controlWithCC = {
if (~note60,
//Note On, the pattern is controlled by cc 10
{Pbindef(\autoFlow, \freq, Pfunc{~valCC10 * 1000 + 50});},
//Note Off, the pattern works automatically
{Pbindef(\autoFlow, \freq, Pwhite(440, 460, inf))}
);
};
//
~checkControl = Routine({
inf.do {
~controlWithCC.value;
0.02.wait;
}
}).play;
)