#ifndef WORLD_AUDIO_H
#define WORLD_AUDIO_H
-#include "common.h"
-#include "audio.h"
+#include "world.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; i<vg_list_size(world_ambient_layers); i++ )
- {
- struct world_ambient_layer *layer = &world_ambient_layers[i];
- sfx_system *sys = &layer->sys;
- 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; i<vg_list_size(world_ambient_layers); i++ )
- {
- struct world_ambient_layer *layer = &world_ambient_layers[i];
-
- if( !layer->sys.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; i<vg_list_size(world_ambient_layers); i++ )
- {
- struct world_ambient_layer *layer = &world_ambient_layers[i];
-
- if( layer->sys.is_playing )
- audio_spacialize( &layer->sys, layer->pos, around, ears, 30.0f );
- }
-}
-
-static void world_audio_debug(void)
-{
- for( int i=0; i<vg_list_size(world_ambient_layers); i++ )
- {
- struct world_ambient_layer *layer = &world_ambient_layers[i];
-
- if( layer->sys.is_playing )
- {
- vg_line_pt3( layer->pos, 1.0f, 0xffff00ff );
- }
- }
-}
+VG_STATIC void world_fadeout_audio( world_instance *world );
+VG_STATIC void world_audio_sample_distances( v3f co, int *index, float *value );
+VG_STATIC enum audio_sprite_type world_audio_sample_sprite_random( v3f origin,
+ v3f output );
#endif /* WORLD_AUDIO_H */