32template <
typename... Args>
42 name =
"metro_" + std::to_string(scheduler->get_next_task_id());
53 name =
"seq_" + std::to_string(scheduler->get_next_task_id());
61std::shared_ptr<Vruta::SoundRoutine>
schedule_line(
float start_value,
float end_value,
float duration_seconds, uint32_t step_duration,
bool retain, std::string
name)
65 name =
"seq_" + std::to_string(scheduler->get_next_task_id());
68 auto line = std::make_shared<Vruta::SoundRoutine>(
Kriya::line(start_value, end_value, duration_seconds, step_duration, retain));
78 name =
"pattern_" + std::to_string(scheduler->get_next_task_id());
87 auto cur_val = task->get_state<
float>(
"current_value");
101 auto task_ptr = std::make_shared<Vruta::SoundRoutine>(std::move(task));
107 auto task_ptr = std::make_shared<Vruta::GraphicsRoutine>(std::move(task));
113 auto task_ptr = std::make_shared<Vruta::FreeRoutine>(std::move(task));
143 const std::shared_ptr<Core::Window>&
window,
150 name =
"key_press_" + std::to_string(event_manager->get_next_event_id());
153 auto event = std::make_shared<Vruta::Event>(
156 event_manager->add_event(event,
name);
160 const std::shared_ptr<Core::Window>&
window,
167 name =
"key_release_" + std::to_string(event_manager->get_next_event_id());
170 auto event = std::make_shared<Vruta::Event>(
173 event_manager->add_event(event,
name);
177 const std::shared_ptr<Core::Window>&
window,
183 name =
"any_key_" + std::to_string(event_manager->get_next_event_id());
186 auto event = std::make_shared<Vruta::Event>(
189 event_manager->add_event(event,
name);
193 const std::shared_ptr<Core::Window>&
window,
195 std::function<
void(
double,
double)>
callback,
200 name =
"mouse_press_" + std::to_string(event_manager->get_next_event_id());
203 auto event = std::make_shared<Vruta::Event>(
206 event_manager->add_event(event,
name);
210 const std::shared_ptr<Core::Window>&
window,
212 std::function<
void(
double,
double)>
callback,
217 name =
"mouse_release_" + std::to_string(event_manager->get_next_event_id());
220 auto event = std::make_shared<Vruta::Event>(
223 event_manager->add_event(event,
name);
227 const std::shared_ptr<Core::Window>&
window,
228 std::function<
void(
double,
double)>
callback,
233 name =
"mouse_move_" + std::to_string(event_manager->get_next_event_id());
236 auto event = std::make_shared<Vruta::Event>(
239 event_manager->add_event(event,
name);
243 const std::shared_ptr<Core::Window>&
window,
245 std::function<
void(
double,
double)>
callback,
250 name =
"mouse_drag_" + std::to_string(event_manager->get_next_event_id());
253 auto event = std::make_shared<Vruta::Event>(
256 event_manager->add_event(event,
name);
260 const std::shared_ptr<Core::Window>&
window,
261 std::function<
void(
double,
double)>
callback,
266 name =
"scroll_" + std::to_string(event_manager->get_next_event_id());
269 auto event = std::make_shared<Vruta::Event>(
272 event_manager->add_event(event,
name);
282 uint64_t sample_rate = 48000;
286 return static_cast<uint64_t
>(seconds * (double)sample_rate);
291 uint32_t sample_rate = 48000;
292 uint32_t block_size = 512;
304 uint32_t block_size = 512;
315 uint64_t sample_rate = 48000;
320 return static_cast<double>(samples) / (
double)sample_rate;
324 std::shared_ptr<Vruta::NetworkSource> source,
330 name =
"net_msg_" + std::to_string(event_manager->get_next_event_id());
332 event_manager->add_event(
342 auto source = std::make_shared<Vruta::NetworkSource>(info);
348 std::shared_ptr<Vruta::NetworkSource> source,
349 std::string sender_address,
355 name =
"net_msg_from_" + std::to_string(event_manager->get_next_event_id());
357 event_manager->add_event(
358 std::make_shared<Vruta::Event>(
365 std::string sender_address,
369 auto source = std::make_shared<Vruta::NetworkSource>(info);
375 std::shared_ptr<Vruta::NetworkSource> source,
382 name =
"net_msg_match_" + std::to_string(event_manager->get_next_event_id());
384 event_manager->add_event(
385 std::make_shared<Vruta::Event>(
396 auto source = std::make_shared<Vruta::NetworkSource>(info);
#define MF_ERROR(comp, ctx,...)
Core engine lifecycle and configuration API.
std::weak_ptr< Core::Window > window
GlobalStreamInfo & get_stream_info()
Gets the current stream configuration.
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, std::shared_ptr< IO::IOManager > io_manager=nullptr)
Coroutine resumed when a caller-supplied condition becomes true.
A C++20 coroutine-based graphics processing task with frame-accurate timing.
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.
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.
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 line(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::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::Event on_message_matching(std::shared_ptr< Vruta::NetworkSource > source, std::function< bool(const Core::NetworkMessage &)> predicate, std::function< void(const Core::NetworkMessage &)> callback)
Creates an Event coroutine that fires only when a predicate matches.
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.
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::Event mouse_dragged(std::shared_ptr< Core::Window > window, IO::MouseButtons button, std::function< void(double, double)> callback)
Creates an Event coroutine that triggers on mouse drag with specific button.
std::shared_ptr< Vruta::Routine > metro(double interval_seconds, std::function< void()> callback, Vruta::ProcessingToken token)
Creates a periodic event generator that executes a callback at regular intervals.
Vruta::Event on_message_from(std::shared_ptr< Vruta::NetworkSource > source, std::string sender_address, std::function< void(const Core::NetworkMessage &)> callback)
Creates an Event coroutine that fires only for messages from a specific sender.
Vruta::Event on_message(std::shared_ptr< Vruta::NetworkSource > source, std::function< void(const Core::NetworkMessage &)> callback)
Creates an Event coroutine that fires on every message received by a source.
uint64_t samples_to_blocks(uint64_t samples, uint32_t block_size)
Convert samples to number of processing blocks.
uint64_t seconds_to_blocks(double seconds, uint32_t sample_rate, uint32_t block_size)
Convert seconds to number of processing blocks.
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 on_mouse_drag(const std::shared_ptr< Core::Window > &window, IO::MouseButtons button, std::function< void(double, double)> callback, std::string name)
Schedule a mouse drag handler.
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.
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...
uint64_t seconds_to_samples(double seconds)
Converts a time duration in seconds to the equivalent number of audio samples.
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.
void schedule_task(const std::string &name, Vruta::SoundRoutine &&task, bool initialize)
Schedules a new sound routine task.
float * get_line_value(const std::string &name)
Gets a pointer to a task's current value.
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.
uint64_t seconds_to_blocks(double seconds)
Converts a time duration in seconds to the equivalent number of processing blocks.
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< Vruta::SoundRoutine > schedule_line(float start_value, float end_value, float duration_seconds, uint32_t step_duration, bool retain, std::string name)
Creates a line generator that interpolates between values over time and schedules it for evaluation.
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.
void on_network_message_from(std::shared_ptr< Vruta::NetworkSource > source, std::string sender_address, std::function< void(const Core::NetworkMessage &)> callback, std::string name)
Schedule an on_message_from handler with an existing NetworkSource.
Core::Engine & get_context()
Gets the default engine instance.
double samples_to_seconds(uint64_t samples)
Converts a number of audio samples to the equivalent time duration in seconds.
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.
void on_network_message(std::shared_ptr< Vruta::NetworkSource > source, std::function< void(const Core::NetworkMessage &)> callback, std::string name)
Schedule an on_message handler with an existing NetworkSource.
void on_network_message_matching(std::shared_ptr< Vruta::NetworkSource > source, std::function< bool(const Core::NetworkMessage &)> predicate, std::function< void(const Core::NetworkMessage &)> callback, std::string name)
Schedule an on_message_matching handler with an existing NetworkSource.
uint64_t samples_to_blocks(uint64_t samples)
Converts samples to blocks based on current block size.
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.
Describes one logical send/receive endpoint managed by a backend.
uint32_t buffer_size
Number of samples per processing block.
uint32_t sample_rate
Number of samples processed per second (Hz)
A received datagram or framed message with sender metadata.