From a776be0bf3d8086fe550a23f13a4fefc883b38e1 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sun, 22 Feb 2026 02:35:11 +0545 Subject: [PATCH] feat(include/audio): Add sound configuration loading and extended sound pack structures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce API to load sound configurations and expand SoundPack with richer audio data for multi‑key mappings and generic press handling, enabling more flexible audio management. New Features - Added `load_sound_config` prototype in `include/audio/config.h`. Enhancements - Extended `SoundPack` with generic press arrays, release data fields, and multi‑key mapping structs. - Added `AudioVoice` struct and `MAX_MIXER_VOICES` for voice management. - Added `generic_press_data`, `generic_press_samples`, `release_data`, and `release_samples` fields. --- include/audio/config.h | 8 ++++++++ include/audio/types.h | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 include/audio/config.h diff --git a/include/audio/config.h b/include/audio/config.h new file mode 100644 index 0000000..c491826 --- /dev/null +++ b/include/audio/config.h @@ -0,0 +1,8 @@ +#ifndef VBX_AUDIO_CONFIG_H +#define VBX_AUDIO_CONFIG_H + +#include "audio/types.h" + +int load_sound_config(const char *config_path, SoundPack *pack); + +#endif // VBX_AUDIO_CONFIG_H diff --git a/include/audio/types.h b/include/audio/types.h index 743a725..ad3c0bb 100644 --- a/include/audio/types.h +++ b/include/audio/types.h @@ -8,23 +8,43 @@ typedef struct { int start_ms; int duration_ms; + short *pcm_data; + uint32_t num_samples; } SoundMapping; typedef struct { char press_file[256]; char release_file[256]; char generic_press_files[5][256]; + short *generic_press_data[5]; + uint32_t generic_press_samples[5]; int num_generic_press_files; char sound_file[256]; + short *release_data; + uint32_t release_samples; SoundMapping key_mappings[512]; struct { char *press; char *release; + short *press_data; + uint32_t press_samples; + short *release_data; + uint32_t release_samples; } multi_key_mappings[512]; int is_multi; SF_INFO sf_info; } SoundPack; +typedef struct { + short *data; + uint32_t total_samples; + uint32_t current_pos; + float volume; + int active; +} AudioVoice; + +#define MAX_MIXER_VOICES 32 + typedef struct { int key_code; int thread_id;