diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-14 13:57:13 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-14 13:57:13 +0100 |
commit | 07adbf48e0781cd8c95983c1871a84b6160ee5bf (patch) | |
tree | e3a55673b20ebaa3baec6665c107c177bd59ff14 /src/example/audio_internal.cpp | |
parent | 01c09a196c3f3e5cefaa4119a95a1cdeb7b9c263 (diff) |
implement asset + more WIP audio system
Diffstat (limited to 'src/example/audio_internal.cpp')
-rw-r--r-- | src/example/audio_internal.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/example/audio_internal.cpp b/src/example/audio_internal.cpp index ff55a59..9b60e6b 100644 --- a/src/example/audio_internal.cpp +++ b/src/example/audio_internal.cpp @@ -4,7 +4,9 @@ */ #include <crepe/api/Config.h> +#include <crepe/facade/SoundContext.h> #include <crepe/facade/Sound.h> +#include <crepe/Asset.h> #include <crepe/util/Log.h> #include <thread> @@ -24,12 +26,18 @@ int _ = []() { }(); int main() { + SoundContext ctx{}; + Sound sound{ctx}; // Load a background track (Ogg Vorbis) - auto bgm = Sound("../mwe/audio/bgm.ogg"); + auto _bgm = sound.clone(Asset{"mwe/audio/bgm.ogg"}); + Sound & bgm = *dynamic_cast<Sound *>(_bgm.get()); // Load three short samples (WAV) - auto sfx1 = Sound("../mwe/audio/sfx1.wav"); - auto sfx2 = Sound("../mwe/audio/sfx2.wav"); - auto sfx3 = Sound("../mwe/audio/sfx3.wav"); + auto _sfx1 = sound.clone(Asset{"mwe/audio/sfx1.wav"}); + Sound & sfx1 = *dynamic_cast<Sound *>(_sfx1.get()); + auto _sfx2 = sound.clone(Asset{"mwe/audio/sfx2.wav"}); + Sound & sfx2 = *dynamic_cast<Sound *>(_sfx2.get()); + auto _sfx3 = sound.clone(Asset{"mwe/audio/sfx3.wav"}); + Sound & sfx3 = *dynamic_cast<Sound *>(_sfx3.get()); // Start the background track bgm.play(); |