Wayverb
setup.h
1 #pragma once
2 
3 #include "waveguide/boundary_coefficient_finder.h"
4 #include "waveguide/cl/utils.h"
5 #include "waveguide/mesh_descriptor.h"
6 #include "waveguide/program.h"
7 
8 #include "core/cl/include.h"
9 #include "core/program_wrapper.h"
10 #include "core/spatial_division/scene_buffers.h"
11 #include "core/spatial_division/voxel_collection.h"
12 
13 #include "utilities/aligned/vector.h"
14 #include "utilities/map_to_vector.h"
15 
16 #include "glm/fwd.hpp"
17 
18 namespace wayverb {
19 namespace waveguide {
20 
21 constexpr bool is_inside(const condensed_node& c) {
22  return c.boundary_type & id_inside;
23 }
24 
26 
27 class vectors final {
28 public:
29  vectors(util::aligned::vector<condensed_node> nodes,
30  util::aligned::vector<coefficients_canonical> coefficients,
32 
33  template <size_t n>
34  const util::aligned::vector<boundary_index_array<n>>& get_boundary_indices()
35  const;
36 
37  const util::aligned::vector<condensed_node>& get_condensed_nodes() const;
38  const util::aligned::vector<coefficients_canonical>& get_coefficients()
39  const;
40 
41  void set_coefficients(coefficients_canonical c);
42  void set_coefficients(util::aligned::vector<coefficients_canonical> c);
43 
44 private:
45  util::aligned::vector<condensed_node> condensed_nodes_;
46  util::aligned::vector<coefficients_canonical> coefficients_;
47  boundary_index_data boundary_index_data_;
48 };
49 
50 template <>
51 inline const util::aligned::vector<boundary_index_array<1>>&
52 vectors::get_boundary_indices<1>() const {
53  return boundary_index_data_.b1;
54 }
55 template <>
56 inline const util::aligned::vector<boundary_index_array<2>>&
57 vectors::get_boundary_indices<2>() const {
58  return boundary_index_data_.b2;
59 }
60 template <>
61 inline const util::aligned::vector<boundary_index_array<3>>&
62 vectors::get_boundary_indices<3>() const {
63  return boundary_index_data_.b3;
64 }
65 
67 
68 template <size_t N>
69 static boundary_data_array<N> construct_boundary_data_array(
70  const boundary_index_array<N>& arr) {
72  for (auto i = 0u; i != N; ++i) {
73  ret.array[i].coefficient_index = arr.array[i];
74  }
75  return ret;
76 }
77 
78 template <size_t n>
79 inline util::aligned::vector<boundary_data_array<n>> get_boundary_data(
80  const vectors& d) {
81  const auto indices = d.get_boundary_indices<n>();
82  return util::map_to_vector(begin(indices), end(indices), [](const auto& i) {
83  return construct_boundary_data_array(i);
84  });
85 }
86 
87 } // namespace waveguide
88 } // namespace wayverb
Definition: boundary_index_array.h:9
IIR filter coefficient storage.
Definition: filter_structs.h:40
Definition: setup.h:27
Definition: capsule_base.h:9
Definition: boundary_coefficient_finder.h:36