25template <
typename Callable>
26void schedule_metro(
double interval_seconds, Callable&& callback, std::string name =
"")
28 std::function<void()> func = std::forward<Callable>(callback);
29 schedule_metro(interval_seconds, std::move(func), std::move(name));
32template <
typename... Args>
33void schedule_sequence(
const std::vector<std::pair<
double, std::function<
void(Args...)>>>& sequence,
34 std::string name =
"", Args... args)
36 std::vector<std::pair<double, std::function<void()>>> seq;
37 for (
const auto& [time, func] : sequence) {
38 seq.emplace_back(time, [func, args...]() { func(args...); });
43template <
typename PatternFunc,
typename Callback>
45 double interval_seconds, std::string name =
"")
47 auto pattern_wrapper = [pf = std::forward<PatternFunc>(pattern_func)](uint64_t idx) -> std::any {
51 auto callback_wrapper = [cb = std::forward<Callback>(callback)](std::any val) {
55 std::function<std::any(uint64_t)> pattern_fn = pattern_wrapper;
56 std::function<void(std::any)> callback_fn = callback_wrapper;
59 interval_seconds, std::move(name));
62template <
typename FuncType>
63std::shared_ptr<Buffers::BufferProcessor>
attach_quick_process(FuncType&& processor, std::shared_ptr<Buffers::AudioBuffer> buffer)
65 std::function<void(std::shared_ptr<Buffers::AudioBuffer>)> func = std::forward<FuncType>(processor);
77template <
typename Callable>
80 std::shared_ptr<Nodes::Generator::Logic> logic_node,
bool open =
true)
82 std::function<void()> func = std::forward<Callable>(callback);
83 return Gate(scheduler, std::move(func), std::move(logic_node), open);
94template <
typename Callable>
99 std::shared_ptr<Nodes::Generator::Logic> logic_node)
101 std::function<void()> func = std::forward<Callable>(callback);
102 return Trigger(scheduler, target_state, std::move(func), std::move(logic_node));
112template <
typename Callable>
116 std::shared_ptr<Nodes::Generator::Logic> logic_node)
118 std::function<void()> func = std::forward<Callable>(callback);
119 return Toggle(scheduler, std::move(func), std::move(logic_node));
void schedule_metro(double interval_seconds, std::function< void()> callback, std::string name)
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)
Creates a sequence task that calls functions at specified times and addes it to the default scheduler...
void schedule_pattern(std::function< std::any(uint64_t)> pattern_func, std::function< void(std::any)> callback, double interval_seconds, std::string name)
Schedules a pattern generator that produces values based on a pattern function and addes it to the de...