Timeline Viz
src.xil_pipeline.timeline_viz
Multitrack timeline visualization for the audio pipeline.
Renders a visual representation of asset placement across all four audio layers (dialogue, ambience, music, SFX). Two output formats are supported:
- Terminal ASCII timeline — printed to stdout, auto-scaled to terminal width.
- HTML interactive timeline — self-contained file with hover tooltips and zoom.
No pydub dependency — consumes label tuples only.
Usage (from XILP005): python XILP005_daw_export.py --episode S02E03 --timeline python XILP005_daw_export.py --episode S02E03 --timeline-html
LayerSpan
dataclass
A single asset placement on the timeline.
Attributes:
-
start_s(float) –Start time in seconds.
-
end_s(float) –End time in seconds.
-
label(str) –Human-readable label (speaker name, SFX text, etc.).
-
ramp_in_s(float | None) –Fade-in duration in seconds, or
Noneif not set. -
ramp_out_s(float | None) –Fade-out duration in seconds, or
Noneif not set. -
play_duration(float | None) –Percentage of file to play, or
Noneif not set. -
snippet(str | None) –First 5 words of dialogue text for HTML tooltip, or
None. -
volume_pct(float | None) –Volume percentage (100 = unity), or
Noneif not set. -
seq(int | None) –Sequence number from the parsed script, or
None.
Source code in src/xil_pipeline/timeline_viz.py
TimelineData
dataclass
Complete timeline data for all four layers.
Attributes:
-
tag(str) –Episode tag (e.g.
"S02E03"). -
total_duration_s(float) –Total episode duration in seconds.
-
layers(dict[str, list[LayerSpan]]) –Mapping of layer name to list of :class:
LayerSpaninstances. -
sections(list[LayerSpan]) –Script-section bands (cold-open, act1, …) for the structure ruler. Kept out of
layersso they are not counted as assets. -
scenes(list[LayerSpan]) –Script-scene bands (scene-1, scene-2, …) for the structure ruler.
Source code in src/xil_pipeline/timeline_viz.py
layers
class-attribute
instance-attribute
build_timeline_data
build_timeline_data(tag: str, total_s: float, dlg_labels: list, amb_labels: list, mus_labels: list, sfx_labels: list, vf_labels: list | None = None, *, section_bands: list | None = None, scene_bands: list | None = None) -> TimelineData
Wrap the layer label lists into a :class:TimelineData object.
Label tuples may be 3-element (start_s, end_s, text),
5-element (start_s, end_s, text, ramp_in_s, ramp_out_s),
6-element (start_s, end_s, text, ramp_in_s, ramp_out_s, play_duration), or
7-element (start_s, end_s, text, ramp_in_s, ramp_out_s, play_duration, snippet).
Parameters:
-
tag(str) –Episode tag.
-
total_s(float) –Total episode duration in seconds.
-
dlg_labels(list) –Dialogue label 7-tuples
(start_s, end_s, speaker, None, None, None, snippet). -
amb_labels(list) –Ambience label tuples (may carry ramp data).
-
mus_labels(list) –Music label tuples (may carry ramp data).
-
sfx_labels(list) –SFX label tuples.
-
vf_labels(list | None, default:None) –Vintage filter label tuples (may carry ramp data).
-
section_bands(list | None, default:None) –Script-section
(start_s, end_s, label)tuples from :func:mix_common.derive_structure_bands, for the structure ruler. -
scene_bands(list | None, default:None) –Script-scene
(start_s, end_s, label)tuples.
Returns:
-
TimelineData–A populated :class:
TimelineDatainstance.
Source code in src/xil_pipeline/timeline_viz.py
render_terminal_timeline
Render a multi-line Unicode timeline string for terminal display.
Parameters:
-
data(TimelineData) –Timeline data from :func:
build_timeline_data. -
width(int | None, default:None) –Terminal width in characters. If
None, auto-detected via :func:shutil.get_terminal_size.
Returns:
-
str–Multi-line string suitable for printing to stdout.
Source code in src/xil_pipeline/timeline_viz.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | |
render_text_timeline_map
Write a human-readable cue sheet of the episode's foreground timing.
Dialogue and SFX spans interleaved chronologically; music and ambience are omitted — they are background layers that do not move the foreground timeline.
Parameters:
-
data(TimelineData) –Timeline data from :func:
build_timeline_data. -
output_path(str) –Path to write the text map.
-
slug(str, default:'') –Show slug for the header (omitted when empty).
Returns:
-
str–The path written (same as output_path).
Source code in src/xil_pipeline/timeline_viz.py
render_html_timeline
render_html_timeline(data: TimelineData, output_path: str, stems_dir: str | None = None, *, slug: str = '', tag: str = '', layers_dir: str | None = None) -> str
Write a self-contained HTML timeline file.
Parameters:
-
data(TimelineData) –Timeline data from :func:
build_timeline_data. -
output_path(str) –Path to write the HTML file.
-
stems_dir(str | None, default:None) –Directory of episode stem MP3 files. When provided, clicking a timeline block plays the corresponding stem via an embedded audio player (served by Gradio's
/gradio_api/file=endpoint). -
slug(str, default:'') –Show slug — embedded as
XIL_SLUGJS constant for the right-click sound profile editor. -
tag(str, default:'') –Episode tag — embedded as
XIL_TAGJS constant. -
layers_dir(str | None, default:None) –Directory of the DAW layer WAVs (
{tag}_layer_{key}.wav). Existing layer files are embedded asLAYER_AUDIO(with an mtime cache-buster) to power the full-mix transport; when absent the transport UI is hidden.
Returns:
-
str–The path written (same as output_path).
Source code in src/xil_pipeline/timeline_viz.py
1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 | |