Skip to content

acl/core/interpolation_utils.h

#include "acl/core/interpolation_utils.h"

The functions that find the samples and the interpolation alpha at a sample time.

find_linear_interpolation_samples_with_duration

void find_linear_interpolation_samples_with_duration(
    uint32_t num_samples,
    float duration,
    float sample_time,
    sample_rounding_policy rounding_policy,
    sample_looping_policy looping_policy,
    uint32_t& out_sample_index0,
    uint32_t& out_sample_index1,
    float& out_interpolation_alpha)

Calculates the sample indices and the interpolation required to linearly interpolate when the samples are uniform. The returned sample indices are clamped and do not loop. If the sample rate is available, prefer using find_linear_interpolation_samples_with_sample_rate instead. It is faster and more accurate. If the wrap looping policy is used:

  • the num_samples value must be the actual number of samples stored in memory, it must not include the artificially repeating first sample.
  • the duration value must include the repeating first sample
void find_linear_interpolation_samples_with_duration(
    uint32_t num_samples,
    float duration,
    float sample_time,
    sample_rounding_policy rounding_policy,
    uint32_t& out_sample_index0,
    uint32_t& out_sample_index1,
    float& out_interpolation_alpha)

Calculates the sample indices and the interpolation required to linearly interpolate when the samples are uniform. The returned sample indices are clamped and do not loop. If the sample rate is available, prefer using find_linear_interpolation_samples_with_sample_rate instead. It is faster and more accurate.

Deprecated

Specify explicitly the sample_looping_policy, to be removed in v3.0

find_linear_interpolation_samples_with_sample_rate

void find_linear_interpolation_samples_with_sample_rate(
    uint32_t num_samples,
    float sample_rate,
    float sample_time,
    sample_rounding_policy rounding_policy,
    sample_looping_policy looping_policy,
    uint32_t& out_sample_index0,
    uint32_t& out_sample_index1,
    float& out_interpolation_alpha)

Calculates the sample indices and the interpolation required to linearly interpolate when the samples are uniform. The returned sample indices are clamped and do not loop.

void find_linear_interpolation_samples_with_sample_rate(
    uint32_t num_samples,
    float sample_rate,
    float sample_time,
    sample_rounding_policy rounding_policy,
    uint32_t& out_sample_index0,
    uint32_t& out_sample_index1,
    float& out_interpolation_alpha)

Calculates the sample indices and the interpolation required to linearly interpolate when the samples are uniform. The returned sample indices are clamped and do not loop.

Deprecated

Specify explicitly the sample_looping_policy, to be removed in v3.0

find_linear_interpolation_alpha

float find_linear_interpolation_alpha(
    float sample_index,
    uint32_t sample_index0,
    uint32_t sample_index1,
    sample_rounding_policy rounding_policy,
    sample_looping_policy looping_policy)

Calculates the sample indices and the interpolation required to linearly interpolate when the samples are uniform. This function does not support looping.

float find_linear_interpolation_alpha(
    float sample_index,
    uint32_t sample_index0,
    uint32_t sample_index1,
    sample_rounding_policy rounding_policy)

Calculates the sample indices and the interpolation required to linearly interpolate when the samples are uniform. This function does not support looping.

Deprecated

Specify explicitly the sample_looping_policy, to be removed in v3.0

apply_rounding_policy

float apply_rounding_policy(float interpolation_alpha, sample_rounding_policy policy)

Modify an interpolation alpha value given a sample rounding policy.