Audaspace
1.9.0
A high level audio library.
Toggle main menu visibility
Loading...
Searching...
No Matches
fx
Convolver.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
24
25
#include "
FFTConvolver.h
"
26
#include "
util/ThreadPool.h
"
27
#include "
util/FFTPlan.h
"
28
29
#include <memory>
30
#include <vector>
31
#include <mutex>
32
#include <future>
33
#include <atomic>
34
#include <deque>
35
36
AUD_NAMESPACE_BEGIN
40
class
AUD_API
Convolver
41
{
42
private
:
46
int
m_N;
47
51
int
m_M;
52
56
int
m_L;
57
61
std::shared_ptr<std::vector<std::shared_ptr<std::vector<std::complex<sample_t>>>>> m_irBuffers;
62
66
std::vector<fftwf_complex*> m_threadAccBuffers;
67
71
std::vector<std::unique_ptr<FFTConvolver>> m_fftConvolvers;
72
76
int
m_numThreads;
77
81
std::shared_ptr<ThreadPool> m_threadPool;
82
86
std::vector<std::future<bool>> m_futures;
87
91
std::mutex m_sumMutex;
92
96
std::atomic_bool m_resetFlag;
97
101
fftwf_complex* m_accBuffer;
102
106
std::deque<fftwf_complex*> m_delayLine;
107
111
int
m_irLength;
112
116
int
m_tailCounter;
117
121
bool
m_eos;
122
123
// delete copy constructor and operator=
124
Convolver(
const
Convolver&) =
delete
;
125
Convolver& operator=(
const
Convolver&) =
delete
;
126
127
public
:
128
136
Convolver
(std::shared_ptr<std::vector<std::shared_ptr<std::vector<std::complex<sample_t>>>>> ir,
int
irLength, std::shared_ptr<ThreadPool> threadPool, std::shared_ptr<FFTPlan> plan);
137
138
virtual
~Convolver();
139
149
void
getNext
(
sample_t
* inBuffer,
sample_t
* outBuffer,
int
& length,
bool
& eos);
150
154
void
reset
();
155
160
std::shared_ptr<std::vector<std::shared_ptr<std::vector<std::complex<sample_t>>>>>
getImpulseResponse
();
161
166
void
setImpulseResponse
(std::shared_ptr<std::vector<std::shared_ptr<std::vector<std::complex<sample_t>>>>> ir);
167
168
private
:
169
174
bool
threadFunction(
int
id
);
175
};
176
177
AUD_NAMESPACE_END
AUD_NAMESPACE_END
#define AUD_NAMESPACE_END
Closes the audaspace namespace aud.
Definition
Audaspace.h:119
sample_t
float sample_t
Sample type.(float samples).
Definition
Audaspace.h:126
AUD_NAMESPACE_BEGIN
#define AUD_NAMESPACE_BEGIN
Opens the audaspace namespace aud.
Definition
Audaspace.h:116
AUD_API
#define AUD_API
Used for exporting symbols in the shared library.
Definition
Audaspace.h:93
FFTConvolver.h
The FFTConvolver class.
FFTPlan.h
The FFTPlan class.
ThreadPool.h
The ThreadPool class.
Convolver::Convolver
Convolver(std::shared_ptr< std::vector< std::shared_ptr< std::vector< std::complex< sample_t > > > > > ir, int irLength, std::shared_ptr< ThreadPool > threadPool, std::shared_ptr< FFTPlan > plan)
Creates a new FFTConvolver.
Convolver::setImpulseResponse
void setImpulseResponse(std::shared_ptr< std::vector< std::shared_ptr< std::vector< std::complex< sample_t > > > > > ir)
Changes the impulse response and resets the convolver.
Convolver::getNext
void getNext(sample_t *inBuffer, sample_t *outBuffer, int &length, bool &eos)
Convolves the data that is provided with the inpulse response.
Convolver::reset
void reset()
Resets all the internally stored data so the convolution of a new sound can be started.
Convolver::getImpulseResponse
std::shared_ptr< std::vector< std::shared_ptr< std::vector< std::complex< sample_t > > > > > getImpulseResponse()
Retrieves the current impulse response being used.
Generated by
1.17.0