Struct Subframe
A struct that represents a time within a frame interval.
Namespace: Unity.LiveCapture
Syntax
public struct Subframe : IComparable, IComparable<Subframe>, IEquatable<Subframe>
Remarks
The value is stored as a fractional number so that computations are guaranteed to have predictable results and consistent precision.
Constructors
Subframe(Int32, Int32)
Creates a new Subframe instance.
Declaration
public Subframe(int subframe, int resolution)
Parameters
Type | Name | Description |
---|---|---|
Int32 | subframe | The subframe value used to indicate a time somewhere within the duration of the frame.
This value is clamped to the range [0, |
Int32 | resolution | The number of possible subframe values in the frame. If this value is not greater than zero, the subframe value is treated as zero. |
Fields
DefaultResolution
The default resolution of the subframe value.
Declaration
public const int DefaultResolution = null
Field Value
Type | Description |
---|---|
Int32 |
Remarks
Values such as 80 or 100 are typical for SMTPE timecode. This chosen value is the lowest common multiple of 80, 100, and 2048, which allows for exact precision when using those values or smaller powers of 2.
MaxResolution
The maximum supported subframe resolution.
Declaration
public const int MaxResolution = null
Field Value
Type | Description |
---|---|
Int32 |
Properties
Resolution
The number of possible subframe values in the frame.
Declaration
public readonly int Resolution { get; }
Property Value
Type | Description |
---|---|
Int32 |
Remarks
This value is in the range [1, MaxResolution]
Value
The subframe within the frame.
Declaration
public readonly int Value { get; }
Property Value
Type | Description |
---|---|
Int32 |
Remarks
This value is in the range [0,
Methods
AsDouble()
Gets the subframe value as a
Declaration
public double AsDouble()
Returns
Type | Description |
---|---|
Double | The subframe value in the range [0, 1]. |
AsFloat()
Gets the subframe value as a
Declaration
public float AsFloat()
Returns
Type | Description |
---|---|
Single | The subframe value in the range [0, 1]. |
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(Subframe)
Compares this instance to a specified Subframe and returns an indication of their relative values.
Declaration
public int CompareTo(Subframe other)
Parameters
Type | Name | Description |
---|---|---|
Subframe | 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(Subframe)
Returns a value indicating whether this instance is equal to a specified Subframe.
Declaration
public bool Equals(Subframe other)
Parameters
Type | Name | Description |
---|---|---|
Subframe | other | A value to compare with this instance. |
Returns
Type | Description |
---|---|
Boolean | true if |
FromDouble(Double, Int32)
Creates a new Subframe value from a
Declaration
public static Subframe FromDouble(double subframe, int resolution = null)
Parameters
Type | Name | Description |
---|---|---|
Double | subframe | A subframe value used to indicate a time somewhere within the duration of the frame. It is clamped to the range [0, 1]. |
Int32 | resolution | The number of possible subframe values in the frame. If this value is not greater than zero, the subframe value is treated as zero. |
Returns
Type | Description |
---|---|
Subframe | A new Subframe that represents the given frame time. |
FromFloat(Single, Int32)
Creates a new Subframe value from a
Declaration
public static Subframe FromFloat(float subframe, int resolution = null)
Parameters
Type | Name | Description |
---|---|---|
Single | subframe | A subframe value used to indicate a time somewhere within the duration of the frame. It is clamped to the range [0, 1]. |
Int32 | resolution | The number of possible subframe values in the frame. If this value is not greater than zero, the subframe value is treated as zero. |
Returns
Type | Description |
---|---|
Subframe | A new Subframe that represents the given frame time. |
GetHashCode()
Returns the hash code for this instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | The hash code for this instance. |
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
Equality(Subframe, Subframe)
Determines whether two specified instances of Subframe are equal.
Declaration
public static bool operator ==(Subframe a, Subframe b)
Parameters
Type | Name | Description |
---|---|---|
Subframe | a | The first instance to compare. |
Subframe | b | The second instance to compare. |
Returns
Type | Description |
---|---|
Boolean |
Explicit(Subframe to Double)
Gets the value of a Subframe as a
Declaration
public static explicit operator double (Subframe subframe)
Parameters
Type | Name | Description |
---|---|---|
Subframe | subframe | The value to cast. |
Returns
Type | Description |
---|---|
Double | The subframe value in the range [0, 1]. |
Explicit(Subframe to Single)
Gets the value of a Subframe as a
Declaration
public static explicit operator float (Subframe subframe)
Parameters
Type | Name | Description |
---|---|---|
Subframe | subframe | The value to cast. |
Returns
Type | Description |
---|---|
Single | The subframe value in the range [0, 1]. |
GreaterThan(Subframe, Subframe)
Declaration
public static bool operator>(Subframe a, Subframe b)
Parameters
Type | Name | Description |
---|---|---|
Subframe | a | The first instance to compare. |
Subframe | b | The second instance to compare. |
Returns
Type | Description |
---|---|
Boolean |
GreaterThanOrEqual(Subframe, Subframe)
Declaration
public static bool operator >=(Subframe a, Subframe b)
Parameters
Type | Name | Description |
---|---|---|
Subframe | a | The first instance to compare. |
Subframe | b | The second instance to compare. |
Returns
Type | Description |
---|---|
Boolean |
Inequality(Subframe, Subframe)
Determines whether two specified instances of Subframe are not equal.
Declaration
public static bool operator !=(Subframe a, Subframe b)
Parameters
Type | Name | Description |
---|---|---|
Subframe | a | The first instance to compare. |
Subframe | b | The second instance to compare. |
Returns
Type | Description |
---|---|
Boolean | true if |
LessThan(Subframe, Subframe)
Declaration
public static bool operator <(Subframe a, Subframe b)
Parameters
Type | Name | Description |
---|---|---|
Subframe | a | The first instance to compare. |
Subframe | b | The second instance to compare. |
Returns
Type | Description |
---|---|
Boolean |
LessThanOrEqual(Subframe, Subframe)
Determines whether one specified Subframe is earlier than or the same as another specified Subframe.
Declaration
public static bool operator <=(Subframe a, Subframe b)
Parameters
Type | Name | Description |
---|---|---|
Subframe | a | The first instance to compare. |
Subframe | b | The second instance to compare. |
Returns
Type | Description |
---|---|
Boolean | true if |