MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1#ifdef __has_include
2#if __has_include("user_project.hpp")
3#include "user_project.hpp"
4#define HAS_USER_PROJECT
5#else
7#endif
8#endif
9
11{
12#ifdef HAS_USER_PROJECT
13 try {
14 settings();
15 } catch (const std::exception& e) {
16 MF_ERROR(MayaFlux::Journal::Component::USER, MayaFlux::Journal::Context::Init, "Error during user initialization: {}", e.what());
17 }
18#endif
19}
20
21void run()
22{
23#ifdef HAS_USER_PROJECT
24 try {
25 compose();
26 } catch (const std::exception& e) {
28 }
29#endif
30}
31
32int main(int argc, char* argv[])
33{
34 try {
35 MF_LOG(MayaFlux::Journal::Component::USER, MayaFlux::Journal::Context::Init, "=== MayaFlux Creative Coding Framework ===");
37 "Version: {}.{}.{}", MAYAFLUX_VERSION_MAJOR, MAYAFLUX_VERSION_MINOR, MAYAFLUX_VERSION_PATCH);
39
40 bool config_override = false;
41#ifdef MAYAFLUX_CONFIG_OVERRIDE
42 config_override = true;
43#endif
44
45 std::string config_path;
46 for (int i = 1; i < argc; ++i) {
47 if (std::string_view(argv[i]) == "--config" && i + 1 < argc) {
48 config_path = argv[++i];
49 } else if (std::string_view(argv[i]) == "--config-override") {
50 config_override = true;
51 }
52 }
53
54 if (config_path.empty()) {
55 namespace fs = std::filesystem;
56 auto candidate = fs::path(Config::SOURCE_DIR) / "mayaflux.json";
57 if (fs::exists(candidate))
58 config_path = candidate.string();
59 }
60
61 if (config_override) {
63 "Config override active: file loads after settings()");
64 initialize();
65 if (!config_path.empty())
67 } else {
68 if (!config_path.empty())
70 initialize();
71 }
72
74
76
77 MF_LOG(Journal::Component::USER, Journal::Context::Init, "=== AudioVisual Processing Active ===");
78
79 run();
80
81 std::cout << "Press Ctrl-C to stop...\n";
83
85
86 } catch (const std::exception& e) {
87 std::cerr << "Error: " << e.what() << std::flush;
88 return 1;
89 }
90
91 return 0;
92}
#define MF_LOG(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
Single include for the user facing API.
int main(int argc, char *argv[])
Definition main.cpp:32
void run()
Definition main.cpp:21
void initialize()
Definition main.cpp:10
bool load_config_from_file(const std::string &path)
Load engine configuration from a JSON file, applying any present fields to the pre-Init config struct...
Definition Config.cpp:189
@ Init
Engine/subsystem initialization.
@ Runtime
General runtime operations (default fallback)
@ USER
User code, scripts, plugins.
void Start()
Starts audio processing on the default engine.
Definition Core.cpp:130
void Init()
Initializes the default engine with default settings.
Definition Core.cpp:106
void Await()
Blocks launcher until Ctrl-C is pressed (optional convenience function)
Definition Core.cpp:149
void End()
Stops and cleans up the default engine.
Definition Core.cpp:156