Audiokinetic's Community Q&A is the forum where users can ask and answer questions within the Wwise and Strata communities. If you would like to get an answer from Audiokinetic's Technical support team, make sure you use the Support Tickets page.

0 votes
Hi,

I'm Working on Unity and I want to get the information about the music segment that is playing, like duration or cursor position for example.

Do you have any example?

 

Thanks
in General Discussion by Javier C. (150 points)

1 Answer

0 votes

As I know,Wwise provides an IntegrationDemo with rich example code in the SDK.
It seems that the feature you want to know about happens to have a page dedicated to it.
I've taken one of the codes and put it below.

The main API for your goal is AK::SoundEngine::GetSourcePlayPosition( m_iPlayingID, &uPosition );
You can run the already compiled IntegrationDemo in the SDK and look at the code to see how to implement it.
Code Address... \Wwise2019.2.6.7381\SDK\samples\IntegrationDemo\DemoPages\...

void DemoMusicCallbacks::Draw()

{

    DemoMusicCallbacksBase::Draw();

 

    if ( m_bIsPlaying )

    {

        char strBuf[50];

        int iPosX = m_pParentMenu->GetWidth() / 4;

        int iPosY = m_pParentMenu->GetHeight() / 3;

 

        AkTimeMs uPosition;

 

        // Get the current play position and store it in a string buffer

        AK::SoundEngine::GetSourcePlayPosition( m_iPlayingID, &uPosition );

        snprintf( strBuf, 50"Bar: %d\nBeat: %d\nPosition=%d", (int)m_uiBarCount, (int)m_uiBeatCount, (int)uPosition );

 

        // Draw the play position and subtitles

        DrawTextOnScreen( strBuf, iPosX, iPosY, DrawStyle_Text );

    }

}

It was written in C++ so there should be not many difference,

Hope this helps :)

by Hou Chenzhong (Audiokinetic) (6.0k points)
...