Getting Sound Duration at Runtime

In order to get a sound’s duration at runtime, an event to play that sound needs to be posted to the audio middleware first. Once it has been posted, the middleware will callback to the audio system with the duration information. If you are interested in this information, you can simply connect to the AudioTriggerNotificationBus by the ATL trigger Id that was used.

By overriding the ReportDurationInfo function, you will be notified with that information.

C++ Example: Getting a Sound’s Duration

class MyClass
    : protected AudioTriggerNotificationBus::Handler
{
public:
    MyClass()
    {
        TAudioControlID triggerId = ...;
        AudioTriggerNotificationBus::Handler::BusConnect(TriggerNotificationIdType{ this });
 
        // execute the m_triggerId ...
        if (auto audioSystem = AZ::Interface<IAudioSystem>::Get();
            audioSystem != nullptr)
        {
            // Example 1: via raw Audio Request
            Audio::ObjectRequest::ExecuteTrigger execTrigger;
            execTrigger.m_triggerId = triggerId;
            execTrigger.m_owner = this;
            audioSystem->PushRequest(AZStd::move(execTrigger));

            // Example 2: via AudioProxy
            IAudioProxy* proxy = audioSystem->GetAudioProxy();
            if (proxy)
            {
                // The second parameter is the "owner" override, which matches
                // what Id is connected to on the notification bus.
                proxy->Initialize("Example Sound", this);
                proxy->ExecuteTrigger(triggerId);
                proxy->Release();
            }
        }
    }
 
    ~MyClass()
    {
        AudioTriggerNotificationBus::Handler::BusDisconnect();
    }
 
protected:
    void ReportDurationInfo(
        TAudioControlID triggerId,
        TAudioEventID eventId,
        float duration,
        float estimatedDuration) override
    {
        // ...
    }
};

Copyright © 2026 DawnEngine. All rights reserved.

DawnEngine is a commercial 3D engine distributed under the DawnEngine end-user license agreement. Engine binaries and source are proprietary and are not covered by the licenses below.

Documentation only: the prose and templates on this site are a derivative work of Open 3D Engine (O3DE) documentation by the O3DE Contributors, used under CC BY 4.0 (documentation content), Apache 2.0 (site code), and the MIT license (inline code samples).

The open-source 3D engine that DawnEngine is built on top of is Open 3D Engine . DawnEngine is not affiliated with, endorsed by, or sponsored by The Linux Foundation or the O3DE project. “O3DE” and “Open 3D Engine” are trademarks of The Linux Foundation.