SampleBuffer<T>
SampleBuffer stores sample points in a circular buffer. The buffer is backed by an array that currently cannot be resized. The buffer is guaranteed to be ever increasing, i.e. this[n].Time > this[n-1].
Type Parameters
T
The sample type (e.g., float, int, Vector3) corresponding to the value type of the binding.
Constructors
SampleBuffer() | Creates an empty SampleBuffer. |
Properties
Capacity | The maximum number of samples in the buffer. |
Count | The current number of samples in the buffer. |
this[int] | |
Last |
Methods
GetAdjacentSamples(double) | Searches the buffer for the two samples adjacent to the given time. Returns (default, default, -1) if the buffer is empty. Returns (sample[0], sample[0], 0) if the buffer contains less than two samples - or if time pre-dates the first sample. Otherwise, it returns the sample before (or equal to) the given time, and the next sample in the buffer. IsLastSample is true if the second returned sample is the last sample in the buffer. |
GetEnumerator() | |
PopBack() | Removes the oldest sample in the buffer. |
PushFront(Sample<T>) | Adds a new sample to the front of the buffer. If the buffer Capacity has already been reached, the oldest sample is removed. Samples should always be added with increasing timestamps. If multiple samples with identical timestamps are added, only the first sample is added and the rest are discarded. This ensures that buffer times are always incrementing. |
RemoveOutdatedSamples(double, int) | Removes outdated samples from the samples buffer. A sample is considered outdated if its timestamp is equal to or older than the given time. The number of samples left guarantees that both interpolation and extrapolation can happen. |
Reset() | |
SetLast(Sample<T>) | |
TryMeasureMaxSampleDuration(out double) | Calculates the maximum duration between two samples frames in the last Coherence.Interpolation.SampleBuffer`1.sampleCountForMeasuringDuration samples. It also stops measuring when it reaches a stopped sample. Used for measuring real SampleRate. |