버전

menu_open

Integration Details - GetSourcePlayPosition

Introduction

In certain circumstances, the game engine requires information about the current playback position of a particular sound. For example, games that support rendering video and audio contents in a synchronous manner must query the playback position of sounds to render game visuals appropriately. If this has to be done on a frame-by-frame basis (such as to synchronize lip movement and dialog), then playback position queries are preferable over markers. Another advantage of playback position queries is that the source files do not need to be edited. The AK::SoundEngine::GetSourcePlayPosition() method returns the time elapsed on an event's first sound playback.

Note.gif
Note: Markers are useful for signalling specific events happening in a sound file, as opposed to small increments in sound playback.

Integration

To be able to query the playback position of a source, you must pass the AK_EnableGetSourcePlayPosition flag to the AK::SoundEngine::PostEvent() method. This informs the sound engine that the source associated with this event should be given special consideration because AK::SoundEngine::GetSourcePlayPosition() can be called at any time for this AkPlayingID.

You can then call the AK::SoundEngine::GetSourcePlayPosition() method by passing the AkPlayingID received from the call to AK::SoundEngine::PostEvent() to get the current playback position of the source being played.

Example

The following piece of code illustrates the AK::SoundEngine::GetSourcePlayPosition() method's usage:

(...)
static AkPlayingID g_markersPlayingID = 0;
(...)

(...)

g_markersPlayingID = AK::SoundEngine::PostEvent( AK::EVENTS::PLAY_MARKERS_TEST, GAME_OBJECT_ID_MARKERS,
    AK_EnableGetSourcePlayPosition, NULL, NULL );

(...)

AkTimeMs uPosition = 0;
// Somewhere in your game loop (happens periodically):
AK::SoundEngine::GetSourcePlayPosition( g_markersPlayingID, &uPosition );
// Now handle lip synchronization by using uPosition

Limitations

  • When an event contains multiple play actions, GetSourcePlayPosition() returns the position of the first source played by the target of the first play action occurring at time 0. When this source stops, the source whose position is returned is undefined.
  • Continuous (random or sequence) containers return the position of the sound that is currently playing. When there are many sounds, the source whose position is returned is undefined. In crossfade or sample-accurate transitions, the next source returns its position only when the previous source has finished playing.
  • When used with extrapolation, looping sources may overshoot the loop end for a short period of time when the loop occurs.
  • Dynamic pitch changes may result in slightly offset playback positions for a short period of time during the transition.
See also:

이 페이지가 도움이 되었나요?

지원이 필요하신가요?

질문이 있으신가요? 문제를 겪고 계신가요? 더 많은 정보가 필요하신가요? 저희에게 문의해주시면 도와드리겠습니다!

지원 페이지를 방문해 주세요

작업하는 프로젝트에 대해 알려주세요. 언제든지 도와드릴 준비가 되어 있습니다.

프로젝트를 등록하세요. 아무런 조건이나 의무 사항 없이 빠른 시작을 도와드리겠습니다.

Wwise를 시작해 보세요