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 everyone,

I'm just getting into programming with UE5 + Wwise 2024.1.1.8691 and can't solve this linker error I get when trying to use GetSourcePlayPosition():

Error        CompilerResultsLog        WwisePlaybackActor.cpp.obj : error LNK2019: unresolved external symbol "enum AKRESULT __cdecl AK::SoundEngine::GetSourcePlayPosition(unsigned int,int *,bool)" (?GetSourcePlayPosition@SoundEngine@AK@@YA?AW4AKRESULT@@IPEAH_N@Z) referenced in function "public: virtual void __cdecl AWwisePlaybackActor::Tick(float)" (?Tick@AWwisePlaybackActor@@UEAAXM@Z)

Error        CompilerResultsLog        C:\Users\Leo\Documents\Unreal Projects\Visualiser_Tool\Binaries\Win64\UnrealEditor-Visualiser_Tool-2631.dll : fatal error LNK1120: 1 unresolved externals

I've added EnableGetSourcePlayPosition to AkGameplayTypes.h per this article : https://alessandrofama.com/tutorials/wwise/unreal-engine/playback-position
And I've also used the AK_EnableGetSourcePlayPosition flag. Not sure if the error is related to my implementation of the function or something with my Wwise implementation; posting events works fine.

Any help would be much appreciated, thank you.

Here's my code:

#include "Visualiser_Tool/Public/WwisePlaybackActor.h"
#include "Engine/Engine.h"
#include "Logging/LogMacros.h"
#include "AkGameplayStatics.h"

AWwisePlaybackActor::AWwisePlaybackActor()
{
    PrimaryActorTick.bCanEverTick = true;
    PlayingID = AK_INVALID_PLAYING_ID;
}

void AWwisePlaybackActor::BeginPlay()
{
    Super::BeginPlay();

    if (AssignedEvent)
    {
       FOnAkPostEventCallback nullCallback;
       const int32 Flags = AK_EnableGetSourcePlayPosition;

       PlayingID = UAkGameplayStatics::PostEvent(AssignedEvent,this,Flags,nullCallback);
    }
}

void AWwisePlaybackActor::Tick(float DeltaTime)
{
    Super::Tick(DeltaTime);

    if (PlayingID != AK_INVALID_PLAYING_ID)
    {
       AkTimeMs CurrentPositionMs = 0;
       AKRESULT Result = AK::SoundEngine::GetSourcePlayPosition(PlayingID, &CurrentPositionMs, true);
    }
}
in General Discussion by Leo V. (140 points)

1 Answer

+1 vote
 
Best answer

Hi Leo,

I wouldn't recommend following my tutorials anymore, as they target Wwise 2019 and Unreal Engine 4, and many code conventions and workflows have changed.

As mentioned in the Unreal Engine C++ Projects documentation page:

Note:
You must use the WwiseSoundEngine module's IWwiseSoundEngineAPI interface for all AK::SoundEngine calls.

In practice, this means you'd have to replace your current code in the Tick function with:

if (auto* SoundEngine = IWwiseSoundEngineAPI::Get())
{
    if (PlayingID != AK_INVALID_PLAYING_ID)
    {
        AkTimeMs CurrentPositionMs = 0;
        SoundEngine->GetSourcePlayPosition(PlayingID, &CurrentPositionMs, true);
    }
}

You'll need to include "Wwise/API/WwiseSoundEngineAPI.h" for this to work.


Trying to post the event on this actor will still fail with the warning:

LogAkAudio: Warning: Failed to post AkAudioEvent 'MyAwesomeEvent' with an actor that doesn't have an AkComponent on Root.

To avoid this issue and properly hear the event you have posted, add an Ak Component to this actor in the Details tab of the Unreal Inspector while the actor is selected.

ago by Alessandro Famà (460 points)
selected ago by Leo V.
Hi Alessandro,

Thanks for the informative reply, I've got it working now - hopefully this post helps anyone else who skims through documentation :)
...