Repository navigation
Timeline and Waveform Editor
Section: Desktop App · Desktop-UI-Architecture · Home · Media-Playback-System
The Timeline & Waveform Editor is the desktop app workstation surface for media alignment: duration-based peak buckets, multi-track timeline, transcript segment edits, dub review against source, and speaker tracks with synchronized scrubbing.
The editor follows a strict separation between domain logic, playback services, and UI presentation. The AvaloniaProjectDisplayBuilder acts as a coordination layer, transforming domain entities into view models suitable for the Avalonia UI shell.
The timeline is composed of multiple tracks and clips. Each clip represents a temporal segment of media, such as a source video or a generated dub.
| Class/Record | Purpose |
|---|---|
TimelineTrackViewModel |
Represents a horizontal lane in the editor (e.g., Source, Ambiance, or Speaker). |
TimelineClipViewModel |
A discrete block of media within a track defined by start and end seconds. |
WaveformSummary |
Contains visualization data derived from normalized PCM audio. |
WaveformSegmentBoundary |
Defines the temporal bounds of a transcript segment for waveform highlighting. |
The following diagram illustrates the relationship between the project builders and the timeline components.
classDiagram
class AvaloniaProjectDisplayBuilder {
+BuildTimelineTracks()
+BuildWaveformSegmentBoundaries()
}
class TimelineTrackViewModel {
+string Name
+AppColor Color
+ObservableCollection~TimelineClipViewModel~ Clips
}
class TimelineClipViewModel {
+double StartSeconds
+double EndSeconds
+string Label
+WaveformSummary Waveform
}
class WaveformSummary {
+IReadOnlyList~float~ Peaks
+double DurationSeconds
}
AvaloniaProjectDisplayBuilder ..> TimelineTrackViewModel : creates
TimelineTrackViewModel "1" *-- "many" TimelineClipViewModel : contains
TimelineClipViewModel o-- WaveformSummary : displays
Waveform generation is performed from normalized PCM audio data. The editor uses "peak buckets" to maintain performance during rendering while preserving a consistent visual contract.
The WaveformLayout.Build function calculates the specific coordinates for rendering a waveform on a canvas. It maps audio peaks to visual bars based on the available width and height.
- Peak Sampling: The system determines how many bars to render based on the canvas width.
-
Amplitude Mapping: It iterates through the
WaveformSummarypeaks, calculating the maximum amplitude for each bucket to determine bar height. - Temporal Mapping: It translates time-based data (playback position and segment boundaries) into pixel-based coordinates.
flowchart TD
Start[Request Waveform Layout] --> GetWaveform[Get WaveformSummary & Segments]
GetWaveform --> CalcBars[Calculate renderBarCount based on Width]
CalcBars --> Loop[Iterate through Bar Indices]
Loop --> FindMax[Find Max Amplitude in Peak Bucket]
FindMax --> BuildBar[Create WaveformBarLayout]
BuildBar --> Next{More Bars?}
Next -- Yes --> Loop
Next -- No --> Markers[Map Time to Pixels for Markers & Cursor]
Markers --> Final[Return WaveformCanvasLayout]
The WaveformMapping utility provides the logic for bidirectional conversion between timeline time and UI coordinates.
-
TimeToPixel:
(timeSeconds / durationSeconds) * width(clamped 0.0 to 1.0). -
PixelToTime:
(pixel / width) * durationSeconds.
The editor enforces strict rules for clip placement to prevent overlaps and ensure data integrity.
The UiHelpers.CanPlaceClip method validates whether a new clip can be added to a track without conflicting with existing clips. It checks the proposed start and duration against the current collection of clips.
// Example placement validation from tests
(double Start, double Duration)[] existing = track.Clips
.Select(clip => (clip.StartSeconds, clip.DurationSeconds))
.ToArray();
bool canPlace = UiHelpers.CanPlaceClip(newStart, newDuration, existing);The BuildTimelineTracks method dynamically constructs the editor's visual lanes based on project state:
- Source Track: Added if media is present, displaying the full source media waveform.
- Ambiance Track: Added if an ambiance stem (Music + SFX) is available.
- Speaker Tracks: Individual tracks for each detected speaker, containing clips for both original dialogue segments and generated dubs.
The shell redesign mockup defines the intended UX for the timeline dock.
- Timeline Bar: Contains tools for Splitting (S), Merging, Trimming, and Deleting (Del) clips, along with zoom controls and a timecode display.
-
Track Headers: Displays speaker names, colors (from the
SpeakerPalette), and Mute/Solo controls. - Visual Feedback: A playhead (vertical line) indicates the current playback position across all tracks.
The Timeline & Waveform Editor provides a robust framework for managing temporal media data within Trackdub. By utilizing peak-based waveform summaries and a multi-track view model architecture, it enables precise alignment and review of dubbing artifacts. The editor's reliance on the WaveformMapping logic ensures that visual representation remains perfectly synchronized with the underlying audio and transcript data.
Trackdub Engineering Wiki · Trackdub-gated · Trackdub · Contributing
Overview
Architecture
Pipeline
- Pipeline-Orchestration
- Media-Ingest-and-Preparation
- Transcription-and-VAD
- Diarization-and-Speaker-Management
- Translation-Engine
- Text-to-Speech
- Lip-Sync-and-Synthesis
- Mixing-and-Export
Desktop App
AI & Inference
- Inference-Routing-and-Planning
- ONNX-Execution-Providers
- Model-Manifests-and-Governance
- Hardware-Starter-Packs
Media & Audio
Data
Cloud & SaaS
- Cloud-API-and-Job-Management
- Web-Dashboard
- Billing-and-Quota-Management
- Webhook-Delivery-System
- Cloud-Infrastructure-Deployment
Development
Links