medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 5cf6f34a70e3297c9eed22ac6291559b8e4a0244
parent 17e6e5f68c9b1982d10df8789edec98bd53e4412
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sun Jan 31 11:26:23 +0000

Add test_audio so the sound binary works

Diffstat:
test_audio.cc | 41+++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+), 0 deletions(-)
diff --git a/test_audio.cc b/test_audio.cc @@ -0,0 +1,41 @@ +#include <unistd.h> +#include <math.h> + +#include "platform_opengl.h" + +#include "game.h" +#include "wave.h" +#include "audio.h" +#include "platform_thread.h" + +static float t = 0.0f; + +static u8 audio_memory[ megabytes( 64 ) ]; +static MemoryArena audio_arena; +static Thread audio_thread; + +extern "C" GAME_INIT( game_init ) { + memarena_init( &audio_arena, audio_memory, sizeof( audio_memory ) ); + audio_init( &audio_arena ); + + u8 * wave = file_get_contents( "02 - Unbreakable.wav" ); + SoundData sound; + bool ok = wave_decode( &audio_arena, wave, &sound ); + assert( ok ); + + // Sound * sin_wave = make_sin_wave( sound.sample_rate, 200 ); + + audio_play_sound( &audio_arena, sound ); + // audio_play_sound( &audio_arena, *sin_wave, true ); + + // thread_init( &audio_thread, mixer, &audio_arena ); +} + +extern "C" GAME_FRAME( game_frame ) { + t += dt; + + glClearColor( sinf( t ), sinf( t ), sinf( t ), 1 ); + glClear( GL_COLOR_BUFFER_BIT ); + + usleep( 200000 ); +}