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!!
Sorry for bringing up an old thread, but this is exactly what I want to try in order to enable a Stereo toggle in my game that can be changed at runtime by the user. I think I figured how to do steps 1 - 6, but I am new to using FMod, and I am not sure how to do step 7. How do you automate a send and a fader and tie it to the global parameter? As in what do you click where in FMod studio and in what order in order to do that?
To automate a send or fader, first select the bus containing that fader or send in the mixer window, so that the send or fader is displayed in the deck. Then, right-click on the fader knob or send level knob in the deck, and select “Add Automation” fro mthe context menu. This adds an automation widget to the property.
Once you’ve added an automation widget to a property, you’ll need to add a parameter to it, and create an automation curve on that parameter. To add a parameter to an automation widget, click the “Add Curve” button, then select the global parameter you want to use, or click “New Parameter” and create a new global parameter that you intend to use.
To add an automation curve on that parameter after adding that parameter to the automation widget, click on the red dashed line to add an automation point, then click on the red line to add more automation points. Click and drag these points to various locations in order to define the shape of the automation curve. In your case, you want to automate the send’s level property such that it is 0 dB when the parameter is set to 1 and -oo dB when it is set to 2, and you want to automate the fader such that it is -oo dB when the global parameter is set to 1 and 0 dB when it is set to 2.
That looks correct, yes.
Hello, apologies for reviving this thread once more, we are also looking to add a similar user setting that allows players to play the game in mono.
In following these steps we noticed that this didn’t work for events using the 3D Object Spatializer. This makes sense because of how it’s routing works, but I was wondering if there were any workarounds for this while still allowing 3D object spatializers to be used.
We have tried destroying and rebuilding the studio system. This works but isn’t the most elegant solution, though it might work as a game setting that requires a restart to be applied.
I was wondering if you have any suggestions for our team?
Would it possible through code to make all 3D Object Spatializers use the fallback regular spatializer when the mono setting is active?
Thanks,
Joe
There are not. Object spatializers, by definition, bypass all normal routing, so any solution that depends on the normal routing path cannot work.
You could potentially use return tracks within each event that uses an object spatializer such that one return track houses the object spatializer and another houses a non-object spatializer, then use sends automated on the global parameter to control which of those return tracks recieves an audible signal. That would allow you to switch between the object spatializer effect and the the non-object spatializer effect live by changing the parameter’s value. This workaround would, however, mean you would not gain the benefit of the object spatializer when using the non-object spatializer instead.
No. The FMOD Engine does not support changing the effects in a signal path at run time; the closest alternative is to have multiple different routing paths and automate the gain of signals routed through them, as in the workaround I suggested above.
Thanks Joseph, the return tracks seems like a good solution for us, we’ve used something similar for another effect, so we’ll try it out as an option for this. Thanks!