Rubber Band Library 4.0.0
RubberBandLiveShifter.h
Go to the documentation of this file.
1/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3/*
4 Rubber Band Library
5 An audio time-stretching and pitch-shifting library.
6 Copyright 2007-2024 Particular Programs Ltd.
7
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of the
11 License, or (at your option) any later version. See the file
12 COPYING included with this distribution for more information.
13
14 Alternatively, if you have a valid commercial licence for the
15 Rubber Band Live Pitch Shifter obtained by agreement with the
16 copyright holders, you may redistribute and/or modify it under the
17 terms described in that licence.
18
19 If you wish to distribute code using Rubber Band Live under terms
20 other than those of the GNU General Public License, you must
21 obtain a valid commercial licence before doing so.
22*/
23
24#ifndef RUBBERBAND_LIVE_SHIFTER_H
25#define RUBBERBAND_LIVE_SHIFTER_H
26
27#define RUBBERBAND_VERSION "4.0.0"
28#define RUBBERBAND_API_MAJOR_VERSION 3
29#define RUBBERBAND_API_MINOR_VERSION 0
30
31#undef RUBBERBAND_LIVE_DLLEXPORT
32#ifdef _MSC_VER
33#define RUBBERBAND_LIVE_DLLEXPORT __declspec(dllexport)
34#else
35#define RUBBERBAND_LIVE_DLLEXPORT
36#endif
37
38#include <vector>
39#include <map>
40#include <string>
41#include <memory>
42#include <cstddef>
43
44namespace RubberBand
45{
46
96{
97public:
98 enum Option {
99 OptionWindowShort = 0x00000000,
100 OptionWindowMedium = 0x00100000,
101
102 OptionFormantShifted = 0x00000000,
103 OptionFormantPreserved = 0x01000000,
104
105 OptionChannelsApart = 0x00000000,
106 OptionChannelsTogether = 0x10000000
107
108 // n.b. Options is int, so we must stop before 0x80000000
109 };
110
115 typedef int Options;
116
118 DefaultOptions = 0x00000000
119 };
120
139 struct Logger {
141 virtual void log(const char *) = 0;
142
144 virtual void log(const char *, double) = 0;
145
147 virtual void log(const char *, double, double) = 0;
148
149 virtual ~Logger() { }
150 };
151
156 RubberBandLiveShifter(size_t sampleRate, size_t channels,
157 Options options);
158
175 RubberBandLiveShifter(size_t sampleRate, size_t channels,
176 std::shared_ptr<Logger> logger,
177 Options options);
178
180
186 void reset();
187
206 void setPitchScale(double scale);
207
231 void setFormantScale(double scale);
232
237 double getPitchScale() const;
238
244 double getFormantScale() const;
245
255 size_t getStartDelay() const;
256
261 size_t getChannelCount() const;
262
272
282 size_t getBlockSize() const;
283
303 void shift(const float *const *input, float *const *output);
304
333 void setDebugLevel(int level);
334
341 static void setDefaultDebugLevel(int level);
342
343protected:
344 class Impl;
345 Impl *m_d;
346
349};
350
351}
352
353#endif
#define RUBBERBAND_LIVE_DLLEXPORT
RubberBandLiveShifter(const RubberBandLiveShifter &)=delete
RubberBandLiveShifter(size_t sampleRate, size_t channels, std::shared_ptr< Logger > logger, Options options)
Construct a pitch shifter object with a custom debug logger.
double getPitchScale() const
Return the last pitch scaling ratio value that was set (either on construction or with setPitchScale(...
static void setDefaultDebugLevel(int level)
Set the default level of debug output for subsequently constructed shifters.
RubberBandLiveShifter & operator=(const RubberBandLiveShifter &)=delete
void setFormantOption(Options options)
Change an OptionFormant configuration setting.
void setPitchScale(double scale)
Set the pitch scaling ratio for the shifter.
void shift(const float *const *input, float *const *output)
Pitch-shift a single block of sample frames.
size_t getStartDelay() const
Return the output delay of the shifter.
void setFormantScale(double scale)
Set a pitch scale for the vocal formant envelope separately from the overall pitch scale.
size_t getBlockSize() const
Query the number of sample frames that must be passed to, and will be returned by,...
double getFormantScale() const
Return the last formant scaling ratio that was set with setFormantScale, or 0.0 if the default automa...
void reset()
Reset the shifter's internal buffers.
RubberBandLiveShifter(size_t sampleRate, size_t channels, Options options)
Construct a pitch shifter object to run at the given sample rate, with the given number of channels.
size_t getChannelCount() const
Return the number of channels this shifter was constructed with.
int Options
A bitwise OR of values from the RubberBandLiveShifter::Option enum.
void setDebugLevel(int level)
Set the level of debug output.
Interface for log callbacks that may optionally be provided to the shifter on construction.
virtual void log(const char *, double)=0
Receive a log message and one accompanying numeric value.
virtual void log(const char *, double, double)=0
Receive a log message and two accompanying numeric values.
virtual void log(const char *)=0
Receive a log message with no numeric values.