224 auto [numeric_data, info] = OperationHelper::extract_structured_double(
const_cast<input_type&
>(input));
227 std::vector<std::span<const double>> data_span;
228 data_span.reserve(numeric_data.size());
230 for (
auto& span : numeric_data) {
231 data_span.emplace_back(span.data(), span.size());
234 std::vector<std::vector<double>> extracted_data;
237 case ExtractionMethod::HIGH_ENERGY_DATA: {
238 double energy_threshold = this->
template get_parameter_or_default<double>(
"energy_threshold", 0.1);
242 case ExtractionMethod::PEAK_DATA: {
243 double threshold = this->
template get_parameter_or_default<double>(
"threshold", 0.1);
244 double min_distance = this->
template get_parameter_or_default<double>(
"min_distance", 10.0);
245 uint32_t region_size = this->
template get_parameter_or_default<uint32_t>(
"region_size", 256);
246 extracted_data =
extract_peak_data(data_span, threshold, min_distance, region_size);
249 case ExtractionMethod::OUTLIER_DATA: {
250 double std_dev_threshold = this->
template get_parameter_or_default<double>(
"std_dev_threshold", 2.0);
254 case ExtractionMethod::HIGH_SPECTRAL_DATA: {
255 double spectral_threshold = this->
template get_parameter_or_default<double>(
"spectral_threshold", 0.1);
259 case ExtractionMethod::ABOVE_MEAN_DATA: {
260 double mean_multiplier = this->
template get_parameter_or_default<double>(
"mean_multiplier", 1.5);
264 case ExtractionMethod::OVERLAPPING_WINDOWS: {
265 double overlap = this->
template get_parameter_or_default<double>(
"overlap", 0.5);
269 case ExtractionMethod::ZERO_CROSSING_DATA: {
270 double threshold = this->
template get_parameter_or_default<double>(
"threshold", 0.0);
271 double min_distance = this->
template get_parameter_or_default<double>(
"min_distance", 1.0);
272 uint32_t region_size = this->
template get_parameter_or_default<uint32_t>(
"region_size", 1);
276 case ExtractionMethod::SILENCE_DATA: {
277 double silence_threshold = this->
template get_parameter_or_default<double>(
"silence_threshold", 0.01);
278 uint32_t min_duration = this->
template get_parameter_or_default<uint32_t>(
"min_duration", 1024);
279 extracted_data =
extract_silence_data(data_span, silence_threshold, min_duration, m_window_size, m_hop_size);
282 case ExtractionMethod::ONSET_DATA: {
283 double threshold = this->
template get_parameter_or_default<double>(
"threshold", 0.3);
284 uint32_t region_size = this->
template get_parameter_or_default<uint32_t>(
"region_size", 512);
285 uint32_t fft_window = this->
template get_parameter_or_default<uint32_t>(
"fft_window_size", 1024);
286 extracted_data =
extract_onset_data(data_span, threshold, region_size, fft_window, m_hop_size);
290 throw std::invalid_argument(
"Unknown extraction method");
293 output_type output = this->convert_result(extracted_data, structure_info);
295 output.template set_metadata<std::string>(
"extractor_type",
"FeatureExtractor");
296 output.template set_metadata<std::string>(
"extraction_method", method_to_string(m_method));
297 output.template set_metadata<uint32_t>(
"window_size",
static_cast<uint32_t
>(m_window_size));
298 output.template set_metadata<uint32_t>(
"hop_size",
static_cast<uint32_t
>(m_hop_size));
299 output.template set_metadata<size_t>(
"extracted_samples", extracted_data.size());
300 output.template set_metadata<size_t>(
"original_samples", data_span.size());
304 }
catch (
const std::exception& e) {
305 throw std::runtime_error(std::string(
"FeatureExtractor failed: ") + e.what());