Hi
I’m trying to move my project from Fmod Ex to Unity. The code was worked fine in Ex, but not in Unity. The code looks like:
using UnityEngine;
using System.Collections;
using FMOD;
public class _Oscillators : MonoBehaviour {
FMOD.RESULT Fresult;
FMOD.System Fsystem;
FMOD.DSP Fdsp;
FMOD.Channel Fchannel;
FMOD.ChannelGroup Fchannelgroup;
System.IntPtr ptr;
// Use this for initialization
void Start () {
ptr = new System.IntPtr();
Fsystem = new FMOD.System(ptr);
Fresult = new FMOD.RESULT();
FMOD_Initialize();
Fchannel = new FMOD.Channel(ptr);
Fdsp = new FMOD.DSP(ptr);
Fresult = Fsystem.createDSPByType(DSP_TYPE.OSCILLATOR, out Fdsp);
Fresult = Fdsp.setParameterInt((int)DSP_OSCILLATOR.TYPE, 0);
Fresult = Fdsp.setParameterInt((int)DSP_OSCILLATOR.RATE, 220);
Fresult = Fsystem.playDSP(Fdsp, null, false, out Fchannel);
Fresult = Fchannel.setVolume(1.0f);
Fsystem.update();
}
private void FMOD_Initialize()
{
Fresult = FMOD.Factory.System_Create(out Fsystem);
ERRCHECK(Fresult, "create system");
}
private void FMOD_DeInitialize()
{
Fresult = Fsystem.close();
ERRCHECK(Fresult, "close");
}
private void ERRCHECK(FMOD.RESULT Fresult, string comment)
{
if (Fresult != FMOD.RESULT.OK)
{
UnityEngine.Debug.Log ("FMOD error in " + comment + ": " + Fresult + "-" + FMOD.Error.String(Fresult));
}
}
}
Unfortunately, at FMOD.Factory.System_Create(out Fsystem) it gives an ‘ERR_MEMORY-not enough memory or resources’ message. What am I doing wrong?