134{
135 return std::visit(
136 [&](const auto& vec) -> double {
137 using T = typename std::decay_t<decltype(vec)>::value_type;
138
139 if constexpr (std::is_same_v<T, uint8_t>
140 || std::is_same_v<T, uint16_t>
141 || std::is_same_v<T, float>) {
142
143 if (elem_index >= vec.size())
144 return 0.0;
145
146 double raw {};
147 double type_max = 1.0;
148
149 if constexpr (std::is_same_v<T, uint8_t>) {
150 raw = static_cast<double>(vec[elem_index]);
151 type_max = 255.0;
152 } else if constexpr (std::is_same_v<T, uint16_t>) {
153 if (is_float_format(format)) {
154 raw = static_cast<double>(decode_half(vec[elem_index]));
155 } else {
156 raw = static_cast<double>(vec[elem_index]);
157 type_max = 65535.0;
158 }
159 } else {
160 raw = static_cast<double>(vec[elem_index]);
161 }
162
163 if (!range)
164 return raw / type_max;
165
167 return std::numeric_limits<double>::quiet_NaN();
168
170 if (span <= 0.0)
171 return 0.0;
172
173 return std::clamp((raw -
range->min) / span, 0.0, 1.0);
174 } else {
175 return 0.0;
176 }
177 },
178 v);
179}
std::vector< double > range(std::span< const double > data, size_t n_windows, uint32_t hop_size, uint32_t window_size)
Value range (max - min) per window.