Trying to add a Shared Effect before the fader to a series of events via script, I found this old thread that shares how to add an effect using relationships.insert() on the effects array, however that function will not take an effects chain as an input. Is this a bug? Using FMOD Studio 2.03
here’s an example just using the console to grab an effect chain and an event:
effect = studio.window.browserCurrent()
(ManagedObject:EffectPreset)
e = studio.window.browserCurrent()
(ManagedObject:Event)
e.masterTrack.mixerGroup.effectChain.relationships.effects.insert(0, effect)
Error: Relationship ‘effects’ expects a destination of entity type ‘MixerEffect’.
Due to the abstraction that Shared Effects make use of to be shared, EffectPreset can’t just be added to the effect chain. The effect itself needs to be created first, which will create a ManagedObject:ProxyEffect.
Following the snippet you posted, the simplest way to do this at present is to do the following:
// Get ManagedObject:EffectPreset from studio.window
var effect = studio.window.browserCurrent();
// Get ManagedObject:Event from studio.window
var e = studio.window.browserCurrent();
// Create ProxyEffect from EffectPreset and insert into effect chain
var proxyEffect = e.masterTrack.mixerGroup.effectChain.addEffect(effect)
// Move new ProxyEffect to be the first effect in the chain
var totalFX = proxyEffect.owner.relationships.effects.destinations.length;
proxyEffect.owner.relationships.effects.insert(0, proxyEffect.owner.relationships.effects.destinations[totalFX - 1]);
This is definitely not an ideal way to go about it, and addEffect() should have an overload that allows for you to specify the index that the effect is inserted at - I’ve added this to our internal feature/improvement tracker.