Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/laguna1989/openalpp
Modern OOP C++14 audio library built on OpenAL for Windows, macOS, Linux and web (emscripten).
https://github.com/laguna1989/openalpp
audio audio-library cpp cpp14-library oop openal openal-soft
Last synced: 2 months ago
JSON representation
Modern OOP C++14 audio library built on OpenAL for Windows, macOS, Linux and web (emscripten).
- Host: GitHub
- URL: https://github.com/laguna1989/openalpp
- Owner: Laguna1989
- License: mit
- Created: 2021-12-28T11:59:25.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-06-26T04:54:23.000Z (7 months ago)
- Last Synced: 2024-06-26T17:49:01.153Z (7 months ago)
- Topics: audio, audio-library, cpp, cpp14-library, oop, openal, openal-soft
- Language: C++
- Homepage:
- Size: 1.28 MB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
OpenALpp
========
[![codecov](https://codecov.io/gh/Laguna1989/OpenALpp/branch/master/graph/badge.svg?token=X68KWFTRZG)](https://codecov.io/gh/Laguna1989/OpenALpp)
[![Tests](https://github.com/Laguna1989/OpenALpp/actions/workflows/test_verification.yml/badge.svg)](https://github.com/Laguna1989/OpenALpp/actions/workflows/test_verification.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)OpenALpp is a modern OOP C++20 audio library built on [OpenAL Soft](https://github.com/kcat/openal-soft)
for Windows, macOS, Linux and web (emscripten). It supports loading of wav, mp3, FLAC and ogg files
via [libnyquist](https://github.com/ddiakopoulos/libnyquist).How to build
------------1. `git clone https://github.com/Laguna1989/OpenALpp.git && cd OpenALpp`
2. `mkdir build && cd build`
3. `cmake ..`
4. `cmake --build . --target OpenALpp_Lib`How to measure Code Coverage with [OpenCppCoverage](https://github.com/OpenCppCoverage/OpenCppCoverage)
-----------```
OpenCppCoverage.exe
--sources \OpenALpp\impl\
--excluded_sources \OpenALpp\test\
--excluded_sources \OpenALpp\ext*
--excluded_sources \OpenALpp\cmake-build-debug*
.\path\to\unit_tests\OpenALpp_UnitTests.exe
```Code Example
----------```
#include "oalpp/sound_context.hpp"
#include "oalpp/sound_data.hpp"
#include "oalpp/sound.hpp"using namespace oalpp;
SoundContext ctx;
SoundData buffer { "audio.mp3" };
Sound snd { buffer };
snd.play();while (snd.isPlaying()) {
snd.update();
}
```Common Pitfalls
------------* `Sound` has a dependency on `SoundContext`. You need to keep the `SoundContext` alive as long as you want to use
sounds.
* Note that this does not apply to `SoundData`, which can be created independently of `SoundContext`.
* Sound has a dependency to the `SoundData` that is passed in the constructor. You need to keep the `SoundData` alive as
long as any `Sound` might access it.
* You can bundle `SoundData` and `Sound` together in your implementation.
* Alternatively you can write your own `SoundDataManager` to avoid creating multiple `SoundData`s for the same file.
* Your sound will stop after some seconds, even if the audio file contains a longer sound. `Sound`s do not update
themselves. You need to call `update()` regularly.How to include OpenALpp in your project
---------------------------------------CMakeLists.txt
```
FetchContent_Declare(
openalpp
GIT_REPOSITORY https://github.com/Laguna1989/OpenALpp.git
GIT_TAG master
)FetchContent_MakeAvailable(openalpp)
add_executable(MyProject main.cpp)
target_link_libraries(MyProject OpenALpp_Lib)
```CMake Options
-------------* `OALPP_ENABLE_UNIT_TESTS` - Enable unit tests - default `ON`
* `OALPP_ENABLE_APPROVAL_TESTS` - Enable approval tests - default `ON`
* `OALPP_ENABLE_INTEGRATION_TESTS` - Enable integration test - default `ON`
* `OALPP_STATIC_LIBRARY` - Build OpenALpp and dependencies as static library - default `ON`Compiler compatibility
----------------------* Microsoft Visual C++ 2019
* clang++ from version 8
* g++ from version 9
* emscripten g++ version 9Dependencies
------------* CMake 3.19
* One of the compatible compilersAll other dependencies (`openal-soft` and `libnyquist`) are automatically fetched via CMake.