Audaspace  1.6.0
A high level audio library.
FFTConvolver.h
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright 2015-2016 Juan Francisco Crespo Galán
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 ******************************************************************************/
16 
17 #pragma once
18 
25 #include "IReader.h"
26 #include "ISound.h"
27 #include "util/FFTPlan.h"
28 
29 #include <memory>
30 #include <vector>
31 
37 {
38 private:
42  std::shared_ptr<FFTPlan> m_plan;
43 
47  int m_N;
48 
52  int m_M;
53 
57  int m_L;
58 
62  int m_realBufLen;
63 
67  std::complex<sample_t>* m_inBuffer;
68 
72  sample_t* m_shiftBuffer;
73 
77  float* m_tail;
78 
82  std::shared_ptr<std::vector<std::complex<sample_t>>> m_irBuffer;
83 
87  int m_tailPos;
88 
89  // delete copy constructor and operator=
90  FFTConvolver(const FFTConvolver&) = delete;
91  FFTConvolver& operator=(const FFTConvolver&) = delete;
92 
93 public:
99  FFTConvolver(std::shared_ptr<std::vector<std::complex<sample_t>>> ir, std::shared_ptr<FFTPlan> plan);
100  virtual ~FFTConvolver();
101 
112  void getNext(const sample_t* inBuffer, sample_t* outBuffer, int& length);
113 
125  void getNext(const sample_t* inBuffer, sample_t* outBuffer, int& length, fftwf_complex* transformedData);
126 
137  void getNext(const fftwf_complex* inBuffer, sample_t* outBuffer, int& length);
138 
148  void getTail(int& length, bool& eos, sample_t* buffer);
149 
153  void clear();
154 
163  void IFFT_FDL(const fftwf_complex* inBuffer, sample_t* outBuffer, int& length);
164 
170  void getNextFDL(const std::complex<sample_t>* inBuffer, std::complex<sample_t>* accBuffer);
171 
181  void getNextFDL(const sample_t* inBuffer, std::complex<sample_t>* accBuffer, int& length, fftwf_complex* transformedData);
182 
187  void setImpulseResponse(std::shared_ptr<std::vector<std::complex<sample_t>>> ir);
188 
193  std::shared_ptr<std::vector<std::complex<sample_t>>> getImpulseResponse();
194 };
195 
#define AUD_NAMESPACE_BEGIN
Opens the audaspace namespace aud.
Definition: Audaspace.h:116
The ISound interface.
#define AUD_API
Used for exporting symbols in the shared library.
Definition: Audaspace.h:93
The IReader interface.
float sample_t
Sample type.(float samples)
Definition: Audaspace.h:126
This class allows to easily convolve a sound using the Fourier transform.
Definition: FFTConvolver.h:36
#define AUD_NAMESPACE_END
Closes the audaspace namespace aud.
Definition: Audaspace.h:119
The FFTPlan class.