Wayverb
simulation_parameters.h
1 #pragma once
2 
3 #include <cstdlib>
4 #include <tuple>
5 
6 namespace wayverb {
7 namespace waveguide {
8 
9 struct single_band_parameters final {
11  double cutoff;
12 
16 };
17 
18 constexpr auto to_tuple(const single_band_parameters& x) {
19  return std::tie(x.cutoff, x.usable_portion);
20 }
21 
22 constexpr bool operator==(const single_band_parameters& a,
23  const single_band_parameters& b) {
24  return to_tuple(a) == to_tuple(b);
25 }
26 
27 constexpr bool operator!=(const single_band_parameters& a,
28  const single_band_parameters& b) {
29  return !(a == b);
30 }
31 
37  size_t bands;
38 
40  double cutoff;
41 
44 };
45 
46 constexpr auto to_tuple(const multiple_band_constant_spacing_parameters& x) {
47  return std::tie(x.bands, x.cutoff, x.usable_portion);
48 }
49 
50 constexpr bool operator==(const multiple_band_constant_spacing_parameters& a,
52  return to_tuple(a) == to_tuple(b);
53 }
54 
55 constexpr bool operator!=(const multiple_band_constant_spacing_parameters& a,
57  return !(a == b);
58 }
59 
60 constexpr auto compute_cutoff_frequency(double sample_rate,
61  double usable_portion) {
62  return sample_rate * 0.25 * usable_portion;
63 }
64 
65 constexpr auto compute_sampling_frequency(double cutoff,
66  double usable_portion) {
67  return cutoff / (0.25 * usable_portion);
68 }
69 
70 template <typename T>
71 constexpr auto compute_sampling_frequency(const T& t) {
72  return compute_sampling_frequency(t.cutoff, t.usable_portion);
73 }
74 
75 } // namespace waveguide
76 } // namespace wayverb
size_t bands
Definition: simulation_parameters.h:37
double usable_portion
As above.
Definition: simulation_parameters.h:43
double usable_portion
Definition: simulation_parameters.h:15
double cutoff
The cutoff to use for all bands.
Definition: simulation_parameters.h:40
Definition: simulation_parameters.h:9
double cutoff
The actual cutoff of the waveguide mesh in Hz.
Definition: simulation_parameters.h:11
Definition: capsule_base.h:9