@Orvillain
Blooming blooms of bloomington! That was a lot easier than I had thought it was going to be! More or less the example in the documentation was all I needed to do. Here's the code for setting up the broadcaster. This happens in the main interface onInit function.
const var b = Engine.createBroadcaster({
id: "sampleListener",
args: ["eventType", "samplerId", "data"]
});
b.attachToSampleMap("Kick_sampler", "SampleMapChanged", "");
b.addListener("", "funky", function(eventType, samplerId, data)
{
build_sampler_routing(samplerId);
});
This triggers a function called build_sampler_routing, which takes the samplerId in as an argument:
inline function build_sampler_routing(sampler_id)
{
local parts = sampler_id.split('_');
local slot_name = parts[0];
local routing_matrix = slots[slot_name]['sampler_routing_matrix'];
routing_matrix.setNumChannels(sampler_channel_count);
local slot_default_routing_data = default_channel_data[slot_name];
for (channel in slot_default_routing_data)
{
local channel_data = slot_default_routing_data[channel];
routing_matrix.addConnection(channel_data['source_idx'][0], channel_data['sampler_output_idx'][0]);
if (channel_data['source_idx'].length > 1 && channel_data['sampler_output_idx'].length > 1)
{
routing_matrix.addConnection(channel_data['source_idx'][1], channel_data['sampler_output_idx'][1]);
}
}
}
That's how I needed it to work for my script anyway. Your mileage may blooming well very.
Also shout out to @d-healey - signed up to your patreon guv, and learnt about broadcasters from your video. Would definitely love to see more there. Seems like broadcasters can handle a lot of the heavy lifting when it comes to communicating between different parts of a plugin.