MayaFlux 0.3.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ time_stretch()

std::vector< double > MayaFlux::Kinesis::Discrete::time_stretch ( std::span< const double >  data,
double  stretch_factor 
)

Time-stretch via linear interpolation resampling Fast but alias-naive: no anti-aliasing pre-filter is applied when stretch_factor < 1.

Suitable for control signals and non-critical upsampling. For audio time-stretching use Discrete::phase_vocoder_stretch (PhaseVocoder.hpp).

Parameters
dataSource span
stretch_factor>1 = longer/slower, <1 = shorter/faster; 1 returns copy
Returns
Resampled vector

Definition at line 220 of file Transform.cpp.

221{
222 if (data.empty() || stretch_factor <= 0.0)
223 return {};
224
225 if (stretch_factor == 1.0)
226 return { data.begin(), data.end() };
227
228 const auto out_size = static_cast<size_t>(
229 static_cast<double>(data.size()) * stretch_factor);
230
231 if (out_size == 0)
232 return {};
233
234 std::vector<double> out(out_size);
235 interpolate_linear(data, out);
236 return out;
237}

References interpolate_linear().

+ Here is the call graph for this function: