tiny.rig.Playback
Defined in tiny.rig.
API (7)
Actions
Public operations.
advancesampleTime: The time to sample the clip at: the playhead, or the start of its step.step: The index of the pose on show, when stepping.
Fields and members
Public fields and members.
Source
Source: fun/rig/src/playback.zig:23
zig
pub const Playback = struct { /// Seconds into the clip. time: f64 = 0, speed: f32 = 1, loop: bool = true, /// Poses shown a second, or null for a new pose at every sample. step_rate: ?f32 = null, pub fn advance(playback: *Playback, seconds: f64) void { assert(std.math.isFinite(seconds)); assert(std.math.isFinite(playback.speed)); playback.time += seconds * playback.speed; } /// The index of the pose on show, when stepping. A playhead within /// `time.boundary_tolerance` of a step boundary counts as on it, so a /// clock advanced by a rounded 1/60 each tick still turns poses on /// exact ticks. pub fn step(playback: Playback) ?i64 { const rate = playback.step_rate orelse return null; assert(std.math.isFinite(rate)); assert(rate > 0); const position = time.floorSnapped(playback.time * rate); assert(@abs(position) < max_exact_step); return @intFromFloat(position); } /// The time to sample the clip at: the playhead, or the start of its /// step. pub fn sampleTime(playback: Playback) f64 { const index = playback.step() orelse return playback.time; return @as(f64, @floatFromInt(index)) / playback.step_rate.?; }};Source: fun/rig/src/root.zig:43
zig
pub const Playback = playback.Playback;Audit
| Definitions | 4 |
|---|---|
| Public names | 4 |
| Members | 4 |
| Version | 26.7.0 |
| Revision | daab053ee433 |