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

◆ process_to_container_async() [1/2]

template<typename CompleteFn >
void MayaFlux::Yantra::Granular::process_to_container_async ( const std::shared_ptr< GranularMatrix > &  matrix,
const std::shared_ptr< Kakshya::SignalSourceContainer > &  container,
AnalysisType  analysis_type,
CompleteFn &&  on_complete,
const GranularConfig config = {},
const std::string &  qualifier = {},
GranularOutput  output = GranularOutput::CONTAINER 
)

Async offline granular pipeline (AnalysisType path).

Runs the full pipeline on a background thread owned by matrix and invokes on_complete with the result. Returns immediately.

Parameters
matrixComputeMatrix that owns the async future.
containerSource signal data.
analysis_typeAttribution category.
on_completeCalled on the worker thread with the finished container.
configPipeline scalar parameters.
qualifierScalar to extract. Empty uses type default.
outputCONTAINER for concatenative, CONTAINER_ADDITIVE for OLA.

Definition at line 533 of file GranularWorkflow.hpp.

538 {},
539 const std::string& qualifier = {},
540 GranularOutput output = GranularOutput::CONTAINER)
541{
542 auto ctx = make_granular_context(config, analysis_type, qualifier);
543
544 ctx.execution_metadata["container"] = container;
545 if (config.taper)
546 ctx.execution_metadata["grain_taper"] = config.taper;
547
548 auto seg_op = matrix->get_operation<SegmentOp>("segment");
549 auto attr_op = matrix->get_operation<AttributeOp>("attribute");
550 auto sort_op = matrix->get_operation<SortOp>("sort");
551 apply_context_parameters(seg_op, ctx);
552 apply_context_parameters(attr_op, ctx);
553 apply_context_parameters(sort_op, ctx);
554
555 matrix->with_async(make_granular_input(container), [seg_op, attr_op, sort_op, ctx, output](auto chain) {
556 auto sorted = chain
557 .template then<SegmentOp>("segment")
558 .template then<AttributeOp>("attribute")
559 .template then<SortOp>("sort")
560 .to_io();
561 if (output == GranularOutput::CONTAINER_ADDITIVE) {
562 return safe_any_cast_or_throw<
563 Datum<std::shared_ptr<Kakshya::SignalSourceContainer>>>(
564 reconstruct_grains_additive(std::any(sorted), ctx));
565 }
566 return safe_any_cast_or_throw<
567 Datum<std::shared_ptr<Kakshya::SignalSourceContainer>>>(
568 reconstruct_grains(std::any(sorted), ctx)); }, std::forward<CompleteFn>(on_complete));
569}