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

◆ processing_function()

void MayaFlux::Buffers::BlockFeedbackProcessor::processing_function ( const std::shared_ptr< Buffer > &  buffer)
overridevirtual

The core processing function that must be implemented by derived classes.

Parameters
bufferBuffer to process

This method is where the actual transformation logic is implemented. It should contain the algorithmic details of how the buffer's data is transformed, analyzed, or processed. The implementation can utilize any backend capabilities available to the processor, including:

  • Parallel Processing: Using multi-threading or GPU compute for large datasets
  • Data Transformations: Applying mathematical operations, filters, or effects
  • Feature Extraction: Analyzing data characteristics for further processing

Derived classes must override this method to provide specific processing behavior.

Implements MayaFlux::Buffers::BufferProcessor.

Definition at line 55 of file BlockFeedbackProcessor.cpp.

56{
57 auto audio = std::dynamic_pointer_cast<AudioBuffer>(buffer);
58 if (!audio || !m_transform) {
59 return;
60 }
61
62 auto& data = audio->get_data();
63 const size_t samples = data.size();
64 if (samples == 0) {
65 return;
66 }
67
68 auto [found, inserted] = m_states.try_emplace(buffer.get());
69 State& state = found->second;
70 if (inserted) {
71 state.coefs = m_coefficients;
72 }
73
74 if (state.blocks.size() != m_lag_blocks || state.blocks.front().size() != samples) {
75 state.blocks.assign(m_lag_blocks, std::vector<double>(samples, 0.0));
76 state.kept.assign(samples, 0.0);
77 state.next = 0;
78 }
79
80 const std::vector<double>& previous = state.blocks.at(state.next);
81
82 if (m_retain_input) {
83 std::ranges::copy(data, state.kept.begin());
84 }
85
86 state.feature = m_transform(std::span<double>(data), std::span<const double>(previous), std::span<double>(state.coefs));
87
88 state.blocks.at(state.next) = m_retain_input ? state.kept : data;
89 state.next = (state.next + 1) % m_lag_blocks;
90
91 if (m_observer) {
92 m_observer(state.feature);
93 }
94}
std::shared_ptr< NetworkGeometryBuffer > buffer
std::unordered_map< const Buffer *, State > m_states

References MayaFlux::Buffers::BlockFeedbackProcessor::State::blocks, buffer, MayaFlux::Buffers::BlockFeedbackProcessor::State::coefs, MayaFlux::Buffers::BlockFeedbackProcessor::State::feature, MayaFlux::Buffers::BlockFeedbackProcessor::State::kept, m_coefficients, m_lag_blocks, m_observer, m_retain_input, m_states, m_transform, and MayaFlux::Buffers::BlockFeedbackProcessor::State::next.