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 FrameRate instance.
Declaration
public FrameRate(int frameRate)
Parameters
Type | Name | Description |
---|---|---|
int | frameRate | The frame rate in Hz. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown if |
FrameRate(int, int, bool)
Creates a new FrameRate instance.
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 |
---|---|
ArgumentOutOfRangeException | Thrown if |
Properties
Denominator
The frame rate fraction denominator.
Declaration
public int Denominator { get; }
Property Value
Type | Description |
---|---|
int |
FrameInterval
Gets the length of time between frames in seconds.
Declaration
public 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 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 bool IsValid { get; }
Property Value
Type | Description |
---|---|
bool |
Numerator
The frame rate fraction numerator.
Declaration
public int Numerator { get; }
Property Value
Type | Description |
---|---|
int |
Reciprocal
Gets the reciprocal of the frame rate fraction.
Declaration
public FrameRate Reciprocal { get; }
Property Value
Type | Description |
---|---|
FrameRate |
Methods
AsDouble()
Gets the frame rate as a double.
Declaration
public double AsDouble()
Returns
Type | Description |
---|---|
double | The frame rate in Hz. |
AsFloat()
Gets the frame rate as a float.
Declaration
public 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 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 FrameRate and returns an indication of their relative values.
Declaration
public int CompareTo(FrameRate other)
Parameters
Type | Name | Description |
---|---|---|
FrameRate | 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 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 FrameRate.
Declaration
public bool Equals(FrameRate other)
Parameters
Type | Name | Description |
---|---|---|
FrameRate | other | A value to compare with this instance. |
Returns
Type | Description |
---|---|
bool | true if |
GetHashCode()
Returns the hash code for this instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | The hash code for this instance. |
Overrides
IsFactorOf(FrameRate)
Checks if this FrameRate is a factor of another.
Declaration
public bool IsFactorOf(FrameRate other)
Parameters
Type | Name | Description |
---|---|---|
FrameRate | other | The frame rate to compare against. |
Returns
Type | Description |
---|---|
bool | true if this frame rate is a factor of |
Remarks
This is based on the time between frames, so 48 fps is considered a factor of 24 fps.
IsMultipleOf(FrameRate)
Checks if this FrameRate is a multiple of another.
Declaration
public bool IsMultipleOf(FrameRate other)
Parameters
Type | Name | Description |
---|---|---|
FrameRate | other | The frame rate to compare against. |
Returns
Type | Description |
---|---|
bool | true if this frame rate is a multiple of |
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 string ToString()
Returns
Type | Description |
---|---|
string | A string that represents the current instance. |
Overrides
Operators
operator /(FrameRate, FrameRate)
Computes the division of two FrameRate values.
Declaration
public static FrameRate operator /(FrameRate a, FrameRate b)
Parameters
Type | Name | Description |
---|---|---|
FrameRate | a | The dividend. |
FrameRate | b | The divisor. |
Returns
Type | Description |
---|---|
FrameRate | The quotient. |
Exceptions
Type | Condition |
---|---|
OverflowException | Thrown if the resulting frame rate is not representable using the FrameRate type. |
operator ==(FrameRate, FrameRate)
Determines whether two specified instances of FrameRate are equal.
Declaration
public static bool operator ==(FrameRate a, FrameRate b)
Parameters
Type | Name | Description |
---|---|---|
FrameRate | a | The first instance to compare. |
FrameRate | b | The second instance to compare. |
Returns
Type | Description |
---|---|
bool |
explicit operator double(FrameRate)
Declaration
public static explicit operator double(FrameRate rate)
Parameters
Type | Name | Description |
---|---|---|
FrameRate | 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 |
---|---|---|
FrameRate | 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 |
---|---|---|
FrameRate | a | The first instance to compare. |
FrameRate | b | The second instance to compare. |
Returns
Type | Description |
---|---|
bool |
operator >=(FrameRate, FrameRate)
Determines whether one specified FrameRate is greater than or the same as another specified FrameRate.
Declaration
public static bool operator >=(FrameRate a, FrameRate b)
Parameters
Type | Name | Description |
---|---|---|
FrameRate | a | The first instance to compare. |
FrameRate | b | The second instance to compare. |
Returns
Type | Description |
---|---|
bool | true if |
implicit operator FrameRate(StandardFrameRate)
Gets the FrameRate that corresponds to a StandardFrameRate value.
Declaration
public static implicit operator FrameRate(StandardFrameRate rate)
Parameters
Type | Name | Description |
---|---|---|
StandardFrameRate | rate | The standard frame rate. |
Returns
Type | Description |
---|---|
FrameRate | The standard frame rate value. |
operator !=(FrameRate, FrameRate)
Determines whether two specified instances of FrameRate are not equal.
Declaration
public static bool operator !=(FrameRate a, FrameRate b)
Parameters
Type | Name | Description |
---|---|---|
FrameRate | a | The first instance to compare. |
FrameRate | b | The second instance to compare. |
Returns
Type | Description |
---|---|
bool | true if |
operator <(FrameRate, FrameRate)
Declaration
public static bool operator <(FrameRate a, FrameRate b)
Parameters
Type | Name | Description |
---|---|---|
FrameRate | a | The first instance to compare. |
FrameRate | b | The second instance to compare. |
Returns
Type | Description |
---|---|
bool |
operator <=(FrameRate, FrameRate)
Declaration
public static bool operator <=(FrameRate a, FrameRate b)
Parameters
Type | Name | Description |
---|---|---|
FrameRate | a | The first instance to compare. |
FrameRate | b | The second instance to compare. |
Returns
Type | Description |
---|---|
bool |
operator *(FrameRate, FrameRate)
Computes the multiple of two FrameRate values.
Declaration
public static FrameRate operator *(FrameRate a, FrameRate b)
Parameters
Type | Name | Description |
---|---|---|
FrameRate | a | The first operand. |
FrameRate | b | The second operand. |
Returns
Type | Description |
---|---|
FrameRate | The multiplied frame rate. |
Exceptions
Type | Condition |
---|---|
OverflowException | Thrown if the resulting frame rate is not representable using the FrameRate type. |