Wayverb
multiband.h
1 #pragma once
2 
3 #include "hrtf/entry.h"
4 
5 #include "frequency_domain/multiband_filter.h"
6 
7 #include "utilities/map.h"
8 
9 namespace hrtf_data {
10 
11 constexpr util::range<double> audible_range{20, 20000};
12 
13 inline auto hrtf_band_centres_hz() {
14  return frequency_domain::band_centres<entry::bands>(audible_range);
15 }
16 
17 inline auto hrtf_band_centres(double sample_rate) {
18  return util::map([&](auto i) { return i / sample_rate; },
19  hrtf_band_centres_hz());
20 }
21 
22 inline auto hrtf_band_params_hz() {
23  return frequency_domain::compute_multiband_params<entry::bands>(
24  audible_range, 1);
25 }
26 
27 inline auto hrtf_band_params(double sample_rate) {
28  const auto hz = hrtf_band_params_hz();
29  return frequency_domain::make_edges_and_width_factor(
30  util::map([&](auto i) { return i / sample_rate; }, hz.edges),
31  hz.width_factor);
32 }
33 
34 template <typename It, typename Callback>
35 void multiband_filter(It begin,
36  It end,
37  double sample_rate,
38  const Callback& callback) {
39  frequency_domain::multiband_filter(
40  begin, end, hrtf_band_params(sample_rate), callback);
41 }
42 
43 template <typename It>
44 auto per_band_energy(It begin, It end, double sample_rate) {
45  return frequency_domain::per_band_energy(
46  begin, end, hrtf_band_params(sample_rate));
47 }
48 
49 } // namespace hrtf_data
Definition: entry.h:7