Struct Subframe
A struct that represents a time within a frame interval.
Namespace: Unity.LiveCapture
Assembly: Unity.LiveCapture.dll
Syntax
[Serializable]
public struct Subframe
Remarks
The value is stored as a fractional number so that computations are guaranteed to have predictable results and consistent precision.
Constructors
Subframe(int, int)
Creates a new Subframe instance.
Declaration
public Subframe(int subframe, int resolution)
Parameters
| Type | Name | Description |
|---|---|---|
| int | subframe | The subframe value used to indicate a time somewhere within the duration of the frame.
This value is clamped to the range [0, |
| int | 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 = 51200
Field Value
| Type | Description |
|---|---|
| int |
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 = 65535
Field Value
| Type | Description |
|---|---|
| int |
Properties
Resolution
The number of possible subframe values in the frame.
Declaration
public int Resolution { get; }
Property Value
| Type | Description |
|---|---|
| int |
Remarks
This value is in the range [1, MaxResolution]
Value
The subframe within the frame.
Declaration
public int Value { get; }
Property Value
| Type | Description |
|---|---|
| int |
Remarks
This value is in the range [0,
Methods
AsDouble()
Gets the subframe value as a double.
Declaration
public double AsDouble()
Returns
| Type | Description |
|---|---|
| double | The subframe value in the range [0, 1]. |
AsFloat()
Gets the subframe value as a float.
Declaration
public float AsFloat()
Returns
| Type | Description |
|---|---|
| float | 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 |
|---|---|
| int | 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 |
|---|---|
| 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(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 |
|---|---|
| bool | true if |
FromDouble(double, int)
Declaration
public static Subframe FromDouble(double subframe, int resolution = 51200)
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]. |
| int | 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(float, int)
Declaration
public static Subframe FromFloat(float subframe, int resolution = 51200)
Parameters
| Type | Name | Description |
|---|---|---|
| float | subframe | A subframe value used to indicate a time somewhere within the duration of the frame. It is clamped to the range [0, 1]. |
| int | 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 |
|---|---|
| int | The hash code for this instance. |
Overrides
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 ==(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 |
|---|---|
| bool |
explicit operator double(Subframe)
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 operator float(Subframe)
Declaration
public static explicit operator float(Subframe subframe)
Parameters
| Type | Name | Description |
|---|---|---|
| Subframe | subframe | The value to cast. |
Returns
| Type | Description |
|---|---|
| float | The subframe value in the range [0, 1]. |
operator >(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 |
|---|---|
| bool |
operator >=(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 |
|---|---|
| bool |
operator !=(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 |
|---|---|
| bool | true if |
operator <(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 |
|---|---|
| bool |
operator <=(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 |
|---|---|
| bool | true if |