MayaFlux 0.3.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Core.hpp
Go to the documentation of this file.
1#pragma once
2
3/**
4 * @file API/Core.hpp
5 * @brief Core engine lifecycle and configuration API
6 *
7 * This header provides the fundamental engine control and configuration
8 * functions that form the foundation of the MayaFlux framework. All other
9 * subsystems depend on the engine being properly initialized and configured.
10 *
11 * The Core API handles:
12 * - Engine initialization with various stream configurations
13 * - Engine lifecycle management (Start, Pause, Resume, End)
14 * - Access to core engine context and configuration
15 * - Global stream information queries
16 *
17 * This is typically the first API users interact with when setting up
18 * a MayaFlux application, and other API modules depend on these functions
19 * for accessing engine subsystems.
20 */
21namespace MayaFlux {
22
23namespace Core {
24 struct GlobalStreamInfo;
25 struct GlobalGraphicsConfig;
26 struct GlobalInputConfig;
27 class Engine;
28}
29
30//-------------------------------------------------------------------------
31// Engine Management
32//-------------------------------------------------------------------------
33
34/**
35 * @brief Checks if the default engine has been initialized
36 * @return true if the engine is initialized, false otherwise
37 */
38bool is_initialized();
39
40/**
41 * @brief Gets the default engine instance
42 * @return Reference to the default Engine
43 *
44 * Creates the engine if it doesn't exist yet. This is the centrally managed
45 * engine instance that all convenience functions in this namespace operate on.
46 */
47MAYAFLUX_API Core::Engine& get_context();
48
49/**
50 * @brief Replaces the default engine with a new instance
51 * @param instance New engine instance to use as default
52 *
53 * Transfers state from the old engine to the new one if possible.
54 *
55 * @warning This function uses move semantics. After calling this function,
56 * the engine instance passed as parameter will be left in a moved-from state
57 * and should not be used further. This is intentional to avoid resource duplication
58 * and ensure proper transfer of ownership. Users should be careful to not access
59 * the moved-from instance after calling this function.
60 *
61 * This function is intended for advanced use cases where custom engine configuration
62 * is required beyond what the standard initialization functions provide.
63 */
64MAYAFLUX_API void set_and_transfer_context(Core::Engine instance);
65
66/**
67 * @brief Initializes the default engine with specified parameters
68 * @param sample_rate Audio sample rate in Hz
69 * @param buffer_size Size of audio processing buffer in frames
70 * @param num_out_channels Number of output channels
71 * @param num_in_channels Number of input channels
72 *
73 * Convenience wrapper for Engine::Init() on the default engine.
74 */
75MAYAFLUX_API void Init(uint32_t sample_rate, uint32_t buffer_size = 512, uint32_t num_out_channels = 2, uint32_t num_in_channels = 0);
76
77/**
78 * @brief Initializes the default engine with default settings
79 *
80 * Convenience wrapper for Engine::Init() on the default engine.
81 */
82MAYAFLUX_API void Init();
83
84/**
85 * @brief Initializes the default engine with specified stream and graphics info
86 * @param stream_info Configuration for sample rate, buffer size, and channels
87 * @param graphics_info Configuration for graphics/windowing backend
88 * @param input_config Configuration for input handling
89 *
90 * Convenience wrapper for Engine::Init() on the default engine.
91 */
92MAYAFLUX_API void Init(Core::GlobalStreamInfo stream_info, Core::GlobalGraphicsConfig graphics_config, Core::GlobalInputConfig input_config);
93
94/**
95 * @brief Starts audio processing on the default engine
96 *
97 * Convenience wrapper for Engine::Start() on the default engine.
98 */
99MAYAFLUX_API void Start();
100
101/**
102 * @brief Pauses audio processing on the default engine
103 *
104 * Convenience wrapper for Engine::Pause() on the default engine.
105 */
106MAYAFLUX_API void Pause();
107
108/**
109 * @brief Resumes audio processing on the default engine
110 *
111 * Convenience wrapper for Engine::Resume() on the default engine.
112 */
113MAYAFLUX_API void Resume();
114
115/**
116 * @brief Blocks launcher until user input (optional convenience function)
117 *
118 * Use this only in launcher applications that need to block the main
119 * thread until shutdown is requested.
120 *
121 * On macOS: Spawns input thread and allow GLFW to run on main thread
122 * On Linux/Windows: Simple blocking cin.get()
123 *
124 * Usage (optional):
125 * ```cpp
126 * engine->start_graphics();
127 * std::cout << "Press Enter to stop...\n";
128 * MayaFlux::Await(); // Blocks here (optional)
129 * engine->stop_graphics();
130 * ```
131 */
132MAYAFLUX_API void Await();
133
134/**
135 * @brief Stops and cleans up the default engine
136 *
137 * Convenience wrapper for Engine::End() on the default engine.
138 */
139MAYAFLUX_API void End();
140
141}
@ Core
Core engine, backend, subsystems.
void Resume()
Resumes audio processing on the default engine.
Definition Core.cpp:122
void Start()
Starts audio processing on the default engine.
Definition Core.cpp:110
void Pause()
Pauses audio processing on the default engine.
Definition Core.cpp:115
void Init()
Initializes the default engine with default settings.
Definition Core.cpp:86
void set_and_transfer_context(Core::Engine instance)
Replaces the default engine with a new instance.
Definition Core.cpp:63
Core::Engine & get_context()
Gets the default engine instance.
Definition Core.cpp:58
void Await()
Blocks launcher until user input (optional convenience function)
Definition Core.cpp:129
bool is_initialized()
Checks if the default engine has been initialized.
Definition Core.cpp:50
void End()
Stops and cleans up the default engine.
Definition Core.cpp:136
Main namespace for the Maya Flux audio engine.
Definition LiveAid.hpp:6