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

◆ pattern() [3/4]

template<std::incrementable Index = uint64_t, typename Generator , typename Callback >
requires PatternGenerator<Generator, Index> && PatternCallback<Callback, typename PatternTraits<Generator, Index>::value_type>
std::shared_ptr< Vruta::Routine > MayaFlux::Kriya::pattern ( Generator  generator,
Callback  callback,
std::vector< double >  durations,
Vruta::ProcessingToken  token = Vruta::ProcessingToken::SAMPLE_ACCURATE 
)

Creates a pattern whose steps are spaced by a list of durations.

Template Parameters
IndexStep index type, default uint64_t
Parameters
generatorCallable from the step index to any value
callbackCallable that takes the generated value
durationsSeconds to wait after each step, stepped through in order and repeated
tokenSelects the routine type that runs the pattern
Returns
The routine, or nullptr for an empty function, an empty list or an unsupported token

The first step runs at once. After step i the routine waits durations[i % size], rounded to the routine's own units and never less than one unit. A single interval is a list of one: pattern(gen, cb, { 0.125 }). A throw from the generator or callback is logged and ends the pattern.

auto routine = Kriya::pattern(generate, apply, { 0.25, 0.25, 0.5 });
scheduler->add_task(routine);
std::shared_ptr< Vruta::Routine > pattern(std::function< std::any(uint64_t)> pattern_func, std::function< void(std::any)> callback, std::function< bool(uint64_t)> ready, Vruta::ProcessingToken token)
The std::any, uint64_t form of the condition driven pattern.
Definition Pattern.cpp:5