From ca6a3d1148bfcbbc29183d41f5ecbf6b5383a315 Mon Sep 17 00:00:00 2001 From: ThePlayerRolo Date: Thu, 10 Jul 2025 12:36:21 -0400 Subject: [PATCH 1/7] Allocate Sequence --- autogen/lua_definitions/functions.lua | 6 ++++++ docs/lua/functions-6.md | 21 +++++++++++++++++++++ docs/lua/functions.md | 1 + src/pc/lua/smlua_functions_autogen.c | 16 ++++++++++++++++ src/pc/lua/utils/smlua_audio_utils.c | 14 ++++++++++++++ src/pc/lua/utils/smlua_audio_utils.h | 3 +++ 6 files changed, 61 insertions(+) diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index 3a09077fb..d90952d3b 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -10180,6 +10180,12 @@ function audio_sample_play(audio, position, volume) -- ... end +--- @return integer +--- Allocates an `audio` sequence +function allocate_seq() + -- ... +end + --- Resets camera config overrides function camera_reset_overrides() -- ... diff --git a/docs/lua/functions-6.md b/docs/lua/functions-6.md index 7bb215c22..ac77b3a13 100644 --- a/docs/lua/functions-6.md +++ b/docs/lua/functions-6.md @@ -1458,6 +1458,27 @@ Plays an `audio` sample at `position` with `volume`
+## [allocate_seq](#allocate_seq) + +### Description +Allocates an `audio` sequence + +### Lua Example +`local integerValue = allocate_seq()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`u32 allocate_seq(void);` + +[:arrow_up_small:](#) + +
+ --- # functions from smlua_camera_utils.h diff --git a/docs/lua/functions.md b/docs/lua/functions.md index 1f1f41c22..df13bcbde 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -1824,6 +1824,7 @@ - [audio_sample_destroy](functions-6.md#audio_sample_destroy) - [audio_sample_stop](functions-6.md#audio_sample_stop) - [audio_sample_play](functions-6.md#audio_sample_play) + - [allocate_seq](functions-6.md#allocate_seq)
diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index fdd758841..81c517d02 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -30759,6 +30759,21 @@ int smlua_func_audio_sample_play(lua_State* L) { return 1; } +int smlua_func_allocate_seq(UNUSED lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 0) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "allocate_seq", 0, top); + return 0; + } + + + lua_pushinteger(L, allocate_seq()); + + return 1; +} + ////////////////////////// // smlua_camera_utils.h // ////////////////////////// @@ -38038,6 +38053,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "audio_sample_destroy", smlua_func_audio_sample_destroy); smlua_bind_function(L, "audio_sample_stop", smlua_func_audio_sample_stop); smlua_bind_function(L, "audio_sample_play", smlua_func_audio_sample_play); + smlua_bind_function(L, "allocate_seq", smlua_func_allocate_seq); // smlua_camera_utils.h smlua_bind_function(L, "camera_reset_overrides", smlua_func_camera_reset_overrides); diff --git a/src/pc/lua/utils/smlua_audio_utils.c b/src/pc/lua/utils/smlua_audio_utils.c index 2345b0878..6067b3ea2 100644 --- a/src/pc/lua/utils/smlua_audio_utils.c +++ b/src/pc/lua/utils/smlua_audio_utils.c @@ -4,6 +4,8 @@ #define STB_VORBIS_HEADER_ONLY #include "pc/utils/stb_vorbis.c" +#define MAX_CUSTOM_SEQS 1024 + #include "types.h" #include "seq_ids.h" #include "audio/external.h" @@ -29,6 +31,8 @@ struct AudioOverride { struct AudioOverride sAudioOverrides[MAX_AUDIO_OVERRIDE] = { 0 }; +static u32 sCustomSeqsCount = 0; + static void smlua_audio_utils_reset(struct AudioOverride* override) { if (override == NULL) { return; } @@ -65,6 +69,7 @@ void smlua_audio_utils_reset_all(void) { #endif smlua_audio_utils_reset(&sAudioOverrides[i]); } + sCustomSeqsCount = 0; } bool smlua_audio_utils_override(u8 sequenceId, s32* bankId, void** seqData) { @@ -619,3 +624,12 @@ void smlua_audio_custom_deinit(void) { sModAudioPool = NULL; } } + + +u32 allocate_seq() { + if ((sCustomSeqsCount + SEQ_COUNT) < MAX_CUSTOM_SEQS) { + return (++sCustomSeqsCount + SEQ_COUNT); + } + LOG_ERROR("Cannot allocate more custom sequences."); + return 0; +} \ No newline at end of file diff --git a/src/pc/lua/utils/smlua_audio_utils.h b/src/pc/lua/utils/smlua_audio_utils.h index 4fc276548..193c0b4cd 100644 --- a/src/pc/lua/utils/smlua_audio_utils.h +++ b/src/pc/lua/utils/smlua_audio_utils.h @@ -76,4 +76,7 @@ void audio_custom_update_volume(void); void audio_custom_shutdown(void); void smlua_audio_custom_deinit(void); +/* |description|Allocates an `audio` sequence|descriptionEnd| */ +u32 allocate_seq(void); + #endif From a5dad2204cbf03c005dcfd56c2bd2ad46bd55476 Mon Sep 17 00:00:00 2001 From: ThePlayerRolo Date: Thu, 10 Jul 2025 14:13:44 -0400 Subject: [PATCH 2/7] Edit Naming To Be Consistent --- autogen/lua_definitions/functions.lua | 4 ++-- docs/lua/functions-6.md | 8 ++++---- docs/lua/functions.md | 2 +- src/pc/lua/smlua_functions_autogen.c | 8 ++++---- src/pc/lua/utils/smlua_audio_utils.c | 2 +- src/pc/lua/utils/smlua_audio_utils.h | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index d90952d3b..ca0479cba 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -10181,8 +10181,8 @@ function audio_sample_play(audio, position, volume) end --- @return integer ---- Allocates an `audio` sequence -function allocate_seq() +--- Allocates an `audio` sequence ID +function allocate_sequence() -- ... end diff --git a/docs/lua/functions-6.md b/docs/lua/functions-6.md index ac77b3a13..ddabd215f 100644 --- a/docs/lua/functions-6.md +++ b/docs/lua/functions-6.md @@ -1458,13 +1458,13 @@ Plays an `audio` sample at `position` with `volume`
-## [allocate_seq](#allocate_seq) +## [allocate_sequence](#allocate_sequence) ### Description -Allocates an `audio` sequence +Allocates an `audio` sequence ID ### Lua Example -`local integerValue = allocate_seq()` +`local integerValue = allocate_sequence()` ### Parameters - None @@ -1473,7 +1473,7 @@ Allocates an `audio` sequence - `integer` ### C Prototype -`u32 allocate_seq(void);` +`u32 allocate_sequence(void);` [:arrow_up_small:](#) diff --git a/docs/lua/functions.md b/docs/lua/functions.md index df13bcbde..a2696bae3 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -1824,7 +1824,7 @@ - [audio_sample_destroy](functions-6.md#audio_sample_destroy) - [audio_sample_stop](functions-6.md#audio_sample_stop) - [audio_sample_play](functions-6.md#audio_sample_play) - - [allocate_seq](functions-6.md#allocate_seq) + - [allocate_sequence](functions-6.md#allocate_sequence)
diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index 81c517d02..55c91833d 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -30759,17 +30759,17 @@ int smlua_func_audio_sample_play(lua_State* L) { return 1; } -int smlua_func_allocate_seq(UNUSED lua_State* L) { +int smlua_func_allocate_sequence(UNUSED lua_State* L) { if (L == NULL) { return 0; } int top = lua_gettop(L); if (top != 0) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "allocate_seq", 0, top); + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "allocate_sequence", 0, top); return 0; } - lua_pushinteger(L, allocate_seq()); + lua_pushinteger(L, allocate_sequence()); return 1; } @@ -38053,7 +38053,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "audio_sample_destroy", smlua_func_audio_sample_destroy); smlua_bind_function(L, "audio_sample_stop", smlua_func_audio_sample_stop); smlua_bind_function(L, "audio_sample_play", smlua_func_audio_sample_play); - smlua_bind_function(L, "allocate_seq", smlua_func_allocate_seq); + smlua_bind_function(L, "allocate_sequence", smlua_func_allocate_sequence); // smlua_camera_utils.h smlua_bind_function(L, "camera_reset_overrides", smlua_func_camera_reset_overrides); diff --git a/src/pc/lua/utils/smlua_audio_utils.c b/src/pc/lua/utils/smlua_audio_utils.c index 6067b3ea2..5a91877c4 100644 --- a/src/pc/lua/utils/smlua_audio_utils.c +++ b/src/pc/lua/utils/smlua_audio_utils.c @@ -626,7 +626,7 @@ void smlua_audio_custom_deinit(void) { } -u32 allocate_seq() { +u32 allocate_sequence() { if ((sCustomSeqsCount + SEQ_COUNT) < MAX_CUSTOM_SEQS) { return (++sCustomSeqsCount + SEQ_COUNT); } diff --git a/src/pc/lua/utils/smlua_audio_utils.h b/src/pc/lua/utils/smlua_audio_utils.h index 193c0b4cd..9976353e0 100644 --- a/src/pc/lua/utils/smlua_audio_utils.h +++ b/src/pc/lua/utils/smlua_audio_utils.h @@ -76,7 +76,7 @@ void audio_custom_update_volume(void); void audio_custom_shutdown(void); void smlua_audio_custom_deinit(void); -/* |description|Allocates an `audio` sequence|descriptionEnd| */ -u32 allocate_seq(void); +/* |description|Allocates an `audio` sequence ID|descriptionEnd| */ +u32 allocate_sequence(void); #endif From 0983fee91622a0f9b9d44ba316c8069ddfa8da63 Mon Sep 17 00:00:00 2001 From: ThePlayerRolo Date: Thu, 10 Jul 2025 14:19:26 -0400 Subject: [PATCH 3/7] quick fix --- src/pc/lua/utils/smlua_audio_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pc/lua/utils/smlua_audio_utils.c b/src/pc/lua/utils/smlua_audio_utils.c index 5a91877c4..84e6fac17 100644 --- a/src/pc/lua/utils/smlua_audio_utils.c +++ b/src/pc/lua/utils/smlua_audio_utils.c @@ -626,7 +626,7 @@ void smlua_audio_custom_deinit(void) { } -u32 allocate_sequence() { +u32 allocate_sequence(void) { if ((sCustomSeqsCount + SEQ_COUNT) < MAX_CUSTOM_SEQS) { return (++sCustomSeqsCount + SEQ_COUNT); } From f20d2381671ee5c8845502b3737b3ebeb2d9f12c Mon Sep 17 00:00:00 2001 From: ThePlayerRolo Date: Sat, 12 Jul 2025 21:07:37 -0400 Subject: [PATCH 4/7] Updates according to review --- autogen/lua_definitions/functions.lua | 12 ++++---- docs/lua/functions-6.md | 42 +++++++++++++-------------- docs/lua/functions.md | 2 +- src/pc/lua/smlua_functions_autogen.c | 32 ++++++++++---------- src/pc/lua/utils/smlua_audio_utils.c | 23 +++++++-------- src/pc/lua/utils/smlua_audio_utils.h | 5 ++-- 6 files changed, 56 insertions(+), 60 deletions(-) diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index ca0479cba..3abfa9174 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -10056,6 +10056,12 @@ function smlua_audio_utils_replace_sequence(sequenceId, bankId, defaultVolume, m -- ... end +--- @return integer +--- Allocates an `audio` sequence ID +function smlua_audio_utils_allocate_sequence() + -- ... +end + --- @param filename string --- @return ModAudio --- Loads an `audio` stream by `filename` (with extension) @@ -10180,12 +10186,6 @@ function audio_sample_play(audio, position, volume) -- ... end ---- @return integer ---- Allocates an `audio` sequence ID -function allocate_sequence() - -- ... -end - --- Resets camera config overrides function camera_reset_overrides() -- ... diff --git a/docs/lua/functions-6.md b/docs/lua/functions-6.md index ddabd215f..5817e451d 100644 --- a/docs/lua/functions-6.md +++ b/docs/lua/functions-6.md @@ -1034,6 +1034,27 @@ Replaces the sequence corresponding to `sequenceId` with one called `m64Name`.m6
+## [smlua_audio_utils_allocate_sequence](#smlua_audio_utils_allocate_sequence) + +### Description +Allocates an `audio` sequence ID + +### Lua Example +`local integerValue = smlua_audio_utils_allocate_sequence()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`u8 smlua_audio_utils_allocate_sequence(void);` + +[:arrow_up_small:](#) + +
+ ## [audio_stream_load](#audio_stream_load) ### Description @@ -1458,27 +1479,6 @@ Plays an `audio` sample at `position` with `volume`
-## [allocate_sequence](#allocate_sequence) - -### Description -Allocates an `audio` sequence ID - -### Lua Example -`local integerValue = allocate_sequence()` - -### Parameters -- None - -### Returns -- `integer` - -### C Prototype -`u32 allocate_sequence(void);` - -[:arrow_up_small:](#) - -
- --- # functions from smlua_camera_utils.h diff --git a/docs/lua/functions.md b/docs/lua/functions.md index a2696bae3..31e0e42a9 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -1806,6 +1806,7 @@ - smlua_audio_utils.h - [smlua_audio_utils_reset_all](functions-6.md#smlua_audio_utils_reset_all) - [smlua_audio_utils_replace_sequence](functions-6.md#smlua_audio_utils_replace_sequence) + - [smlua_audio_utils_allocate_sequence](functions-6.md#smlua_audio_utils_allocate_sequence) - [audio_stream_load](functions-6.md#audio_stream_load) - [audio_stream_destroy](functions-6.md#audio_stream_destroy) - [audio_stream_play](functions-6.md#audio_stream_play) @@ -1824,7 +1825,6 @@ - [audio_sample_destroy](functions-6.md#audio_sample_destroy) - [audio_sample_stop](functions-6.md#audio_sample_stop) - [audio_sample_play](functions-6.md#audio_sample_play) - - [allocate_sequence](functions-6.md#allocate_sequence)
diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index 55c91833d..c0c5e3d1c 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -30431,6 +30431,21 @@ int smlua_func_smlua_audio_utils_replace_sequence(lua_State* L) { return 1; } +int smlua_func_smlua_audio_utils_allocate_sequence(UNUSED lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 0) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "smlua_audio_utils_allocate_sequence", 0, top); + return 0; + } + + + lua_pushinteger(L, smlua_audio_utils_allocate_sequence()); + + return 1; +} + int smlua_func_audio_stream_load(lua_State* L) { if (L == NULL) { return 0; } @@ -30759,21 +30774,6 @@ int smlua_func_audio_sample_play(lua_State* L) { return 1; } -int smlua_func_allocate_sequence(UNUSED lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 0) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "allocate_sequence", 0, top); - return 0; - } - - - lua_pushinteger(L, allocate_sequence()); - - return 1; -} - ////////////////////////// // smlua_camera_utils.h // ////////////////////////// @@ -38035,6 +38035,7 @@ void smlua_bind_functions_autogen(void) { // smlua_audio_utils.h smlua_bind_function(L, "smlua_audio_utils_reset_all", smlua_func_smlua_audio_utils_reset_all); smlua_bind_function(L, "smlua_audio_utils_replace_sequence", smlua_func_smlua_audio_utils_replace_sequence); + smlua_bind_function(L, "smlua_audio_utils_allocate_sequence", smlua_func_smlua_audio_utils_allocate_sequence); smlua_bind_function(L, "audio_stream_load", smlua_func_audio_stream_load); smlua_bind_function(L, "audio_stream_destroy", smlua_func_audio_stream_destroy); smlua_bind_function(L, "audio_stream_play", smlua_func_audio_stream_play); @@ -38053,7 +38054,6 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "audio_sample_destroy", smlua_func_audio_sample_destroy); smlua_bind_function(L, "audio_sample_stop", smlua_func_audio_sample_stop); smlua_bind_function(L, "audio_sample_play", smlua_func_audio_sample_play); - smlua_bind_function(L, "allocate_sequence", smlua_func_allocate_sequence); // smlua_camera_utils.h smlua_bind_function(L, "camera_reset_overrides", smlua_func_camera_reset_overrides); diff --git a/src/pc/lua/utils/smlua_audio_utils.c b/src/pc/lua/utils/smlua_audio_utils.c index 84e6fac17..d6080082b 100644 --- a/src/pc/lua/utils/smlua_audio_utils.c +++ b/src/pc/lua/utils/smlua_audio_utils.c @@ -4,8 +4,6 @@ #define STB_VORBIS_HEADER_ONLY #include "pc/utils/stb_vorbis.c" -#define MAX_CUSTOM_SEQS 1024 - #include "types.h" #include "seq_ids.h" #include "audio/external.h" @@ -31,7 +29,7 @@ struct AudioOverride { struct AudioOverride sAudioOverrides[MAX_AUDIO_OVERRIDE] = { 0 }; -static u32 sCustomSeqsCount = 0; +static u8 sCustomSeqIndex = SEQ_COUNT; static void smlua_audio_utils_reset(struct AudioOverride* override) { if (override == NULL) { return; } @@ -69,7 +67,7 @@ void smlua_audio_utils_reset_all(void) { #endif smlua_audio_utils_reset(&sAudioOverrides[i]); } - sCustomSeqsCount = 0; + sCustomSeqIndex = SEQ_COUNT; } bool smlua_audio_utils_override(u8 sequenceId, s32* bankId, void** seqData) { @@ -159,6 +157,14 @@ void smlua_audio_utils_replace_sequence(u8 sequenceId, u8 bankId, u8 defaultVolu LOG_LUA_LINE("Could not find m64 at path: %s", m64path); } +u8 smlua_audio_utils_allocate_sequence(void) { + if (sCustomSeqIndex< MAX_AUDIO_OVERRIDE) { + return sCustomSeqIndex++; + } + LOG_ERROR("Cannot allocate more custom sequences."); + return 0; +} + /////////////// // mod audio // /////////////// @@ -623,13 +629,4 @@ void smlua_audio_custom_deinit(void) { ma_engine_uninit(&sModAudioEngine); sModAudioPool = NULL; } -} - - -u32 allocate_sequence(void) { - if ((sCustomSeqsCount + SEQ_COUNT) < MAX_CUSTOM_SEQS) { - return (++sCustomSeqsCount + SEQ_COUNT); - } - LOG_ERROR("Cannot allocate more custom sequences."); - return 0; } \ No newline at end of file diff --git a/src/pc/lua/utils/smlua_audio_utils.h b/src/pc/lua/utils/smlua_audio_utils.h index 9976353e0..f9e6f2b9a 100644 --- a/src/pc/lua/utils/smlua_audio_utils.h +++ b/src/pc/lua/utils/smlua_audio_utils.h @@ -8,6 +8,8 @@ void smlua_audio_utils_reset_all(void); bool smlua_audio_utils_override(u8 sequenceId, s32* bankId, void** seqData); /* |description|Replaces the sequence corresponding to `sequenceId` with one called `m64Name`.m64 with `bankId` and `defaultVolume`|descriptionEnd| */ void smlua_audio_utils_replace_sequence(u8 sequenceId, u8 bankId, u8 defaultVolume, const char* m64Name); +/* |description|Allocates an `audio` sequence ID|descriptionEnd| */ +u8 smlua_audio_utils_allocate_sequence(void); //////////////// // mod sounds // @@ -76,7 +78,4 @@ void audio_custom_update_volume(void); void audio_custom_shutdown(void); void smlua_audio_custom_deinit(void); -/* |description|Allocates an `audio` sequence ID|descriptionEnd| */ -u32 allocate_sequence(void); - #endif From 88e084d5ef544b006947384e124ebd3050d1f06f Mon Sep 17 00:00:00 2001 From: ThePlayerRolo Date: Mon, 14 Jul 2025 18:01:15 -0400 Subject: [PATCH 5/7] Final fix (hopefully) --- autogen/lua_definitions/functions.lua | 2 +- docs/lua/functions-6.md | 2 +- src/pc/lua/utils/smlua_audio_utils.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index 3abfa9174..a84ba5877 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -10057,7 +10057,7 @@ function smlua_audio_utils_replace_sequence(sequenceId, bankId, defaultVolume, m end --- @return integer ---- Allocates an `audio` sequence ID +--- Allocates a new sequence ID function smlua_audio_utils_allocate_sequence() -- ... end diff --git a/docs/lua/functions-6.md b/docs/lua/functions-6.md index 5817e451d..8e554ae05 100644 --- a/docs/lua/functions-6.md +++ b/docs/lua/functions-6.md @@ -1037,7 +1037,7 @@ Replaces the sequence corresponding to `sequenceId` with one called `m64Name`.m6 ## [smlua_audio_utils_allocate_sequence](#smlua_audio_utils_allocate_sequence) ### Description -Allocates an `audio` sequence ID +Allocates a new sequence ID ### Lua Example `local integerValue = smlua_audio_utils_allocate_sequence()` diff --git a/src/pc/lua/utils/smlua_audio_utils.h b/src/pc/lua/utils/smlua_audio_utils.h index f9e6f2b9a..f632fca68 100644 --- a/src/pc/lua/utils/smlua_audio_utils.h +++ b/src/pc/lua/utils/smlua_audio_utils.h @@ -8,7 +8,7 @@ void smlua_audio_utils_reset_all(void); bool smlua_audio_utils_override(u8 sequenceId, s32* bankId, void** seqData); /* |description|Replaces the sequence corresponding to `sequenceId` with one called `m64Name`.m64 with `bankId` and `defaultVolume`|descriptionEnd| */ void smlua_audio_utils_replace_sequence(u8 sequenceId, u8 bankId, u8 defaultVolume, const char* m64Name); -/* |description|Allocates an `audio` sequence ID|descriptionEnd| */ +/* |description|Allocates a new sequence ID|descriptionEnd| */ u8 smlua_audio_utils_allocate_sequence(void); //////////////// From 707dc7ca80ee7dd76a0dd5bbcbdce1462d4dc36f Mon Sep 17 00:00:00 2001 From: ThePlayerRolo Date: Sat, 19 Jul 2025 17:58:53 -0400 Subject: [PATCH 6/7] Update smlua_audio_utils.c --- src/pc/lua/utils/smlua_audio_utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pc/lua/utils/smlua_audio_utils.c b/src/pc/lua/utils/smlua_audio_utils.c index d6080082b..662654e8f 100644 --- a/src/pc/lua/utils/smlua_audio_utils.c +++ b/src/pc/lua/utils/smlua_audio_utils.c @@ -158,7 +158,7 @@ void smlua_audio_utils_replace_sequence(u8 sequenceId, u8 bankId, u8 defaultVolu } u8 smlua_audio_utils_allocate_sequence(void) { - if (sCustomSeqIndex< MAX_AUDIO_OVERRIDE) { + if (sCustomSeqIndex < MAX_AUDIO_OVERRIDE) { return sCustomSeqIndex++; } LOG_ERROR("Cannot allocate more custom sequences."); @@ -629,4 +629,4 @@ void smlua_audio_custom_deinit(void) { ma_engine_uninit(&sModAudioEngine); sModAudioPool = NULL; } -} \ No newline at end of file +} From 67edb1316fdf6495f8ec66b1911589c4b2a53151 Mon Sep 17 00:00:00 2001 From: ThePlayerRolo Date: Fri, 19 Sep 2025 20:05:33 -0400 Subject: [PATCH 7/7] Update smlua_audio_utils again --- src/pc/lua/utils/smlua_audio_utils.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/pc/lua/utils/smlua_audio_utils.c b/src/pc/lua/utils/smlua_audio_utils.c index d6080082b..deb059c46 100644 --- a/src/pc/lua/utils/smlua_audio_utils.c +++ b/src/pc/lua/utils/smlua_audio_utils.c @@ -29,8 +29,6 @@ struct AudioOverride { struct AudioOverride sAudioOverrides[MAX_AUDIO_OVERRIDE] = { 0 }; -static u8 sCustomSeqIndex = SEQ_COUNT; - static void smlua_audio_utils_reset(struct AudioOverride* override) { if (override == NULL) { return; } @@ -67,7 +65,6 @@ void smlua_audio_utils_reset_all(void) { #endif smlua_audio_utils_reset(&sAudioOverrides[i]); } - sCustomSeqIndex = SEQ_COUNT; } bool smlua_audio_utils_override(u8 sequenceId, s32* bankId, void** seqData) { @@ -158,8 +155,10 @@ void smlua_audio_utils_replace_sequence(u8 sequenceId, u8 bankId, u8 defaultVolu } u8 smlua_audio_utils_allocate_sequence(void) { - if (sCustomSeqIndex< MAX_AUDIO_OVERRIDE) { - return sCustomSeqIndex++; + for (u8 seqId = SEQ_COUNT + 1; seqId < MAX_AUDIO_OVERRIDE; seqId++) { + if (!sAudioOverrides[seqId].enabled) { + return seqId; + } } LOG_ERROR("Cannot allocate more custom sequences."); return 0;