From e6392c0ba7d2848888df11b831cb44863740dddc Mon Sep 17 00:00:00 2001 From: David Reid Date: Sat, 5 Sep 2020 10:15:06 +1000 Subject: [PATCH] Add hello world example for engine. --- research/_examples/engine_hello_world.c | 34 +++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 research/_examples/engine_hello_world.c diff --git a/research/_examples/engine_hello_world.c b/research/_examples/engine_hello_world.c new file mode 100644 index 00000000..224fc54b --- /dev/null +++ b/research/_examples/engine_hello_world.c @@ -0,0 +1,34 @@ +/* +This example demonstrates how to initialize an audio engine and play a sound. + +This will play the sound specified on the command line. +*/ +#define MINIAUDIO_IMPLEMENTATION +#include "../../miniaudio.h" +#include "../miniaudio_engine.h" + +int main(int argc, char** argv) +{ + ma_result result; + ma_engine engine; + + if (argc < 2) { + printf("No input file."); + return -1; + } + + result = ma_engine_init(NULL, &engine); + if (result != MA_SUCCESS) { + printf("Failed to initialize audio engine."); + return -1; + } + + ma_engine_play_sound(&engine, argv[1], NULL); + + printf("Press Enter to quit..."); + getchar(); + + ma_engine_uninit(&engine); + + return 0; +}