feat: enhance waveform rendering and add auto-centering #7798
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.
PR Description
Reason for change
This PR addresses two significant user experience issues in the AudioUltra component, particularly impacting workflows with synchronized media like TimeSeries or GPS visualizations:
The solution implements two key enhancements:
WaveformRenderer.ts
. The component now always performs a full render of the visible waveform area. This completely eliminates visual tearing and ensures a smooth, consistent display.centerToTime()
method has been introduced. When a seek event originates from an external, synchronized component, the waveform and spectrogram views now automatically center on the new time position, with the playhead positioned precisely in the middle. This behavior is isolated to external sync events to avoid interfering with local user interactions.Screenshots & Demo
Here are "before" and "after" videos demonstrating the improvements.
Before:
The video shows the lack of centering on external seeks and visual tearing during scrolling.
https://www.loom.com/share/377a287e98ef42239feea0631bdc7ce8
After:
This video showcases the new smart centering feature and the smooth, tear-free waveform rendering.
https://www.loom.com/share/a504416edb144f7b9e336a36f7fe091b
Rollout strategy
This is a direct enhancement to the existing AudioUltra component. The changes are UX improvements and bug fixes that can be rolled out directly without a feature flag or environment variable. The
autoCenter
parameter, which controls this behavior, is already part of the component's configuration.Testing
The changes have been verified through the following steps:
zoom > 1
).Risks
Reviewer notes
web/libs/editor/src/lib/AudioUltra/Visual/Renderer/WaveformRenderer.ts
, where the logic forrenderPartialWave
has been removed in favor of always callingrenderWave
.web/libs/editor/src/tags/object/AudioUltra/model.js
: ThehandleSyncSeek
action now callscenterToTime(time)
within arequestAnimationFrame
to ensure correct timing.web/libs/editor/src/lib/AudioUltra/Waveform.ts
: A newcenterToTime
method was added, which orchestrates the centering and uses anotherrequestAnimationFrame
to prevent race conditions between scrolling and playhead updates.web/libs/editor/src/lib/AudioUltra/Visual/Visualizer.ts
: A correspondingcenterToTime
method was added to handle the scroll position calculation.requestAnimationFrame
calls are intentional and crucial for ensuring that UI updates (scrolling, seeking) are fully processed before dependent actions (playhead positioning, drawing) are executed.General notes
This change significantly improves the usability of Label Studio for any project involving synchronized media. It makes navigating complex, multi-modal data far more intuitive and less frustrating for the user.