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/BinauralSound.h"
18 #include "fx/BinauralReader.h"
19 #include "Exception.h"
20 
21 #include <cstring>
22 
23 AUD_NAMESPACE_BEGIN
24 
BinauralSound(std::shared_ptr<ISound> sound,std::shared_ptr<HRTF> hrtfs,std::shared_ptr<Source> source,std::shared_ptr<ThreadPool> threadPool)25 BinauralSound::BinauralSound(std::shared_ptr<ISound> sound, std::shared_ptr<HRTF> hrtfs, std::shared_ptr<Source> source, std::shared_ptr<ThreadPool> threadPool) :
26 	BinauralSound(sound, hrtfs, source, threadPool, std::make_shared<FFTPlan>(0.0))
27 {
28 }
29 
BinauralSound(std::shared_ptr<ISound> sound,std::shared_ptr<HRTF> hrtfs,std::shared_ptr<Source> source,std::shared_ptr<ThreadPool> threadPool,std::shared_ptr<FFTPlan> plan)30 BinauralSound::BinauralSound(std::shared_ptr<ISound> sound, std::shared_ptr<HRTF> hrtfs, std::shared_ptr<Source> source, std::shared_ptr<ThreadPool> threadPool, std::shared_ptr<FFTPlan> plan) :
31 	m_sound(sound), m_hrtfs(hrtfs), m_source(source), m_threadPool(threadPool), m_plan(plan)
32 {
33 }
34 
createReader()35 std::shared_ptr<IReader> BinauralSound::createReader()
36 {
37 	return std::make_shared<BinauralReader>(m_sound->createReader(), m_hrtfs, m_source, m_threadPool, m_plan);
38 }
39 
getHRTFs()40 std::shared_ptr<HRTF> BinauralSound::getHRTFs()
41 {
42 	return m_hrtfs;
43 }
44 
setHRTFs(std::shared_ptr<HRTF> hrtfs)45 void BinauralSound::setHRTFs(std::shared_ptr<HRTF> hrtfs)
46 {
47 	m_hrtfs = hrtfs;
48 }
49 
getSource()50 std::shared_ptr<Source> BinauralSound::getSource()
51 {
52 	return m_source;
53 }
54 
setSource(std::shared_ptr<Source> source)55 void BinauralSound::setSource(std::shared_ptr<Source> source)
56 {
57 	m_source = source;
58 }
59 
60 AUD_NAMESPACE_END
61