aboutsummaryrefslogtreecommitdiff
path: root/src/example/audio_internal.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-04 08:28:18 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-04 08:28:18 +0100
commit06f65659fc6ffde7cabd2135040cbfbf089e5a24 (patch)
treee3570bea52b87b6919550ee81d17927ccbc11cc5 /src/example/audio_internal.cpp
parent128969619a22dfc17a9ea35335c0d21c6ad0c954 (diff)
parent6aa8fdd04728b6a499f526de727514ae3d0490b4 (diff)
merge `origin/master` into `master`
Diffstat (limited to 'src/example/audio_internal.cpp')
-rw-r--r--src/example/audio_internal.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/example/audio_internal.cpp b/src/example/audio_internal.cpp
index 1199e2d..f35ad9d 100644
--- a/src/example/audio_internal.cpp
+++ b/src/example/audio_internal.cpp
@@ -5,26 +5,40 @@
#include <crepe/Sound.h>
#include <crepe/util/log.h>
+#include <crepe/api/Config.h>
-#include <chrono>
#include <thread>
using namespace crepe;
+using namespace crepe::api;
using namespace std;
using namespace std::chrono_literals;
using std::make_unique;
-int main() {
- dbg_trace();
+// Unrelated stuff that is not part of this POC
+int _ = [] () {
+ // Show dbg_trace() output
+ auto & cfg = api::Config::get_instance();
+ cfg.log.level = util::LogLevel::TRACE;
+
+ return 0; // satisfy compiler
+}();
+
+
+int main() {
+ // Load a background track (Ogg Vorbis)
auto bgm = Sound("../mwe/audio/bgm.ogg");
+ // 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");
+ // Start the background track
bgm.play();
- // play each sample sequentially
+ // Play each sample sequentially while pausing and resuming the background
+ // track
this_thread::sleep_for(500ms);
sfx1.play();
this_thread::sleep_for(500ms);
@@ -35,11 +49,12 @@ int main() {
bgm.play();
this_thread::sleep_for(500ms);
- // play all samples simultaniously
+ // Play all samples simultaniously
sfx1.play();
sfx2.play();
sfx3.play();
this_thread::sleep_for(1000ms);
- return 0;
+ // Stop all audio and exit
+ return EXIT_SUCCESS;
}