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
impl JamSyncController
Sourcepub fn new(
frame_rate: FrameRate,
config: JamSyncConfig,
) -> Result<Self, TimecodeError>
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).
Sourcepub fn with_default_config(frame_rate: FrameRate) -> Result<Self, TimecodeError>
pub fn with_default_config(frame_rate: FrameRate) -> Result<Self, TimecodeError>
Sourcepub fn state(&self) -> JamSyncState
pub fn state(&self) -> JamSyncState
Current synchronisation state.
Sourcepub fn feed_reference(&mut self, tc: Timecode)
pub fn feed_reference(&mut self, tc: Timecode)
Feed an incoming reference timecode frame.
This drives the state machine forward:
WaitingForReference→Lockingon the first call.Locking→Lockedafterlock_thresholdconsecutive sequential frames.Holdover→Locked(immediate re-lock) when a sequential frame arrives.
Sourcepub fn output(&mut self) -> Timecode
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.
Sourcepub fn reset(&mut self) -> Result<(), TimecodeError>
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.
Sourcepub fn enter_holdover(&mut self)
pub fn enter_holdover(&mut self)
Force the controller into Holdover state (e.g. reference cable
disconnected).
Sourcepub fn frames_since_reference(&self) -> u64
pub fn frames_since_reference(&self) -> u64
Number of output() calls since the last feed_reference() call.