32template <
typename... Args>
43void schedule_metro(
double interval_seconds, std::function<
void()> callback, std::string name)
47 name =
"metro_" + std::to_string(scheduler->get_next_task_id());
49 auto metronome = std::make_shared<Vruta::SoundRoutine>(
create_metro(interval_seconds, std::move(callback)));
59void schedule_sequence(std::vector<std::pair<
double, std::function<
void()>>> seq, std::string name)
63 name =
"seq_" + std::to_string(scheduler->get_next_task_id());
65 auto tseq = std::make_shared<Vruta::SoundRoutine>(
create_sequence(std::move(seq)));
79void schedule_pattern(std::function<std::any(uint64_t)> pattern_func, std::function<
void(std::any)> callback,
double interval_seconds, std::string name)
83 name =
"pattern_" + std::to_string(scheduler->get_next_task_id());
85 auto pattern = std::make_shared<Vruta::SoundRoutine>(
create_pattern(std::move(pattern_func), std::move(callback), interval_seconds));
92 auto cur_val = task->get_state<
float>(
"current_value");
106 auto task_ptr = std::make_shared<Vruta::SoundRoutine>(std::move(task));
126 const std::shared_ptr<Core::Window>& window,
128 std::function<
void()> callback,
133 name =
"key_press_" + std::to_string(event_manager->get_next_event_id());
136 auto event = std::make_shared<Vruta::Event>(
139 event_manager->add_event(event, name);
143 const std::shared_ptr<Core::Window>& window,
145 std::function<
void()> callback,
150 name =
"key_release_" + 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,
161 std::function<
void(
IO::Keys)> callback,
166 name =
"any_key_" + std::to_string(event_manager->get_next_event_id());
169 auto event = std::make_shared<Vruta::Event>(
172 event_manager->add_event(event, name);
176 const std::shared_ptr<Core::Window>& window,
178 std::function<
void(
double,
double)> callback,
183 name =
"mouse_press_" + 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_release_" + 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,
211 std::function<
void(
double,
double)> callback,
216 name =
"mouse_move_" + std::to_string(event_manager->get_next_event_id());
219 auto event = std::make_shared<Vruta::Event>(
222 event_manager->add_event(event, name);
226 const std::shared_ptr<Core::Window>& window,
227 std::function<
void(
double,
double)> callback,
232 name =
"scroll_" + std::to_string(event_manager->get_next_event_id());
235 auto event = std::make_shared<Vruta::Event>(
238 event_manager->add_event(event, name);
248 uint64_t sample_rate = 48000;
252 return static_cast<uint64_t
>(seconds * (double)sample_rate);
257 uint32_t sample_rate = 48000;
258 uint32_t block_size = 512;
270 uint32_t block_size = 512;
281 uint64_t sample_rate = 48000;
286 return static_cast<double>(samples) / (
double)sample_rate;
290 std::shared_ptr<Vruta::NetworkSource> source,
296 name =
"net_msg_" + std::to_string(event_manager->get_next_event_id());
298 event_manager->add_event(
299 std::make_shared<Vruta::Event>(
Kriya::on_message(std::move(source), std::move(callback))),
308 auto source = std::make_shared<Vruta::NetworkSource>(info);
314 std::shared_ptr<Vruta::NetworkSource> source,
315 std::string sender_address,
321 name =
"net_msg_from_" + std::to_string(event_manager->get_next_event_id());
323 event_manager->add_event(
324 std::make_shared<Vruta::Event>(
331 std::string sender_address,
335 auto source = std::make_shared<Vruta::NetworkSource>(info);
341 std::shared_ptr<Vruta::NetworkSource> source,
348 name =
"net_msg_match_" + std::to_string(event_manager->get_next_event_id());
350 event_manager->add_event(
351 std::make_shared<Vruta::Event>(
362 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)
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::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::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::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::SoundRoutine metro(Vruta::TaskScheduler &scheduler, double interval_seconds, std::function< void()> callback)
Creates a periodic event generator that executes a callback at regular intervals.
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 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...
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.
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.
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< 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.
Vruta::SoundRoutine create_line(float start_value, float end_value, float duration_seconds, uint32_t step_duration, bool retain)
Creates a line generator that interpolates between values over time.
Vruta::SoundRoutine create_sequence(std::vector< std::pair< double, std::function< void()> > > seq)
Creates a sequence task that calls functions at specified times.
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.