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

◆ processing_function()

void MayaFlux::Buffers::AudioContextProcessor::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 87 of file AudioContextProcessor.cpp.

88{
89 auto audio = std::dynamic_pointer_cast<AudioBuffer>(buffer);
90 if (!audio) {
92 "AudioContextProcessor received a non-audio buffer");
93 return;
94 }
95
96 auto& samples = audio->get_data();
97 if (samples.empty()) {
98 return;
99 }
100
101 const uint64_t sequence = m_next++;
102 const uint64_t depth = m_slots.size();
103 const bool due = sequence >= depth;
104 const uint64_t expected = due ? sequence - depth : 0;
105 auto& slot = m_slots[sequence % depth];
106
107 std::vector<double> delivered;
108 bool busy = false;
109
110 if (slot.fence != Portal::Graphics::INVALID_FENCE) {
111 if (Portal::Graphics::get_shader_foundry().is_fence_signaled(slot.fence)) {
112 const auto result = slot.context->collect_result();
114 if (due && slot.sequence == expected) {
115 delivered = slot.context->decode_primary(result);
116 }
117 } else {
118 busy = true;
119 }
120 }
121
122 if (!busy) {
123 submit(slot, sequence, samples);
124 }
125
126 if (delivered.empty()) {
127 if (due) {
128 ++m_missed;
129 if (!m_missing) {
130 m_missing = true;
132 "AudioContextProcessor block {} was not complete, output is silent until results arrive in time", expected);
133 }
134 }
135 audio->clear();
136 return;
137 }
138
139 m_missing = false;
140
141 const size_t copied = std::min(samples.size(), delivered.size());
142 std::copy_n(delivered.begin(), copied, samples.begin());
143 std::fill(samples.begin() + static_cast<std::ptrdiff_t>(copied), samples.end(), 0.0);
144}
#define MF_RT_WARN(comp, ctx,...)
#define MF_RT_ERROR(comp, ctx,...)
void submit(Slot &slot, uint64_t sequence, std::span< const double > samples)
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains).
@ Buffers
Buffers, Managers, processors and processing chains.
std::shared_ptr< Vruta::Routine > sequence(std::vector< std::pair< double, std::function< void()> > > sequence, Vruta::ProcessingToken token)
Creates a temporal sequence that executes callbacks at specified time offsets.
Definition Tasks.cpp:50
constexpr FenceID INVALID_FENCE
MAYAFLUX_API ShaderFoundry & get_shader_foundry()
Get the global shader compiler instance.

References MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, depth(), MayaFlux::Portal::Graphics::get_shader_foundry(), MayaFlux::Portal::Graphics::INVALID_FENCE, m_missed, m_missing, m_next, m_slots, MF_RT_ERROR, MF_RT_WARN, and submit().

Referenced by operator=().

Here is the call graph for this function:
Here is the caller graph for this function: