RubberBandStretcher.h
Go to the documentation of this file.00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 00002 00003 /* 00004 Rubber Band 00005 An audio time-stretching and pitch-shifting library. 00006 Copyright 2007-2011 Chris Cannam. 00007 00008 This program is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU General Public License as 00010 published by the Free Software Foundation; either version 2 of the 00011 License, or (at your option) any later version. See the file 00012 COPYING included with this distribution for more information. 00013 */ 00014 00015 #ifndef _RUBBERBANDSTRETCHER_H_ 00016 #define _RUBBERBANDSTRETCHER_H_ 00017 00018 #define RUBBERBAND_VERSION "1.7-gpl" 00019 #define RUBBERBAND_API_MAJOR_VERSION 2 00020 #define RUBBERBAND_API_MINOR_VERSION 5 00021 00022 #include <vector> 00023 #include <map> 00024 #include <cstddef> 00025 00051 namespace RubberBand 00052 { 00053 00054 class RubberBandStretcher 00055 { 00056 public: 00266 enum Option { 00267 00268 OptionProcessOffline = 0x00000000, 00269 OptionProcessRealTime = 0x00000001, 00270 00271 OptionStretchElastic = 0x00000000, 00272 OptionStretchPrecise = 0x00000010, 00273 00274 OptionTransientsCrisp = 0x00000000, 00275 OptionTransientsMixed = 0x00000100, 00276 OptionTransientsSmooth = 0x00000200, 00277 00278 OptionDetectorCompound = 0x00000000, 00279 OptionDetectorPercussive = 0x00000400, 00280 OptionDetectorSoft = 0x00000800, 00281 00282 OptionPhaseLaminar = 0x00000000, 00283 OptionPhaseIndependent = 0x00002000, 00284 00285 OptionThreadingAuto = 0x00000000, 00286 OptionThreadingNever = 0x00010000, 00287 OptionThreadingAlways = 0x00020000, 00288 00289 OptionWindowStandard = 0x00000000, 00290 OptionWindowShort = 0x00100000, 00291 OptionWindowLong = 0x00200000, 00292 00293 OptionSmoothingOff = 0x00000000, 00294 OptionSmoothingOn = 0x00800000, 00295 00296 OptionFormantShifted = 0x00000000, 00297 OptionFormantPreserved = 0x01000000, 00298 00299 OptionPitchHighSpeed = 0x00000000, 00300 OptionPitchHighQuality = 0x02000000, 00301 OptionPitchHighConsistency = 0x04000000, 00302 00303 OptionChannelsApart = 0x00000000, 00304 OptionChannelsTogether = 0x10000000, 00305 00306 // n.b. Options is int, so we must stop before 0x80000000 00307 }; 00308 00309 typedef int Options; 00310 00311 enum PresetOption { 00312 DefaultOptions = 0x00000000, 00313 PercussiveOptions = 0x00102000 00314 }; 00315 00324 RubberBandStretcher(size_t sampleRate, 00325 size_t channels, 00326 Options options = DefaultOptions, 00327 double initialTimeRatio = 1.0, 00328 double initialPitchScale = 1.0); 00329 ~RubberBandStretcher(); 00330 00336 void reset(); 00337 00359 void setTimeRatio(double ratio); 00360 00386 void setPitchScale(double scale); 00387 00392 double getTimeRatio() const; 00393 00398 double getPitchScale() const; 00399 00409 size_t getLatency() const; 00410 00417 void setTransientsOption(Options options); 00418 00425 void setDetectorOption(Options options); 00426 00435 void setPhaseOption(Options options); 00436 00445 void setFormantOption(Options options); 00446 00453 void setPitchOption(Options options); 00454 00462 void setExpectedInputDuration(size_t samples); 00463 00487 void setMaxProcessSize(size_t samples); 00488 00507 size_t getSamplesRequired() const; 00508 00533 void setKeyFrameMap(const std::map<size_t, size_t> &); 00534 00552 void study(const float *const *input, size_t samples, bool final); 00553 00560 void process(const float *const *input, size_t samples, bool final); 00561 00575 int available() const; 00576 00584 size_t retrieve(float *const *output, size_t samples) const; 00585 00591 float getFrequencyCutoff(int n) const; 00592 00598 void setFrequencyCutoff(int n, float f); 00599 00605 size_t getInputIncrement() const; 00606 00616 std::vector<int> getOutputIncrements() const; 00617 00627 std::vector<float> getPhaseResetCurve() const; 00628 00637 std::vector<int> getExactTimePoints() const; 00638 00643 size_t getChannelCount() const; 00644 00652 void calculateStretch(); 00653 00661 void setDebugLevel(int level); 00662 00669 static void setDefaultDebugLevel(int level); 00670 00671 protected: 00672 class Impl; 00673 Impl *m_d; 00674 }; 00675 00676 } 00677 00678 #endif
Generated on Thu May 17 22:54:24 2012 for Rubber Band Library by
1.6.3