Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
zrythm::dsp::Stretcher Class Reference

Time and pitch stretching API. More...

#include <src/dsp/stretcher.h>

Public Types

enum class  Backend { Rubberband , Paulstretch , SBSMS }

Public Member Functions

 Stretcher (const Stretcher &)=delete
Stretcher & operator= (const Stretcher &)=delete
 Stretcher (Stretcher &&)=delete
Stretcher & operator= (Stretcher &&)=delete
signed_frame_t stretch (const float *in_samples_l, const float *in_samples_r, size_t in_samples_size, float *out_samples_l, float *out_samples_r, size_t out_samples_wanted)
 Perform stretching.
unsigned int get_latency () const
 Get latency in number of samples.
void set_time_ratio (double ratio)
zrythm::utils::audio::AudioBuffer stretch_interleaved (zrythm::utils::audio::AudioBuffer &in_samples)
 Perform stretching.

Static Public Member Functions

static std::unique_ptr< Stretcher > create_rubberband (units::sample_rate_t samplerate, unsigned channels, double time_ratio, double pitch_ratio, bool realtime)
 Create a new Stretcher using the rubberband backend.

Detailed Description

Time and pitch stretching API.

Definition at line 17 of file stretcher.h.

Member Enumeration Documentation

◆ Backend

Enumerator
Rubberband 

Rubberband.

Paulstretch 

Paulstretch.

SBSMS 

SBSMS - Subband Sinusoidal Modeling Synthesis.

Definition at line 20 of file stretcher.h.

Member Function Documentation

◆ create_rubberband()

std::unique_ptr< Stretcher > zrythm::dsp::Stretcher::create_rubberband ( units::sample_rate_t samplerate,
unsigned channels,
double time_ratio,
double pitch_ratio,
bool realtime )
static

Create a new Stretcher using the rubberband backend.

Parameters
samplerateThe new samplerate.
time_ratioThe ratio to multiply time by (eg if the BPM is doubled, this will be 0.5).
pitch_ratioThe ratio to pitch by. This will normally be 1.0 when time-stretching).
realtimeWhether to perform realtime stretching (lower quality but fast enough to be used real-time).
Exceptions
std::runtime_errorIf parameters are invalid.

◆ stretch()

signed_frame_t zrythm::dsp::Stretcher::stretch ( const float * in_samples_l,
const float * in_samples_r,
size_t in_samples_size,
float * out_samples_l,
float * out_samples_r,
size_t out_samples_wanted )

Perform stretching.

Parameters
in_samples_lThe left samples.
in_samples_rThe right channel samples. If this is nullptr, the audio is assumed to be mono.
in_samples_sizeThe number of input samples per channel.
Returns
The number of output samples generated per channel.

◆ stretch_interleaved()

zrythm::utils::audio::AudioBuffer zrythm::dsp::Stretcher::stretch_interleaved ( zrythm::utils::audio::AudioBuffer & in_samples)

Perform stretching.

Warning
Not real-time safe, does allocations.
Parameters
in_samplesInput samples (interleaved).
Returns
The output samples (interleaved).

The documentation for this class was generated from the following file: