I'm putting together a Allen & Heath Xone:K2 mapping using Javascript. I have a basic mapping with full LED feedback operating and control over the MainTrackBank but looking for advice on handling multiples of the same controller.
My goal is to have the mapping cover 4 separate controllers, however, not all 4 will be plugged in all the time. Either 2 or 4 K2's will be used at a time.
I want the first two controllers to control the drum rack alone, and the next 2 controllers to control the mixer section of the remaining tracks.
If only 2 controllers are being used, it should only control the main mixer.
Currently, I'm just hard coding the channel the K2 is running on and when filtering out the midi notes allocating the channel number to the correct K2. Is there a better way to handle this? eg.
This isn't my code, but it's similar in nature.
Code: Select all
class Control {
constructor(public note, public channel) {}
}
const control = new Control(42, 6);
onMidi(status, note, velocity) {
if (isNoteOn(status)) {
const channel = getChannel(status);
if (note === control.note && channel === control.channel) {
// do stuff
}
}
}
My code isn't currently published to Github as it's horrendous and needs a good refactor and a typescript upgrade, but if you need to see it I can make it happen.
Thanks for any assistance!