an.sound_anchors#
Sound cues timed by the picture (an#317): at: {when: <node>, reaches: {y: px}} and until:.
A record scratch has to land when the last line of a crawl becomes readable.
Writing that second into the scene means solving the crawl’s geometry outside
an, and every layout change moves the picture away from the sound. Here the
cue names the event instead, and resolve_cue_anchors() finds the second
when the film is laid out:
at: {when: crawl/line_7, reaches: {y: 840}}— the first instant the node’s on-screen centre crosses that frame row (orxcolumn), from the very document the stage renders (compiled_document), through the camera, parallax and a crawl’s tilt (an.stage.timeline.screen_position()), sampled at every film frame and interpolated between the two that straddle it; plusoffset;at: {when: musket, event: land}— the instant an item’s hold event happens in the compiled shot (the hold report’sevents:grasp,place,contact,release,land,bounce,rest; and atopple’s,an.stage.topple),nthpicking the n-th; plusoffset. A swap’s clink lands on the frame the sabre reaches the socket, wherever the timing of the reach moves it;at: {when: book/body, changes: state, to: page_l}— the instant of the shot’snthset(ortween) of that node’s property (to that value, whentois given), read from the shot’s own actions: no stage document is needed, so it works in any shot (an#815); plusoffset. A page-turn sound follows the page wherever itssetis retimed;until: {cue: scratch, offset: 0.12}— the cue ends at that cue’s start plusoffset(itsdurationis derived).
A cue’s second is where its sound’s sync point goes (sync in its
sound.json, an.sounds.set_sync(): a clip whose clink comes 0.78 s
after a scrape is placed 0.78 s early), so an anchored hit sounds on its frame.
It runs on the in-memory settled copy of the scene (as the measured shot
lengths do, an.measurements): scene.md keeps the anchor, never the
second. Each resolved cue is reported as an info finding — “scratch at
33.03 s (crawl/line_7 reached y=840)” — which the render report records. An
anchor that cannot be resolved (no such node, never reached, a shot no stage
draws) refuses before any browser launches.
Functions
|
Shot-local seconds of |
|
Shot-local seconds of |
|
Shot-local seconds at which |
|
Shot-local seconds of |
|
|
Exceptions
A cue's anchor cannot be resolved: the message says which and why. |
- exception an.sound_anchors.SoundAnchorError[source]#
Bases:
ValueErrorA cue’s anchor cannot be resolved: the message says which and why.
- an.sound_anchors.anchor_in_document(doc, anchor, *, shot_id, fps, duration, where, shot=None, mall=None)[source]#
Shot-local seconds of
anchor(an event, an authored change ofshot, or a crossing), before itsoffset.- Return type:
- an.sound_anchors.change_in_shot(shot, anchor, *, where, play_extent=None)[source]#
Shot-local seconds of
anchor’s authored change: the start of thenthsetortweenofshotwhose target isanchor.whenand propertyanchor.changes(and whose value, a set’svalueor a tween’sto_value, isanchor.towhen given), in time order.play_extentis the compile’s (an.stage.compile.play_extent_of()), so asetafter a natural-lengthplayin asequenceis timed where the picture has it.>>> from an.ir.schema import SetAction, Shot >>> shot = Shot(id="s", actions=[ ... SetAction(target="book/body", property="state", value="page_l", at=1.5), ... SetAction(target="book/body", property="state", value="page_r", at=3.0), ... ]) >>> change_in_shot(shot, CueAnchor(when="book/body", changes="state", to="page_r"), where="x") 3.0 >>> change_in_shot(shot, CueAnchor(when="book/body", changes="state", nth=2), where="x") 3.0
- Return type:
- an.sound_anchors.crossing_in_document(doc, anchor, *, shot_id, fps, duration, where)[source]#
Shot-local seconds at which
anchor.when’s centre first reachesanchor.reaches, in a compiled stage document.- Return type:
- an.sound_anchors.event_in_document(doc, anchor, *, shot_id, where)[source]#
Shot-local seconds of
anchor’s hold event (thentheventof itemwhen) in a compiled stage document.- Return type:
- an.sound_anchors.resolve_cue_anchors(scene, ctx, renderers, *, film_starts)[source]#
scene(a copy) with every anchoredatresolved to seconds and everyuntilto a duration.ctx: the render context the shots are compiled under renderers: each shot’s renderer, in timeline order film_starts: each shot’s start in film time (a
meta.soundsanchor’sshot-local second is moved there)