3 #include "core/attenuator/null.h" 4 #include "core/cl/iterator.h" 5 #include "core/cl/scene_structs.h" 6 #include "core/mixdown.h" 7 #include "core/vector_look_up_table.h" 9 #include "hrtf/multiband.h" 11 #include "utilities/aligned/vector.h" 19 namespace stochastic {
21 template <
typename T,
size_t... Ix>
22 constexpr
auto array_to_bands_type(
const std::array<T, 8>& t,
23 std::index_sequence<Ix...>) {
24 return core::bands_type{{
static_cast<float>(t[Ix])...}};
28 constexpr
auto array_to_bands_type(
const std::array<T, 8>& t) {
29 return array_to_bands_type(t, std::make_index_sequence<8>{});
34 double constant_mean_event_occurrence(
double speed_of_sound,
36 double mean_event_occurrence(
double constant,
double t);
38 template <
typename Engine>
39 auto interval_size(Engine& engine,
double mean_occurrence) {
42 std::uniform_real_distribution<double> distribution{1.0, 0.0};
43 return std::log(1.0 / distribution(engine)) / mean_occurrence;
46 double t0(
double constant);
49 util::aligned::vector<float> sequence;
60 util::aligned::vector<core::bands_type> histogram;
64 void sum_vectors(T& a,
const T& b) {
65 a.resize(std::max(a.size(), b.size()));
67 for (
auto j = begin(b), e = end(b); j != e; ++i, ++j) {
74 template <
size_t Az,
size_t El>
81 template <
size_t Az,
size_t El>
84 for (
auto i = 0; i != Az; ++i) {
85 for (
auto j = 0; j != El; ++j) {
86 sum_vectors(a.histogram.table[i][j], b.histogram.table[i][j]);
89 a.sample_rate = b.sample_rate;
92 template <
size_t Az,
size_t El>
94 util::aligned::vector<core::bands_type>,
99 for (
size_t a = 0; a != Az; ++a) {
100 for (
size_t e = 0; e != El; ++e) {
101 ret = std::max(ret, hist.table[a][e].size());
108 template <
size_t Az,
size_t El>
110 return max_size(hist.histogram) / hist.sample_rate;
113 template <
size_t Az,
size_t El>
114 auto sum_directional_histogram(
116 util::aligned::vector<core::bands_type> ret;
117 for (
auto azimuth_index = 0ul; azimuth_index != Az; ++azimuth_index) {
118 for (
auto elevation_index = 0ul; elevation_index != El;
120 const auto& segment =
121 histogram.histogram.table[azimuth_index][elevation_index];
122 ret.resize(std::max(ret.size(), segment.size()));
123 for (
auto i = 0ul, end = segment.size(); i != end; ++i) {
124 ret[i] += segment[i];
132 template <
typename Method>
139 template <
size_t Az,
size_t El>
140 auto compute_summed_histogram(
143 return sum_directional_histogram(histogram);
146 template <
size_t Az,
size_t El,
typename Method>
147 auto compute_summed_histogram(
149 const Method& method) {
150 using hist = std::decay_t<decltype(histogram.histogram)>;
152 util::aligned::vector<core::bands_type> ret;
154 for (
auto azimuth_index = 0ul; azimuth_index != Az; ++azimuth_index) {
155 for (
auto elevation_index = 0ul; elevation_index != El;
159 const auto pointing = hist::pointing(
160 typename hist::index_pair{azimuth_index, elevation_index});
165 const auto att = attenuation(method, pointing);
166 const auto factor = att * att;
168 const auto& segment =
169 histogram.histogram.table[azimuth_index][elevation_index];
172 ret.resize(std::max(ret.size(), segment.size()));
176 for (
auto i = 0ul, end = segment.size(); i != end; ++i) {
177 ret[i] += segment[i] * factor;
185 util::aligned::vector<core::bands_type> weight_sequence(
188 double acoustic_impedance);
190 util::aligned::vector<float> postprocessing(
const energy_histogram& histogram,
192 double acoustic_impedance);
194 template <
size_t Az,
size_t El,
typename Method>
195 util::aligned::vector<float> postprocessing(
197 const Method& method,
199 double acoustic_impedance) {
200 const auto summed = compute_summed_histogram(histogram, method);
201 return postprocessing(summed, sequence, acoustic_impedance);
Definition: postprocessing.h:48
Definition: postprocessing.h:58
Definition: pressure.h:22
Definition: capsule_base.h:9
Definition: vector_look_up_table.h:26
Definition: postprocessing.h:75