Audio

Qualified name: algan.animation\_timeline.animation\_contexts.Audio

class Audio(source, *, wait_at_end=0.0, **kwargs)[source]

Bases: AnimationContext

Play a sound, and fit the block’s animations to its length.

The context’s runtime is taken from the audio, so whatever you animate inside is stretched or squeezed to finish with the sound. That inversion is the point: you describe what should happen while a clip plays, rather than timing the clip against the animation.

Parameters:
  • source (str) – Path to an audio file, or an already-loaded moviepy audio clip.

  • wait_at_end (float) – Extra seconds to hold after the audio finishes, before the block ends. Defaults to 0.

  • **kwargs (Any) – Passed to AnimationContext. Note runtime is set from the audio and should not be passed.

Examples

with Audio("whoosh.wav"):
    square.move(RIGHT * 5)  # takes exactly as long as the clip

See also

Speech

The same, driven by a line of narration transcript.

Methods

Attributes

animation_manager

child_contexts

combine_easing

composed_easing

current_time

Where the authoring cursor sits within this context, in seconds.

easing

end_time

The furthest time anything recorded in this context reaches, in seconds.

equalize_runtimes

finished

kwargs

lag_ratio

new_animation

new_mobs

prev_context

priority_level

record_attr_modifications

record_funcs

runtime

runtime_per_part

spawn_at_end