test_audio.cc (948B)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #include <unistd.h> #include <math.h> #include "glad.h" #include "game.h" #include "wave.h" #include "log.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 ); } |