playNote targeting multiple layers at once

The playNote() function allows to specify which layer the midi note is sent to, which obviously is useful for articulation-switching etc.
I was wondering though if anyone knows a good way to play multiple, select layers at once. From what I see, playNote() expects a single layer object, not a table with layers or anything like that.
So if I want to target multiple layers at once, I can do something like the following code snippet, and it does work. However it creates performance issues very quickly. Like in my example with just 3 layers it already swallows notes when I play moderately fast, which makes sense given that it has to iterate through that for loop.

local targetLayer1 = this.parent:getLayer("firstLayer")
local targetLayer2 = this.parent:getLayer("secondLayer")
local targetLayer3 = this.parent:getLayer("thirdLayer")
layerTable = {targetLayer1, targetLayer2, targetLayer3}

function onNote(event)
	for i, targetLayer in ipairs(layerTable)  do
        	local id1 = playNote(event.note, event.velocity, -1, targetLayer)

Any suggestions for a better, more efficient way of doing this?
Maybe I should mention that I’m looking for a general solution - meaning that I don’t always know how many or which layers will be played, hence hard-coding, say, 3 calls to playNote isn’t an option. The ‘layerTable’ from my example just happens to have 3 items here, another time it might be 5, and yet another one it might be only 2 items.
Also, the layers could (and likely would) live in separate sections of my program tree, so a otherwise good trick such as targeting the parent layer holding all of them will not work in my case. Imagine that you have a bunch of microphones that recorded the same audio event, each living in its own layer, but you only want to ‘switch on’/ aka trigger some of them.

Hi Kerphelio,

How do you determine which layers should be played?
Does it depend on the note being played so it can change from one note to another?

If not then maybe you could target the LayerMidiMute parameter instead to choose which layers should play.