|
Untitled
|
Audio probe baking, portal creation, probe volumes, and emitter functions. More...
#include "audio/audio.h"#include "SDL2/SDL_mutex.h"#include "SDL2/SDL_thread.h"#include "core/camera.h"#include "load/init.h"#include "utilities/mathf.h"#include "miniaudio/miniaudio.h"#include "render/render.h"#include <string.h>#include "core/engine_types.h"#include "core/acceleration.h"#include "utilities/engine_utilities.h"#include "fftw3.h"#include <math.h>#include "audio/audio_ir.h"#include "utilities/utilities.h"#include <stdatomic.h>#include <stddef.h>#include <stdio.h>Go to the source code of this file.
Macros | |
| #define | SAMPLE_IDX(i, sh, b) |
| #define | Y_00 0.28209479177387814f |
| #define | APORTAL_VISIBILITY_RADIUS 1.0f |
Functions | |
| void | heap_swap (OpenNode *a, OpenNode *b) |
| Swaps A and B. | |
| void | heap_push (Vector *h) |
| After a node has been pushed to the top of the stack, we reorder by f score. | |
| OpenNode | heap_pop (Vector *h) |
| Pops the bottommost root off of the OpenNode Vector and then places the topmost node onto the bottom and resorts. | |
| void | reconstruct_path_aportal (AStarWorkspace *WS, int start, int end) |
| Traverses the AStarStateStack and backtracks to find the entire path. | |
| int | a_star_aportal (AStarWorkspace *WS, int start, int end) |
| Conducts AStar between a start and end point in AudioPortals. | |
| float | calculate_path_volume_equal_power (float path_distance, float min_distance, float max_distance) |
| Calculates volume over a path. | |
| bool | pathfind_audio_occlusion (vec3 listener_pos, int closest_l, vec3 emitter_pos, vec3 *out_pos, float *out_volume, float *distance) |
| Finds closest AudioPortal to the AudioEmitter and calls AStar to pathfind, then calulcates the volume. | |
| vec3 | pos_to_pv_local (OBB *obb, vec3 pos) |
| Converts a position to local OBB space. | |
| int | query_probe_volume (vec3 pos) |
| Checks which ProbeVolume a position is inside. | |
| void | remove_audio_pv (APV *apv, bool *apb) |
| Frees an APV from its slot. | |
| void | load_audio_pv (APV *apv, ProbeVolume *pv) |
| Loads an APV into a slot. | |
| void | interpolate_nearest_aprobes (vec3 pos, AudioProbeWeights *out_w) |
| Interpolates between 4 closest AudioProbes within one singular ProbeVolume and weighs them based on distance. | |
| float | process_biquad (Biquad *filter, float in_sample) |
| Processes a biquad filter over a sample. | |
| void | init_bandpass (Biquad *filter, float sample_rate, float center_freq, float q) |
| Initializes a bandpass filter for the synthetic IR. | |
| void | generate_synthetic_IR_tail (float *out_tail, float fade_start, AudioProbe *probe, float rms) |
| Generates a synthetic IR tail for a given AudioProbe based on its RT60. | |
| void | compute_schroeder_edc (float *energy_histogram, float *edc_out) |
| Generates an Energy Decay Curve for input IR samples. | |
| float | extract_rms (AudioProbe *probe, int fade_start, int window_size) |
| Extracts the RMS from a certain sample range before the synthetic IR. | |
| void | extract_t60 (float *edc_db, AudioProbe *probe, int band, float bin_duration_seconds, int last_sample) |
| Extracts the RT60 from an EDC for computing a synthetic IR. | |
| void | process_probe_chunk (int start, int count) |
| Path traces from AudioProbes within a certain chunk of a ProbeVolume and processes samples per AudioProbe, forming a synthetic IR from the RT60. | |
| void | recalculate_audio_portal_paths () |
| Recalculates the adjacency map of portals between each other. | |
| int | find_closest_visible_aportal (vec3 pos) |
| Finds the closest audio portal for a star to travel through. | |
| void | init_new_audio_portal (vec3 pos) |
| Creates an audio portal by expanding the vector. | |
| void | remove_audio_portal (int id) |
| Removes an audio portal from the vector. | |
| void | load_emitter (AudioEmitter *emitter, const char *filepath, bool is_loop, bool is_occludable, float base_volume) |
| Loads an existing emitter into miniaudio. | |
| AudioEmitter * | init_emitter (const char *filepath, bool is_loop, bool is_occludable, float base_volume) |
| Initialized an audio emitter and sets up its audio object in miniaudio. | |
| void | unload_emitter (int id) |
| Unloads an emitter from miniaudio. | |
| void | destroy_emitter (int id) |
| Unloads an emitter from miniaudio and frees the emitter as well. | |
| void | play_emitter (AudioEmitter *emitter, vec3 pos) |
| Starts playing an emitter. | |
| void | end_emitter (AudioEmitter *e) |
| Stops playing an emitter. | |
| void | audio_update (Player *player) |
| Spatializes the audio from the player's position. | |
| void | SDLAudioCallback (void *pUserData, Uint8 *pStream, int len) |
| Passes frames to miniaudio in the audio thread. | |
| int | query_audio_probe (ProbeVolume *pv, vec3 pos, ivec3 *out_local) |
| Queries which audio probe is closest to given position. | |
| void | reset_audio_pvs () |
| Reset audio pvs, frees each slot in the global audio pv slots. | |
| void | check_audio_pv () |
| Finds the closest audio PVs to the player and loads the closest ones into open slots based on distance. | |
| void | update_player_audio_probe () |
| Determines if a new IR needs to be signaled from the background thread. | |
| void | bake_audio_probe_volume (ProbeVolume *pv) |
| Bakes an audio probe volume. | |
| void | update_audio_occlusion (Player *player) |
| Raycasts from player to audio sources to determine occlusion and performs a star if necessary. | |
| void | init_normalized_lpf (float cutoff_hz, float sample_rate, float *out_kernel) |
| void | init_band_kernels (float sample_rate, float f1_hz, float f2_hz, float f3_hz, float f4_hz, float f5_hz, float out_kernels[6][31]) |
Variables | |
| float | BAND_IMPULSES [6][31] |
Audio probe baking, portal creation, probe volumes, and emitter functions.
Definition in file audio.c.
| #define SAMPLE_IDX | ( | i, | |
| sh, | |||
| b ) |
Definition at line 412 of file audio.c.
Referenced by process_probe_chunk().
| #define Y_00 0.28209479177387814f |
Definition at line 415 of file audio.c.
Referenced by process_probe_chunk().
| void init_normalized_lpf | ( | float | cutoff_hz, |
| float | sample_rate, | ||
| float * | out_kernel ) |
<Frequency kernel size for distributing samples during audio bake
<Center of the kernel for distributing samples during audio bake
<Frequency kernel size for distributing samples during audio bake
<Frequency kernel size for distributing samples during audio bake
Definition at line 1849 of file audio.c.
References AUDIO_KERNEL_CENTER, AUDIO_KERNEL_SIZE, init_normalized_lpf(), M_PI, and n.
Referenced by init_band_kernels(), and init_normalized_lpf().
| void init_band_kernels | ( | float | sample_rate, |
| float | f1_hz, | ||
| float | f2_hz, | ||
| float | f3_hz, | ||
| float | f4_hz, | ||
| float | f5_hz, | ||
| float | out_kernels[6/**< The amount of bands to use for audio probe baking */][31/**< Frequency kernel size for distributing samples during audio bake */] ) |
<Frequency kernel size for distributing samples during audio bake
<Frequency kernel size for distributing samples during audio bake
<Frequency kernel size for distributing samples during audio bake
<Frequency kernel size for distributing samples during audio bake
<Frequency kernel size for distributing samples during audio bake
<Frequency kernel size for distributing samples during audio bake
<Center of the kernel for distributing samples during audio bake
Definition at line 1881 of file audio.c.
References AUDIO_KERNEL_CENTER, AUDIO_KERNEL_SIZE, AUDIO_NUM_BANDS, init_band_kernels(), init_normalized_lpf(), and n.
Referenced by init(), init_band_kernels(), and init_band_kernels().
| float BAND_IMPULSES[6][31] |
Definition at line 28 of file audio.c.
Referenced by init(), and process_probe_chunk().