MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ append_windows()

template<ComputeData InputType = std::vector<Kakshya::DataVariant>, ComputeData OutputType = Eigen::MatrixXd>
void MayaFlux::Yantra::WaveformAnalyzer< InputType, OutputType >::append_windows ( ChannelWaveform & out,
size_t first,
size_t count,
uint32_t min_lag,
const WaveformAnalyzerConfig & cfg,
const ChunkMeasures & m ) const
inlineprivate

Definition at line 654 of file WaveformAnalyzer.hpp.

656 {
657 const bool full_row = cfg.keep_profiles;
658 const uint32_t correlation_lags = m.correlation_lags;
659 const uint32_t distance_lags = m.distance_lags;
660 const double window = static_cast<double>(cfg.window_size);
661 for (size_t w = 0; w < count; ++w) {
662 const size_t start = (first + w) * cfg.hop_size;
663 out.window_positions.emplace_back(start, start + cfg.window_size);
664
665 const double level = std::sqrt(m.energy[w] / window);
666 out.level.push_back(level);
667 out.crossing_rate.push_back(m.crossings[w] / (window - 1.0));
668 out.peak.push_back(m.peak[w]);
669 out.dc_offset.push_back(m.sum[w] / window);
670 out.crest_factor.push_back(level > 0.0 ? m.peak[w] / level : 0.0);
671
672 const double* row = full_row ? m.rows.data() + w * correlation_lags : nullptr;
673 const double at_zero = full_row ? row[0] : m.zero[w];
674 const bool varying = at_zero >= k_variance_floor;
675 double best = 0.0;
676 uint32_t best_lag = 0;
677 if (varying && m.picks[w].found() && m.picks[w].value > 0.0) {
678 best = m.picks[w].value / at_zero;
679 best_lag = min_lag + m.picks[w].index;
680 if (cfg.unbiased_periodicity) {
681 best *= window / (window - static_cast<double>(best_lag));
682 }
683 }
684 const double bounded = std::min(best, k_strength_ceiling);
685 out.periodicity.push_back(best);
686 out.period.push_back(static_cast<double>(best_lag));
687 out.frequency.push_back(best_lag > 0 ? cfg.sample_rate / static_cast<double>(best_lag) : 0.0);
688 out.harmonicity.push_back(best > 0.0 ? bounded / (1.0 - bounded) : 0.0);
689
690 if (cfg.keep_profiles) {
691 for (uint32_t lag = 0; lag < correlation_lags; ++lag) {
692 out.autocorrelation.values.push_back(varying ? row[lag] / row[0] : 0.0);
693 }
694 const double* gaps = m.distance.data() + w * distance_lags;
695 for (uint32_t column = 0; column < distance_lags; ++column) {
696 out.mean_difference.values.push_back(gaps[column] / (window - static_cast<double>(min_lag + column)));
697 }
698 }
699 }
700 }
static constexpr double k_variance_floor
static constexpr double k_strength_ceiling
Time-domain descriptors of every channel, run on the GPU.

Referenced by MayaFlux::Yantra::WaveformAnalyzer< std::vector< Kakshya::DataVariant >, Eigen::MatrixXd >::measure_chunk(), and MayaFlux::Yantra::WaveformAnalyzer< std::vector< Kakshya::DataVariant >, Eigen::MatrixXd >::measure_chunk_native().

Here is the caller graph for this function: