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

◆ process_to_stream_async() [2/2]

template<typename CompleteFn >
void MayaFlux::Yantra::Granular::process_to_stream_async ( const std::shared_ptr< GranularMatrix > &  matrix,
const std::shared_ptr< Kakshya::SignalSourceContainer > &  container,
AttributeExecutor  executor,
CompleteFn &&  on_complete,
const GranularConfig config = {},
GranularOutput  output = GranularOutput::STREAM 
)

Async offline granular pipeline terminating in a DynamicSoundStream (AttributeExecutor path).

Parameters
matrixComputeMatrix that owns the async future.
containerSource signal data.
executorLambda receiving grain samples and context, returning a scalar.
on_completeCalled on the worker thread with the finished stream.
configPipeline scalar parameters.
outputSTREAM for concatenative, STREAM_ADDITIVE for OLA.

Definition at line 695 of file GranularWorkflow.hpp.

700 {},
701 GranularOutput output = GranularOutput::STREAM)
702{
703 auto ctx = make_granular_context(config, std::move(executor));
704 ctx.execution_metadata["container"] = container;
705 if (config.taper)
706 ctx.execution_metadata["grain_taper"] = config.taper;
707
708 auto seg_op = matrix->get_operation<SegmentOp>("segment");
709 auto attr_op = matrix->get_operation<AttributeOp>("attribute");
710 auto sort_op = matrix->get_operation<SortOp>("sort");
711 apply_context_parameters(seg_op, ctx);
712 apply_context_parameters(attr_op, ctx);
713 apply_context_parameters(sort_op, ctx);
714
715 matrix->with_async(
716 make_granular_input(container),
717 [ctx, output](auto chain) {
718 auto sorted = chain
719 .template then<SegmentOp>("segment")
720 .template then<AttributeOp>("attribute")
721 .template then<SortOp>("sort")
722 .to_io();
723 if (output == GranularOutput::STREAM_ADDITIVE) {
724 return safe_any_cast_or_throw<
726 reconstruct_grains_additive_stream(std::any(sorted), ctx));
727 }
728 return safe_any_cast_or_throw<
729 Datum<std::shared_ptr<Kakshya::SignalSourceContainer>>>(
730 reconstruct_grains_stream(std::any(sorted), ctx));
731 },
732 [on_complete = std::forward<CompleteFn>(on_complete)](
733 const Datum<std::shared_ptr<Kakshya::SignalSourceContainer>>& result) {
734 on_complete(std::dynamic_pointer_cast<Kakshya::DynamicSoundStream>(result.data));
735 });
736}
void apply_context_parameters(std::shared_ptr< OperationType > operation, const ExecutionContext &ctx)
Applies context parameters to an operation.
Input/Output container for computation pipeline data flow with structure preservation.
Definition DataIO.hpp:24