23template <
typename Callable>
26 std::function<void()> func = std::forward<Callable>(
callback);
30template <
typename... Args>
32 std::string
name =
"", Args... args)
34 std::vector<std::pair<double, std::function<void()>>> seq;
35 for (
const auto& [time, func] :
sequence) {
36 seq.emplace_back(time, [func, args...]() { func(args...); });
41template <
typename PatternFunc,
typename Callback>
43 double interval_seconds, std::string
name =
"")
45 auto pattern_wrapper = [pf = std::forward<PatternFunc>(pattern_func)](uint64_t idx) -> std::any {
49 auto callback_wrapper = [cb = std::forward<Callback>(
callback)](std::any val) {
53 std::function<std::any(uint64_t)> pattern_fn = pattern_wrapper;
54 std::function<void(std::any)> callback_fn = callback_wrapper;
57 std::vector<double> { interval_seconds }, std::move(
name));
60template <
typename FuncType>
61std::shared_ptr<Buffers::BufferProcessor>
attach_quick_process(FuncType&& processor, std::shared_ptr<Buffers::AudioBuffer>
buffer)
63 std::function<void(std::shared_ptr<Buffers::AudioBuffer>)> func = std::forward<FuncType>(processor);
75template <
typename Callable>
78 std::shared_ptr<Nodes::Generator::Logic> logic_node,
bool open =
true)
80 std::function<void()> func = std::forward<Callable>(
callback);
81 return Gate(scheduler, std::move(func), std::move(logic_node), open);
92template <
typename Callable>
97 std::shared_ptr<Nodes::Generator::Logic> logic_node)
99 std::function<void()> func = std::forward<Callable>(
callback);
100 return Trigger(scheduler, target_state, std::move(func), std::move(logic_node));
110template <
typename Callable>
114 std::shared_ptr<Nodes::Generator::Logic> logic_node)
116 std::function<void()> func = std::forward<Callable>(
callback);
117 return Toggle(scheduler, std::move(func), std::move(logic_node));
Single include for the user facing API.
std::shared_ptr< NetworkGeometryBuffer > buffer
A C++20 coroutine-based audio processing task with sample-accurate timing.
Token-based multimodal task scheduling system for unified coroutine processing.
Vruta::SoundRoutine Gate(std::function< void()> callback, std::shared_ptr< Nodes::Generator::Logic > logic_node, bool open)
Coroutine that executes callback continuously while logic node outputs true.
Vruta::SoundRoutine Toggle(std::function< void()> callback, std::shared_ptr< Nodes::Generator::Logic > logic_node)
Coroutine that executes callback on any logic node state change.
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.
Vruta::SoundRoutine Trigger(bool target_state, std::function< void()> callback, std::shared_ptr< Nodes::Generator::Logic > logic_node)
Coroutine that executes callback when logic node changes to specific state.
void schedule_metro(double interval_seconds, std::function< void()> callback, std::string name, Vruta::ProcessingToken token)
Creates a metronome task and addes it to the default scheduler list for evaluation.
void schedule_sequence(std::vector< std::pair< double, std::function< void()> > > seq, std::string name, Vruta::ProcessingToken token)
Creates a sequence task that calls functions at specified times and addes it to the default scheduler...
std::shared_ptr< Buffers::BufferProcessor > attach_quick_process(F &&processor, std::initializer_list< unsigned int > channels={ 0 })
Attaches a processing function to one or more channels.
void schedule_pattern(std::function< std::any(uint64_t)> pattern_func, std::function< void(std::any)> callback, std::vector< double > durations, std::string name, Vruta::ProcessingToken token)
Schedules a pattern generator whose steps are spaced by a list of durations.
Main namespace for the Maya Flux audio engine.