X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=audio.h;h=4b57a7998a13d4705284bc961c2dcf858f12b571;hb=4eccfd7252f8ff165670842df537441afae5458b;hp=0572d6dcf52b623fc7a3f313c370e0d70e0f4d7c;hpb=d4746875c05dd3e077e1b266e50ffe4856b45502;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/audio.h b/audio.h index 0572d6d..4b57a79 100644 --- a/audio.h +++ b/audio.h @@ -1,149 +1,58 @@ -#ifndef AUDIO_H -#define AUDIO_H +/* + * Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved + */ -#include "common.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_vol_control audio_vol_all = { .val = 1.0f, .name = "All" }; - -sfx_set audio_board = -{ - .sources = "sound/skate.ogg\0" - "sound/wheel.ogg\0" - "sound/slide.ogg\0" - "sound/reverb.ogg\0" -}; - -sfx_system audio_player0 = -{ - .vol = 0.0f, - .ch = 1, - .vol_src = &audio_vol_all, - .name = "Player0", - .flags = SFX_FLAG_REPEAT | SFX_FLAG_PERSISTENT -}; - -sfx_system audio_player1 = -{ - .vol = 0.0f, - .ch = 1, - .vol_src = &audio_vol_all, - .name = "Player1", - .flags = SFX_FLAG_REPEAT | SFX_FLAG_PERSISTENT -}; - -sfx_system audio_player2 = -{ - .vol = 0.0f, - .ch = 1, - .vol_src = &audio_vol_all, - .name = "Player2", - .flags = SFX_FLAG_REPEAT | SFX_FLAG_PERSISTENT -}; - -sfx_system audio_player3 = -{ - .vol = 0.0f, - .ch = 1, - .vol_src = &audio_vol_all, - .name = "Player3", - .flags = SFX_FLAG_REPEAT | SFX_FLAG_PERSISTENT -}; - -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 ); +#pragma once - 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 - }); -} - -static void audio_free(void) -{ - sfx_set_free( &audio_board ); -} - -static void audio_sample_occlusion( v3f origin ) -{ - float d = 0.0f, - sample_dist = 880.0f; - - int sample_count = 8; - - for( int i=0; i