Wayverb
hrtf.h
1 #pragma once
2 
3 #include "core/cl/scene_structs.h"
4 #include "core/orientation.h"
5 
6 #include "glm/glm.hpp"
7 
8 namespace wayverb {
9 namespace core {
10 namespace attenuator {
11 
12 class hrtf final {
13 public:
14  using orientation_t = class orientation;
15 
16  enum class channel { left, right };
17 
18  explicit hrtf(const orientation_t& o = orientation_t(),
19  channel channel = channel::left,
20  float radius = 0.1f);
21 
22  void set_channel(channel channel);
23  channel get_channel() const;
24 
25  void set_radius(float radius);
26  float get_radius() const;
27 
28  template <typename Archive>
29  void serialize(Archive&);
30 
31  orientation_t orientation;
32 
33 private:
34  channel channel_;
35  float radius_;
36 };
37 
38 bool operator==(const hrtf& a, const hrtf& b);
39 bool operator!=(const hrtf& a, const hrtf& b);
40 
41 template <typename T, size_t... Ix>
42 constexpr auto to_cl_float_vector(const std::array<T, sizeof...(Ix)>& x,
43  std::index_sequence<Ix...>) {
44  using return_type = ::detail::cl_vector_constructor_t<float, sizeof...(Ix)>;
45  return return_type{{static_cast<float>(std::get<Ix>(x))...}};
46 }
47 
48 template <typename T, size_t I>
49 constexpr auto to_cl_float_vector(const std::array<T, I>& x) {
50  return to_cl_float_vector(x, std::make_index_sequence<I>{});
51 }
52 
53 bands_type attenuation(const hrtf& hrtf, const glm::vec3& incident);
54 
55 glm::vec3 get_ear_position(const hrtf& hrtf, const glm::vec3& base_position);
56 
57 } // namespace attenuator
58 } // namespace core
59 } // namespace wayverb
Definition: hrtf.h:12
Definition: traits.cpp:2
Definition: capsule_base.h:9
Invariant: pointing_ is a unit vector.
Definition: orientation.h:15