Audaspace 1.5.0
A high level audio library.
Loading...
Searching...
No Matches
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{
38private:
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
93public:
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_END
Closes the audaspace namespace aud.
Definition Audaspace.h:119
float sample_t
Sample type.(float samples)
Definition Audaspace.h:126
#define AUD_NAMESPACE_BEGIN
Opens the audaspace namespace aud.
Definition Audaspace.h:116
#define AUD_API
Used for exporting symbols in the shared library.
Definition Audaspace.h:93
The FFTPlan class.
The IReader interface.
The ISound interface.
This class allows to easily convolve a sound using the Fourier transform.
Definition FFTConvolver.h:37
void getTail(int &length, bool &eos, sample_t *buffer)
Gets the internally stored extra data which is result of the convolution.
FFTConvolver(std::shared_ptr< std::vector< std::complex< sample_t > > > ir, std::shared_ptr< FFTPlan > plan)
Creates a new FFTConvolver.
void IFFT_FDL(const fftwf_complex *inBuffer, sample_t *outBuffer, int &length)
Calculates the Inverse Fast Fourier Transform of the input array.
void getNextFDL(const sample_t *inBuffer, std::complex< sample_t > *accBuffer, int &length, fftwf_complex *transformedData)
Transforms an input array of real data to the frequency domain and multiplies it by the impulse respo...
std::shared_ptr< std::vector< std::complex< sample_t > > > getImpulseResponse()
Retrieves the current impulse response being used.
void clear()
Resets the internally stored data so a new convolution can be started.
void getNext(const sample_t *inBuffer, sample_t *outBuffer, int &length)
Convolves the data that is provided with the inpulse response.
void setImpulseResponse(std::shared_ptr< std::vector< std::complex< sample_t > > > ir)
Changes the impulse response and resets the FFTConvolver.
void getNext(const fftwf_complex *inBuffer, sample_t *outBuffer, int &length)
Convolves the data that is provided with the inpulse response.
void getNext(const sample_t *inBuffer, sample_t *outBuffer, int &length, fftwf_complex *transformedData)
Convolves the data that is provided with the inpulse response.
void getNextFDL(const std::complex< sample_t > *inBuffer, std::complex< sample_t > *accBuffer)
Multiplicates a frequency domain input by the impulse response and accumulates the result to a buffer...