Struct FrameRate
A struct that stores a frame rate in Hz as a fractional number to avoid imprecision.
Namespace: Unity.LiveCapture
Assembly: Unity.LiveCapture.dll
Syntax
[Serializable]
public struct FrameRate
Constructors
FrameRate(int)
Creates a new Frame
Declaration
public FrameRate(int frameRate)
Parameters
Type | Name | Description |
---|---|---|
int | frameRate | The frame rate in Hz. |
Exceptions
Type | Condition |
---|---|
Argument |
Thrown if |
FrameRate(int, int, bool)
Creates a new Frame
Declaration
public FrameRate(int numerator, int denominator, bool isDropFrame)
Parameters
Type | Name | Description |
---|---|---|
int | numerator | The fraction numerator. |
int | denominator | The fraction denominator. |
bool | isDropFrame | Should drop frame calculations be performed when converting between clock time and frame time using this frame rate. |
Exceptions
Type | Condition |
---|---|
Argument |
Thrown if |
Properties
Denominator
The frame rate fraction denominator.
Declaration
public readonly int Denominator { get; }
Property Value
Type | Description |
---|---|
int |
FrameInterval
Gets the length of time between frames in seconds.
Declaration
public readonly double FrameInterval { get; }
Property Value
Type | Description |
---|---|
double |
IsDropFrame
Should drop frame calculations be performed when converting between clock time and frame time using this frame rate.
Declaration
public readonly bool IsDropFrame { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
This can only be true for NTSC frame rates.
IsValid
Is the frame rate valid.
Declaration
public readonly bool IsValid { get; }
Property Value
Type | Description |
---|---|
bool |
Numerator
The frame rate fraction numerator.
Declaration
public readonly int Numerator { get; }
Property Value
Type | Description |
---|---|
int |
Reciprocal
Gets the reciprocal of the frame rate fraction.
Declaration
public readonly FrameRate Reciprocal { get; }
Property Value
Type | Description |
---|---|
Frame |
Methods
AsDouble()
Gets the frame rate as a double.
Declaration
public readonly double AsDouble()
Returns
Type | Description |
---|---|
double | The frame rate in Hz. |
AsFloat()
Gets the frame rate as a float.
Declaration
public readonly float AsFloat()
Returns
Type | Description |
---|---|
float | The frame rate in Hz. |
CompareTo(object)
Compares this instance to a specified object and returns an indication of their relative values.
Declaration
public readonly int CompareTo(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to compare with this instance. |
Returns
Type | Description |
---|---|
int | A signed number indicating the relative values of this instance and |
CompareTo(FrameRate)
Compares this instance to a specified Frame
Declaration
public readonly int CompareTo(FrameRate other)
Parameters
Type | Name | Description |
---|---|---|
Frame |
other | The value to compare with this instance. |
Returns
Type | Description |
---|---|
int | A signed number indicating the relative values of this instance and |
Equals(object)
Returns a value indicating whether this instance is equal to a specified object.
Declaration
public override readonly bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | An object to compare with this instance. |
Returns
Type | Description |
---|---|
bool | true if |
Overrides
Equals(FrameRate)
Returns a value indicating whether this instance is equal to a specified Frame
Declaration
public readonly bool Equals(FrameRate other)
Parameters
Type | Name | Description |
---|---|---|
Frame |
other | A value to compare with this instance. |
Returns
GetHashCode()
Returns the hash code for this instance.
Declaration
public override readonly int GetHashCode()
Returns
Type | Description |
---|---|
int | The hash code for this instance. |
Overrides
IsFactorOf(FrameRate)
Checks if this Frame
Declaration
public readonly bool IsFactorOf(FrameRate other)
Parameters
Type | Name | Description |
---|---|---|
Frame |
other | The frame rate to compare against. |
Returns
Remarks
This is based on the time between frames, so 48 fps is considered a factor of 24 fps.
IsMultipleOf(FrameRate)
Checks if this Frame
Declaration
public readonly bool IsMultipleOf(FrameRate other)
Parameters
Type | Name | Description |
---|---|---|
Frame |
other | The frame rate to compare against. |
Returns
Remarks
This is based on the time between frames, so 24 fps is considered a multiple of 48 fps.
IsNtsc(int, int)
Checks if a frame rate is an NTSC frame rate (23.976, 29.970, 59.94).
Declaration
public static bool IsNtsc(int numerator, int denominator)
Parameters
Type | Name | Description |
---|---|---|
int | numerator | The frame rate fraction numerator. |
int | denominator | The frame rate fraction denominator. |
Returns
Type | Description |
---|---|
bool | true if the given fraction corresponds to an NTSC frame rate; otherwise, false. |
ToString()
Returns a string that represents the current instance.
Declaration
public override readonly string ToString()
Returns
Type | Description |
---|---|
string | A string that represents the current instance. |
Overrides
Operators
operator /(FrameRate, FrameRate)
Computes the division of two Frame
Declaration
public static FrameRate operator /(FrameRate a, FrameRate b)
Parameters
Returns
Type | Description |
---|---|
Frame |
The quotient. |
Exceptions
Type | Condition |
---|---|
Overflow |
Thrown if the resulting frame rate is not representable
using the Frame |
operator ==(FrameRate, FrameRate)
Indicates whether two specified instances of Frame
Declaration
public static bool operator ==(FrameRate a, FrameRate b)
Parameters
Type | Name | Description |
---|---|---|
Frame |
a | The first instance to compare. |
Frame |
b | The second instance to compare. |
Returns
explicit operator double(FrameRate)
Declaration
public static explicit operator double(FrameRate rate)
Parameters
Type | Name | Description |
---|---|---|
Frame |
rate | The value to cast. |
Returns
Type | Description |
---|---|
double | The frame rate in Hz. |
explicit operator float(FrameRate)
Declaration
public static explicit operator float(FrameRate rate)
Parameters
Type | Name | Description |
---|---|---|
Frame |
rate | The value to cast. |
Returns
Type | Description |
---|---|
float | The frame rate in Hz. |
operator >(FrameRate, FrameRate)
Declaration
public static bool operator >(FrameRate a, FrameRate b)
Parameters
Type | Name | Description |
---|---|---|
Frame |
a | The first instance to compare. |
Frame |
b | The second instance to compare. |
Returns
operator >=(FrameRate, FrameRate)
Indicates whether one specified Frame
Declaration
public static bool operator >=(FrameRate a, FrameRate b)
Parameters
Type | Name | Description |
---|---|---|
Frame |
a | The first instance to compare. |
Frame |
b | The second instance to compare. |
Returns
implicit operator FrameRate(StandardFrameRate)
Gets the Frame
Declaration
public static implicit operator FrameRate(StandardFrameRate rate)
Parameters
Type | Name | Description |
---|---|---|
Standard |
rate | The standard frame rate. |
Returns
Type | Description |
---|---|
Frame |
The standard frame rate value. |
operator !=(FrameRate, FrameRate)
Indicates whether two specified instances of Frame
Declaration
public static bool operator !=(FrameRate a, FrameRate b)
Parameters
Type | Name | Description |
---|---|---|
Frame |
a | The first instance to compare. |
Frame |
b | The second instance to compare. |
Returns
operator <(FrameRate, FrameRate)
Declaration
public static bool operator <(FrameRate a, FrameRate b)
Parameters
Type | Name | Description |
---|---|---|
Frame |
a | The first instance to compare. |
Frame |
b | The second instance to compare. |
Returns
operator <=(FrameRate, FrameRate)
Declaration
public static bool operator <=(FrameRate a, FrameRate b)
Parameters
Type | Name | Description |
---|---|---|
Frame |
a | The first instance to compare. |
Frame |
b | The second instance to compare. |
Returns
operator *(FrameRate, FrameRate)
Computes the multiple of two Frame
Declaration
public static FrameRate operator *(FrameRate a, FrameRate b)
Parameters
Returns
Type | Description |
---|---|
Frame |
The multiplied frame rate. |
Exceptions
Type | Condition |
---|---|
Overflow |
Thrown if the resulting frame rate is not representable
using the Frame |