Wayverb
postprocess.h
1 #pragma once
2 
3 #include "raytracer/stochastic/postprocessing.h"
4 
5 namespace wayverb {
6 namespace raytracer {
7 namespace stochastic {
8 
9 struct size_functor final {
10  template <typename T>
11  auto operator()(const T& t) const {
12  return t.size();
13  }
14 };
15 
16 template <size_t Az, size_t El, typename Method>
17 auto postprocess(const directional_energy_histogram<Az, El>& histogram,
18  const Method& method,
19  double room_volume,
20  const core::environment& environment,
21  double sample_rate) {
22  const auto& table = histogram.histogram.table;
23 
24  const auto max_size = std::accumulate(
25  std::begin(table),
26  std::end(table),
27  0ul,
28  [&](auto a, const auto& b) {
29  if (std::distance(std::begin(b), std::end(b)) == 0) {
30  return a;
31  }
32  const auto make_size_iterator = [](auto it) {
33  return util::make_mapping_iterator_adapter(std::move(it),
34  size_functor{});
35  };
36  return std::max(
37  a,
38  *std::max_element(make_size_iterator(std::begin(b)),
39  make_size_iterator(std::end(b))));
40  });
41 
42  const auto max_seconds = max_size / histogram.sample_rate;
43 
44  const auto dirac_sequence = generate_dirac_sequence(
45  environment.speed_of_sound, room_volume, sample_rate, max_seconds);
46  return postprocessing(
47  histogram, method, dirac_sequence, environment.acoustic_impedance);
48 }
49 
50 } // namespace stochastic
51 } // namespace raytracer
52 } // namespace wayverb
Definition: postprocessing.h:48
Definition: pressure.h:22
Definition: environment.h:6
Definition: capsule_base.h:9