SAL
A C++ library for spatial audio.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
room.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_ROOM_H
10 #define SAL_ROOM_H
11 
12 #include "saltypes.h"
13 #include "point.h"
14 #include "iirfilter.h"
15 #include "comparisonop.h"
16 
17 namespace sal {
18 
19 
23 };
24 
25 
26 class Room {
27 public:
28  // This is the standard constructor where you feed the room `shape` and for
29  // each face of the shape you also provide a filter. The order in the
30  // `filters` vector follows that of the employed shape.
31  Room(const std::vector<mcl::IirFilter>& wall_filters) noexcept :
33 
34  const std::vector<mcl::IirFilter>& wall_filters() const noexcept {
35  return wall_filters_;
36  }
37 
38  // Resets the wall filters. Warning! It may cancel the state of the old ones,
39  // with probable audible artifacts.
40  void SetWallFilters(const std::vector<mcl::IirFilter>& wall_filters) noexcept {
42  }
43 
44  void SetWallFilter(const Int wall_id, const mcl::IirFilter& filter) noexcept {
45  ASSERT(wall_id>=0 && wall_id<num_boundary_points());
46  wall_filters_[wall_id] = filter;
47  }
48 
49  void SetWallFilters(const mcl::IirFilter& filter) noexcept {
50  wall_filters_.assign(num_faces(), filter);
51  }
52 
53  void SetFiltersNumeratorCoefficient(const Int coeff_id, const Sample value) {
54  for (Int i=0; i < (Int) wall_filters_.size(); ++i) {
55  wall_filters_[i].SetNumeratorCoefficient(coeff_id, value);
56  }
57  }
58 
59  // Returns a vector of points located at geometrical reflections,
60  // relative to source and destinatin points.
61  virtual std::vector<mcl::Point>
62  CalculateBoundaryPoints(const mcl::Point& source,
63  const mcl::Point& destination) const noexcept = 0;
64 
65  virtual std::vector<mcl::IirFilter>
66  GetBoundaryFilters(const mcl::Point& source_point,
67  const mcl::Point& mic_point) const noexcept = 0;
68 
69  virtual sal::Int num_boundary_points() const noexcept = 0;
70 
71  // Returns the shape's number of faces.
72  virtual sal::Int num_faces() const noexcept = 0;
73 
74  // Returns the maximum distance between two points inside the shape.
75  virtual sal::Length max_distance() const noexcept = 0;
76 
82  virtual bool
83  IsPointInRoom(const mcl::Point& point,
84  const sal::Length wall_distance = 0.0) const noexcept = 0;
85 
86  virtual std::string ShapeDescription() const noexcept = 0;
87 
88  virtual ~Room() noexcept {}
89 protected:
90  std::vector<mcl::IirFilter> wall_filters_;
92 };
93 
94 } // namespace sal
95 
96 #endif