AudioTrack¶
from acron.anim import AudioTrack
- class AudioTrack(times, streams, length: float)¶
Bases:
objectGodot’s
AnimationPlayeraudio track: streams keyed on a clip’s clock.A Godot animation can carry
type = "audio"tracks – a list of{stream, start_offset, end_offset}clips at keyed times on a node that is anAudioStreamPlayer. They are how a walk cycle carries its own footsteps, and nothing else can: the feet land at 0.8 s and 2.03 s of a 2.5 s cycle, so a footstep timed off the wall clock is in step with the animation only while the animation runs at exactly one times speed and never crossfades. Acron has no equivalent – anAnimControlis frames, not events – so this is the piece that has to be built.Feed it the clip’s own MONOTONIC time (
BlendClock.time_of(), which accumulates rather than wrapping) once per step; it returns the streams whose key the playhead crossed since the last call, in order, and it handles a cycle that wrapped – or several, if a step was long.Two things it deliberately does not do:
it does not play anything. What a stream IS belongs to the game (a
res://path here, anacron.audio.SoundBankcall there), and an animation module that reached for an audio manager would drag one into every port that only wants poses.it does not scale the volume. Godot’s
use_blendmakes an audio track’s volume the track’s own blend weight, so footsteps fade in with the walk they belong to; the caller knows that weight (it is the same number it passed toapply_weights()) and applies it.
A clip that LEAVES a blend loses its clock –
BlendClockdrops the entry, so the nexttime_ofis 0 again – and this notices that by the time going backwards, and starts the new cycle cleanly rather than firing every key between the two.Inheritance diagram
digraph inheritance2b24ac9bed { bgcolor=transparent; rankdir=BT; size="8.0, 12.0"; "AudioTrack" [URL="acron.anim.AudioTrack.html#acron.anim.AudioTrack",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="Godot's ``AnimationPlayer`` **audio track**: streams keyed on a clip's clock."]; }