MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Depot.hpp
Go to the documentation of this file.
1#pragma once
2
3/**
4 * @file API/Depot.hpp
5 * @brief Audio file loading and container management API
6 *
7 * This header provides high-level functions for loading audio files and integrating
8 * them with the MayaFlux buffer system. It handles file format detection, audio
9 * data extraction, and automatic buffer setup for immediate playback or processing.
10 */
11
12namespace MayaFlux {
13
14namespace IO {
15 class SoundFileReader;
16}
17
18namespace Kakshya {
21}
22
23namespace Buffers {
24 class ContainerBuffer;
25 class TextureBuffer;
26}
27
28/**
29 * @brief Loads an audio file into a SoundFileContainer with automatic format detection
30 * @param filepath Path to the audio file to load
31 * @return Shared pointer to loaded SoundFileContainer, or nullptr on failure
32 *
33 * Provides comprehensive audio file loading with format detection, sample rate conversion,
34 * and bit depth optimization. Supports all FFmpeg formats including WAV, MP3, FLAC, OGG, etc.
35 * The container is immediately ready for use with buffer system integration.
36 * Returns nullptr on failure with error details logged to stderr.
37 */
38MAYAFLUX_API std::shared_ptr<MayaFlux::Kakshya::SoundFileContainer> load_audio_file(const std::string& filepath);
39
40/**
41 * @brief Connects a SoundFileContainer to the buffer system for immediate playback
42 * @param container SoundFileContainer to connect to buffers
43 * @return Vector of shared pointers to created ContainerBuffer instances
44 *
45 * Establishes connection between loaded audio container and engine's buffer system,
46 * enabling immediate audio playback through the standard processing pipeline.
47 * Creates ContainerBuffer instances for each channel and connects to AUDIO_BACKEND token.
48 * Multiple containers can be connected simultaneously for layered playback.
49 */
50MAYAFLUX_API std::vector<std::shared_ptr<Buffers::ContainerBuffer>> hook_sound_container_to_buffers(const std::shared_ptr<MayaFlux::Kakshya::SoundFileContainer>& container);
51
52/**
53 * @brief creates a new container of the specified type
54 * @tparam ContainerType Type of container to create (must be derived from SignalSourceContainer)
55 * @tparam Args Constructor argument types
56 * @param args Constructor arguments for the container
57 * @return Shared pointer to the created container
58 */
59template <typename ContainerType, typename... Args>
60 requires std::derived_from<ContainerType, Kakshya::SignalSourceContainer>
61auto create_container(Args&&... args) -> std::shared_ptr<ContainerType>
62{
63 return std::make_shared<ContainerType>(std::forward<Args>(args)...);
64}
65
66/**
67 * @brief Loads an image file into a TextureBuffer
68 * @param filepath Path to the image file to load
69 * @return Shared pointer to loaded TextureBuffer, or nullptr on failure
70 *
71 * Supports common image formats such as PNG, JPEG, BMP, TGA, PSD, GIF, HDR, PIC, and PNM.
72 * Returns nullptr on failure with error details logged to stderr.
73 */
74MAYAFLUX_API std::shared_ptr<Buffers::TextureBuffer> load_image_file(const std::string& filepath);
75
76/**
77 * @brief Checks if the given file is an audio file based on its extension
78 * @param filepath Path to the file to check
79 * @return true if the file is recognized as an audio file, false otherwise
80 */
81MAYAFLUX_API bool is_audio(const std::filesystem::path& filepath);
82
83/**
84 * @brief Checks if the given file is an image file based on its extension
85 * @param filepath Path to the file to check
86 * @return true if the file is recognized as an image file, false otherwise
87 */
88MAYAFLUX_API bool is_image(const std::filesystem::path& filepath);
89
90}
AudioBuffer implementation backed by a StreamContainer.
A hybrid buffer managing both a textured quad geometry and its pixel data.
FFmpeg-based audio file reader for MayaFlux.
Data-driven interface for managing arbitrary processable signal sources.
File-backed audio container with complete streaming functionality.
std::shared_ptr< MayaFlux::Kakshya::SoundFileContainer > load_audio_file(const std::string &filepath)
Loads an audio file into a SoundFileContainer with automatic format detection.
Definition Depot.cpp:18
bool is_image(const fs::path &filepath)
Definition Depot.cpp:144
bool is_audio(const fs::path &filepath)
Definition Depot.cpp:162
std::shared_ptr< Buffers::TextureBuffer > load_image_file(const std::string &filepath)
Loads an image file into a TextureBuffer.
Definition Depot.cpp:117
auto create_container(Args &&... args) -> std::shared_ptr< ContainerType >
creates a new container of the specified type
Definition Depot.hpp:61
std::vector< std::shared_ptr< Buffers::ContainerBuffer > > hook_sound_container_to_buffers(const std::shared_ptr< MayaFlux::Kakshya::SoundFileContainer > &container)
Connects a SoundFileContainer to the buffer system for immediate playback.
Definition Depot.cpp:84
Main namespace for the Maya Flux audio engine.
Definition LiveAid.hpp:6