X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=audio.h;h=51445b665b6edfc70e49a8d247e326bf90be157a;hb=8c376ed2e4021a18b0a6c6e800109d67ad09d198;hp=212ed9f19d8231a13e004122d5c5b7a39d8ae994;hpb=5f4eb3866525724188461589485ac1aa50d08870;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/audio.h b/audio.h index 212ed9f..51445b6 100644 --- a/audio.h +++ b/audio.h @@ -1,158 +1,213 @@ +/* + * Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved + */ + #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 "world.h" -static float audio_occlusion_current = 0.0f, - k_audio_occlusion_rate = 1.0f; - -static int k_audio_debug_soundscape = 0; - -sfx_set audio_board = +audio_clip audio_board[] = { - .sources = "sound/skate.ogg\0" - "sound/wheel.ogg\0" - "sound/slide.ogg\0" - "sound/reverb.ogg\0" + { .path="sound/skate_hpf.ogg" }, + { .path="sound/wheel.ogg" }, + { .path="sound/slide.ogg" }, + { .path="sound/grind_enter.ogg" }, + { .path="sound/grind_exit.ogg" }, + { .path="sound/grind_loop.ogg" }, + { .path="sound/woodslide.ogg" }, + { .path="sound/metalscrape.ogg" }, + { .path="sound/slidetap.ogg" } }; -sfx_system audio_player0 = +audio_clip audio_taps[] = { - .vol = 0.0f, - .ch = 1, - .vol_src = &audio_vol_all, - .name = "Player0", - .flags = SFX_FLAG_REPEAT | SFX_FLAG_PERSISTENT + { .path="sound/tap0.ogg" }, + { .path="sound/tap1.ogg" }, + { .path="sound/tap2.ogg" }, + { .path="sound/tap3.ogg" } }; -sfx_system audio_player1 = +audio_clip audio_hits[] = { - .vol = 0.0f, - .ch = 1, - .vol_src = &audio_vol_all, - .name = "Player1", - .flags = SFX_FLAG_REPEAT | SFX_FLAG_PERSISTENT + { .path="sound/hit0.ogg" }, + { .path="sound/hit1.ogg" }, + { .path="sound/hit2.ogg" }, + { .path="sound/hit3.ogg" }, + { .path="sound/hit4.ogg" } }; -sfx_system audio_player2 = -{ - .vol = 0.0f, - .ch = 1, - .vol_src = &audio_vol_all, - .name = "Player2", - .flags = SFX_FLAG_REPEAT | SFX_FLAG_PERSISTENT +audio_clip audio_splash = +{ .path = "sound/splash.ogg" }; + +audio_clip audio_jumps[] = { + { .path = "sound/jump0.ogg" }, + { .path = "sound/jump1.ogg" }, }; -sfx_system audio_player3 = -{ - .vol = 0.0f, - .ch = 1, - .vol_src = &audio_vol_all, - .name = "Player3", - .flags = SFX_FLAG_REPEAT | SFX_FLAG_PERSISTENT +audio_clip audio_footsteps[] = { + {.path = "sound/step_concrete0.ogg" }, + {.path = "sound/step_concrete1.ogg" }, + {.path = "sound/step_concrete2.ogg" }, + {.path = "sound/step_concrete3.ogg" } }; -static void audio_init(void) -{ - sfx_set_init( &audio_board, NULL ); - sfx_set_play( &audio_board, &audio_player0, 0 ); - sfx_set_play( &audio_board, &audio_player1, 1 ); - sfx_set_play( &audio_board, &audio_player2, 2 ); - sfx_set_play( &audio_board, &audio_player3, 3 ); - - vg_convar_push( (struct vg_convar){ - .name = "aud_debug_soundscape", - .data = &k_audio_debug_soundscape, - .data_type = k_convar_dtype_i32, - .opt_i32 = { .min=0, .max=1, .clamp=0 }, - .persistent = 1 - }); - - vg_convar_push( (struct vg_convar){ - .name = "aud_occlusion_rate", - .data = &k_audio_occlusion_rate, - .data_type = k_convar_dtype_f32, - .opt_f32 = { .clamp = 0 }, - .persistent = 1 - }); -} +audio_clip audio_footsteps_grass[] = { + {.path = "sound/step_bush0.ogg" }, + {.path = "sound/step_bush1.ogg" }, + {.path = "sound/step_bush2.ogg" }, + {.path = "sound/step_bush3.ogg" }, + {.path = "sound/step_bush4.ogg" }, + {.path = "sound/step_bush5.ogg" } +}; -static void audio_free(void) -{ - sfx_set_free( &audio_board ); -} +audio_clip audio_footsteps_wood[] = { + {.path = "sound/step_wood0.ogg" }, + {.path = "sound/step_wood1.ogg" }, + {.path = "sound/step_wood2.ogg" }, + {.path = "sound/step_wood3.ogg" }, + {.path = "sound/step_wood4.ogg" }, + {.path = "sound/step_wood5.ogg" } +}; -static void audio_spacialize( sfx_system *sys, - v3f pos, v3f camera, v3f ears, float vol ) -{ - float attn = (v3_dist( pos, camera ) / vol) +1.0f; +audio_clip audio_lands[] = { + { .path = "sound/land0.ogg" }, + { .path = "sound/land1.ogg" }, + { .path = "sound/land2.ogg" }, + { .path = "sound/landsk0.ogg" }, + { .path = "sound/landsk1.ogg" }, + { .path = "sound/onto.ogg" }, + { .path = "sound/outo.ogg" }, +}; - v3f delta; - v3_sub( pos, camera, delta ); - v3_normalize( delta ); - - float pan = v3_dot( ears, delta ); +audio_clip audio_water[] = { + { .path = "sound/wave0.ogg" }, + { .path = "sound/wave1.ogg" }, + { .path = "sound/wave2.ogg" }, + { .path = "sound/wave3.ogg" }, + { .path = "sound/wave4.ogg" }, + { .path = "sound/wave5.ogg" } +}; - sys->vol = 1.0f/(attn*attn); - sys->pan = pan; -} +audio_clip audio_grass[] = { + { .path = "sound/grass0.ogg" }, + { .path = "sound/grass1.ogg" }, + { .path = "sound/grass2.ogg" }, + { .path = "sound/grass3.ogg" }, +}; -static void audio_sample_occlusion( v3f origin ) +audio_clip audio_ambience[] = { - float d = 0.0f, - sample_dist = 880.0f; + { .path="sound/town_generic.ogg" } +}; - int sample_count = 8; +audio_clip audio_gate_pass = { + .path = "sound/gate_pass.ogg" +}; - for( int i=0; i 0.1f ) + accum -= 0.1f; + else return; - gui_fill_rect( ui_global_ctx.cursor, 0x55cccccc ); - gui_text( ui_global_ctx.cursor, buf, 1, 0 ); + v3f sprite_pos; + enum audio_sprite_type sprite_type = + world_audio_sample_sprite_random( co, sprite_pos ); + + if( sprite_type != k_audio_sprite_type_none ){ + if( sprite_type == k_audio_sprite_type_grass ){ + audio_ambient_sprite_play( sprite_pos, &audio_grass[rand()%4] ); + } + else if( sprite_type == k_audio_sprite_type_water ){ + if( world->water.enabled ) + audio_ambient_sprite_play( sprite_pos, &audio_water[rand()%6] ); + } + } } #endif /* AUDIO_H */