aboutsummaryrefslogtreecommitdiff
path: root/src/example/audio_internal.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-08 13:48:01 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-08 13:48:01 +0200
commit6b7a670d60fec808e4fd1fcf3a8df2c503dcbdf4 (patch)
treeaeb947a0001088ae2caddca85062845a276ceffb /src/example/audio_internal.cpp
parentc6cbde11c080c994577a7ebe4b966c25870dec1f (diff)
parent515aab5ab7e3281d2d77177724aae42cffc6faae (diff)
Merge branch 'loek/cleanup' of github.com:lonkaars/crepe
Diffstat (limited to 'src/example/audio_internal.cpp')
-rw-r--r--src/example/audio_internal.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/example/audio_internal.cpp b/src/example/audio_internal.cpp
new file mode 100644
index 0000000..1199e2d
--- /dev/null
+++ b/src/example/audio_internal.cpp
@@ -0,0 +1,45 @@
+/** \file
+ *
+ * Standalone example for usage of the internal \c Sound class.
+ */
+
+#include <crepe/Sound.h>
+#include <crepe/util/log.h>
+
+#include <chrono>
+#include <thread>
+
+using namespace crepe;
+using namespace std;
+using namespace std::chrono_literals;
+using std::make_unique;
+
+int main() {
+ dbg_trace();
+
+ auto bgm = Sound("../mwe/audio/bgm.ogg");
+ auto sfx1 = Sound("../mwe/audio/sfx1.wav");
+ auto sfx2 = Sound("../mwe/audio/sfx2.wav");
+ auto sfx3 = Sound("../mwe/audio/sfx3.wav");
+
+ bgm.play();
+
+ // play each sample sequentially
+ this_thread::sleep_for(500ms);
+ sfx1.play();
+ this_thread::sleep_for(500ms);
+ sfx2.play();
+ bgm.pause();
+ this_thread::sleep_for(500ms);
+ sfx3.play();
+ bgm.play();
+ this_thread::sleep_for(500ms);
+
+ // play all samples simultaniously
+ sfx1.play();
+ sfx2.play();
+ sfx3.play();
+ this_thread::sleep_for(1000ms);
+
+ return 0;
+}