Hi,
I want to create a button in Unity to switch (toggle) between stereo and mono output. Is this possible via c#?
Thanks!
Hi,
I want to create a button in Unity to switch (toggle) between stereo and mono output. Is this possible via c#?
Thanks!
Hi, It looks like you can do this by setting the software format from the core system.
var core = FMODUnity.RuntimeManager.CoreSystem;
core.setSoftwareFormat(0, FMOD.SPEAKERMODE.MONO, 0);
Here’s the page in the documentation: System::setSoftwareFormat
Hi, Aishi!! Thanks for your help.
I tried to implement this button, but it’s not working.
I still have doubts related to what comes after FMOD.SPEAKERMODE.STEREO, ____
But anyway, even the mono didn’t work.
Here’s my code:
public void ToggleMonoStereo(bool isMono)
{
if (!isMono)
{
MasterMono();
}
else
{
MasterStereo();
}
}
public void MasterMono()
{
var core = FMODUnity.RuntimeManager.CoreSystem;
core.setSoftwareFormat(48000, FMOD.SPEAKERMODE.MONO, 0);
}
public void MasterStereo()
{
var core = FMODUnity.RuntimeManager.CoreSystem;
core.setSoftwareFormat(48000, FMOD.SPEAKERMODE.STEREO, 1);
}
System::setSoftwareFormat only works when called before the System is initialized. The last parameter is only really relevant for FMOD.SPEAKERMODE.RAW, so you can leave it at 0.
Thanks for the clarification, Mathew!
So it’s not possible to change from stereo to mono during runtime?
Yes and no.
As Mathew said, it’s not possible to change the channel count of your game’s output at runtime without destroying and rebuilding the Studio system.
However, it is possible to make your game switch between outputting stereo format and outputting the same mono signal to both channels by using a combination of sends and return buses. In FMOD Studio:
This setup will ensure that when the global parameter is set to 2, your game’s output will be stereo; but when the parameter is set to 1, your game’s output will be downmixed to mono and output equally on both channels. This should allow you to treat the output as switching between stereo and mono for most practical purposes.
Alternatively, if you prefer not to use a global parameter, you could instead set the send to -oo dB and the fader to 0 dB, and create a snapshot that sets the send to 0 dB and the fader to -oo dB when an instance of the snapshot is active.
Thanks a ton, Joseph!! It worked perfectly for my needs!!