223 {
224 try {
226 DataStructureInfo structure_info = info;
227
228 std::vector<std::span<const double>> channels;
229 channels.reserve(numeric_data.size());
230 for (auto& s : numeric_data)
231 channels.emplace_back(s.data(), s.size());
232
233 std::vector<std::vector<double>> extracted_data;
234
236
239 this->template get_parameter_or_default<double>("energy_threshold", 0.1),
241 break;
242
245 this->template get_parameter_or_default<double>("threshold", 0.1),
246 this->template get_parameter_or_default<double>("min_distance", 10.0),
247 this->template get_parameter_or_default<uint32_t>("region_size", 256));
248 break;
249
252 this->template get_parameter_or_default<double>("std_dev_threshold", 2.0),
254 break;
255
258 this->template get_parameter_or_default<double>("spectral_threshold", 0.1),
260 break;
261
264 this->template get_parameter_or_default<double>("mean_multiplier", 1.5),
266 break;
267
271 this->template get_parameter_or_default<double>("overlap", 0.5));
272 break;
273
276 this->template get_parameter_or_default<double>("threshold", 0.0),
277 this->template get_parameter_or_default<double>("min_distance", 1.0),
278 this->template get_parameter_or_default<uint32_t>("region_size", 1));
279 break;
280
283 this->template get_parameter_or_default<double>("silence_threshold", 0.01),
284 this->template get_parameter_or_default<uint32_t>("min_duration", 1024),
286 break;
287
290 this->template get_parameter_or_default<double>("threshold", 0.3),
291 this->template get_parameter_or_default<uint32_t>("region_size", 512),
292 this->template get_parameter_or_default<uint32_t>("fft_window_size", 1024),
294 break;
295
296 default:
298 }
299
300 output_type output = this->convert_result(extracted_data, structure_info);
301
302 output.template set_metadata<std::string>("extractor_type", "FeatureExtractor");
304 output.template set_metadata<uint32_t>(
"window_size",
static_cast<uint32_t
>(
m_window_size));
305 output.template set_metadata<uint32_t>(
"hop_size",
static_cast<uint32_t
>(
m_hop_size));
306 output.template set_metadata<size_t>("extracted_samples", extracted_data.size());
307
308 return output;
309
310 } catch (const std::exception& e) {
313 }
314 }
#define MF_ERROR(comp, ctx,...)
static std::tuple< std::vector< std::span< double > >, DataStructureInfo > extract_structured_double(T &compute_data)
Extract structured double data from Datum container or direct ComputeData with automatic container ha...
@ ComputeMatrix
Compute operations (Yantra - algorithms, matrices, DSP)
@ Yantra
DSP algorithms, computational units, matrix operations, Grammar.
std::vector< std::vector< double > > extract_outliers(const std::vector< std::span< const double > > &channels, double std_dev_threshold, uint32_t window_size, uint32_t hop_size)
std::vector< std::vector< double > > extract_onsets(const std::vector< std::span< const double > > &channels, double threshold, uint32_t region_size, uint32_t fft_window_size, uint32_t hop_size)
std::vector< std::vector< double > > extract_above_mean(const std::vector< std::span< const double > > &channels, double mean_multiplier, uint32_t window_size, uint32_t hop_size)
std::vector< std::vector< double > > extract_high_energy(const std::vector< std::span< const double > > &channels, double energy_threshold, uint32_t window_size, uint32_t hop_size)
@ ABOVE_MEAN_DATA
Extract data above statistical mean.
@ SILENCE_DATA
Extract actual silent regions.
@ PEAK_DATA
Extract data around detected peaks.
@ OUTLIER_DATA
Extract data from statistical outlier regions.
@ ZERO_CROSSING_DATA
Extract actual data at zero crossing points.
@ HIGH_ENERGY_DATA
Extract data from high-energy regions.
@ HIGH_SPECTRAL_DATA
Extract data from high spectral energy regions.
@ OVERLAPPING_WINDOWS
Extract overlapping windowed data.
@ ONSET_DATA
Extract actual onset/transient regions.
std::vector< std::vector< double > > extract_zero_crossings(const std::vector< std::span< const double > > &channels, double threshold, double min_distance, uint32_t region_size)
std::vector< std::vector< double > > extract_peaks(const std::vector< std::span< const double > > &channels, double threshold, double min_distance, uint32_t region_size)
std::vector< std::vector< double > > extract_silence(const std::vector< std::span< const double > > &channels, double silence_threshold, uint32_t min_duration, uint32_t window_size, uint32_t hop_size)
std::vector< std::vector< double > > extract_overlapping_windows(const std::vector< std::span< const double > > &channels, uint32_t window_size, double overlap)
std::vector< std::vector< double > > extract_high_spectral(const std::vector< std::span< const double > > &channels, double spectral_threshold, uint32_t window_size, uint32_t hop_size)