"getTimelinePosition" function not working correctly

Hi,

For my project, we are using the getTimelinePosition function to feed the background music position to a parameter of another event. It seems, however, that getTimelinePosition does not account for anything you have in the logic track.

If I have a 10-second event with a loop point from 3 to 5 seconds, you would expect getTimelinePosition to return something like

1 2 3 4 5 3 4 5 3 4 5 (etc)

but in this example, getTimelinePosition just counts to 10 and starts over.

My long-winded question is, is getTimelinePosition broken in this regard, or is my team missing something?

Hi Thomas

I have tried to reproduce this issue in one of our examples with no success - it appears to me that getTimelinePosition is working exactly as you expect it to.

Below is a modified version of our simple_event example which sets the “Time” parameter on the “Ambience/Country” event so that playing that event causes it to loop between 18 and 24 seconds. The modified example polls the timeline position and displays some extra statistics. Running the modified example you see the timeline position starts at 16 seconds and loops back to 18 seconds when it reaches 22 seconds.

If you’re able to modify the example to reproduce the issue you’re having, or provide a simple reproduction of your issue, then we can take another look.

Cheers
Derek


/*==============================================================================
Simple Event Example
Copyright (c), Firelight Technologies Pty, Ltd 2012-2017.

Modified example to test behaviour of getTimelinePosition

==============================================================================*/
#include "fmod_studio.hpp"
#include "fmod.hpp"
#include "common.h"

int FMOD_Main()
{
    void *extraDriverData = NULL;
    Common_Init(&extraDriverData);

    FMOD::Studio::System* system = NULL;
    ERRCHECK( FMOD::Studio::System::create(&system) );

    // The example Studio project is authored for 5.1 sound, so set up the system
    // output mode to match
    FMOD::System* lowLevelSystem = NULL;
    ERRCHECK( system->getLowLevelSystem(&lowLevelSystem) );
    ERRCHECK( lowLevelSystem->setSoftwareFormat(0, FMOD_SPEAKERMODE_5POINT1, 0) );

    ERRCHECK( system->initialize(1024, FMOD_STUDIO_INIT_NORMAL, FMOD_INIT_NORMAL, 
        extraDriverData) );
    
    FMOD::Studio::Bank* masterBank = NULL;
    ERRCHECK( system->loadBankFile(Common_MediaPath("Master Bank.bank"), 
        FMOD_STUDIO_LOAD_BANK_NORMAL, &masterBank) );
    
    FMOD::Studio::Bank* stringsBank = NULL;
    ERRCHECK( system->loadBankFile(Common_MediaPath("Master Bank.strings.bank"), 
        FMOD_STUDIO_LOAD_BANK_NORMAL, &stringsBank) );
    
    FMOD::Studio::Bank* ambienceBank = NULL;
    ERRCHECK( system->loadBankFile(Common_MediaPath("Surround_Ambience.bank"), 
        FMOD_STUDIO_LOAD_BANK_NORMAL, &ambienceBank) );

    // Get the Looping Ambience event
    FMOD::Studio::EventDescription* loopingAmbienceDescription = NULL;
    ERRCHECK( system->getEvent("event:/Ambience/Country", 
        &loopingAmbienceDescription) );

    FMOD::Studio::EventInstance* loopingAmbienceInstance = NULL;
    ERRCHECK(loopingAmbienceDescription->createInstance(&loopingAmbienceInstance));

    // Set Time parameter so that we are looping in the NoonLoop
    FMOD_STUDIO_PARAMETER_DESCRIPTION paramDesc;
    ERRCHECK(loopingAmbienceDescription->getParameter("Time", &paramDesc));
    int timeParameterIndex = paramDesc.index;

    ERRCHECK( loopingAmbienceInstance->setParameterValueByIndex(
        timeParameterIndex, 0.3f) );

    // Track timeline position
    int timelinePosition = -1;
    int minimumTimelinePosition = INT_MAX;
    int maximumTimelinePosition = -1;

    ERRCHECK(loopingAmbienceInstance->start());

    do
    {
        Common_Update();

        ERRCHECK(system->update());

        // Poll timeline position
        if (!loopingAmbienceInstance || 
            FMOD_OK != loopingAmbienceInstance->getTimelinePosition(&timelinePosition))
        {
            timelinePosition = -1;
        }

        // Update minimum & maximum
        if (timelinePosition > 0 && timelinePosition < minimumTimelinePosition)
        {
            minimumTimelinePosition = timelinePosition;
        }

        if (timelinePosition > maximumTimelinePosition)
        { 
            maximumTimelinePosition = timelinePosition;
        }

        Common_Draw("==================================================");
        Common_Draw("Simple Event Example.");
        Common_Draw("Copyright (c) Firelight Technologies 2012-2017.");
        Common_Draw("==================================================");
        Common_Draw("");
        Common_Draw("Timeline Position Current: %d", timelinePosition);
        Common_Draw("Timeline Position Min/Max: %d/%d", minimumTimelinePosition, 
            maximumTimelinePosition);
        Common_Sleep(50);
    } while (!Common_BtnPress(BTN_QUIT));
    
    ERRCHECK( ambienceBank->unload() );
    ERRCHECK( stringsBank->unload() );
    ERRCHECK( masterBank->unload() );

    ERRCHECK( system->release() );

    Common_Close();

    return 0;
}

1 Like