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
42 Resample( Resample&&) noexcept = default;
43 Resample& operator=(Resample&&) noexcept = default;
44
45 Resample(const Resample&) = delete;
46 Resample& operator=(const Resample&) = delete;
47
48 static EnumSetting< int > FastMethodSetting;
49 static EnumSetting< int > BestMethodSetting;
50
73 std::pair<size_t, size_t>
74 Process(double factor,
75 const float *inBuffer,
76 size_t inBufferLen,
77 bool lastFlag,
78 float *outBuffer,
79 size_t outBufferLen);
80
81 protected:
82 void SetMethod(const bool useBestMethod);
83
84 protected:
85 int mMethod; // resampler-specific enum for resampling method
86 soxrHandle mHandle; // constant-rate or variable-rate resampler (XOR per instance)
87 bool mbWantConstRateResampling;
88};
89
90#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
Resample(Resample &&) noexcept=default
STL namespace.
void operator()(soxr *p) const
Definition: Resample.h:22