Struct FrameRate
A struct that stores a frame rate in Hz as a fractional number to avoid imprecision.
Namespace: Unity.LiveCapture
Syntax
public struct FrameRate : IComparable, IComparable<FrameRate>, IEquatable<FrameRate>
Constructors
FrameRate(Int32)
Creates a new FrameRate instance.
Declaration
public FrameRate(int frameRate)
Parameters
Type | Name | Description |
---|---|---|
Int32 | frameRate | The frame rate in Hz. |
FrameRate(Int32, Int32, Boolean)
Creates a new FrameRate instance.
Declaration
public FrameRate(int numerator, int denominator, bool isDropFrame)
Parameters
Type | Name | Description |
---|---|---|
Int32 | numerator | The fraction numerator. |
Int32 | denominator | The fraction denominator. |
Boolean | isDropFrame | Should drop frame calculations be performed when converting between clock time and frame time using this frame rate. |
Properties
Denominator
The frame rate fraction denominator.
Declaration
public readonly int Denominator { get; }
Property Value
Type | Description |
---|---|
Int32 |
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 |
---|---|
Boolean |
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 |
---|---|
Boolean |
Numerator
The frame rate fraction numerator.
Declaration
public readonly int Numerator { get; }
Property Value
Type | Description |
---|---|
Int32 |
Reciprocal
Gets the reciprocal of the frame rate fraction.
Declaration
public readonly FrameRate Reciprocal { get; }
Property Value
Type | Description |
---|---|
FrameRate |
Methods
AsDouble()
Gets the frame rate as a
Declaration
public double AsDouble()
Returns
Type | Description |
---|---|
Double | The frame rate in Hz. |
AsFloat()
Gets the frame rate as a
Declaration
public float AsFloat()
Returns
Type | Description |
---|---|
Single | 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 |
---|---|
Int32 | 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 |
---|---|
Int32 | 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 |
---|---|
Boolean | true if |
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 |
---|---|
Boolean | true if |
GetHashCode()
Returns the hash code for this instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | The hash code for this instance. |
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 |
---|---|
Boolean | 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 |
---|---|
Boolean | 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(Int32, Int32)
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 |
---|---|---|
Int32 | numerator | The frame rate fraction numerator. |
Int32 | denominator | The frame rate fraction denominator. |
Returns
Type | Description |
---|---|
Boolean | 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. |
Operators
Division(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. |
Equality(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 |
---|---|
Boolean |
Explicit(FrameRate to Double)
Gets the value of a FrameRate in Hz as a
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(FrameRate to Single)
Gets the value of a FrameRate in Hz as a
Declaration
public static explicit operator float (FrameRate rate)
Parameters
Type | Name | Description |
---|---|---|
FrameRate | rate | The value to cast. |
Returns
Type | Description |
---|---|
Single | The frame rate in Hz. |
GreaterThan(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 |
---|---|
Boolean |
GreaterThanOrEqual(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 |
---|---|
Boolean | true if |
Implicit(StandardFrameRate to FrameRate)
Declaration
public static implicit operator FrameRate(StandardFrameRate rate)
Parameters
Type | Name | Description |
---|---|---|
StandardFrameRate | rate |
Returns
Type | Description |
---|---|
FrameRate |
Inequality(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 |
---|---|
Boolean | true if |
LessThan(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 |
---|---|
Boolean |
LessThanOrEqual(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 |
---|---|
Boolean |
Multiply(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. |