62template <ComputeData InputType = std::vector<Kakshya::DataVariant>, ComputeData OutputType = std::vector<std::vector<
double>>>
76 uint32_t hop_size = 256,
100 return Reflect::get_enum_names_lowercase<ExtractionMethod>();
120 this->set_parameter(
"method", method_name);
181 return Reflect::string_to_enum_or_throw_case_insensitive<ExtractionMethod>(str,
"ExtractionMethod");
191 if (!
input.has_container())
195 if (numeric_data.empty())
197 for (
const auto& span : numeric_data) {
201 }
catch (
const std::exception& e) {
213 return "FeatureExtractor";
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());
233 std::vector<std::vector<double>> extracted_data;
239 this->
template get_parameter_or_default<double>(
"energy_threshold", 0.1),
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));
252 this->
template get_parameter_or_default<double>(
"std_dev_threshold", 2.0),
258 this->
template get_parameter_or_default<double>(
"spectral_threshold", 0.1),
264 this->
template get_parameter_or_default<double>(
"mean_multiplier", 1.5),
271 this->
template get_parameter_or_default<double>(
"overlap", 0.5));
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));
283 this->
template get_parameter_or_default<double>(
"silence_threshold", 0.01),
284 this->
template get_parameter_or_default<uint32_t>(
"min_duration", 1024),
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),
300 output_type output = this->convert_result(extracted_data, structure_info);
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());
310 }
catch (
const std::exception& e) {
321 if (name ==
"method") {
322 if (
auto result = safe_any_cast<std::string>(value)) {
326 if (
auto result = safe_any_cast<ExtractionMethod>(value)) {
333 if (name ==
"window_size") {
334 if (
auto result = safe_any_cast<uint32_t>(value)) {
340 if (name ==
"hop_size") {
341 if (
auto result = safe_any_cast<uint32_t>(value)) {
353 if (name ==
"method") {
356 if (name ==
"window_size") {
359 if (name ==
"hop_size") {
#define MF_ERROR(comp, ctx,...)
Core::GlobalInputConfig input
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...
static std::span< double > extract_numeric_data(const T &compute_data)
extract numeric data from single-variant types
@ ComputeMatrix
Compute operations (Yantra - algorithms, matrices, DSP)
@ Yantra
DSP algorithms, computational units, matrix operations, Grammar.
bool validate_window_parameters(uint32_t window_size, uint32_t hop_size, size_t data_size) noexcept
Validate window/hop parameters for windowed processing.
std::string enum_to_lowercase_string(EnumType value) noexcept
Universal enum to lowercase string converter using magic_enum.
ExtractionType
Categories of extraction operations for discovery and organization.
@ FEATURE_GUIDED
Extract based on feature analysis.
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)
ExtractionMethod
Supported extraction methods for FeatureExtractor.
@ 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)
Metadata about data structure for reconstruction.
Input/Output container for computation pipeline data flow with structure preservation.