libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
TimecodeGenerator Class Reference

General-purpose timecode generator. More...

#include <timecodegenerator.h>

Public Types

enum  RunMode { Still , Forward , Reverse }
 Run mode for the generator. More...
 

Public Member Functions

 TimecodeGenerator ()=default
 Constructs a default generator with no frame rate set.
 
 TimecodeGenerator (const FrameRate &frameRate, bool dropFrame=false)
 Constructs a generator with the given frame rate.
 
FrameRate frameRate () const
 Returns the configured frame rate.
 
void setFrameRate (const FrameRate &frameRate)
 Sets the frame rate and re-derives the timecode mode.
 
bool dropFrame () const
 Returns whether drop-frame counting is enabled.
 
void setDropFrame (bool df)
 Enables or disables drop-frame counting.
 
Timecode::Mode timecodeMode () const
 Returns the resolved timecode mode.
 
RunMode runMode () const
 Returns the current run mode.
 
void setRunMode (RunMode mode)
 Sets the run mode.
 
Timecode timecode () const
 Returns the current timecode value.
 
void setTimecode (const Timecode &tc)
 Sets the current timecode value.
 
void jam (const Timecode &tc)
 Jams to a new timecode value mid-run.
 
Timecode advance ()
 Advances the generator by one frame.
 
uint64_t frameCount () const
 Returns the total number of frames advanced.
 
void reset ()
 Resets the generator.
 

Detailed Description

General-purpose timecode generator.

Produces a sequence of timecode values with controllable direction and jam capability. Automatically derives the correct Timecode::Mode from the configured frame rate and drop-frame setting.

This is a simple value class — cheap to copy, no shared state.

Example
gen.setFrameRate(FrameRate(FrameRate::FPS_2997));
gen.setTimecode(Timecode(Timecode::NDF30, 1, 0, 0, 0));
for(int i = 0; i < 100; i++) {
Timecode tc = gen.advance();
// tc is the timecode for this frame
}
Represents a video frame rate as a rational number.
Definition framerate.h:36
Dynamic array container wrapping std::vector.
Definition list.h:40
General-purpose timecode generator.
Definition timecodegenerator.h:37
Class for holding and manipulating timecode.
Definition timecode.h:45
@ NDF30
30 fps non-drop-frame (maps to VTC_FORMAT_30_NDF)
Definition timecode.h:55

Member Enumeration Documentation

◆ RunMode

Run mode for the generator.

Enumerator
Still 

Timecode does not advance.

Forward 

Timecode increments each frame.

Reverse 

Timecode decrements each frame.

Constructor & Destructor Documentation

◆ TimecodeGenerator()

TimecodeGenerator::TimecodeGenerator ( const FrameRate frameRate,
bool  dropFrame = false 
)

Constructs a generator with the given frame rate.

Parameters
frameRateThe frame rate.
dropFrameWhether to use drop-frame counting (only at 30000/1001).

Member Function Documentation

◆ advance()

Timecode TimecodeGenerator::advance ( )

Advances the generator by one frame.

Returns the previous timecode value (the value for the current frame). Forward increments, Reverse decrements, Still returns the same value repeatedly.

Returns
The timecode value before advancing.

◆ dropFrame()

bool TimecodeGenerator::dropFrame ( ) const
inline

Returns whether drop-frame counting is enabled.

Returns
true if drop-frame is active.

◆ frameCount()

uint64_t TimecodeGenerator::frameCount ( ) const
inline

Returns the total number of frames advanced.

Returns
The number of advance() calls since construction or reset.

◆ frameRate()

FrameRate TimecodeGenerator::frameRate ( ) const
inline

Returns the configured frame rate.

Returns
The frame rate.

◆ jam()

void TimecodeGenerator::jam ( const Timecode tc)

Jams to a new timecode value mid-run.

Equivalent to setTimecode() but semantically distinct — use for mid-run resync. Does not change the reset value.

Parameters
tcThe timecode to jam to.

◆ reset()

void TimecodeGenerator::reset ( )

Resets the generator.

Resets frameCount to 0 and timecode to the value set by setTimecode().

◆ runMode()

RunMode TimecodeGenerator::runMode ( ) const
inline

Returns the current run mode.

Returns
The RunMode (Still, Forward, or Reverse).

◆ setDropFrame()

void TimecodeGenerator::setDropFrame ( bool  df)

Enables or disables drop-frame counting.

Only takes effect when the frame rate is 30000/1001. At all other rates, drop-frame is forced to false. Recalculates the timecode mode.

Parameters
dftrue to enable drop-frame.

◆ setFrameRate()

void TimecodeGenerator::setFrameRate ( const FrameRate frameRate)

Sets the frame rate and re-derives the timecode mode.

Parameters
frameRateThe frame rate.

◆ setRunMode()

void TimecodeGenerator::setRunMode ( RunMode  mode)
inline

Sets the run mode.

Parameters
modeThe run mode (Still, Forward, or Reverse).

◆ setTimecode()

void TimecodeGenerator::setTimecode ( const Timecode tc)

Sets the current timecode value.

Also sets the initial value used by reset().

Parameters
tcThe timecode to set.

◆ timecode()

Timecode TimecodeGenerator::timecode ( ) const
inline

Returns the current timecode value.

Returns
The current Timecode.

◆ timecodeMode()

Timecode::Mode TimecodeGenerator::timecodeMode ( ) const
inline

Returns the resolved timecode mode.

Returns
The Timecode::Mode derived from the frame rate and drop-frame setting.

The documentation for this class was generated from the following file: