2#include <ossia/network/dataspace/dataspace_base.hpp>
3#include <ossia/network/domain/domain.hpp>
9template <
typename Impl>
12 using is_unit = std::true_type;
13 using neutral_unit = second_u;
14 using value_type = float;
15 using concrete_type = Impl;
16 using dataspace_type = timing_u;
17 using is_multidimensional = std::false_type;
20struct second_u :
public timing_unit<second_u>
22 static constexpr auto text()
24 constexpr_return(ossia::make_string_array(
"second",
"s"));
27 static constexpr strong_value<neutral_unit>
28 to_neutral(strong_value<concrete_type> self)
33 static constexpr value_type from_neutral(strong_value<neutral_unit> self)
35 return self.dataspace_value;
39 static constexpr auto bounding() {
return ossia::bounding_mode::FREE; }
42struct bark_u :
public timing_unit<bark_u>
44 static constexpr auto text() { constexpr_return(ossia::make_string_array(
"bark")); }
46 static strong_value<neutral_unit> to_neutral(strong_value<concrete_type> self)
48 return 1.0f / (600.f * std::sinh(self.dataspace_value / 6.f));
51 static value_type from_neutral(strong_value<neutral_unit> self)
53 return 6.f * ossia::asinh(1.0f / (self.dataspace_value * 600.0f));
57 static constexpr auto bounding() {
return ossia::bounding_mode::FREE; }
60struct bpm_u :
public timing_unit<bpm_u>
62 static constexpr auto text() { constexpr_return(ossia::make_string_array(
"bpm")); }
64 static constexpr strong_value<neutral_unit>
65 to_neutral(strong_value<concrete_type> self)
67 return 60.0f / self.dataspace_value;
70 static constexpr value_type from_neutral(strong_value<neutral_unit> self)
72 return 60.0f / self.dataspace_value;
74 static ossia::domain_base<float> domain() {
return {0.f, 240.f}; }
76 static constexpr auto bounding() {
return ossia::bounding_mode::FREE; }
79struct cent_u :
public timing_unit<cent_u>
81 static constexpr auto text() { constexpr_return(ossia::make_string_array(
"cents")); }
83 static strong_value<neutral_unit> to_neutral(strong_value<concrete_type> self)
85 return 1.f / (440.0f * ossia::exp2((self.dataspace_value - 6900.0f) / 1200.0f));
88 static value_type from_neutral(strong_value<neutral_unit> self)
91 + 1200.0f * std::log(1.f / (440.0f * self.dataspace_value))
95 static ossia::domain_base<float> domain() {
return {0.f, 12700.f}; }
97 static constexpr auto bounding() {
return ossia::bounding_mode::FREE; }
100struct frequency_u :
public timing_unit<frequency_u>
102 static constexpr auto text()
104 constexpr_return(ossia::make_string_array(
"Hz",
"hz",
"Hertz"));
107 static constexpr strong_value<neutral_unit>
108 to_neutral(strong_value<concrete_type> self)
110 return 1.0f / self.dataspace_value;
113 static constexpr value_type from_neutral(strong_value<neutral_unit> self)
115 return 1.0f / self.dataspace_value;
118 static ossia::domain_base<float> domain() {
return {0.f, 24000.f}; }
123struct mel_u :
public timing_unit<mel_u>
125 static constexpr auto text() { constexpr_return(ossia::make_string_array(
"mel")); }
127 static strong_value<neutral_unit> to_neutral(strong_value<concrete_type> self)
129 return 1.0f / (700.0f * (std::pow(10.f, self.dataspace_value / 2595.0f) - 1.0f));
132 static value_type from_neutral(strong_value<neutral_unit> self)
134 return 2595.0f * std::log10(1.f + 1.0f / (self.dataspace_value * 700.0f));
137 static ossia::domain_base<float> domain() {
return {0.f, 4016.f}; }
142struct midi_pitch_u :
public timing_unit<midi_pitch_u>
144 static constexpr auto text()
146 constexpr_return(ossia::make_string_array(
"midinote",
"midipitch",
"pitch"));
149 static strong_value<neutral_unit> to_neutral(strong_value<concrete_type> self)
151 return 1.f / (440.0f * ossia::exp2((self.dataspace_value - 69.0f) / 12.0f));
154 static value_type from_neutral(strong_value<neutral_unit> self)
156 return 69.0f - 12.0f * std::log(440.0f * self.dataspace_value) / float(ossia::ln_2);
159 static ossia::domain_base<float> domain() {
return {0.f, 127.f}; }
164struct millisecond_u :
public timing_unit<millisecond_u>
166 static constexpr auto text()
168 constexpr_return(ossia::make_string_array(
"ms",
"millisecond"));
171 static constexpr strong_value<neutral_unit>
172 to_neutral(strong_value<concrete_type> self)
174 return 0.001f * self.dataspace_value;
177 static constexpr value_type from_neutral(strong_value<neutral_unit> self)
179 return 1000.0f * self.dataspace_value;
184 static constexpr auto bounding() {
return ossia::bounding_mode::FREE; }
187struct sample_u :
public timing_unit<sample_u>
189 static constexpr auto text() { constexpr_return(ossia::make_string_array(
"sample")); }
192 void set_rate(
double r) { rate = r; }
194 constexpr strong_value<neutral_unit> to_neutral(strong_value<concrete_type> self)
196 return self.dataspace_value / rate;
199 constexpr value_type from_neutral(strong_value<neutral_unit> self)
201 return self.dataspace_value * rate;
204 static ossia::domain_base<float> domain() {
return {0.f, 44100.f}; }
211static constexpr T exp_69_12 = 53.817370576237730753992030478925753282562192;
213struct playback_speed_u :
public timing_unit<playback_speed_u>
215 static constexpr auto text() { constexpr_return(ossia::make_string_array(
"speed")); }
217 static strong_value<neutral_unit> to_neutral(strong_value<concrete_type> self)
219 return exp_69_12<float> / (440.0f * self.dataspace_value);
222 static value_type from_neutral(strong_value<neutral_unit> self)
224 return exp_69_12<float> / (440.0f * self.dataspace_value);
227 static ossia::domain_base<float> domain() {
return {0.f, 2.f}; }
domain A domain of values
Definition domain_base.hpp:23