docs: audio playback position reports - #208
Open
LautaroPetaccio wants to merge 1 commit into
Open
LautaroPetaccio wants to merge 1 commit into
LautaroPetaccio wants to merge 1 commit into
Conversation
Add a "Playback position reports" section to the SDK7 sounds page, covering the opt-in reportPlaybackPosition flag on AudioSource and the audioEventsSystem APIs that read the reports: registerAudioPlaybackEntity, getAudioPlayback, removeAudioPlaybackEntity and getSceneTimeAtTick. Explain why the reports are the only reliable way to know what the player is hearing, how to resolve sceneTime and offset against the scene clock to get the moment the audible clip started, and the output latency caveat that no field reports. Also correct the audio events section: an AudioSource clip only reaches MS_NONE, MS_ERROR, MS_LOADING, MS_READY and MS_PLAYING, the paused, buffering and seeking states only occur on an AudioStream, and timestamp is a monotonic counter rather than a time value.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Documents the new audio playback position reports on the SDK7 Sounds page (
creator/sdk7/3d-essentials/sounds.md).What's new on the page
tickNumber,currentOffsetandclipLengthfields the renderer writes intoAudioEventwhile a clip plays, and why they're the only reliable way to know what the player is actually hearing (currentTimeis a write-only seek, and a clip starts some milliseconds after the scene asks for it).reportPlaybackPositiononAudioSourceis required, otherwise no position is ever written and the playback callbacks never run. Explains why it's opt-in: a position report is written every time the playhead moves, far more often than a state change, and a scene can have many audio sources, so scenes only pay for it where they need it. Every code example creates itsAudioSourcewith the flag set.registerAudioPlaybackEntity(entity, callback)with its{ report, sceneTime, offset }payload, plusgetAudioPlayback()andremoveAudioPlaybackEntity().sceneTime - offsetis the moment the audible clip started rather than a lag, andgetSceneTimeAtTick()for scenes that handle raw reports (it works forVideoEventtoo).currentOffsetis the decoder's read position, not the moment sound leaves the speaker. Output latency adds tens of milliseconds that no field carries, roughly constant per device, so calibrate once if you need better than tick accuracy.Corrections to the existing audio events content
AudioSourceclip only ever reachesMS_NONE,MS_ERROR,MS_LOADING,MS_READYandMS_PLAYING.MS_PAUSED,MS_BUFFERINGandMS_SEEKINGonly occur on anAudioStream, and there's no pause for a clip: settingplayingto false stops and rewinds it.timestampis a monotonic counter the renderer increments per report, not a time value. The page previously described it as the time of the state change.currentTimeproperty bullet now says it's a seek command that the renderer never writes back.Related work
Supersedes decentraland/documentation#609, which targeted the now-archived
decentraland/documentationrepo. The content has been converted from Hugo shortcodes to GitBook syntax and reconciled with the audio events content that already exists on this page.