AVPKit
IAudioResampler.h
1 /*******************************************************************************
2  * Copyright (c) 2024, 2026, Olivier Ayache. All rights reserved.
3  *
4  * This file is part of AVPKit.
5  *
6  * AVPKit is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * AVPKit is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with AVPKit. If not, see <http://www.gnu.org/licenses/>.
18  *******************************************************************************/
19 
20 #ifndef IAUDIORESAMPLER_H_
21 #define IAUDIORESAMPLER_H_
22 
23 #include <com/avpkit/ferry/RefCounted.h>
24 #include <com/avpkit/core/AVPKit.h>
25 #include <com/avpkit/core/IAudioSamples.h>
26 
27 namespace com { namespace avpkit { namespace core
28  {
32  class VS_API_AVPKIT IAudioResampler : public com::avpkit::ferry::RefCounted
33  {
34  public:
39  virtual int getOutputChannels()=0;
44  virtual int getOutputRate()=0;
45 
50  virtual int getInputChannels()=0;
55  virtual int getInputRate()=0;
86  virtual int resample(IAudioSamples *outputSamples, IAudioSamples *inputSamples,
87  int32_t numSamples)=0;
88 
109  static IAudioResampler* make(int32_t outputChannels, int32_t inputChannels,
110  int32_t outputRate, int32_t inputRate);
111 
112  /*
113  * Added for 1.21
114  */
115 
121 
127 
132  virtual int32_t getFilterLen()=0;
133 
138  virtual int32_t getLog2PhaseCount()=0;
139 
144  virtual bool isLinear()=0;
145 
150  virtual double getCutoffFrequency()=0;
151 
176  static IAudioResampler* make(int32_t outputChannels, int32_t inputChannels,
177  int32_t outputRate, int32_t inputRate,
178  IAudioSamples::Format outputFmt, IAudioSamples::Format inputFmt);
179 
206  static IAudioResampler* make(int32_t outputChannels, int32_t inputChannels,
207  int32_t outputRate, int32_t inputRate,
208  IAudioSamples::Format outputFmt, IAudioSamples::Format inputFmt,
209  int32_t filterLen, int32_t log2PhaseCount,
210  bool isLinear, double cutoffFrequency);
211 
212  protected:
213  IAudioResampler();
214  virtual ~IAudioResampler();
215 
216  public:
217  /*
218  * Added for 3.2
219  */
220 
232 
243  int32_t numSamples)=0;
244 
245  };
246 
247  }}}
248 
249 #endif /*IAUDIORESAMPLER_H_*/
Used to resample IAudioSamples to different sample rates or number of channels.
virtual int getInputRate()=0
sample rate expected in input audio.
virtual int getInputChannels()=0
number of channels expected in input audio.
virtual IAudioSamples::Format getOutputFormat()=0
Get the sample format we expect to resample to.
virtual int32_t getFilterLen()=0
Get the length of each filter in the resampler filter bank.
virtual IAudioSamples::Format getInputFormat()=0
Get the sample format we expect to resample from.
virtual int32_t getLog2PhaseCount()=0
Get log2(number of entries in filter bank).
virtual bool isLinear()=0
Are we linearly interpolating between filters?
virtual double getCutoffFrequency()=0
What is the cuttoff frequency used?
virtual int resample(IAudioSamples *outputSamples, IAudioSamples *inputSamples, int32_t numSamples)=0
Re-sample up to numSamples from inputSamples to outputSamples.
virtual int getOutputChannels()=0
number of channels in output audio.
virtual int32_t getMinimumNumSamplesRequiredInOutputSamples(IAudioSamples *inSamples)=0
Get the minimum number of samples that must be placeable in an output set of samples in order for a r...
virtual int32_t getMinimumNumSamplesRequiredInOutputSamples(int32_t numSamples)=0
Get the minimum number of samples that must be placeable in an output set of samples in order for a r...
virtual int getOutputRate()=0
sample rate of output audio.
A set of raw (decoded) samples, plus a timestamp for when to play those samples relative to other ite...
Definition: IAudioSamples.h:38
Format
The format we use to represent audio.
Definition: IAudioSamples.h:46
Parent of all Ferry objects – it mains reference counts in native code.
Definition: RefCounted.h:85
WARNING: Do not use logging in this class, and do not set any static file variables to values other t...