SAL
A C++ library for spatial audio.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ism.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: Enzo De Sena, enzodesena@gmail.com
7  */
8 
9 #ifndef SAL_ISM_H
10 #define SAL_ISM_H
11 
12 #include "cuboidroom.h"
13 #include "source.h"
14 #include "delayfilter.h"
15 #include "microphone.h"
16 #include "firfilter.h"
17 
18 namespace sal {
19 
23 };
24 
25 class Ism {
26 private:
27  Room* const room_;
28  sal::Source* const source_;
29  sal::Microphone* const microphone_;
30 
31  sal::Int rir_length_;
32  IsmInterpolation interpolation_;
33  sal::Time sampling_frequency_;
34  sal::Length random_distance_;
35 
36  sal::Time peterson_window_;
37 
38  std::vector<sal::Sample> rir_;
39  std::vector<sal::Time> images_delay_;
40  std::vector<mcl::Point> images_position_;
41 
42  std::vector<sal::DelayFilter> images_int_delay_filter_;
43  std::vector<mcl::FirFilter> images_frac_delay_filter_;
44 
45  bool modified_;
46 
47  void CalculateRir();
48 
49  void WriteSample(const sal::Time& delay_norm,
50  const sal::Sample& gid);
51 public:
52  Ism(Room* const room,
53  sal::Source* const source,
54  sal::Microphone* const microphone,
55  IsmInterpolation interpolation,
56  sal::Int rir_length,
57  const sal::Time sampling_frequency);
58 
59  void Run(const Sample* input_data, const Int num_samples,
60  Buffer& output_buffer);
61 
62  // Triggers a self-update of the network. Has to be called after microphone,
63  // room or source (not including stream push) is updated.
64  void Update();
65 
66  std::vector<sal::Sample> rir() { return rir_; }
67  std::vector<sal::Time> images_delay() { return images_delay_; }
68 
69  void SetPetersonWindow(sal::Time duration) { peterson_window_ = duration; }
70 
71  void SetRandomDistance(sal::Length distance) { random_distance_ = distance; }
72 
73  static bool Test();
74 };
75 
76 } // namespace sal
77 
78 #endif