How to add EffectPreset to event's master track

Hello,

I am trying to add an EffectPreset to the master track of an event. So far I managed to add a default spatialiser effect by using

event.masterTrack.mixerGroup.effectChain.addEffect('SpatialiserEffect');

The API documentation for MixerBusEffectChain.addEffect(effectDefinition) states that “The effectDefinition argument can either be an EffectPreset, a MixerEffect that is a preset […]”.

Now, I know the MixerBusEffectChain and my master track effect chain are two different things, but I was wondering if it works the same? If so, what would be the best way to do it and if not, is there a workaround?

Under the hood, your master track’s effect chain is an object of type MixerBusEffectChain - you can observe this by doing event.masterTrack.mixerGroup.effectChain.dump() and observing the type at the top of the dump.

In the case of adding an EffectPreset to effectChain, you need to have a reference to the specific EffectPreset you want to add to the chain. The easiest way to demonstrate this is to open the Preset Browser, select a preset effect from the “Effects” tab, and run var effectPreset = studio.window.browserCurrent() in the console to store a reference. You can then run event.masterTrack.mixerGroup.effectChain.addEffect(effectPreset);, which will add the preset effect you selected to the event’s master track.

Hey Leah,

thanks so much, that works!
One follow up question: Is there a way to find all effect presets in the project and display them by name without using studio.window.browserCurrent()? I want to have a dropdown to choose an effect chain to add to an event.

I used this: var presetEffectChain = studio.project.model.EffectChain.findInstances(); but I can’t figure out how to get to the effect chain name.

To get an array of all effect presets in the project, you’ll want to use var effectPresets = studio.project.model.EffectPreset.findInstances();. This array will include Effect Chains. You can then get the name of each preset/chain from the name member, i.e. effectPresets[i].name.