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

◆ process()

void MayaFlux::Kakshya::PlotProcessor::process ( const std::shared_ptr< SignalSourceContainer > &  container)
overridevirtual

Acquire data from all bound sources and write into the container.

For each bound series: acquires from source, writes into container m_data, then copies m_data into processed_data. Unbound series are left unchanged. Called from the graphics thread by Forma before the geometry function runs.

Implements MayaFlux::Kakshya::DataProcessor.

Definition at line 146 of file PlotProcessor.cpp.

147{
148 auto plot = std::dynamic_pointer_cast<PlotContainer>(container);
149 if (!plot) {
150 MF_ERROR(C, X, "PlotProcessor::process: container is not a PlotContainer");
151 return;
152 }
153
154 m_processing.store(true, std::memory_order_release);
155
156 for (auto& [idx, b] : m_bindings) {
157 if (idx >= plot->series_count())
158 continue;
159
160 thread_local std::vector<double> staging;
161 staging.resize(plot->series_size(idx));
162
163 {
164 auto frame = plot->get_frame(idx);
165 if (frame.size() == staging.size()) {
166 std::ranges::copy(frame, staging.begin());
167 } else {
168 std::ranges::fill(staging, 0.0);
169 }
170 }
171
172 switch (b.source_type) {
173 case SourceType::NODE:
174 acquire_from_node(b, staging);
175 break;
178 break;
180 acquire_from_network(b, staging);
181 break;
183 acquire_from_callable(b, staging);
184 break;
185 case SourceType::RAW:
186 acquire_from_raw(b, staging);
187 break;
188 }
189
190 plot->write_series(idx, staging);
191 }
192
193 auto& src = plot->get_data();
194 auto& dst = plot->get_processed_data();
195 dst.resize(src.size());
196 for (size_t i = 0; i < src.size(); ++i)
197 dst[i] = src[i];
198
199 m_processing.store(false, std::memory_order_release);
200}
#define MF_ERROR(comp, ctx,...)
size_t b
void acquire_from_raw(SeriesBinding &b, std::vector< double > &series)
std::unordered_map< uint32_t, SeriesBinding > m_bindings
void acquire_from_audio_buffer(SeriesBinding &b, std::vector< double > &series)
void acquire_from_callable(SeriesBinding &b, std::vector< double > &series)
void acquire_from_node(SeriesBinding &b, std::vector< double > &series)
void acquire_from_network(SeriesBinding &b, std::vector< double > &series)
std::pair< Mapped< std::shared_ptr< Kakshya::PlotContainer > >, Surface > plot(std::string title, uint32_t width, uint32_t height, std::shared_ptr< Kakshya::PlotContainer > container, Plot::SeriesSpec spec)
Create a live plot in a new window.
Definition Forma.cpp:247

References acquire_from_audio_buffer(), acquire_from_callable(), acquire_from_network(), acquire_from_node(), acquire_from_raw(), AUDIO_BUFFER, b, CALLABLE, m_bindings, m_processing, MF_ERROR, NETWORK, NODE, and RAW.

+ Here is the call graph for this function: