X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=audio.h;h=212ed9f19d8231a13e004122d5c5b7a39d8ae994;hb=5f4eb3866525724188461589485ac1aa50d08870;hp=0572d6dcf52b623fc7a3f313c370e0d70e0f4d7c;hpb=d4746875c05dd3e077e1b266e50ffe4856b45502;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/audio.h b/audio.h index 0572d6d..212ed9f 100644 --- a/audio.h +++ b/audio.h @@ -1,7 +1,10 @@ +#include "common.h" +static void audio_spacialize( sfx_system *sys, + v3f pos, v3f camera, v3f ears, float vol ); + #ifndef AUDIO_H #define AUDIO_H -#include "common.h" #include "world.h" static float audio_occlusion_current = 0.0f, @@ -9,8 +12,6 @@ static float audio_occlusion_current = 0.0f, static int k_audio_debug_soundscape = 0; -sfx_vol_control audio_vol_all = { .val = 1.0f, .name = "All" }; - sfx_set audio_board = { .sources = "sound/skate.ogg\0" @@ -85,6 +86,21 @@ static void audio_free(void) sfx_set_free( &audio_board ); } +static void audio_spacialize( sfx_system *sys, + v3f pos, v3f camera, v3f ears, float vol ) +{ + float attn = (v3_dist( pos, camera ) / vol) +1.0f; + + v3f delta; + v3_sub( pos, camera, delta ); + v3_normalize( delta ); + + float pan = v3_dot( ears, delta ); + + sys->vol = 1.0f/(attn*attn); + sys->pan = pan; +} + static void audio_sample_occlusion( v3f origin ) { float d = 0.0f, @@ -95,14 +111,7 @@ static void audio_sample_occlusion( v3f origin ) for( int i=0; i