C# - Failing to load samples

Hi,

I’m trying to wrap my head around the Studio API to eventually integrate it into my application.

I have successfuly played back a wave file using the Core API, along with some basic FFT analysis.

I’m now stuck at playing back FMOD Studio events. I am following the steps from the documentation:

  1. Init the Studio System > OK
  2. Load Bank (incl. strings) > OK
  3. Explicitly load samples > Forever in LOADING state, but can be skipped
  4. Lookup Event via path and create an instance from the EventDescription > OK
  5. Call Start on the instance > OK, but now the instance is forever stuck in the STARTING state as it fails to load the sample and never plays

Using system.flushSampleLoading() after sample load calls does not block (strange) and neither fixes anything.

The Studio project is compiled for Desktop and functions fully in Unity.

I’m using the *.cs wrappers and dlls included in the API installation.

Is there anything I’m missing in the setup process or anywhere else? Any help is much appreciated, thanks!

Here’s the test app source and build incl. the FMOD Studio project

Are you able to check the FMOD_RESULT returned from all the FMOD functions, it may shed some light on any issues.

Yes, I have wrapped every FMOD function with a check function that stops the program (and reports the output) unless the result is OK. And (unfortunately), all FMOD functions return with OK so the program runs fine - but never loads the samples.

static void emitStudioEventExample()
{
    var system = initStudioSystem();

    Console.WriteLine("Loading banks");

    FMOD.Studio.Bank bank;
    checkResult(system.loadBankFile("bank/Build/Desktop/Master.bank", FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out bank));
    FMOD.Studio.Bank stringsBank;
    checkResult(system.loadBankFile("bank/Build/Desktop/Master.strings.bank", FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out stringsBank)); // Must be loaded for Event paths to work

    FMOD.Studio.LOADING_STATE lState = FMOD.Studio.LOADING_STATE.ERROR;

    Console.WriteLine("Loading sample data");
    checkResult(bank.loadSampleData());

    do
    {
        checkResult(bank.getSampleLoadingState(out lState));
        Console.WriteLine(lState.ToString());
        System.Threading.Thread.Sleep(500);
    }
    while (lState != FMOD.Studio.LOADING_STATE.LOADED);

    checkResult(system.flushSampleLoading());

    FMOD.Studio.EventDescription[] evList;
    bank.getEventList(out evList);

    foreach (var evv in evList)
    {
        string path;
        evv.getPath(out path);
        Console.WriteLine(path);

        Guid guid;
        evv.getID(out guid);
        Console.WriteLine(guid);
    }

    Console.WriteLine("Getting event");

    FMOD.Studio.EventDescription ev;
    checkResult(system.getEvent("event:/Event", out ev));

    checkResult(ev.loadSampleData());

    do
    {
        // Gets stuck here with "LOADING"
        checkResult(ev.getSampleLoadingState(out lState));
        Console.WriteLine(lState);
        System.Threading.Thread.Sleep(500);
    }
    while (lState != FMOD.Studio.LOADING_STATE.LOADED);

    Console.WriteLine("Creating new event instance");

    FMOD.Studio.EventInstance instance;
    checkResult(ev.createInstance(out instance));
    checkResult(instance.start());

    while (true) {
        FMOD.Studio.PLAYBACK_STATE pState;
        instance.getPlaybackState(out pState);
        Console.WriteLine(pState);

        System.Threading.Thread.Sleep(500);

    };
}