foley.weave.anchor#
Symbolic-anchor → sample-onset heuristics — the SELECT→WEAVE timing bridge (report 06 §2.4).
Pure, stdlib-only functions that turn a placed sound’s symbolic anchor (SELECT’s
"on 'pushed open'" string, or a resolved Placement) into a
concrete trigger time (seconds) against a forced-aligned word_timeline
([{'word','start','end'}, ...]). Cheapest-first, exactly as report 06 §2.4:
word anchor (one-shots) — fire on the onset of the trigger word;
pre-roll — shift a clip earlier so its salient transient lands on the anchor;
sentence span (beds) — start at the first word of the sentence, run to the last;
scene / paragraph boundary (stingers, ambience swaps) — the boundary’s first word;
pause snapping — nudge an onset to the nearest inter-word gap to avoid masking speech.
These are pure (anchor, word_timeline) -> seconds functions with no I/O and no
heavy dependency, so they are independently unit-testable and keep import
foley.weave dol-only. foley.weave.anchor.parse_symbolic_anchor is the single
SSOT bridge from SELECT’s sparse TimelineItem.onset string to a
Placement.
Module Attributes
Inter-word gap (seconds) that ends a sentence segment (report 06 §2.4 uses |
Functions
|
Parse SELECT's sparse symbolic |
|
Resolve a |
- foley.weave.anchor.SEGMENT_GAP_S: float = 0.35#
Inter-word gap (seconds) that ends a sentence segment (report 06 §2.4 uses
> ~350 msas a lightweight sentence segmenter over the aligned transcript).
- foley.weave.anchor.parse_symbolic_anchor(onset, *, layer=Layer.sfx_fg, loop=False)[source]#
Parse SELECT’s sparse symbolic
onsetstring into a resolved-laterPlacement.The anchor type follows the item’s role (report 06 §2.4): beds (
loop/ambience/music) span a sentence, stingers land on a scene boundary, and everything else is a word anchor; therefis the quoted phrase the sound lands on. ANoneonset means “no cue”: beds span from the start, one-shots sit atabsolute0. A bare number (defensive — SELECT is told never to emit one) is read as an absolute offset in seconds.- Parameters:
- Return type:
- Returns:
A
Placementwhoseonset(seconds) is resolved later byresolve_anchor()against theword_timeline.
- foley.weave.anchor.resolve_anchor(placement, word_timeline, *, snap_pauses=False)[source]#
Resolve a
Placementto a concrete(onset_seconds, duration_seconds).Dispatches on
placement.anchor(report 06 §2.4):absoluteuses the stored offset;wordfires on the trigger word;sentencespans its sentence (fillingdurationwhen unset — beds loop to fill it);scene/paragraphland on the boundary.pre_rollis then subtracted (clamped at 0), and — whensnap_pauses— the onset snaps to the nearest inter-word gap.- Parameters:
- Return type:
- Returns:
(onset_seconds, duration_seconds_or_None).durationis filled only for a span anchor whoseplacement.durationwas unset.