MayaFlux 0.4.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
6#define MAYASIMPLE
8#endif
9#endif
10
12{
13#ifdef HAS_USER_PROJECT
14 try {
15 settings();
16 } catch (const std::exception& e) {
17 MF_ERROR(MayaFlux::Journal::Component::USER, MayaFlux::Journal::Context::Init, "Error during user initialization: {}", e.what());
18 }
19#endif
20}
21
22void run()
23{
24#ifdef HAS_USER_PROJECT
25 try {
26 compose();
27 } catch (const std::exception& e) {
29 }
30#endif
31}
32
33int main(int argc, char* argv[])
34{
35 try {
36 MF_LOG(MayaFlux::Journal::Component::USER, MayaFlux::Journal::Context::Init, "=== MayaFlux Creative Coding Framework ===");
38 "Version: {}.{}.{}", MAYAFLUX_VERSION_MAJOR, MAYAFLUX_VERSION_MINOR, MAYAFLUX_VERSION_PATCH);
40
41 bool config_override = false;
42#ifdef MAYAFLUX_CONFIG_OVERRIDE
43 config_override = true;
44#endif
45
46 std::string config_path;
47 for (int i = 1; i < argc; ++i) {
48 if (std::string_view(argv[i]) == "--config" && i + 1 < argc) {
49 config_path = argv[++i];
50 } else if (std::string_view(argv[i]) == "--config-override") {
51 config_override = true;
52 }
53 }
54
55 if (config_path.empty()) {
56 namespace fs = std::filesystem;
57 auto candidate = fs::path(Config::SOURCE_DIR) / "mayaflux.json";
58 if (fs::exists(candidate))
59 config_path = candidate.string();
60 }
61
62 if (config_override) {
64 "Config override active: file loads after settings()");
65 initialize();
66 if (!config_path.empty())
68 } else {
69 if (!config_path.empty())
71 initialize();
72 }
73
75
77
78 MF_LOG(Journal::Component::USER, Journal::Context::Init, "=== AudioVisual Processing Active ===");
79
80 run();
81
82 std::cout << "Press Enter [Return] to stop...\n";
84
86
87 } catch (const std::exception& e) {
88 std::cerr << "Error: " << e.what() << std::flush;
89 return 1;
90 }
91
92 return 0;
93}
#define MF_LOG(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
int main(int argc, char *argv[])
Definition main.cpp:33
void run()
Definition main.cpp:22
void initialize()
Definition main.cpp:11
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:162
@ 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:120
void Init()
Initializes the default engine with default settings.
Definition Core.cpp:96
void Await()
Blocks launcher until user input (optional convenience function)
Definition Core.cpp:139
void End()
Stops and cleans up the default engine.
Definition Core.cpp:146