32template <
typename... Args>
42 name =
"metro_" + std::to_string(scheduler->get_next_task_id());
44 auto metronome =
Kriya::metro(interval_seconds, std::move(callback), token);
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());
81 auto pattern =
Kriya::pattern(std::move(pattern_func), std::move(callback), interval_seconds, token);
88 auto cur_val = task->get_state<
float>(
"current_value");
102 auto task_ptr = std::make_shared<Vruta::SoundRoutine>(std::move(task));
108 auto task_ptr = std::make_shared<Vruta::GraphicsRoutine>(std::move(task));
114 auto task_ptr = std::make_shared<Vruta::FreeRoutine>(std::move(task));
134 const std::shared_ptr<Core::Window>& window,
136 std::function<
void()> callback,
141 name =
"key_press_" + std::to_string(event_manager->get_next_event_id());
144 auto event = std::make_shared<Vruta::Event>(
147 event_manager->add_event(event, name);
151 const std::shared_ptr<Core::Window>& window,
153 std::function<
void()> callback,
158 name =
"key_release_" + std::to_string(event_manager->get_next_event_id());
161 auto event = std::make_shared<Vruta::Event>(
164 event_manager->add_event(event, name);
168 const std::shared_ptr<Core::Window>& window,
169 std::function<
void(
IO::Keys)> callback,
174 name =
"any_key_" + std::to_string(event_manager->get_next_event_id());
177 auto event = std::make_shared<Vruta::Event>(
180 event_manager->add_event(event, name);
184 const std::shared_ptr<Core::Window>& window,
186 std::function<
void(
double,
double)> callback,
191 name =
"mouse_press_" + std::to_string(event_manager->get_next_event_id());
194 auto event = std::make_shared<Vruta::Event>(
197 event_manager->add_event(event, name);
201 const std::shared_ptr<Core::Window>& window,
203 std::function<
void(
double,
double)> callback,
208 name =
"mouse_release_" + std::to_string(event_manager->get_next_event_id());
211 auto event = std::make_shared<Vruta::Event>(
214 event_manager->add_event(event, name);
218 const std::shared_ptr<Core::Window>& window,
219 std::function<
void(
double,
double)> callback,
224 name =
"mouse_move_" + std::to_string(event_manager->get_next_event_id());
227 auto event = std::make_shared<Vruta::Event>(
230 event_manager->add_event(event, name);
234 const std::shared_ptr<Core::Window>& window,
236 std::function<
void(
double,
double)> callback,
241 name =
"mouse_drag_" + std::to_string(event_manager->get_next_event_id());
244 auto event = std::make_shared<Vruta::Event>(
247 event_manager->add_event(event, name);
251 const std::shared_ptr<Core::Window>& window,
252 std::function<
void(
double,
double)> callback,
257 name =
"scroll_" + std::to_string(event_manager->get_next_event_id());
260 auto event = std::make_shared<Vruta::Event>(
263 event_manager->add_event(event, name);
273 uint64_t sample_rate = 48000;
277 return static_cast<uint64_t
>(seconds * (double)sample_rate);
282 uint32_t sample_rate = 48000;
283 uint32_t block_size = 512;
295 uint32_t block_size = 512;
306 uint64_t sample_rate = 48000;
311 return static_cast<double>(samples) / (
double)sample_rate;
315 std::shared_ptr<Vruta::NetworkSource> source,
321 name =
"net_msg_" + std::to_string(event_manager->get_next_event_id());
323 event_manager->add_event(
324 std::make_shared<Vruta::Event>(
Kriya::on_message(std::move(source), std::move(callback))),
333 auto source = std::make_shared<Vruta::NetworkSource>(info);
339 std::shared_ptr<Vruta::NetworkSource> source,
340 std::string sender_address,
346 name =
"net_msg_from_" + std::to_string(event_manager->get_next_event_id());
348 event_manager->add_event(
349 std::make_shared<Vruta::Event>(
356 std::string sender_address,
360 auto source = std::make_shared<Vruta::NetworkSource>(info);
366 std::shared_ptr<Vruta::NetworkSource> source,
373 name =
"net_msg_match_" + std::to_string(event_manager->get_next_event_id());
375 event_manager->add_event(
376 std::make_shared<Vruta::Event>(
387 auto source = std::make_shared<Vruta::NetworkSource>(info);
#define MF_ERROR(comp, ctx,...)
Core engine lifecycle and configuration API.
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)
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.
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.
std::shared_ptr< Vruta::Routine > pattern(std::function< std::any(uint64_t)> pattern_func, std::function< void(std::any)> callback, double interval_seconds, Vruta::ProcessingToken token)
Creates a generative algorithm that produces values based on a pattern function.
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_pattern(std::function< std::any(uint64_t)> pattern_func, std::function< void(std::any)> callback, double interval_seconds, std::string name, Vruta::ProcessingToken token)
Schedules a pattern generator that produces values based on a pattern function and addes it to the de...
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.
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.