diff --git a/CHANGELOG.md b/CHANGELOG.md index 71638abcea..541535be22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Allow identifying assets in code from their path (#1177. **@GalaxyCrush**). +- Added an Audio asset (#230, **@Dageus**, **@diogomsmiranda**). ### Fixed @@ -46,6 +47,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Replaced OpenAL audio device with Miniaudio backend (#1005, **@Dageus**, **@diogomsmiranda**). ### Fixed + - Spot light angle mismatch between light and shadows (#1310, **@tomas7770**). - Spot shadows cause light range cutoff (#1312, **@tomas7770**). - Precision error in split screen size calculations (**@mkuritsu**). diff --git a/engine/CMakeLists.txt b/engine/CMakeLists.txt index e29913c7ee..13a420688d 100644 --- a/engine/CMakeLists.txt +++ b/engine/CMakeLists.txt @@ -36,6 +36,9 @@ set(CUBOS_ENGINE_SOURCE "src/utils/free_camera/plugin.cpp" "src/utils/free_camera/controller.cpp" + "src/audio/audio.cpp" + "src/audio/bridge.cpp" + "src/assets/plugin.cpp" "src/assets/assets.cpp" "src/assets/bridge.cpp" diff --git a/engine/include/cubos/engine/audio/audio.hpp b/engine/include/cubos/engine/audio/audio.hpp new file mode 100644 index 0000000000..85d6add166 --- /dev/null +++ b/engine/include/cubos/engine/audio/audio.hpp @@ -0,0 +1,29 @@ +/// @file +/// @brief Class @ref cubos::engine::Audio. +/// @ingroup audio-plugin + +#pragma once + +#include +#include +#include + +#include + +namespace cubos::engine +{ + /// @brief Asset containing raw Audio data. + /// + /// @ingroup audio-plugin + struct CUBOS_ENGINE_API Audio + { + CUBOS_REFLECT; + + /// @brief Audio buffer. + cubos::core::al::Buffer buffer; + + explicit Audio(const std::shared_ptr& context, core::memory::Stream& stream); + Audio(Audio&& other) noexcept; + ~Audio(); + }; +} // namespace cubos::engine diff --git a/engine/include/cubos/engine/audio/bridge.hpp b/engine/include/cubos/engine/audio/bridge.hpp new file mode 100644 index 0000000000..d7d8329106 --- /dev/null +++ b/engine/include/cubos/engine/audio/bridge.hpp @@ -0,0 +1,36 @@ +/// @file +/// @brief Class @ref cubos::engine::AudioBridge. +/// @ingroup audio-plugin + +#pragma once + +#include + +#include +#include + +namespace cubos::engine +{ + /// @brief Bridge which loads and saves @ref Audio assets. + /// + /// Uses the default supported file formats from miniaudio.h, which are WAV, FLAC, and MP3. + /// + /// @ingroup audio-plugin + class AudioBridge : public FileBridge + { + + std::shared_ptr mContext; + + public: + /// @brief Constructs a bridge. + AudioBridge(std::shared_ptr context) + : FileBridge(core::reflection::reflect