SAL
A C++ library for spatial audio.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fdtd.h
Go to the documentation of this file.
1 /*
2  Spatial Audio Library (SAL)
3  Copyright (c) 2013-2018, Enzo De Sena
4  All rights reserved.
5 
6  Authors:
7  Niccolo' Antonello
8  Enzo De Sena, enzodesena@gmail.com
9  */
10 
11 
12 #ifndef SAL_FDTD_H
13 #define SAL_FDTD_H
14 
15 
16 #include "cuboidroom.h"
17 #include "source.h"
18 #include "microphone.h"
19 
20 namespace sal {
21 
22 class Fdtd {
23 private:
24  Room* const room_;
25  sal::Source* const source_;
26  sal::Microphone* const microphone_;
27  sal::Sample xi_;
28  sal::Sample lmb_;
29 
30  sal::Time sampling_frequency_;
31 
32  std::vector<sal::Sample> rir_;
33 
34  static
35  sal::Signal RunFdtd(sal::Int Nx, sal::Int Ny, sal::Int Nz,
36  sal::Int Nt,
37  std::vector<std::vector<std::vector<sal::Int> > > G,
38  sal::Sample xi,
39  const Sample* signal,
40  sal::Sample lmb,
41  sal::Int position_x,
42  sal::Int position_y,
43  sal::Int position_z,
44  sal::Int position_m_x,
45  sal::Int position_m_y,
46  sal::Int position_m_z);
47 
48  template<class T>
49  static
50  void
51  Initialise3DArray(std::vector<std::vector<std::vector<T> > >& array,
52  sal::Int size_x, sal::Int size_y, sal::Int size_z) {
53  array.resize(size_x);
54  for (sal::Int i = 0; i < size_x; ++i) {
55  array[i].resize(size_y);
56  for (sal::Int j = 0; j < size_y; ++j) {
57  array[i][j].resize(size_z);
58  }
59  }
60  }
61 
62 public:
63  Fdtd(Room* const room,
64  sal::Source* const source,
65  sal::Microphone* const microphone,
66  const sal::Time sampling_frequency,
67  sal::Sample xi,
68  sal::Sample lmb);
69 
70 
71  void Run(const MonoBuffer& input_buffer, Buffer& output_buffer);
72 
73  sal::Signal rir() const { return rir_; }
74 
75  static
76  std::vector<std::vector<std::vector<sal::Int> > >
78 
79  static bool Test();
80  static sal::Time SimulationTime();
81 };
82 
83 } // namespace raily
84 
85 
86 #endif