00001
00002
00003
00004 #ifndef _RUBBERBANDSTRETCHER_H_
00005 #define _RUBBERBANDSTRETCHER_H_
00006
00007 #define RUBBERBAND_VERSION "1.2.0"
00008 #define RUBBERBAND_API_MAJOR_VERSION 2
00009 #define RUBBERBAND_API_MINOR_VERSION 0
00010
00011 #include <vector>
00012
00038 namespace RubberBand
00039 {
00040
00041 class RubberBandStretcher
00042 {
00043 public:
00199 enum Option {
00200
00201 OptionProcessOffline = 0x00000000,
00202 OptionProcessRealTime = 0x00000001,
00203
00204 OptionStretchElastic = 0x00000000,
00205 OptionStretchPrecise = 0x00000010,
00206
00207 OptionTransientsCrisp = 0x00000000,
00208 OptionTransientsMixed = 0x00000100,
00209 OptionTransientsSmooth = 0x00000200,
00210
00211 OptionPhaseLaminar = 0x00000000,
00212 OptionPhaseIndependent = 0x00002000,
00213
00214 OptionThreadingAuto = 0x00000000,
00215 OptionThreadingNever = 0x00010000,
00216 OptionThreadingAlways = 0x00020000,
00217
00218 OptionWindowStandard = 0x00000000,
00219 OptionWindowShort = 0x00100000,
00220 OptionWindowLong = 0x00200000,
00221
00222 OptionFormantShifted = 0x00000000,
00223 OptionFormantPreserved = 0x01000000,
00224
00225 OptionPitchHighSpeed = 0x00000000,
00226 OptionPitchHighQuality = 0x02000000,
00227 OptionPitchHighConsistency = 0x04000000
00228 };
00229
00230 typedef int Options;
00231
00232 enum PresetOption {
00233 DefaultOptions = 0x00000000,
00234 PercussiveOptions = 0x00102000
00235 };
00236
00245 RubberBandStretcher(size_t sampleRate,
00246 size_t channels,
00247 Options options = DefaultOptions,
00248 double initialTimeRatio = 1.0,
00249 double initialPitchScale = 1.0);
00250 ~RubberBandStretcher();
00251
00257 void reset();
00258
00280 void setTimeRatio(double ratio);
00281
00307 void setPitchScale(double scale);
00308
00313 double getTimeRatio() const;
00314
00319 double getPitchScale() const;
00320
00330 size_t getLatency() const;
00331
00338 void setTransientsOption(Options options);
00339
00348 void setPhaseOption(Options options);
00349
00358 void setFormantOption(Options options);
00359
00366 void setPitchOption(Options options);
00367
00375 void setExpectedInputDuration(size_t samples);
00376
00389 size_t getSamplesRequired() const;
00390
00406 void setMaxProcessSize(size_t samples);
00407
00425 void study(const float *const *input, size_t samples, bool final);
00426
00433 void process(const float *const *input, size_t samples, bool final);
00434
00448 int available() const;
00449
00457 size_t retrieve(float *const *output, size_t samples) const;
00458
00464 float getFrequencyCutoff(int n) const;
00465
00471 void setFrequencyCutoff(int n, float f);
00472
00478 size_t getInputIncrement() const;
00479
00489 std::vector<int> getOutputIncrements() const;
00490
00500 std::vector<float> getPhaseResetCurve() const;
00501
00510 std::vector<int> getExactTimePoints() const;
00511
00516 size_t getChannelCount() const;
00517
00525 void calculateStretch();
00526
00534 void setDebugLevel(int level);
00535
00542 static void setDefaultDebugLevel(int level);
00543
00544 protected:
00545 class Impl;
00546 Impl *m_d;
00547 };
00548
00549 }
00550
00551 #endif