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

◆ transform_window() [2/2]

template<OperationReadyData DataType>
DataType MayaFlux::Yantra::transform_window ( DataType &  input,
Nodes::Generator::WindowType  window_type,
uint32_t  window_size = 0 
)

Windowing transformation using C++20 ranges (IN-PLACE)

Template Parameters
DataTypeOperationReadyData type
Parameters
inputInput data - WILL BE MODIFIED
window_typeType of window to apply
window_sizeSize of window (0 = full data size)
Returns
Windowed data

Definition at line 101 of file SpectralHelper.hpp.

104{
105 auto [target_data, structure_info] = OperationHelper::extract_structured_double(input);
106
107 uint32_t size = window_size > 0 ? window_size : smallest_size(target_data);
108
109 auto window = Nodes::Generator::generate_window(size, window_type);
110
111 for (auto& span : target_data) {
112 auto data_view = span | std::views::take(std::min(size, static_cast<uint32_t>(span.size())));
113 auto window_view = window | std::views::take(data_view.size());
114
115 std::ranges::transform(data_view, window_view, data_view.begin(),
116 [](double sample, double win) { return sample * win; });
117 }
118
119 auto reconstructed_data = target_data
120 | std::views::transform([](const auto& span) {
121 return std::vector<double>(span.begin(), span.end());
122 })
123 | std::ranges::to<std::vector>();
124
125 return OperationHelper::reconstruct_from_double<DataType>(reconstructed_data, structure_info);
126}
uint64_t smallest_size(std::vector< std::vector< double > > &data)

References MayaFlux::Yantra::OperationHelper::extract_structured_double(), MayaFlux::Nodes::Generator::generate_window(), and smallest_size().

+ Here is the call graph for this function: