Attaching EventInstance to multiple ports via pass through (attachChannelGroupToPort)?

I’m currently trying to set up playing certain events via their regular channel group output but additionally also via the controller audio and controller vibration (so the event should be played on all three at the same time). One thing that isn’t clear to me atm is whether attachChannelGroupToPort can used to do this with a single EventInstance or whether we need to create three instances, one for each output?

attachChannelGroupToPort has a passThru parameter, so I would think that I could call it twice, with different ports (controller audio + controller vibration), and then start the event. But detachChannelGroupFromPort only takes the group as parameter, so I think either attaching a channel group to two ports will have the second one override the first one, or detach will remove all ports?

Finally, do I need to clean this all up (detach channel group, release channel group, release event instance), or will releasing the event instance automatically clean up the port attachment and its channel group?

A ChannelGroup can only be attached to a single port at a time. You could create multiple EventInstances, or you could route the audio at the DSP level. We have a doc on this which explains the concept of DSP routing: Creating an effect and making all Channels send to it; except you would be routing into a ChannelGroup and attaching to an output port, instead of just sending to a DSP effect:

  • Create one ChannelGroup for each port and attach with ChannelGroup::attachChannelGroupToPort
  • Get the tail dsp for each ChannelGroup using ChannelGroup.getDSP(FMOD.CHANNELCONTROL_DSP_INDEX.TAIL, out dsp)
  • Drill down into your EventInstance to get its Head DSP and attach it to each ChannelGroup’s tail DSP with DSP::addInput

Alternatively you could set this all up in FMOD Studio using Sends and Returns which would be simpler