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
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 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 | |