X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world_audio.h;h=07d66d1cc300a2daca4a6df3d3962c62a35f3355;hb=8d336ea2cde7c596296dbaf0d3ce27a82c6c6cf0;hp=e6ee331a8ee1267e91c6194e750e441008de4b89;hpb=5f4eb3866525724188461589485ac1aa50d08870;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world_audio.h b/world_audio.h index e6ee331..07d66d1 100644 --- a/world_audio.h +++ b/world_audio.h @@ -1,105 +1,7 @@ -#ifndef WORLD_AUDIO_H -#define WORLD_AUDIO_H +#pragma once +#include "world.h" -#include "common.h" -#include "audio.h" - -sfx_set audio_birds = -{ - .sources = "sound/bird0.ogg\0" - "sound/bird1.ogg\0" - "sound/bird2.ogg\0" -}; - -static float k_audio_random_freq = 1.0f/10.0f, - k_audio_random_hz = 1.0f; - -static double world_audio_last_tick = 0.0; - -static struct world_ambient_layer -{ - sfx_system sys; - v3f pos; -} -world_ambient_layers[8]; - -static void world_audio_init(void) -{ - sfx_set_init( &audio_birds, NULL ); - - vg_convar_push( (struct vg_convar){ - .name = "aud_random_freq", - .data = &k_audio_random_freq, - .data_type = k_convar_dtype_f32, - .opt_f32 = { .clamp = 0 }, - .persistent = 1 - }); - - for( int i=0; isys; - sys->vol = 1.0f; - sys->ch = 1; - sys->vol_src = &audio_vol_all; - sys->name = "ambient"; - sys->flags = SFX_FLAG_PERSISTENT; - } -} - -static void world_audio_spawn_random( v3f around ) -{ - for( int i=0; isys.is_playing ) - { - sfx_set_playrnd( &audio_birds, &layer->sys, 0, 3 ); - - v3f chance; - vg_rand_sphere( chance ); - v3_muladds( around, chance, 100.0f, layer->pos ); - - return; - } - } -} - -static void world_audio_update( v3f around, v3f ears ) -{ - if( world_audio_last_tick + (double)k_audio_random_hz < vg_time ) - { - world_audio_last_tick = vg_time; - - float chance = vg_randf(); - if( chance < k_audio_random_freq ) - { - world_audio_spawn_random( around ); - } - } - - /* Spacialize */ - for( int i=0; isys.is_playing ) - audio_spacialize( &layer->sys, layer->pos, around, ears, 30.0f ); - } -} - -static void world_audio_debug(void) -{ - for( int i=0; isys.is_playing ) - { - vg_line_pt3( layer->pos, 1.0f, 0xffff00ff ); - } - } -} - -#endif /* WORLD_AUDIO_H */ +void world_fadeout_audio( world_instance *world ); +void world_audio_sample_distances( v3f co, int *index, float *value ); +enum audio_sprite_type +world_audio_sample_sprite_random( v3f origin, v3f output );