Answered
0
0

Hi,
I have Unity 4.5.5p4 Pro and FMOD 1.05.05 Integration running on Mac 10.9.5. I successfully imported a MasterBank, added the Fmod Listener to the camera and reproduced the Event Asset with a FMODStudioEventEmitter.
But then I tried to follow the online guide to reproduce/start an event from script. No error is showing but also no audio or any kind of feedback (I also enabled FMOD_DEBUG).
My script is this:

public class testfmod : MonoBehaviour 
{
    FMOD.Studio.EventInstance laserEvt;
    FMOD.Studio.ParameterInstance pitchParam;

    private float pitchTest;    

    // Use this for initialization
    void Start () 
    {

        laserEvt = FMOD_StudioSystem.instance.GetEvent("event:/lasers");    
        FMOD.RESULT res =  laserEvt.start();        
        laserEvt.getParameter("pitch", out pitchParam);     
    }

    // Update is called once per frame
    void Update () 
    {
        if( Input.GetKey (KeyCode.UpArrow))
        {
            pitchParam.setValue(0.5f);
        }
        else
        {
            pitchParam.setValue(0.0f);
        }

        laserEvt.getPitch(out pitchTest);
        Debug.Log("Current Pitch is: " + pitchTest);
    }

    void OnDisable()
    {
        laserEvt.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
        laserEvt.release();
    }
}

Anyone is getting the same issues? Any help?

  • Nicholas Wilcox
    Your code looks correct. The issue must lie somewhere else in the project. Maybe attach this script to a game object with a FMODStudioEventEmitter on it, and see if you can hear both events.
  • You must to post comments
Best Answer
0
0

Thanks Nicholas.
I have an update on it. After trying a little bit of everything I got it to work forcing the event.pause to false. Also I noticed that if the camera with FMODListener is too far from any emitter when scene starts it will be deaf for the rest of the execution. If the listener and the emitter are closer than I can move the emitter far away and the sound is still played.
So the line that did the trick for me was this

// Use this for initialization
    void Start () 
    {
        Debug.Log ( laserAsset.path );
        laserEvt = FMOD_StudioSystem.instance.GetEvent("event:/lasers");    
        FMOD.RESULT res =  laserEvt.start();
        laserEvt.setPaused(false); // <-- this line did the trick
        laserEvt.getParameter("pitch", out pitchParam);     
    }
  • Nicholas Wilcox
    Hi Erik, setPaused(false) shouldn't be needed. However, I briefly reproduced your issue and found setPaused fixed it. After I restarted the editor the issue disappeared in I could remove the setPaused call.
  • Erik Podetti
    Hi Nicholas. Correct, I noticed the same behaviour. After the first execution with setPaused(false) the issue disappeared and I could remove the line. Greetings and thanks for the interest and help.
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.