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 #include "fx/ConvolverSound.h"
18 #include "fx/ConvolverReader.h"
19 #include "Exception.h"
20 
21 #include <cstring>
22 
23 AUD_NAMESPACE_BEGIN
24 
ConvolverSound(std::shared_ptr<ISound> sound,std::shared_ptr<ImpulseResponse> impulseResponse,std::shared_ptr<ThreadPool> threadPool)25 ConvolverSound::ConvolverSound(std::shared_ptr<ISound> sound, std::shared_ptr<ImpulseResponse> impulseResponse, std::shared_ptr<ThreadPool> threadPool) :
26 	ConvolverSound(sound, impulseResponse, threadPool, std::make_shared<FFTPlan>(0.0))
27 {
28 }
29 
ConvolverSound(std::shared_ptr<ISound> sound,std::shared_ptr<ImpulseResponse> impulseResponse,std::shared_ptr<ThreadPool> threadPool,std::shared_ptr<FFTPlan> plan)30 ConvolverSound::ConvolverSound(std::shared_ptr<ISound> sound, std::shared_ptr<ImpulseResponse> impulseResponse, std::shared_ptr<ThreadPool> threadPool, std::shared_ptr<FFTPlan> plan) :
31 	m_sound(sound), m_impulseResponse(impulseResponse), m_threadPool(threadPool), m_plan(plan)
32 {
33 }
34 
createReader()35 std::shared_ptr<IReader> ConvolverSound::createReader()
36 {
37 	return std::make_shared<ConvolverReader>(m_sound->createReader(), m_impulseResponse, m_threadPool, m_plan);
38 }
39 
getImpulseResponse()40 std::shared_ptr<ImpulseResponse> ConvolverSound::getImpulseResponse()
41 {
42 	return m_impulseResponse;
43 }
44 
setImpulseResponse(std::shared_ptr<ImpulseResponse> impulseResponse)45 void ConvolverSound::setImpulseResponse(std::shared_ptr<ImpulseResponse> impulseResponse)
46 {
47 	m_impulseResponse = impulseResponse;
48 }
49 
50 AUD_NAMESPACE_END
51