Expand description
Shared multi-track mixing for assemble and daw. Port of
mix_common.py.
Stems are classified by the parsed script’s direction_type, then built
into a foreground (dialogue, SFX, beats — laid end to end with a gap)
and background layers (ambience looped to the next cue, music at its
cue, the vintage crackle between its markers). Every audio operation is
a Segment call, so the arithmetic is pydub’s.
Modules§
- config
- The slices of the cast and SFX config models the mixing stages read.
Port of the relevant parts of
CastConfiguration,VoiceConfig,SfxEntryandSfxConfigurationinmodels.py. - timeline
- Multitrack timeline views. Port of
timeline_viz.py.
Structs§
- Label
- A label / timeline span: the widest Python label tuple, unset fields
None. - Loop
Spec 🔒 - What distinguishes the two looped layers: which plans, which skip rule, which fallback label, and how a corrupt stem is named in the warning.
- Stem
Plan - Resolved metadata for one stem file (or a boundary sentinel).
Constants§
- AMBIENCE_
LEVEL_ DB - AMBIENCE_
LOOP 🔒 - BACKGROUND_
DIRECTION_ TYPES - Direction types routed to the background layers.
- DEDUPED_
TREATMENTS 🔒 - Treatments that must not stack with the same cast filter.
- FILTER_
REGISTRY 🔒 - The speaker keys
FILTER_REGISTRYknows, for the unknown-filter warning. - MUSIC_
LEVEL_ DB - SPAN_
DIRECTION_ TREATMENTS - Span markers and the treatment each engages, in stacking order.
- VINTAGE_
LOOP 🔒
Statics§
Functions§
- amb_
skip 🔒 - amb_
text 🔒 - apply_
clip_ 🔒effects _apply_clip_effects.- apply_
named_ 🔒filter _apply_named_filter.- apply_
speaker_ filters - apply_
vintage_ filter apply_vintage_filter— mono collapse, pydub single-pole EQ, -3 dB.- build_
ambience_ layer - build_
dialogue_ layer - build_
foreground build_foreground→(foreground, timeline).- build_
foreground_ timeline_ only build_foreground_timeline_only— header durations, no decoding.- build_
looped_ 🔒layer - Shared loop for the ambience and vintage-filter layers. With
renderoff it computes only the labels (compute_*_labels), without decoding. - build_
music_ layer - build_
sfx_ layer - build_
vintage_ filter_ layer - by_seq
- Stable sort by seq, as
sorted(plans, key=lambda p: p.seq). - cast_
filter_ names _cast_filter_names.- collect_
stem_ plans collect_stem_plans(stems_dir, entries_index, sfx_config).- compute_
ambience_ labels - compute_
dialogue_ labels compute_dialogue_labels.- compute_
music_ labels - compute_
sfx_ labels - compute_
vintage_ filter_ labels - cues_
for 🔒 - derive_
structure_ bands derive_structure_bands(entries_index, timeline, total_ms, key).- extract_
seq extract_seq(filepath);Nonewhere Python raisesValueError.- find_
effect_ entry _find_effect_entry: exact key, then em-dash-normalised.- get_str 🔒
- glob_
mp3 🔒 glob.glob(os.path.join(dir, "*.mp3")), sorted.- join
os.path.join(stems_dir, name)spelled the way glob returns it.- label_
text 🔒 - last_
underscore_ 🔒part basename.rsplit("_", 1)[-1].- load 🔒
- Load a stem, as
AudioSegment.from_file. Decode failures are fatal in the builders that do not catch them, as they are in Python. - load_
entries_ index load_entries_index(parsed_path)— insertion-ordered, last entry wins.- loop_
clip 🔒 _loop_clip(clip, duration_ms).- loop_
end 🔒 - The end of a looped span: the next cue of the same kind after this one.
- mp3_
duration_ ms _mp3_duration_ms— mutagen’s header read, truncated to whole ms.- normalize_
effect_ 🔒key - py_int 🔒
int(prefix)for a stem prefix — whitespace, sign and_separators between digits are all accepted by Python.- resolve_
audio_ 🔒params _resolve_audio_params.- sorted_
of 🔒 - span_
marker 🔒 - span_
names_ 🔒to_ apply - span_
scope 🔒 - span_
sentinel_ 🔒markers - Which markers of each span type get a synthetic boundary plan.
- span_
treatments _span_treatments: dialogue seq → treatments of the spans open there.- stem_
basename os.path.splitext(os.path.basename(p))[0].- strip_
chars 🔒 - Python
str.strip(chars). - treat_
dialogue 🔒 - Dialogue treatment shared by the foreground and the dialogue layer.
- trim_
to_ 🔒pct segment[:max(1, int(len(segment) * pct / 100.0))].- tts_
model_ 🔒of - The
COMM::engtext of a dialogue stem, only if mutagen could open it as an MP3 at all (it raises, and the Python swallows, otherwise). - vf_skip 🔒
- vf_text 🔒
- volume_
pct_ to_ db _volume_pct_to_db.- warn_
missing_ 🔒treatment_ codecs _warn_missing_treatment_codecs.