Audacity 3.2.0
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 or later. 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
17template< typename Enum > class EnumSetting;
18
19struct soxr;
20extern "C" void soxr_delete(soxr*);
22 void operator () (soxr *p) const { if (p) soxr_delete(p); }
23};
24using soxrHandle = std::unique_ptr<soxr, soxr_deleter>;
25
26class 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 const 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__
std::unique_ptr< soxr, soxr_deleter > soxrHandle
Definition: Resample.h:24
void soxr_delete(soxr *)
Adapts EnumSettingBase to a particular enumeration type.
Definition: Prefs.h:514
Interface to libsoxr.
Definition: Resample.h:27
bool mbWantConstRateResampling
Definition: Resample.h:81
static EnumSetting< int > FastMethodSetting
Definition: Resample.h:42
soxrHandle mHandle
Definition: Resample.h:80
int mMethod
Definition: Resample.h:79
static EnumSetting< int > BestMethodSetting
Definition: Resample.h:43
void operator()(soxr *p) const
Definition: Resample.h:22