mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Updates according to review
This commit is contained in:
parent
0983fee916
commit
f20d238167
6 changed files with 56 additions and 60 deletions
|
|
@ -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()
|
||||
-- ...
|
||||
|
|
|
|||
|
|
@ -1034,6 +1034,27 @@ Replaces the sequence corresponding to `sequenceId` with one called `m64Name`.m6
|
|||
|
||||
<br />
|
||||
|
||||
## [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:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [audio_stream_load](#audio_stream_load)
|
||||
|
||||
### Description
|
||||
|
|
@ -1458,27 +1479,6 @@ Plays an `audio` sample at `position` with `volume`
|
|||
|
||||
<br />
|
||||
|
||||
## [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:](#)
|
||||
|
||||
<br />
|
||||
|
||||
---
|
||||
# functions from smlua_camera_utils.h
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
<br />
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 //
|
||||
///////////////
|
||||
|
|
@ -624,12 +630,3 @@ void smlua_audio_custom_deinit(void) {
|
|||
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;
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue