Audaspace 1.5.0
A high level audio library.
Loading...
Searching...
No Matches
ConvolverReader.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 "Convolver.h"
28#include "ImpulseResponse.h"
29#include "util/FFTPlan.h"
30#include "util/ThreadPool.h"
31
32#include <memory>
33#include <vector>
34#include <future>
35
37
42{
43private:
47 int m_position;
48
52 std::shared_ptr<IReader> m_reader;
53
57 std::shared_ptr<ImpulseResponse> m_ir;
58
62 int m_N;
63
67 int m_M;
68
72 int m_L;
73
77 std::vector<std::unique_ptr<Convolver>> m_convolvers;
78
82 sample_t* m_outBuffer;
83
87 std::vector<sample_t*> m_vecInOut;
88
92 int m_outBufferPos;
93
97 int m_eOutBufLen;
98
102 int m_outBufLen;
103
107 bool m_eosReader;
108
112 bool m_eosTail;
113
117 int m_inChannels;
118
122 int m_irChannels;
123
127 int m_nChannelThreads;
128
132 int m_lastLengthIn;
133
137 std::shared_ptr<ThreadPool> m_threadPool;
138
142 std::vector<std::future<int>> m_futures;
143
144 // delete copy constructor and operator=
145 ConvolverReader(const ConvolverReader&) = delete;
146 ConvolverReader& operator=(const ConvolverReader&) = delete;
147
148public:
157 ConvolverReader(std::shared_ptr<IReader> reader, std::shared_ptr<ImpulseResponse> ir, std::shared_ptr<ThreadPool> threadPool, std::shared_ptr<FFTPlan> plan);
158 virtual ~ConvolverReader();
159
160 virtual bool isSeekable() const;
161 virtual void seek(int position);
162 virtual int getLength() const;
163 virtual int getPosition() const;
164 virtual Specs getSpecs() const;
165 virtual void read(int& length, bool& eos, sample_t* buffer);
166
167private:
173 void divideByChannel(const sample_t* buffer, int len);
174
180 void joinByChannel(int start, int len);
181
185 void loadBuffer();
186
195 int threadFunction(int id, bool input);
196};
197
#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 Convolver class.
The FFTPlan class.
The IReader interface.
The ISound interface.
The ImpulseResponse class.
The ThreadPool class.
This class represents a reader for a sound that can be modified depending on a given impulse response...
Definition ConvolverReader.h:42
ConvolverReader(std::shared_ptr< IReader > reader, std::shared_ptr< ImpulseResponse > ir, std::shared_ptr< ThreadPool > threadPool, std::shared_ptr< FFTPlan > plan)
Creates a new convolver reader.
virtual int getLength() const
Returns an approximated length of the source in samples.
virtual int getPosition() const
Returns the position of the source as a sample count value.
virtual bool isSeekable() const
Tells whether the source provides seeking functionality or not.
virtual void read(int &length, bool &eos, sample_t *buffer)
Request to read the next length samples out of the source.
virtual Specs getSpecs() const
Returns the specification of the reader.
virtual void seek(int position)
Seeks to a specific position in the source.
This class represents a sound source as stream or as buffer which can be read for example by another ...
Definition IReader.h:35
Specification of a sound source.
Definition Specification.h:119