MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Depot.cpp
Go to the documentation of this file.
1#include "Depot.hpp"
3
7
10
12
13namespace fs = std::filesystem;
14
15namespace MayaFlux {
16
17std::vector<std::shared_ptr<Buffers::SoundContainerBuffer>> prepare_audio_buffers(const std::shared_ptr<Kakshya::SoundFileContainer>& container)
18{
19 if (!container) {
21 "prepare_audio_buffers failed: null container");
22 return {};
23 }
24
25 uint32_t num_channels = container->get_num_channels();
26 std::vector<std::shared_ptr<Buffers::SoundContainerBuffer>> created_buffers;
27
28 for (uint32_t channel = 0; channel < num_channels; ++channel) {
29 auto container_buffer = std::make_shared<MayaFlux::Buffers::SoundContainerBuffer>(
30 channel,
32 container,
33 channel);
34
35 container_buffer->initialize();
36
37 created_buffers.push_back(std::move(container_buffer));
38 }
39
40 return created_buffers;
41}
42
43bool is_image(const fs::path& filepath)
44{
45 if (!fs::exists(filepath) || !fs::is_regular_file(filepath)) {
46 return false;
47 }
48
49 auto ext = filepath.extension().string();
50 std::ranges::transform(ext, ext.begin(),
51 [](unsigned char c) { return std::tolower(c); });
52
53 static const std::unordered_set<std::string> image_extensions = {
54 ".png", ".jpg", ".jpeg", ".bmp", ".tga",
55 ".psd", ".gif", ".hdr", ".pic", ".pnm", ".exr"
56 };
57
58 return image_extensions.contains(ext);
59}
60
61bool is_audio(const fs::path& filepath)
62{
63 if (!fs::exists(filepath) || !fs::is_regular_file(filepath)) {
64 return false;
65 }
66
67 auto ext = filepath.extension().string();
68 std::ranges::transform(ext, ext.begin(),
69 [](unsigned char c) { return std::tolower(c); });
70
71 static const std::unordered_set<std::string> audio_extensions = {
72 ".wav", ".aiff", ".aif", ".flac", ".ogg",
73 ".mp3", ".m4a", ".wma"
74 };
75
76 return audio_extensions.contains(ext);
77}
78
79std::shared_ptr<IO::IOManager> get_io_manager()
80{
82 return get_context().get_io_manager();
83 }
84
86 "Attempted to access IOManager before engine initialization");
87 return nullptr;
88}
89
90}
#define MF_ERROR(comp, ctx,...)
Core engine lifecycle and configuration API.
Audio file loading and container management API.
uint32_t channel
std::shared_ptr< IO::IOManager > get_io_manager()
Gets the IO manager.
Definition Engine.hpp:322
uint32_t get_buffer_size()
Gets the buffer size from the default engine.
Definition Config.cpp:72
@ Runtime
General runtime operations (default fallback)
@ API
MayaFlux/API Wrapper and convenience functions.
bool is_engine_configured()
Checks if the default engine has currently accepted all configurations and initialized all managers.
Definition Config.cpp:10
bool is_image(const fs::path &filepath)
Definition Depot.cpp:43
bool is_audio(const fs::path &filepath)
Definition Depot.cpp:61
Core::Engine & get_context()
Gets the default engine instance.
Definition Core.cpp:68
std::shared_ptr< IO::IOManager > get_io_manager()
Retrieves the global IOManager instance for file loading and buffer management.
Definition Depot.cpp:79
std::vector< std::shared_ptr< Buffers::SoundContainerBuffer > > prepare_audio_buffers(const std::shared_ptr< Kakshya::SoundFileContainer > &container)
Constructs and initializes per-channel SoundContainerBuffers without registering them.
Definition Depot.cpp:17
Main namespace for the Maya Flux audio engine.
Definition Runtime.cpp:12