From 3d14495921a34b8716c66b9cba831afab8e2a4a5 Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 9 Jan 2016 11:44:59 +0100 Subject: [PATCH] Created Use audio module as standalone library (markdown) --- Use-audio-module-as-standalone-library.md | 74 +++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 Use-audio-module-as-standalone-library.md diff --git a/Use-audio-module-as-standalone-library.md b/Use-audio-module-as-standalone-library.md new file mode 100644 index 0000000..2d724bd --- /dev/null +++ b/Use-audio-module-as-standalone-library.md @@ -0,0 +1,74 @@ +raylib audio module can be used as standalone library + +```c +/******************************************************************************************* +* +* raylib audio module as standalone library sample +* +* NOTE: Sample dependencies: +* stb_vorbis - To load OGG data +* +* raylib audio module is distributed with raylib 1.3 (www.raylib.com) +* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) +* +* Copyright (c) 2015 Ramon Santamaria (@raysan5) +* +********************************************************************************************/ + +#include +#include // Windows only, no stardard library + +#include "audio.h" + +#define KEY_ESCAPE 27 + +int main() +{ + // Initialization + //-------------------------------------------------------------------------------------- + unsigned char key; + + InitAudioDevice(); + + Sound fxWav = LoadSound("resources/weird.wav"); // Load WAV audio file + Sound fxOgg = LoadSound("resources/tanana.ogg"); // Load OGG audio file + + PlayMusicStream("resources/ambient.ogg"); + + printf("\nPress s or d to play sounds...\n"); + //-------------------------------------------------------------------------------------- + + while (key != KEY_ESCAPE) + { + // Update + //---------------------------------------------------------------------------------- + if (kbhit()) key = getch(); + + if (key == 's') PlaySound(fxWav); + if (key == 'd') PlaySound(fxOgg); + + key = 0; + + UpdateMusicStream(); + //-------------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + // TODO: Something to draw? + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + UnloadSound(fxWav); // Unload sound data + UnloadSound(fxOgg); // Unload sound data + + CloseAudioDevice(); + //-------------------------------------------------------------------------------------- + + printf("\n\nPress ENTER to close..."); + getchar(); + + return 0; +} +``` \ No newline at end of file