I’m using the Core FMOD API within Unity, but not using the unity integration. When I create a new DSP node, it doesn’t have any input or output channels, even after calling setChannelFormat
. I’ve created a minimal example that shows the problem:
using UnityEngine;
public class FMODTest : MonoBehaviour
{
public FMOD.System FMODSystem;
// Start is called before the first frame update
void Start()
{
CheckResult(FMOD.Factory.System_Create(out FMODSystem));
CheckResult(FMODSystem.init(
512,
FMOD.INITFLAGS.NORMAL | FMOD.INITFLAGS.PROFILE_ENABLE,
(System.IntPtr)null));
Debug.Log("FMOD Core Initialized");
FMOD.ChannelGroup nullCG = new FMOD.ChannelGroup(System.IntPtr.Zero);
CheckResult(FMODSystem.getMasterChannelGroup(out FMOD.ChannelGroup masterCG));
CheckResult(masterCG.getDSP(0, out FMOD.DSP masterFader));
CheckResult(FMODSystem.createDSPByType(FMOD.DSP_TYPE.MIXER, out FMOD.DSP mixer));
masterFader.addInput(mixer, out FMOD.DSPConnection conn);
mixer.setActive(true);
mixer.setChannelFormat(0, 2, FMOD.SPEAKERMODE.STEREO);
conn.getMixMatrix(null, out int outChans, out int inChans);
Debug.LogFormat("Got {0} input channels and {1} output channels", inChans, outChans);
// always shows 0 inputs and 0 outputs
}
// Update is called once per frame
void Update()
{
FMODSystem.update();
}
private void OnDestroy()
{
CheckResult(FMODSystem.release());
}
public static void CheckResult(FMOD.RESULT res) {
if(res != FMOD.RESULT.OK) {
Debug.LogErrorFormat("FMOD Error: {0}", res);
}
}
}