28template <
typename... Args>
39void schedule_metro(
double interval_seconds, std::function<
void()> callback, std::string name)
43 name =
"metro_" + std::to_string(scheduler->get_next_task_id());
45 auto metronome = std::make_shared<Vruta::SoundRoutine>(
create_metro(interval_seconds, std::move(callback)));
55void schedule_sequence(std::vector<std::pair<
double, std::function<
void()>>> seq, std::string name)
59 name =
"seq_" + std::to_string(scheduler->get_next_task_id());
61 auto tseq = std::make_shared<Vruta::SoundRoutine>(
create_sequence(std::move(seq)));
75void schedule_pattern(std::function<std::any(uint64_t)> pattern_func, std::function<
void(std::any)> callback,
double interval_seconds, std::string name)
79 name =
"pattern_" + std::to_string(scheduler->get_next_task_id());
81 auto pattern = std::make_shared<Vruta::SoundRoutine>(
create_pattern(std::move(pattern_func), std::move(callback), interval_seconds));
88 auto cur_val = task->get_state<
float>(
"current_value");
102 auto task_ptr = std::make_shared<Vruta::SoundRoutine>(std::move(task));
122 const std::shared_ptr<Core::Window>& window,
124 std::function<
void()> callback,
129 name =
"key_press_" + std::to_string(event_manager->get_next_event_id());
132 auto event = std::make_shared<Vruta::Event>(
135 event_manager->add_event(event, name);
139 const std::shared_ptr<Core::Window>& window,
141 std::function<
void()> callback,
146 name =
"key_release_" + std::to_string(event_manager->get_next_event_id());
149 auto event = std::make_shared<Vruta::Event>(
152 event_manager->add_event(event, name);
156 const std::shared_ptr<Core::Window>& window,
157 std::function<
void(
IO::Keys)> callback,
162 name =
"any_key_" + std::to_string(event_manager->get_next_event_id());
165 auto event = std::make_shared<Vruta::Event>(
168 event_manager->add_event(event, name);
172 const std::shared_ptr<Core::Window>& window,
174 std::function<
void(
double,
double)> callback,
179 name =
"mouse_press_" + std::to_string(event_manager->get_next_event_id());
182 auto event = std::make_shared<Vruta::Event>(
185 event_manager->add_event(event, name);
189 const std::shared_ptr<Core::Window>& window,
191 std::function<
void(
double,
double)> callback,
196 name =
"mouse_release_" + std::to_string(event_manager->get_next_event_id());
199 auto event = std::make_shared<Vruta::Event>(
202 event_manager->add_event(event, name);
206 const std::shared_ptr<Core::Window>& window,
207 std::function<
void(
double,
double)> callback,
212 name =
"mouse_move_" + std::to_string(event_manager->get_next_event_id());
215 auto event = std::make_shared<Vruta::Event>(
218 event_manager->add_event(event, name);
222 const std::shared_ptr<Core::Window>& window,
223 std::function<
void(
double,
double)> callback,
228 name =
"scroll_" + std::to_string(event_manager->get_next_event_id());
231 auto event = std::make_shared<Vruta::Event>(
234 event_manager->add_event(event, name);
#define MF_ERROR(comp, ctx,...)
Core engine lifecycle and configuration API.
std::shared_ptr< Vruta::EventManager > get_event_manager()
Gets the event manager.
std::shared_ptr< Vruta::TaskScheduler > get_scheduler()
Gets the task scheduler.
static std::shared_ptr< BufferPipeline > create(Vruta::TaskScheduler &scheduler, std::shared_ptr< Buffers::BufferManager > buffer_manager=nullptr)
A C++20 coroutine-based audio processing task with sample-accurate timing.
MouseButtons
Enumeration for mouse buttons.
@ CoroutineScheduling
Coroutine scheduling and temporal coordination (Vruta::TaskScheduler)
@ API
MayaFlux/API Wrapper and convenience functions.
Vruta::Event key_released(std::shared_ptr< Core::Window > window, IO::Keys key, std::function< void()> callback)
Creates an Event coroutine that triggers on specific key release.
Vruta::Event any_key(std::shared_ptr< Core::Window > window, std::function< void(IO::Keys)> callback)
Creates an Event coroutine that triggers on any key press.
Vruta::Event key_pressed(std::shared_ptr< Core::Window > window, IO::Keys key, std::function< void()> callback)
Creates an Event coroutine that triggers on specific key press.
Vruta::Event mouse_moved(std::shared_ptr< Core::Window > window, std::function< void(double, double)> callback)
Creates an Event coroutine that triggers on mouse movement.
Vruta::SoundRoutine sequence(Vruta::TaskScheduler &scheduler, std::vector< std::pair< double, std::function< void()> > > sequence)
Creates a temporal sequence that executes callbacks at specified time offsets.
Vruta::Event mouse_scrolled(std::shared_ptr< Core::Window > window, std::function< void(double, double)> callback)
Creates an Event coroutine that triggers on mouse scroll.
Vruta::Event mouse_released(std::shared_ptr< Core::Window > window, IO::MouseButtons button, std::function< void(double, double)> callback)
Creates an Event coroutine that triggers on specific mouse button release.
Vruta::SoundRoutine pattern(Vruta::TaskScheduler &scheduler, std::function< std::any(uint64_t)> pattern_func, std::function< void(std::any)> callback, double interval_seconds)
Creates a generative algorithm that produces values based on a pattern function.
Vruta::Event mouse_pressed(std::shared_ptr< Core::Window > window, IO::MouseButtons button, std::function< void(double, double)> callback)
Creates an Event coroutine that triggers on specific mouse button press.
Vruta::SoundRoutine line(Vruta::TaskScheduler &scheduler, float start_value, float end_value, float duration_seconds, uint32_t step_duration, bool restartable)
Creates a continuous interpolation generator between two values over time.
Vruta::SoundRoutine metro(Vruta::TaskScheduler &scheduler, double interval_seconds, std::function< void()> callback)
Creates a periodic event generator that executes a callback at regular intervals.
bool cancel_event_handler(const std::string &name)
Cancel an event handler by name.
void on_mouse_move(const std::shared_ptr< Core::Window > &window, std::function< void(double, double)> callback, std::string name)
Schedule a mouse movement handler.
bool update_task_params(const std::string &name, Args... args)
Updates parameters of a scheduled task.
void on_scroll(const std::shared_ptr< Core::Window > &window, std::function< void(double, double)> callback, std::string name)
Schedule a mouse scroll handler.
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.
std::shared_ptr< Vruta::EventManager > get_event_manager()
Gets the event manager from the default engine.
bool restart_task(const std::string &name)
Restarts a scheduled task.
Vruta::SoundRoutine create_pattern(std::function< std::any(uint64_t)> pattern_func, std::function< void(std::any)> callback, double interval_seconds)
Schedules a pattern generator that produces values based on a pattern function.
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 on_mouse_pressed(const std::shared_ptr< Core::Window > &window, IO::MouseButtons button, std::function< void(double, double)> callback, std::string name)
Schedule a mouse button press handler.
Vruta::SoundRoutine create_line(float start_value, float end_value, float duration_seconds, uint32_t step_duration, bool loop)
Creates a line generator that interpolates between values over time.
void schedule_task(const std::string &name, Vruta::SoundRoutine &&task, bool initialize)
Schedules a new sound routine task.
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...
float * get_line_value(const std::string &name)
Gets a pointer to a task's current value.
Vruta::SoundRoutine create_metro(double interval_seconds, std::function< void()> callback)
Creates a simple task that calls a function at a specified interval.
void on_key_released(const std::shared_ptr< Core::Window > &window, IO::Keys key, std::function< void()> callback, std::string name)
Schedule a key release handler.
std::shared_ptr< Kriya::BufferPipeline > create_buffer_pipeline()
Creates a new buffer pipeline instance.
std::shared_ptr< Buffers::BufferManager > get_buffer_manager()
Gets the buffer manager from the default engine.
bool cancel_task(const std::string &name)
Cancels a scheduled task.
Core::Engine & get_context()
Gets the default engine instance.
void on_mouse_released(const std::shared_ptr< Core::Window > &window, IO::MouseButtons button, std::function< void(double, double)> callback, std::string name)
Schedule a mouse button release handler.
Vruta::SoundRoutine create_sequence(std::vector< std::pair< double, std::function< void()> > > seq)
Creates a sequence task that calls functions at specified times.
std::shared_ptr< Vruta::TaskScheduler > get_scheduler()
Gets the task scheduler from the default engine.
void on_any_key(const std::shared_ptr< Core::Window > &window, std::function< void(IO::Keys)> callback, std::string name)
Schedule a handler for any key press.
void on_key_pressed(const std::shared_ptr< Core::Window > &window, IO::Keys key, std::function< void()> callback, std::string name)
Schedule a key press handler.
Main namespace for the Maya Flux audio engine.