aboutsummaryrefslogtreecommitdiff
path: root/src/example
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-05 14:16:57 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-05 14:16:57 +0200
commitf4bb6d57cc88a7e25b3a5f43faafa49a7f500b7c (patch)
treebe9be8157c10599f572d20113795dc14c620a292 /src/example
parent65eda52aa51017f6f7aad158c4f8b6e91054cf0d (diff)
restructure unit tests and dummies
Diffstat (limited to 'src/example')
-rw-r--r--src/example/CMakeLists.txt3
-rw-r--r--src/example/audio_internal.cpp46
2 files changed, 49 insertions, 0 deletions
diff --git a/src/example/CMakeLists.txt b/src/example/CMakeLists.txt
new file mode 100644
index 0000000..bcc9271
--- /dev/null
+++ b/src/example/CMakeLists.txt
@@ -0,0 +1,3 @@
+add_executable(audio_internal EXCLUDE_FROM_ALL audio_internal.cpp)
+target_link_libraries(audio_internal PUBLIC crepe)
+
diff --git a/src/example/audio_internal.cpp b/src/example/audio_internal.cpp
new file mode 100644
index 0000000..09bd55c
--- /dev/null
+++ b/src/example/audio_internal.cpp
@@ -0,0 +1,46 @@
+/** \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;
+}
+