Plugin Downmix

I noticed the FMOD Channel Mix effect is able to take in multiple channels and down mix it to a user specified number of channels, how would I go about writing plugin that takes a signal and down mixes it?

Thank!

To answer my own question, a good example that does this is the fmod_distance_filter plugin. Look at the callback FMOD_DistanceFilter_dspprocess