24#ifndef RUBBERBAND_STRETCHER_H
25#define RUBBERBAND_STRETCHER_H
27#define RUBBERBAND_VERSION "4.0.0"
28#define RUBBERBAND_API_MAJOR_VERSION 3
29#define RUBBERBAND_API_MINOR_VERSION 0
31#undef RUBBERBAND_DLLEXPORT
33#ifndef RUBBERBAND_STATIC
34#define RUBBERBAND_DLLEXPORT __declspec(dllexport)
36#define RUBBERBAND_DLLEXPORT
39#define RUBBERBAND_DLLEXPORT
394 OptionProcessOffline = 0x00000000,
395 OptionProcessRealTime = 0x00000001,
397 OptionStretchElastic = 0x00000000,
398 OptionStretchPrecise = 0x00000010,
400 OptionTransientsCrisp = 0x00000000,
401 OptionTransientsMixed = 0x00000100,
402 OptionTransientsSmooth = 0x00000200,
404 OptionDetectorCompound = 0x00000000,
405 OptionDetectorPercussive = 0x00000400,
406 OptionDetectorSoft = 0x00000800,
408 OptionPhaseLaminar = 0x00000000,
409 OptionPhaseIndependent = 0x00002000,
411 OptionThreadingAuto = 0x00000000,
412 OptionThreadingNever = 0x00010000,
413 OptionThreadingAlways = 0x00020000,
415 OptionWindowStandard = 0x00000000,
416 OptionWindowShort = 0x00100000,
417 OptionWindowLong = 0x00200000,
419 OptionSmoothingOff = 0x00000000,
420 OptionSmoothingOn = 0x00800000,
422 OptionFormantShifted = 0x00000000,
423 OptionFormantPreserved = 0x01000000,
425 OptionPitchHighSpeed = 0x00000000,
426 OptionPitchHighQuality = 0x02000000,
427 OptionPitchHighConsistency = 0x04000000,
429 OptionChannelsApart = 0x00000000,
430 OptionChannelsTogether = 0x10000000,
432 OptionEngineFaster = 0x00000000,
433 OptionEngineFiner = 0x20000000
445 DefaultOptions = 0x00000000,
446 PercussiveOptions = 0x00102000
469 virtual void log(
const char *) = 0;
472 virtual void log(
const char *,
double) = 0;
475 virtual void log(
const char *,
double,
double) = 0;
514 Options options = DefaultOptions,
515 double initialTimeRatio = 1.0,
516 double initialPitchScale = 1.0);
536 std::shared_ptr<Logger> logger,
537 Options options = DefaultOptions,
538 double initialTimeRatio = 1.0,
539 double initialPitchScale = 1.0);
918 void study(
const float *
const *input,
size_t samples,
bool final);
937 void process(
const float *
const *input,
size_t samples,
bool final);
976 size_t retrieve(
float *
const *output,
size_t samples)
const;
#define RUBBERBAND_DLLEXPORT
size_t getPreferredStartPad() const
In RealTime mode (unlike in Offline mode) the stretcher performs no automatic padding or delay/latenc...
void process(const float *const *input, size_t samples, bool final)
Provide a block of "samples" sample frames for processing.
size_t getInputIncrement() const
Retrieve the value of the internal input block increment value.
void setFrequencyCutoff(int n, float f)
Set the value of internal frequency cutoff n to f Hz.
void calculateStretch()
Force the stretcher to calculate a stretch profile.
std::vector< int > getExactTimePoints() const
In offline mode, retrieve the sequence of internal frames for which exact timing has been sought,...
std::vector< float > getPhaseResetCurve() const
In offline mode, retrieve the sequence of internal phase reset detection function values,...
void setDebugLevel(int level)
Set the level of debug output.
float getFrequencyCutoff(int n) const
Return the value of internal frequency cutoff value n.
void reset()
Reset the stretcher's internal buffers.
void setExpectedInputDuration(size_t samples)
Tell the stretcher exactly how many input sample frames it will receive.
void study(const float *const *input, size_t samples, bool final)
Provide a block of "samples" sample frames for the stretcher to study and calculate a stretch profile...
RubberBandStretcher(size_t sampleRate, size_t channels, std::shared_ptr< Logger > logger, Options options=DefaultOptions, double initialTimeRatio=1.0, double initialPitchScale=1.0)
Construct a time and pitch stretcher object with a custom debug logger.
void setFormantScale(double scale)
Set a pitch scale for the vocal formant envelope separately from the overall pitch scale.
double getTimeRatio() const
Return the last time ratio value that was set (either on construction or with setTimeRatio()).
int available() const
Ask the stretcher how many audio sample frames of output data are available for reading (via retrieve...
double getFormantScale() const
Return the last formant scaling ratio that was set with setFormantScale, or 0.0 if the default automa...
size_t getStartDelay() const
Return the output delay of the stretcher.
int Options
A bitwise OR of values from the RubberBandStretcher::Option enum.
static void setDefaultDebugLevel(int level)
Set the default level of debug output for subsequently constructed stretchers.
size_t getProcessSizeLimit() const
Obtain the overall maximum supported process buffer size in sample frames, which is also the maximum ...
Option
Processing options for the timestretcher.
void setPitchOption(Options options)
Change an OptionPitch configuration setting.
void setFormantOption(Options options)
Change an OptionFormant configuration setting.
size_t getLatency() const
Return the start delay of the stretcher.
std::vector< int > getOutputIncrements() const
In offline mode, retrieve the sequence of internal block increments for output, for the entire audio ...
void setDetectorOption(Options options)
Change an OptionDetector configuration setting.
void setPhaseOption(Options options)
Change an OptionPhase configuration setting.
void setMaxProcessSize(size_t samples)
Tell the stretcher the maximum number of sample frames that you will ever be passing in to a single p...
void setTimeRatio(double ratio)
Set the time ratio for the stretcher.
RubberBandStretcher(const RubberBandStretcher &)=delete
RubberBandStretcher(size_t sampleRate, size_t channels, Options options=DefaultOptions, double initialTimeRatio=1.0, double initialPitchScale=1.0)
Construct a time and pitch stretcher object to run at the given sample rate, with the given number of...
RubberBandStretcher & operator=(const RubberBandStretcher &)=delete
size_t getChannelCount() const
Return the number of channels this stretcher was constructed with.
size_t retrieve(float *const *output, size_t samples) const
Obtain some processed output data from the stretcher.
size_t getSamplesRequired() const
Ask the stretcher how many audio sample frames should be provided as input in order to ensure that so...
int getEngineVersion() const
Return the active internal engine version, according to the OptionEngine flag supplied on constructio...
void setPitchScale(double scale)
Set the pitch scaling ratio for the stretcher.
void setKeyFrameMap(const std::map< size_t, size_t > &)
Provide a set of mappings from "before" to "after" sample numbers so as to enforce a particular stret...
void setTransientsOption(Options options)
Change an OptionTransients configuration setting.
double getPitchScale() const
Return the last pitch scaling ratio value that was set (either on construction or with setPitchScale(...
Interface for log callbacks that may optionally be provided to the stretcher on construction.
virtual void log(const char *, double)=0
Receive a log message and one accompanying numeric value.
virtual void log(const char *)=0
Receive a log message with no numeric values.
virtual void log(const char *, double, double)=0
Receive a log message and two accompanying numeric values.