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());
92 auto cur_val = task->get_state<
float>(
"current_value");
106 auto task_ptr = std::make_shared<Vruta::SoundRoutine>(std::move(task));
112 auto task_ptr = std::make_shared<Vruta::GraphicsRoutine>(std::move(task));
118 auto task_ptr = std::make_shared<Vruta::FreeRoutine>(std::move(task));
148 const std::shared_ptr<Core::Window>&
window,
155 name =
"key_press_" + std::to_string(event_manager->get_next_event_id());
158 auto event = std::make_shared<Vruta::Event>(
161 event_manager->add_event(event,
name);
165 const std::shared_ptr<Core::Window>&
window,
172 name =
"key_release_" + std::to_string(event_manager->get_next_event_id());
175 auto event = std::make_shared<Vruta::Event>(
178 event_manager->add_event(event,
name);
182 const std::shared_ptr<Core::Window>&
window,
188 name =
"any_key_" + std::to_string(event_manager->get_next_event_id());
191 auto event = std::make_shared<Vruta::Event>(
194 event_manager->add_event(event,
name);
198 const std::shared_ptr<Core::Window>&
window,
200 std::function<
void(
double,
double)>
callback,
205 name =
"mouse_press_" + std::to_string(event_manager->get_next_event_id());
208 auto event = std::make_shared<Vruta::Event>(
211 event_manager->add_event(event,
name);
215 const std::shared_ptr<Core::Window>&
window,
217 std::function<
void(
double,
double)>
callback,
222 name =
"mouse_release_" + std::to_string(event_manager->get_next_event_id());
225 auto event = std::make_shared<Vruta::Event>(
228 event_manager->add_event(event,
name);
232 const std::shared_ptr<Core::Window>&
window,
233 std::function<
void(
double,
double)>
callback,
238 name =
"mouse_move_" + std::to_string(event_manager->get_next_event_id());
241 auto event = std::make_shared<Vruta::Event>(
244 event_manager->add_event(event,
name);
248 const std::shared_ptr<Core::Window>&
window,
250 std::function<
void(
double,
double)>
callback,
255 name =
"mouse_drag_" + std::to_string(event_manager->get_next_event_id());
258 auto event = std::make_shared<Vruta::Event>(
261 event_manager->add_event(event,
name);
265 const std::shared_ptr<Core::Window>&
window,
266 std::function<
void(
double,
double)>
callback,
271 name =
"scroll_" + std::to_string(event_manager->get_next_event_id());
274 auto event = std::make_shared<Vruta::Event>(
277 event_manager->add_event(event,
name);
287 uint64_t sample_rate = 48000;
291 return static_cast<uint64_t
>(seconds * (double)sample_rate);
296 uint32_t sample_rate = 48000;
297 uint32_t block_size = 512;
309 uint32_t block_size = 512;
320 uint64_t sample_rate = 48000;
325 return static_cast<double>(samples) / (
double)sample_rate;
329 std::shared_ptr<Vruta::NetworkSource> source,
335 name =
"net_msg_" + std::to_string(event_manager->get_next_event_id());
337 event_manager->add_event(
347 auto source = std::make_shared<Vruta::NetworkSource>(info);
353 std::shared_ptr<Vruta::NetworkSource> source,
354 std::string sender_address,
360 name =
"net_msg_from_" + std::to_string(event_manager->get_next_event_id());
362 event_manager->add_event(
363 std::make_shared<Vruta::Event>(
370 std::string sender_address,
374 auto source = std::make_shared<Vruta::NetworkSource>(info);
380 std::shared_ptr<Vruta::NetworkSource> source,
387 name =
"net_msg_match_" + std::to_string(event_manager->get_next_event_id());
389 event_manager->add_event(
390 std::make_shared<Vruta::Event>(
401 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.