Skip to main content

JamSyncController

Struct JamSyncController 

Source
pub struct JamSyncController { /* private fields */ }
Expand description

Controller that synchronises a local timecode generator to an external timecode reference.

§State machine

WaitingForReference ──(first feed_reference)──► Locking
      ▲                                              │
      │              ┌───────────────────────────────┘
      │              │  N consecutive sequential frames
      │              ▼
      │           Locked ◄─────────────────────────────┐
      │              │                                  │
      │   (reference lost > holdover_budget)    (reference resumes)
      │              ▼                                  │
      │          Holdover ──────────────────────────────┘
      │              │
      └──(reset())───┘

Implementations§

Source§

impl JamSyncController

Source

pub fn new( frame_rate: FrameRate, config: JamSyncConfig, ) -> Result<Self, TimecodeError>

Create a new controller for the given frame_rate using the provided config.

§Errors

Returns an error if TimecodeGenerator::at_midnight fails (should not occur for well-defined frame rates).

Source

pub fn with_default_config(frame_rate: FrameRate) -> Result<Self, TimecodeError>

Create a controller with default configuration.

§Errors

See new.

Source

pub fn state(&self) -> JamSyncState

Current synchronisation state.

Source

pub fn feed_reference(&mut self, tc: Timecode)

Feed an incoming reference timecode frame.

This drives the state machine forward:

  • WaitingForReferenceLocking on the first call.
  • LockingLocked after lock_threshold consecutive sequential frames.
  • HoldoverLocked (immediate re-lock) when a sequential frame arrives.
Source

pub fn output(&mut self) -> Timecode

Return the current output timecode.

In Locked or Holdover state the local generator advances by one frame each call. In WaitingForReference or Locking the generator is frozen until lock is acquired.

Calling output() also updates the holdover counter: if frames_since_ref > holdover_budget while in Locked state the controller transitions to Holdover.

Source

pub fn reset(&mut self) -> Result<(), TimecodeError>

Reset the controller to WaitingForReference state.

The local generator is reset to midnight.

§Errors

Returns an error if resetting the generator fails.

Source

pub fn enter_holdover(&mut self)

Force the controller into Holdover state (e.g. reference cable disconnected).

Source

pub fn frames_since_reference(&self) -> u64

Number of output() calls since the last feed_reference() call.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.