We are making a splitscreen game where audio should be played on different devices. To send audio we need to get audio spectrum data. Is there any way to route events to only obtain their spectrum data and not get the entire master output?
We saw a post about having multiple FMOD.Studio.System systems, but trying to get system specific spectrum data we still get the entire master. Is such audio splitting at realtime even possible?
You can get FFT data from a single event, single track, or single instrument by appending an FFT DSP to the head of the Channel or ChannelGroup that you would like to get the audio spectrum data of. Using the Spectrum Analysis Example as a base, you could get the spectrum of a playing event with:
// Play your event instance
FMOD.Studio.EventInstance instance = FMODUnity.RuntimeManager.CreateInstance("path/to/your/event");
instance.start();
if (FMODUnity.RuntimeManager.CoreSystem.createDSPByType(FMOD.DSP_TYPE.FFT, out mFFT) == FMOD.RESULT.OK)
{
mFFT.setParameterInt((int)FMOD.DSP_FFT.WINDOW, (int)FMOD.DSP_FFT_WINDOW_TYPE.HANNING);
mFFT.setParameterInt((int)FMOD.DSP_FFT.WINDOWSIZE, WindowSize * 2);
FMODUnity.RuntimeManager.StudioSystem.flushCommands();
// Get the event instance's channel group
FMOD.ChannelGroup channelGroup;
if (instance.getChannelGroup(out channelGroup) == FMOD.RESULT.OK)
{
// Add fft to the channel group
if (channelGroup.addDSP(FMOD.CHANNELCONTROL_DSP_INDEX.HEAD, mFFT) != FMOD.RESULT.OK)
{
Debug.LogWarningFormat("FMOD: Unable to add mFFT to the channel group");
}
}
}