diff --git a/docs/pages/3_examples/2_engine/main.md b/docs/pages/3_examples/2_engine/main.md index 7762defe4b..2cff5fd327 100644 --- a/docs/pages/3_examples/2_engine/main.md +++ b/docs/pages/3_examples/2_engine/main.md @@ -16,3 +16,4 @@ multiple plugins of the engine: - @subpage examples-engine-events - @copybrief examples-engine-events - @subpage examples-engine-voxels - @copybrief examples-engine-voxels - @subpage examples-engine-imgui - @copybrief examples-engine-imgui +- @subpage examples-engine-audio - @copybrief examples-engine-audio diff --git a/engine/samples/audio/main.cpp b/engine/samples/audio/main.cpp index ac406cba8c..efc6978a52 100644 --- a/engine/samples/audio/main.cpp +++ b/engine/samples/audio/main.cpp @@ -52,13 +52,16 @@ int main(int argc, char** argv) input.bind(*bindings); }); + /// [Adding an AudioListener] cubos.startupSystem("create a camera").call([](Commands cmds) { cmds.create() .add(Position{{0.0F, 0.0F, 0.0F}}) .add(Rotation::lookingAt({-1.0F, -1.0F, -1.0F}, glm::vec3{0.0F, 1.0F, 0.0F})) .add(AudioListener{true}); }); + /// [Adding an AudioListener] + /// [Adding the AudioSource] cubos.startupSystem("create an audio source").after(audioStateInitTag).call([](Commands cmds) { cmds.create() .add(Position{{0.0F, 0.0F, 0.0F}}) @@ -66,16 +69,20 @@ int main(int argc, char** argv) .add(Rotation::lookingAt({-1.0F, -1.0F, -1.0F}, glm::vec3{0.0F, 1.0F, 0.0F})) .add(AudioSource{}); }); + /// [Adding the AudioSource] cubos.system("play audio").call([&currAsset](Input& input, Commands cmds, Query query) { for (auto [ent, src] : query) { + /// [Adding the asset] if (src.sound.isNull()) { src.sound = AudioAssets[0]; cmds.add(ent, AudioPlay{}); } + /// [Adding the asset] + /// [Manipulating audio assets] if (input.justPressed("skip")) { CUBOS_INFO("SKIP: {}", src.sound.getIdString()); @@ -102,6 +109,7 @@ int main(int argc, char** argv) cmds.add(ent, AudioStop{}); CUBOS_INFO("STOPPING: {}", src.sound.getIdString()); } + /// [Manipulating audio assets] } }); diff --git a/engine/samples/audio/page.md b/engine/samples/audio/page.md index d380c64456..5227b82ed5 100644 --- a/engine/samples/audio/page.md +++ b/engine/samples/audio/page.md @@ -1,4 +1,4 @@ -# Audio {#examples-audio-sample} +# Audio {#examples-engine-audio} @brief Using the @ref audio-plugin plugin