Audacity  3.0.3
Resample.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4  Audacity(R) is copyright (c) 1999-2012 Audacity Team.
5  License: GPL v2. See License.txt.
6 
7  Resample.cpp
8  Dominic Mazzoni, Rob Sykes, Vaughan Johnson
9 
10 **********************************************************************/
11 
12 #ifndef __AUDACITY_RESAMPLE_H__
13 #define __AUDACITY_RESAMPLE_H__
14 
15 #include "SampleFormat.h"
16 
17 template< typename Enum > class EnumSetting;
18 
19 struct soxr;
20 extern "C" void soxr_delete(soxr*);
21 struct soxr_deleter {
22  void operator () (soxr *p) const { if (p) soxr_delete(p); }
23 };
24 using soxrHandle = std::unique_ptr<soxr, soxr_deleter>;
25 
26 class MATH_API Resample final
27 {
28  public:
34  //
37  // dMinFactor and dMaxFactor specify the range of factors for variable-rate resampling.
38  // For constant-rate, pass the same value for both.
39  Resample(const bool useBestMethod, const double dMinFactor, const double dMaxFactor);
40  ~Resample();
41 
44 
67  std::pair<size_t, size_t>
68  Process(double factor,
69  float *inBuffer,
70  size_t inBufferLen,
71  bool lastFlag,
72  float *outBuffer,
73  size_t outBufferLen);
74 
75  protected:
76  void SetMethod(const bool useBestMethod);
77 
78  protected:
79  int mMethod; // resampler-specific enum for resampling method
80  soxrHandle mHandle; // constant-rate or variable-rate resampler (XOR per instance)
82 };
83 
84 #endif // __AUDACITY_RESAMPLE_H__
soxrHandle
std::unique_ptr< soxr, soxr_deleter > soxrHandle
Definition: Resample.h:24
Resample::FastMethodSetting
static EnumSetting< int > FastMethodSetting
Definition: Resample.h:42
Resample::mMethod
int mMethod
Definition: Resample.h:79
soxr_deleter
Definition: Resample.h:21
soxr_deleter::operator()
void operator()(soxr *p) const
Definition: Resample.h:22
Resample::mHandle
soxrHandle mHandle
Definition: Resample.h:80
Resample::mbWantConstRateResampling
bool mbWantConstRateResampling
Definition: Resample.h:81
Resample
Interface to libsoxr.
Definition: Resample.h:27
soxr_delete
void soxr_delete(soxr *)
EnumSetting
Adapts EnumSettingBase to a particular enumeration type.
Definition: Prefs.h:351
Resample::BestMethodSetting
static EnumSetting< int > BestMethodSetting
Definition: Resample.h:43
SampleFormat.h