3 #include "raytracer/cl/structs.h" 5 #include "core/attenuator/hrtf.h" 6 #include "core/attenuator/microphone.h" 7 #include "core/attenuator/null.h" 8 #include "core/conversions.h" 10 #include "utilities/map_to_vector.h" 11 #include "utilities/mapping_iterator_adapter.h" 13 #include "glm/glm.hpp" 18 template <
size_t channels>
19 auto attenuate(
const core::attenuator::null& null,
20 const glm::vec3& position,
21 const impulse<channels>& i) {
22 return make_attenuated_impulse(i.volume, i.distance);
27 template <
size_t channels>
28 auto attenuate(
const core::attenuator::microphone& mic,
29 const glm::vec3& position,
30 const impulse<channels>& i) {
31 const auto dir = core::to_vec3{}(i.position) - position;
32 const auto att = attenuation(mic,
dir);
33 return make_attenuated_impulse(i.volume * att, i.distance);
39 template <
size_t channels>
40 auto attenuate(
const core::attenuator::hrtf& hrtf,
41 const glm::vec3& position,
42 const impulse<channels>& i) {
43 const auto adjusted_listener_position = get_ear_position(hrtf, position);
45 const auto impulse_position = core::to_vec3{}(i.position);
47 const auto dir = impulse_position - adjusted_listener_position;
48 const auto att = attenuation(hrtf,
dir);
50 return make_attenuated_impulse(
52 glm::distance(impulse_position, adjusted_listener_position));
55 template <
typename Method>
61 auto operator()(
const T& t)
const {
62 return attenuate(method, position, t);
66 template <
typename Method>
67 auto make_attenuate_mapper(Method method,
const glm::vec3& position) {
71 template <
typename It,
typename Method>
72 auto make_attenuator_iterator(It it, Method method,
const glm::vec3& position) {
73 return util::make_mapping_iterator_adapter(
74 std::move(it), make_attenuate_mapper(std::move(method), position));
Definition: pressure.h:22
Definition: capsule_base.h:9
Definition: attenuator.h:56