Scripting: Loop through content of effect chain

Hi,

Is it possible to loop through all the content of effect chains when scripting for FMOD? Haven’t been able to do this yet.

Sorry about all my scripting questions, but your responses are super helpful!

Cheers,
Nikolaj

No worries!

I have made a script that will log all the effects on the master track on an event:

studio.menu.addMenuItem({
    name: "Examples\\Effect Chain",
    execute: function() {
        var event = studio.window.browserCurrent();

        // Make sure we only continue on events
        if (event.entity === "Event") {
            var effects = event.masterTrack.mixerGroup.effectChain.effects;

            // There will always be a fader so look for more than 1 effect
            if (effects.length <= 1) // Fixed incorrect greater than
            {
                alert("Only found 1 effect which may be the fader");
                return;
            }
            effects.forEach(function(effect)
            {
                console.log(effect);
            })
        }
        else
        {
            // Currently not selecting an event in the studio window
            alert("Please select an event");
        }
    }
});

Console log:

(ManagedObject:MixerBusFader)
(ManagedObject:SpatialiserEffect)
(ManagedObject:SFXReverbEffect)

Let me know if this is the behavior you are after. If not, what content are we looking for?

Edit correcting code

Hi Connor,

Thank you. I was specifically looking for a way to loop through the effects inside an “effect chain”, like EffectChainA in the image here:

The script you shared doesn’t seem to consider effects inside effect chains, so it just says " Only found 1 effect which may be the fader" fort this event

1 Like

Thanks for the info. Sorry about that I got a < the wrong way round…

Here is the updated script to find and log the effects in an effect chain:

studio.menu.addMenuItem({
    name: "Examples\\Effect Chain",
    execute: function() {
        var event = studio.window.browserCurrent();

        // Make sure we only continue on events
        if (event.entity === "Event") {
            var effects = event.masterTrack.mixerGroup.effectChain.effects;
            // There will always be a fader so look for more than 1 effect
            if (effects.length <= 1)
            {
                console.log("Only found 1 effect which may be the fader");
                return;
            }
            var foundEffectChain = false
            effects.forEach(function(effect)
            {
                if (effect.entity == "ProxyEffect")
                {
                    var subChain = effect.preset.effect.effects;
                    if (subChain != null)
                    {
                        console.log("Found an effect chain");
                        foundEffectChain = true;
                        subChain.forEach(function(subEffect)
                        {
                            console.log(subEffect);
                        })
                        console.log("End of the effect chain");
                    }
                }
            })

            if (!foundEffectChain)
                console.log("Could not find an effect chain");
        }
        else
        {
            // Currently not selecting an event in the studio window
            console.log("Please select an event");
        }
    }
});

Thank you Connor, that was super helpful!

1 Like