mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Make bass sound interface easier to handle
This commit is contained in:
parent
034ada738c
commit
725e26fe83
20 changed files with 1200 additions and 1018 deletions
|
|
@ -22,6 +22,7 @@ in_files = [
|
|||
'src/pc/network/network.h',
|
||||
'src/game/hardcoded.h',
|
||||
'src/pc/mods/mod.h',
|
||||
'src/pc/lua/utils/smlua_audio_utils.h',
|
||||
]
|
||||
|
||||
out_filename_c = 'src/pc/lua/smlua_cobject_autogen.c'
|
||||
|
|
@ -81,11 +82,11 @@ override_field_immutable = {
|
|||
"Area": [ "localAreaTimer" ],
|
||||
"Mod": [ "*" ],
|
||||
"ModFile": [ "*" ],
|
||||
"BassAudio": [ "*" ],
|
||||
}
|
||||
|
||||
override_allowed_structs = {
|
||||
"src/pc/network/network.h": [ 'ServerSettings' ],
|
||||
"src/pc/mods/mod.h": [ 'Mod' ],
|
||||
}
|
||||
|
||||
sLuaManuallyDefinedStructs = [{
|
||||
|
|
|
|||
|
|
@ -7080,6 +7080,132 @@ function save_file_set_flags(flags)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio BassAudio
|
||||
--- @return nil
|
||||
function audio_sample_destroy(audio)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param filename string
|
||||
--- @return BassAudio
|
||||
function audio_sample_load(filename)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio BassAudio
|
||||
--- @param position Vec3f
|
||||
--- @param volume number
|
||||
--- @return nil
|
||||
function audio_sample_play(audio, position, volume)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio BassAudio
|
||||
--- @return nil
|
||||
function audio_stream_destroy(audio)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio BassAudio
|
||||
--- @return number
|
||||
function audio_stream_get_frequency(audio)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio BassAudio
|
||||
--- @return boolean
|
||||
function audio_stream_get_looping(audio)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio BassAudio
|
||||
--- @return number
|
||||
function audio_stream_get_position(audio)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio BassAudio
|
||||
--- @return number
|
||||
function audio_stream_get_tempo(audio)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio BassAudio
|
||||
--- @return number
|
||||
function audio_stream_get_volume(audio)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param filename string
|
||||
--- @return BassAudio
|
||||
function audio_stream_load(filename)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio BassAudio
|
||||
--- @return nil
|
||||
function audio_stream_pause(audio)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio BassAudio
|
||||
--- @param restart boolean
|
||||
--- @param volume number
|
||||
--- @return nil
|
||||
function audio_stream_play(audio, restart, volume)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio BassAudio
|
||||
--- @param freq number
|
||||
--- @return nil
|
||||
function audio_stream_set_frequency(audio, freq)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio BassAudio
|
||||
--- @param looping boolean
|
||||
--- @return nil
|
||||
function audio_stream_set_looping(audio, looping)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio BassAudio
|
||||
--- @param pos number
|
||||
--- @return nil
|
||||
function audio_stream_set_position(audio, pos)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio BassAudio
|
||||
--- @param initial_freq number
|
||||
--- @param speed number
|
||||
--- @param pitch boolean
|
||||
--- @return nil
|
||||
function audio_stream_set_speed(audio, initial_freq, speed, pitch)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio BassAudio
|
||||
--- @param tempo number
|
||||
--- @return nil
|
||||
function audio_stream_set_tempo(audio, tempo)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio BassAudio
|
||||
--- @param volume number
|
||||
--- @return nil
|
||||
function audio_stream_set_volume(audio, volume)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio BassAudio
|
||||
--- @return nil
|
||||
function audio_stream_stop(audio)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param sequenceId integer
|
||||
--- @param bankId integer
|
||||
--- @param defaultVolume integer
|
||||
|
|
@ -7138,24 +7264,6 @@ function deref_s32_pointer(pointer)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio_stream integer
|
||||
--- @return nil
|
||||
function destroy_audio(audio_stream)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio_stream integer
|
||||
--- @return nil
|
||||
function destroy_sample(audio_stream)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param sample integer
|
||||
--- @return integer
|
||||
function get_audio_from_sample(sample)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @return integer
|
||||
function get_current_save_file_num()
|
||||
-- ...
|
||||
|
|
@ -7167,12 +7275,6 @@ function get_environment_region(index)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio_stream integer
|
||||
--- @return number
|
||||
function get_frequency_audio(audio_stream)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param m MarioState
|
||||
--- @param index integer
|
||||
--- @return number
|
||||
|
|
@ -7194,41 +7296,17 @@ function get_hand_foot_pos_z(m, index)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio_stream integer
|
||||
--- @return boolean
|
||||
function get_looping_audio(audio_stream)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @return integer
|
||||
function get_network_area_timer()
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio_stream integer
|
||||
--- @return number
|
||||
function get_position_audio(audio_stream)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param initialValue integer
|
||||
--- @return Pointer_integer
|
||||
function get_temp_s32_pointer(initialValue)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio_stream integer
|
||||
--- @return number
|
||||
function get_tempo_audio(audio_stream)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio_stream integer
|
||||
--- @return number
|
||||
function get_volume_audio(audio_stream)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param type HudDisplayValue
|
||||
--- @return integer
|
||||
function hud_get_value(type)
|
||||
|
|
@ -7262,18 +7340,6 @@ function hud_show()
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param file_name string
|
||||
--- @return integer
|
||||
function load_audio(file_name)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param file_name string
|
||||
--- @return integer
|
||||
function load_sample(file_name)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param name string
|
||||
--- @param level integer
|
||||
--- @param area integer
|
||||
|
|
@ -7283,19 +7349,6 @@ function movtexqc_register(name, level, area, type)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio_stream integer
|
||||
--- @return nil
|
||||
function pause_audio(audio_stream)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio_stream integer
|
||||
--- @param restart boolean
|
||||
--- @return nil
|
||||
function play_audio(audio_stream, restart)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param transType integer
|
||||
--- @param time integer
|
||||
--- @param red integer
|
||||
|
|
@ -7319,20 +7372,6 @@ function set_environment_region(index, value)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio_stream integer
|
||||
--- @param freq number
|
||||
--- @return nil
|
||||
function set_frequency_audio(audio_stream, freq)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio_stream integer
|
||||
--- @param looping boolean
|
||||
--- @return nil
|
||||
function set_looping_audio(audio_stream, looping)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param far number
|
||||
--- @return number
|
||||
function set_override_far(far)
|
||||
|
|
@ -7351,42 +7390,6 @@ function set_override_near(near)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio_stream integer
|
||||
--- @param pos number
|
||||
--- @return nil
|
||||
function set_position_audio(audio_stream, pos)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio_stream integer
|
||||
--- @param initial_freq number
|
||||
--- @param speed number
|
||||
--- @param pitch boolean
|
||||
--- @return nil
|
||||
function set_speed_audio(audio_stream, initial_freq, speed, pitch)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio_stream integer
|
||||
--- @param tempo number
|
||||
--- @return nil
|
||||
function set_tempo_audio(audio_stream, tempo)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio_stream integer
|
||||
--- @param volume number
|
||||
--- @return nil
|
||||
function set_volume_audio(audio_stream, volume)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param audio_stream integer
|
||||
--- @return nil
|
||||
function stop_audio(audio_stream)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param aDelay integer
|
||||
--- @return boolean
|
||||
function warp_exit_level(aDelay)
|
||||
|
|
|
|||
|
|
@ -43,6 +43,13 @@
|
|||
--- @field public terrainType integer
|
||||
--- @field public warpNodes ObjectWarpNode
|
||||
|
||||
--- @class BassAudio
|
||||
--- @field public file ModFile
|
||||
--- @field public handle integer
|
||||
--- @field public isStream boolean
|
||||
--- @field public loaded boolean
|
||||
--- @field public rawData string
|
||||
|
||||
--- @class BehaviorDialogs
|
||||
--- @field public BobombBuddyBob1Dialog DialogId
|
||||
--- @field public BobombBuddyBob2Dialog DialogId
|
||||
|
|
@ -696,6 +703,12 @@
|
|||
--- @field public relativePath string
|
||||
--- @field public selectable boolean
|
||||
|
||||
--- @class ModFile
|
||||
--- @field public cachedPath string
|
||||
--- @field public complete boolean
|
||||
--- @field public curOffset integer
|
||||
--- @field public relativePath string
|
||||
|
||||
--- @class ModeTransitionInfo
|
||||
--- @field public frame integer
|
||||
--- @field public lastMode integer
|
||||
|
|
|
|||
|
|
@ -4565,6 +4565,398 @@
|
|||
<br />
|
||||
|
||||
|
||||
## [audio_sample_destroy](#audio_sample_destroy)
|
||||
|
||||
### Lua Example
|
||||
`audio_sample_destroy(audio)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio | [BassAudio](structs.md#BassAudio) |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void audio_sample_destroy(struct BassAudio* audio);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [audio_sample_load](#audio_sample_load)
|
||||
|
||||
### Lua Example
|
||||
`local BassAudioValue = audio_sample_load(filename)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| filename | `string` |
|
||||
|
||||
### Returns
|
||||
[BassAudio](structs.md#BassAudio)
|
||||
|
||||
### C Prototype
|
||||
`struct BassAudio* audio_sample_load(const char* filename);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [audio_sample_play](#audio_sample_play)
|
||||
|
||||
### Lua Example
|
||||
`audio_sample_play(audio, position, volume)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio | [BassAudio](structs.md#BassAudio) |
|
||||
| position | [Vec3f](structs.md#Vec3f) |
|
||||
| volume | `number` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void audio_sample_play(struct BassAudio* audio, Vec3f position, f32 volume);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [audio_stream_destroy](#audio_stream_destroy)
|
||||
|
||||
### Lua Example
|
||||
`audio_stream_destroy(audio)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio | [BassAudio](structs.md#BassAudio) |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void audio_stream_destroy(struct BassAudio* audio);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [audio_stream_get_frequency](#audio_stream_get_frequency)
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = audio_stream_get_frequency(audio)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio | [BassAudio](structs.md#BassAudio) |
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f32 audio_stream_get_frequency(struct BassAudio* audio);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [audio_stream_get_looping](#audio_stream_get_looping)
|
||||
|
||||
### Lua Example
|
||||
`local booleanValue = audio_stream_get_looping(audio)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio | [BassAudio](structs.md#BassAudio) |
|
||||
|
||||
### Returns
|
||||
- `boolean`
|
||||
|
||||
### C Prototype
|
||||
`bool audio_stream_get_looping(struct BassAudio* audio);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [audio_stream_get_position](#audio_stream_get_position)
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = audio_stream_get_position(audio)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio | [BassAudio](structs.md#BassAudio) |
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f32 audio_stream_get_position(struct BassAudio* audio);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [audio_stream_get_tempo](#audio_stream_get_tempo)
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = audio_stream_get_tempo(audio)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio | [BassAudio](structs.md#BassAudio) |
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f32 audio_stream_get_tempo(struct BassAudio* audio);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [audio_stream_get_volume](#audio_stream_get_volume)
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = audio_stream_get_volume(audio)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio | [BassAudio](structs.md#BassAudio) |
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f32 audio_stream_get_volume(struct BassAudio* audio);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [audio_stream_load](#audio_stream_load)
|
||||
|
||||
### Lua Example
|
||||
`local BassAudioValue = audio_stream_load(filename)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| filename | `string` |
|
||||
|
||||
### Returns
|
||||
[BassAudio](structs.md#BassAudio)
|
||||
|
||||
### C Prototype
|
||||
`struct BassAudio* audio_stream_load(const char* filename);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [audio_stream_pause](#audio_stream_pause)
|
||||
|
||||
### Lua Example
|
||||
`audio_stream_pause(audio)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio | [BassAudio](structs.md#BassAudio) |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void audio_stream_pause(struct BassAudio* audio);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [audio_stream_play](#audio_stream_play)
|
||||
|
||||
### Lua Example
|
||||
`audio_stream_play(audio, restart, volume)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio | [BassAudio](structs.md#BassAudio) |
|
||||
| restart | `boolean` |
|
||||
| volume | `number` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void audio_stream_play(struct BassAudio* audio, bool restart, f32 volume);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [audio_stream_set_frequency](#audio_stream_set_frequency)
|
||||
|
||||
### Lua Example
|
||||
`audio_stream_set_frequency(audio, freq)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio | [BassAudio](structs.md#BassAudio) |
|
||||
| freq | `number` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void audio_stream_set_frequency(struct BassAudio* audio, f32 freq);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [audio_stream_set_looping](#audio_stream_set_looping)
|
||||
|
||||
### Lua Example
|
||||
`audio_stream_set_looping(audio, looping)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio | [BassAudio](structs.md#BassAudio) |
|
||||
| looping | `boolean` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void audio_stream_set_looping(struct BassAudio* audio, bool looping);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [audio_stream_set_position](#audio_stream_set_position)
|
||||
|
||||
### Lua Example
|
||||
`audio_stream_set_position(audio, pos)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio | [BassAudio](structs.md#BassAudio) |
|
||||
| pos | `number` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void audio_stream_set_position(struct BassAudio* audio, f32 pos);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [audio_stream_set_speed](#audio_stream_set_speed)
|
||||
|
||||
### Lua Example
|
||||
`audio_stream_set_speed(audio, initial_freq, speed, pitch)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio | [BassAudio](structs.md#BassAudio) |
|
||||
| initial_freq | `number` |
|
||||
| speed | `number` |
|
||||
| pitch | `boolean` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void audio_stream_set_speed(struct BassAudio* audio, f32 initial_freq, f32 speed, bool pitch);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [audio_stream_set_tempo](#audio_stream_set_tempo)
|
||||
|
||||
### Lua Example
|
||||
`audio_stream_set_tempo(audio, tempo)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio | [BassAudio](structs.md#BassAudio) |
|
||||
| tempo | `number` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void audio_stream_set_tempo(struct BassAudio* audio, f32 tempo);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [audio_stream_set_volume](#audio_stream_set_volume)
|
||||
|
||||
### Lua Example
|
||||
`audio_stream_set_volume(audio, volume)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio | [BassAudio](structs.md#BassAudio) |
|
||||
| volume | `number` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void audio_stream_set_volume(struct BassAudio* audio, f32 volume);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [audio_stream_stop](#audio_stream_stop)
|
||||
|
||||
### Lua Example
|
||||
`audio_stream_stop(audio)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio | [BassAudio](structs.md#BassAudio) |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void audio_stream_stop(struct BassAudio* audio);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [smlua_audio_utils_replace_sequence](#smlua_audio_utils_replace_sequence)
|
||||
|
||||
### Lua Example
|
||||
|
|
@ -4757,66 +5149,6 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [destroy_audio](#destroy_audio)
|
||||
|
||||
### Lua Example
|
||||
`destroy_audio(audio_stream)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio_stream | `integer` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void destroy_audio(u32 audio_stream);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [destroy_sample](#destroy_sample)
|
||||
|
||||
### Lua Example
|
||||
`destroy_sample(audio_stream)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio_stream | `integer` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void destroy_sample(u32 audio_stream);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [get_audio_from_sample](#get_audio_from_sample)
|
||||
|
||||
### Lua Example
|
||||
`local integerValue = get_audio_from_sample(sample)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| sample | `integer` |
|
||||
|
||||
### Returns
|
||||
- `integer`
|
||||
|
||||
### C Prototype
|
||||
`u32 get_audio_from_sample(u32 sample);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [get_current_save_file_num](#get_current_save_file_num)
|
||||
|
||||
### Lua Example
|
||||
|
|
@ -4855,26 +5187,6 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [get_frequency_audio](#get_frequency_audio)
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = get_frequency_audio(audio_stream)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio_stream | `integer` |
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f32 get_frequency_audio(u32 audio_stream);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [get_hand_foot_pos_x](#get_hand_foot_pos_x)
|
||||
|
||||
### Lua Example
|
||||
|
|
@ -4938,26 +5250,6 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [get_looping_audio](#get_looping_audio)
|
||||
|
||||
### Lua Example
|
||||
`local booleanValue = get_looping_audio(audio_stream)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio_stream | `integer` |
|
||||
|
||||
### Returns
|
||||
- `boolean`
|
||||
|
||||
### C Prototype
|
||||
`bool get_looping_audio(u32 audio_stream);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [get_network_area_timer](#get_network_area_timer)
|
||||
|
||||
### Lua Example
|
||||
|
|
@ -4976,26 +5268,6 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [get_position_audio](#get_position_audio)
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = get_position_audio(audio_stream)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio_stream | `integer` |
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f32 get_position_audio(u32 audio_stream);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [get_temp_s32_pointer](#get_temp_s32_pointer)
|
||||
|
||||
### Lua Example
|
||||
|
|
@ -5016,46 +5288,6 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [get_tempo_audio](#get_tempo_audio)
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = get_tempo_audio(audio_stream)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio_stream | `integer` |
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f32 get_tempo_audio(u32 audio_stream);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [get_volume_audio](#get_volume_audio)
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = get_volume_audio(audio_stream)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio_stream | `integer` |
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f32 get_volume_audio(u32 audio_stream);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [hud_get_value](#hud_get_value)
|
||||
|
||||
### Lua Example
|
||||
|
|
@ -5157,46 +5389,6 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [load_audio](#load_audio)
|
||||
|
||||
### Lua Example
|
||||
`local integerValue = load_audio(file_name)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| file_name | `string` |
|
||||
|
||||
### Returns
|
||||
- `integer`
|
||||
|
||||
### C Prototype
|
||||
`u32 load_audio(const char* file_name);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [load_sample](#load_sample)
|
||||
|
||||
### Lua Example
|
||||
`local integerValue = load_sample(file_name)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| file_name | `string` |
|
||||
|
||||
### Returns
|
||||
- `integer`
|
||||
|
||||
### C Prototype
|
||||
`u32 load_sample(const char* file_name);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [movtexqc_register](#movtexqc_register)
|
||||
|
||||
### Lua Example
|
||||
|
|
@ -5220,47 +5412,6 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [pause_audio](#pause_audio)
|
||||
|
||||
### Lua Example
|
||||
`pause_audio(audio_stream)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio_stream | `integer` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void pause_audio(u32 audio_stream);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [play_audio](#play_audio)
|
||||
|
||||
### Lua Example
|
||||
`play_audio(audio_stream, restart)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio_stream | `integer` |
|
||||
| restart | `boolean` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void play_audio(u32 audio_stream, bool restart);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [play_transition](#play_transition)
|
||||
|
||||
### Lua Example
|
||||
|
|
@ -5326,48 +5477,6 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [set_frequency_audio](#set_frequency_audio)
|
||||
|
||||
### Lua Example
|
||||
`set_frequency_audio(audio_stream, freq)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio_stream | `integer` |
|
||||
| freq | `number` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void set_frequency_audio(u32 audio_stream, f32 freq);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [set_looping_audio](#set_looping_audio)
|
||||
|
||||
### Lua Example
|
||||
`set_looping_audio(audio_stream, looping)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio_stream | `integer` |
|
||||
| looping | `boolean` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void set_looping_audio(u32 audio_stream, bool looping);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [set_override_far](#set_override_far)
|
||||
|
||||
### Lua Example
|
||||
|
|
@ -5428,112 +5537,6 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [set_position_audio](#set_position_audio)
|
||||
|
||||
### Lua Example
|
||||
`set_position_audio(audio_stream, pos)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio_stream | `integer` |
|
||||
| pos | `number` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void set_position_audio(u32 audio_stream, f32 pos);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [set_speed_audio](#set_speed_audio)
|
||||
|
||||
### Lua Example
|
||||
`set_speed_audio(audio_stream, initial_freq, speed, pitch)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio_stream | `integer` |
|
||||
| initial_freq | `number` |
|
||||
| speed | `number` |
|
||||
| pitch | `boolean` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void set_speed_audio(u32 audio_stream, f32 initial_freq, f32 speed, bool pitch);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [set_tempo_audio](#set_tempo_audio)
|
||||
|
||||
### Lua Example
|
||||
`set_tempo_audio(audio_stream, tempo)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio_stream | `integer` |
|
||||
| tempo | `number` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void set_tempo_audio(u32 audio_stream, f32 tempo);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [set_volume_audio](#set_volume_audio)
|
||||
|
||||
### Lua Example
|
||||
`set_volume_audio(audio_stream, volume)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio_stream | `integer` |
|
||||
| volume | `number` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void set_volume_audio(u32 audio_stream, f32 volume);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [stop_audio](#stop_audio)
|
||||
|
||||
### Lua Example
|
||||
`stop_audio(audio_stream)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| audio_stream | `integer` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void stop_audio(u32 audio_stream);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [warp_exit_level](#warp_exit_level)
|
||||
|
||||
### Lua Example
|
||||
|
|
|
|||
|
|
@ -1322,6 +1322,25 @@
|
|||
<br />
|
||||
|
||||
- smlua_audio_utils.h
|
||||
- [audio_sample_destroy](functions-4.md#audio_sample_destroy)
|
||||
- [audio_sample_load](functions-4.md#audio_sample_load)
|
||||
- [audio_sample_play](functions-4.md#audio_sample_play)
|
||||
- [audio_stream_destroy](functions-4.md#audio_stream_destroy)
|
||||
- [audio_stream_get_frequency](functions-4.md#audio_stream_get_frequency)
|
||||
- [audio_stream_get_looping](functions-4.md#audio_stream_get_looping)
|
||||
- [audio_stream_get_position](functions-4.md#audio_stream_get_position)
|
||||
- [audio_stream_get_tempo](functions-4.md#audio_stream_get_tempo)
|
||||
- [audio_stream_get_volume](functions-4.md#audio_stream_get_volume)
|
||||
- [audio_stream_load](functions-4.md#audio_stream_load)
|
||||
- [audio_stream_pause](functions-4.md#audio_stream_pause)
|
||||
- [audio_stream_play](functions-4.md#audio_stream_play)
|
||||
- [audio_stream_set_frequency](functions-4.md#audio_stream_set_frequency)
|
||||
- [audio_stream_set_looping](functions-4.md#audio_stream_set_looping)
|
||||
- [audio_stream_set_position](functions-4.md#audio_stream_set_position)
|
||||
- [audio_stream_set_speed](functions-4.md#audio_stream_set_speed)
|
||||
- [audio_stream_set_tempo](functions-4.md#audio_stream_set_tempo)
|
||||
- [audio_stream_set_volume](functions-4.md#audio_stream_set_volume)
|
||||
- [audio_stream_stop](functions-4.md#audio_stream_stop)
|
||||
- [smlua_audio_utils_replace_sequence](functions-4.md#smlua_audio_utils_replace_sequence)
|
||||
- [smlua_audio_utils_reset_all](functions-4.md#smlua_audio_utils_reset_all)
|
||||
|
||||
|
|
@ -1339,44 +1358,25 @@
|
|||
- [camera_freeze](functions-4.md#camera_freeze)
|
||||
- [camera_unfreeze](functions-4.md#camera_unfreeze)
|
||||
- [deref_s32_pointer](functions-4.md#deref_s32_pointer)
|
||||
- [destroy_audio](functions-4.md#destroy_audio)
|
||||
- [destroy_sample](functions-4.md#destroy_sample)
|
||||
- [get_audio_from_sample](functions-4.md#get_audio_from_sample)
|
||||
- [get_current_save_file_num](functions-4.md#get_current_save_file_num)
|
||||
- [get_environment_region](functions-4.md#get_environment_region)
|
||||
- [get_frequency_audio](functions-4.md#get_frequency_audio)
|
||||
- [get_hand_foot_pos_x](functions-4.md#get_hand_foot_pos_x)
|
||||
- [get_hand_foot_pos_y](functions-4.md#get_hand_foot_pos_y)
|
||||
- [get_hand_foot_pos_z](functions-4.md#get_hand_foot_pos_z)
|
||||
- [get_looping_audio](functions-4.md#get_looping_audio)
|
||||
- [get_network_area_timer](functions-4.md#get_network_area_timer)
|
||||
- [get_position_audio](functions-4.md#get_position_audio)
|
||||
- [get_temp_s32_pointer](functions-4.md#get_temp_s32_pointer)
|
||||
- [get_tempo_audio](functions-4.md#get_tempo_audio)
|
||||
- [get_volume_audio](functions-4.md#get_volume_audio)
|
||||
- [hud_get_value](functions-4.md#hud_get_value)
|
||||
- [hud_hide](functions-4.md#hud_hide)
|
||||
- [hud_render_power_meter](functions-4.md#hud_render_power_meter)
|
||||
- [hud_set_value](functions-4.md#hud_set_value)
|
||||
- [hud_show](functions-4.md#hud_show)
|
||||
- [load_audio](functions-4.md#load_audio)
|
||||
- [load_sample](functions-4.md#load_sample)
|
||||
- [movtexqc_register](functions-4.md#movtexqc_register)
|
||||
- [pause_audio](functions-4.md#pause_audio)
|
||||
- [play_audio](functions-4.md#play_audio)
|
||||
- [play_transition](functions-4.md#play_transition)
|
||||
- [save_file_set_using_backup_slot](functions-4.md#save_file_set_using_backup_slot)
|
||||
- [set_environment_region](functions-4.md#set_environment_region)
|
||||
- [set_frequency_audio](functions-4.md#set_frequency_audio)
|
||||
- [set_looping_audio](functions-4.md#set_looping_audio)
|
||||
- [set_override_far](functions-4.md#set_override_far)
|
||||
- [set_override_fov](functions-4.md#set_override_fov)
|
||||
- [set_override_near](functions-4.md#set_override_near)
|
||||
- [set_position_audio](functions-4.md#set_position_audio)
|
||||
- [set_speed_audio](functions-4.md#set_speed_audio)
|
||||
- [set_tempo_audio](functions-4.md#set_tempo_audio)
|
||||
- [set_volume_audio](functions-4.md#set_volume_audio)
|
||||
- [stop_audio](functions-4.md#stop_audio)
|
||||
- [warp_exit_level](functions-4.md#warp_exit_level)
|
||||
- [warp_restart_level](functions-4.md#warp_restart_level)
|
||||
- [warp_to_castle](functions-4.md#warp_to_castle)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
- [AnimInfo](#AnimInfo)
|
||||
- [Animation](#Animation)
|
||||
- [Area](#Area)
|
||||
- [BassAudio](#BassAudio)
|
||||
- [BehaviorDialogs](#BehaviorDialogs)
|
||||
- [BehaviorTrajectories](#BehaviorTrajectories)
|
||||
- [BehaviorValues](#BehaviorValues)
|
||||
|
|
@ -35,6 +36,7 @@
|
|||
- [MarioBodyState](#MarioBodyState)
|
||||
- [MarioState](#MarioState)
|
||||
- [Mod](#Mod)
|
||||
- [ModFile](#ModFile)
|
||||
- [ModeTransitionInfo](#ModeTransitionInfo)
|
||||
- [NetworkPlayer](#NetworkPlayer)
|
||||
- [Object](#Object)
|
||||
|
|
@ -135,6 +137,20 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [BassAudio](#BassAudio)
|
||||
|
||||
| Field | Type | Access |
|
||||
| ----- | ---- | ------ |
|
||||
| file | [ModFile](structs.md#ModFile) | read-only |
|
||||
| handle | `integer` | read-only |
|
||||
| isStream | `boolean` | read-only |
|
||||
| loaded | `boolean` | read-only |
|
||||
| rawData | `string` | read-only |
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [BehaviorDialogs](#BehaviorDialogs)
|
||||
|
||||
| Field | Type | Access |
|
||||
|
|
@ -998,6 +1014,19 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [ModFile](#ModFile)
|
||||
|
||||
| Field | Type | Access |
|
||||
| ----- | ---- | ------ |
|
||||
| cachedPath | `string` | read-only |
|
||||
| complete | `boolean` | read-only |
|
||||
| curOffset | `integer` | read-only |
|
||||
| relativePath | `string` | read-only |
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [ModeTransitionInfo](#ModeTransitionInfo)
|
||||
|
||||
| Field | Type | Access |
|
||||
|
|
|
|||
|
|
@ -1165,7 +1165,7 @@ static void select_current_sounds(u8 bank) {
|
|||
*
|
||||
* Called from threads: thread4_sound, thread5_game_loop (EU only)
|
||||
*/
|
||||
static f32 get_sound_pan(f32 x, f32 z) {
|
||||
f32 get_sound_pan(f32 x, f32 z) {
|
||||
f32 absX;
|
||||
f32 absZ;
|
||||
f32 pan;
|
||||
|
|
@ -2750,3 +2750,20 @@ void sound_set_background_music_default_volume(u8 seqId, u8 volume) {
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
f32 sound_get_level_intensity(f32 distance) {
|
||||
f32 intensity = 0;
|
||||
if (distance > AUDIO_MAX_DISTANCE) {
|
||||
intensity = 0;
|
||||
}
|
||||
|
||||
f32 volumeRange = VOLUME_RANGE_UNK1;
|
||||
f32 maxSoundDistance = sLevelAcousticReaches[gCurrLevelNum] / 2.0f;
|
||||
if (maxSoundDistance < distance) {
|
||||
intensity = ((AUDIO_MAX_DISTANCE - distance) / (AUDIO_MAX_DISTANCE - maxSoundDistance)) * (1.0f - volumeRange);
|
||||
} else {
|
||||
intensity = 1.0f - distance / maxSoundDistance * volumeRange;
|
||||
}
|
||||
|
||||
return volumeRange * intensity * intensity + 1.0f - volumeRange;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,4 +76,7 @@ struct SPTask *unused_80321460();
|
|||
struct SPTask *unused_80321460(void);
|
||||
#endif
|
||||
|
||||
f32 get_sound_pan(f32 x, f32 z);
|
||||
f32 sound_get_level_intensity(f32 distance);
|
||||
|
||||
#endif // AUDIO_EXTERNAL_H
|
||||
|
|
|
|||
|
|
@ -566,6 +566,7 @@ struct Camera
|
|||
/// The y coordinate of the "center" of the area. Unlike areaCenX and areaCenZ, this is only used
|
||||
/// when paused. See zoom_out_if_paused_and_outside
|
||||
/*0x68*/ f32 areaCenY;
|
||||
/*????*/ Mat4 mtx;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -498,6 +498,9 @@ static void geo_process_camera(struct GraphNodeCamera *node) {
|
|||
// Increment the matrix stack, If we fail to do so. Just return.
|
||||
if (!increment_mat_stack()) { return; }
|
||||
|
||||
// save the camera matrix
|
||||
mtxf_copy(gCamera->mtx, gMatStack[gMatStackIndex]);
|
||||
|
||||
if (node->fnNode.node.children != 0) {
|
||||
gCurGraphNodeCamera = node;
|
||||
node->matrixPtr = &gMatStack[gMatStackIndex];
|
||||
|
|
|
|||
|
|
@ -371,6 +371,7 @@ static int smlua__get_field(lua_State* L) {
|
|||
case LVT_S16: lua_pushinteger(L, *(s16*)p); break;
|
||||
case LVT_S32: lua_pushinteger(L, *(s32*)p); break;
|
||||
case LVT_F32: lua_pushnumber( L, *(f32*)p); break;
|
||||
case LVT_U64: lua_pushinteger(L, *(u64*)p); break;
|
||||
case LVT_COBJECT: smlua_push_object(L, data->lot, p); break;
|
||||
case LVT_COBJECT_P: smlua_push_object(L, data->lot, *(u8**)p); break;
|
||||
case LVT_STRING: lua_pushstring(L, (char*)p); break;
|
||||
|
|
@ -389,6 +390,7 @@ static int smlua__get_field(lua_State* L) {
|
|||
case LVT_S16_P:
|
||||
case LVT_S32_P:
|
||||
case LVT_F32_P:
|
||||
case LVT_U64_P:
|
||||
case LVT_BEHAVIORSCRIPT_P:
|
||||
case LVT_OBJECTANIMPOINTER_P:
|
||||
case LVT_COLLISION_P:
|
||||
|
|
@ -462,6 +464,7 @@ static int smlua__set_field(lua_State* L) {
|
|||
case LVT_S16: *(s16*)p = smlua_to_integer(L, 4); break;
|
||||
case LVT_S32: *(s32*)p = smlua_to_integer(L, 4); break;
|
||||
case LVT_F32: *(f32*)p = smlua_to_number(L, 4); break;
|
||||
case LVT_U64: *(s64*)p = smlua_to_integer(L, 4); break;
|
||||
|
||||
case LVT_COBJECT_P:
|
||||
valuePointer = smlua_to_cobject(L, 4, data->lot);
|
||||
|
|
@ -478,6 +481,7 @@ static int smlua__set_field(lua_State* L) {
|
|||
case LVT_S16_P:
|
||||
case LVT_S32_P:
|
||||
case LVT_F32_P:
|
||||
case LVT_U64_P:
|
||||
case LVT_BEHAVIORSCRIPT_P:
|
||||
case LVT_OBJECTANIMPOINTER_P:
|
||||
case LVT_COLLISION_P:
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ enum LuaValueType {
|
|||
LVT_S32_P,
|
||||
LVT_F32,
|
||||
LVT_F32_P,
|
||||
LVT_U64,
|
||||
LVT_U64_P,
|
||||
LVT_COBJECT,
|
||||
LVT_COBJECT_P,
|
||||
LVT_STRING,
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
#include "src/pc/network/network.h"
|
||||
#include "src/game/hardcoded.h"
|
||||
#include "src/pc/mods/mod.h"
|
||||
#include "src/pc/lua/utils/smlua_audio_utils.h"
|
||||
|
||||
#include "include/object_fields.h"
|
||||
|
||||
|
|
@ -75,6 +76,15 @@ static struct LuaObjectField sAreaFields[LUA_AREA_FIELD_COUNT] = {
|
|||
// { "whirlpools", LOT_???, offsetof(struct Area, whirlpools), false, LOT_??? }, <--- UNIMPLEMENTED
|
||||
};
|
||||
|
||||
#define LUA_BASS_AUDIO_FIELD_COUNT 5
|
||||
static struct LuaObjectField sBassAudioFields[LUA_BASS_AUDIO_FIELD_COUNT] = {
|
||||
{ "file", LVT_COBJECT_P, offsetof(struct BassAudio, file), true, LOT_MODFILE },
|
||||
{ "handle", LVT_U32, offsetof(struct BassAudio, handle), true, LOT_NONE },
|
||||
{ "isStream", LVT_BOOL, offsetof(struct BassAudio, isStream), true, LOT_NONE },
|
||||
{ "loaded", LVT_BOOL, offsetof(struct BassAudio, loaded), true, LOT_NONE },
|
||||
{ "rawData", LVT_STRING_P, offsetof(struct BassAudio, rawData), true, LOT_NONE },
|
||||
};
|
||||
|
||||
#define LUA_BEHAVIOR_DIALOGS_FIELD_COUNT 84
|
||||
static struct LuaObjectField sBehaviorDialogsFields[LUA_BEHAVIOR_DIALOGS_FIELD_COUNT] = {
|
||||
{ "BobombBuddyBob1Dialog", LVT_S32, offsetof(struct BehaviorDialogs, BobombBuddyBob1Dialog), false, LOT_NONE },
|
||||
|
|
@ -233,6 +243,7 @@ static struct LuaObjectField sCameraFields[LUA_CAMERA_FIELD_COUNT] = {
|
|||
// { "filler3C", LOT_???, offsetof(struct Camera, filler3C), false, LOT_??? }, <--- UNIMPLEMENTED
|
||||
{ "focus", LVT_COBJECT, offsetof(struct Camera, focus), true, LOT_VEC3F },
|
||||
{ "mode", LVT_U8, offsetof(struct Camera, mode), false, LOT_NONE },
|
||||
// { "mtx", LVT_???, offsetof(struct Camera, mtx), false, LOT_??? }, <--- UNIMPLEMENTED
|
||||
{ "nextYaw", LVT_S16, offsetof(struct Camera, nextYaw), false, LOT_NONE },
|
||||
{ "pos", LVT_COBJECT, offsetof(struct Camera, pos), true, LOT_VEC3F },
|
||||
{ "unusedVec1", LVT_COBJECT, offsetof(struct Camera, unusedVec1), true, LOT_VEC3F },
|
||||
|
|
@ -810,6 +821,17 @@ static struct LuaObjectField sModFields[LUA_MOD_FIELD_COUNT] = {
|
|||
// { "size", LVT_???, offsetof(struct Mod, size), true, LOT_??? }, <--- UNIMPLEMENTED
|
||||
};
|
||||
|
||||
#define LUA_MOD_FILE_FIELD_COUNT 4
|
||||
static struct LuaObjectField sModFileFields[LUA_MOD_FILE_FIELD_COUNT] = {
|
||||
{ "cachedPath", LVT_STRING_P, offsetof(struct ModFile, cachedPath), true, LOT_NONE },
|
||||
{ "complete", LVT_BOOL, offsetof(struct ModFile, complete), true, LOT_NONE },
|
||||
{ "curOffset", LVT_U64, offsetof(struct ModFile, curOffset), true, LOT_NONE },
|
||||
// { "dataHash", LOT_???, offsetof(struct ModFile, dataHash), true, LOT_??? }, <--- UNIMPLEMENTED
|
||||
// { "fp", LVT_???, offsetof(struct ModFile, fp), true, LOT_??? }, <--- UNIMPLEMENTED
|
||||
{ "relativePath", LVT_STRING, offsetof(struct ModFile, relativePath), true, LOT_NONE },
|
||||
// { "size", LVT_???, offsetof(struct ModFile, size), true, LOT_??? }, <--- UNIMPLEMENTED
|
||||
};
|
||||
|
||||
#define LUA_MODE_TRANSITION_INFO_FIELD_COUNT 6
|
||||
static struct LuaObjectField sModeTransitionInfoFields[LUA_MODE_TRANSITION_INFO_FIELD_COUNT] = {
|
||||
{ "frame", LVT_S16, offsetof(struct ModeTransitionInfo, frame), false, LOT_NONE },
|
||||
|
|
@ -1899,6 +1921,7 @@ struct LuaObjectTable sLuaObjectAutogenTable[LOT_AUTOGEN_MAX - LOT_AUTOGEN_MIN]
|
|||
{ LOT_ANIMINFO, sAnimInfoFields, LUA_ANIM_INFO_FIELD_COUNT },
|
||||
{ LOT_ANIMATION, sAnimationFields, LUA_ANIMATION_FIELD_COUNT },
|
||||
{ LOT_AREA, sAreaFields, LUA_AREA_FIELD_COUNT },
|
||||
{ LOT_BASSAUDIO, sBassAudioFields, LUA_BASS_AUDIO_FIELD_COUNT },
|
||||
{ LOT_BEHAVIORDIALOGS, sBehaviorDialogsFields, LUA_BEHAVIOR_DIALOGS_FIELD_COUNT },
|
||||
{ LOT_BEHAVIORTRAJECTORIES, sBehaviorTrajectoriesFields, LUA_BEHAVIOR_TRAJECTORIES_FIELD_COUNT },
|
||||
{ LOT_BEHAVIORVALUES, sBehaviorValuesFields, LUA_BEHAVIOR_VALUES_FIELD_COUNT },
|
||||
|
|
@ -1929,6 +1952,7 @@ struct LuaObjectTable sLuaObjectAutogenTable[LOT_AUTOGEN_MAX - LOT_AUTOGEN_MIN]
|
|||
{ LOT_MARIOBODYSTATE, sMarioBodyStateFields, LUA_MARIO_BODY_STATE_FIELD_COUNT },
|
||||
{ LOT_MARIOSTATE, sMarioStateFields, LUA_MARIO_STATE_FIELD_COUNT },
|
||||
{ LOT_MOD, sModFields, LUA_MOD_FIELD_COUNT },
|
||||
{ LOT_MODFILE, sModFileFields, LUA_MOD_FILE_FIELD_COUNT },
|
||||
{ LOT_MODETRANSITIONINFO, sModeTransitionInfoFields, LUA_MODE_TRANSITION_INFO_FIELD_COUNT },
|
||||
{ LOT_NETWORKPLAYER, sNetworkPlayerFields, LUA_NETWORK_PLAYER_FIELD_COUNT },
|
||||
{ LOT_OBJECT, sObjectFields, LUA_OBJECT_FIELD_COUNT },
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ enum LuaObjectAutogenType {
|
|||
LOT_ANIMINFO,
|
||||
LOT_ANIMATION,
|
||||
LOT_AREA,
|
||||
LOT_BASSAUDIO,
|
||||
LOT_BEHAVIORDIALOGS,
|
||||
LOT_BEHAVIORTRAJECTORIES,
|
||||
LOT_BEHAVIORVALUES,
|
||||
|
|
@ -38,6 +39,7 @@ enum LuaObjectAutogenType {
|
|||
LOT_MARIOBODYSTATE,
|
||||
LOT_MARIOSTATE,
|
||||
LOT_MOD,
|
||||
LOT_MODFILE,
|
||||
LOT_MODETRANSITIONINFO,
|
||||
LOT_NETWORKPLAYER,
|
||||
LOT_OBJECT,
|
||||
|
|
|
|||
|
|
@ -14592,6 +14592,247 @@ int smlua_func_save_file_set_flags(lua_State* L) {
|
|||
// smlua_audio_utils.h //
|
||||
/////////////////////////
|
||||
|
||||
int smlua_func_audio_sample_destroy(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
|
||||
audio_sample_destroy(audio);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_audio_sample_load(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
const char* filename = smlua_to_string(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
|
||||
smlua_push_object(L, LOT_BASSAUDIO, audio_sample_load(filename));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_audio_sample_play(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 3)) { return 0; }
|
||||
|
||||
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
|
||||
f32* position = smlua_get_vec3f_from_buffer();
|
||||
position[0] = smlua_get_number_field(2, "x");
|
||||
position[1] = smlua_get_number_field(2, "y");
|
||||
position[2] = smlua_get_number_field(2, "z");
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2"); return 0; }
|
||||
f32 volume = smlua_to_number(L, 3);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 3"); return 0; }
|
||||
|
||||
audio_sample_play(audio, position, volume);
|
||||
|
||||
smlua_push_number_field(2, "x", position[0]);
|
||||
smlua_push_number_field(2, "y", position[1]);
|
||||
smlua_push_number_field(2, "z", position[2]);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_audio_stream_destroy(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
|
||||
audio_stream_destroy(audio);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_audio_stream_get_frequency(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
|
||||
lua_pushnumber(L, audio_stream_get_frequency(audio));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_audio_stream_get_looping(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
|
||||
lua_pushboolean(L, audio_stream_get_looping(audio));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_audio_stream_get_position(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
|
||||
lua_pushnumber(L, audio_stream_get_position(audio));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_audio_stream_get_tempo(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
|
||||
lua_pushnumber(L, audio_stream_get_tempo(audio));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_audio_stream_get_volume(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
|
||||
lua_pushnumber(L, audio_stream_get_volume(audio));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_audio_stream_load(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
const char* filename = smlua_to_string(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
|
||||
smlua_push_object(L, LOT_BASSAUDIO, audio_stream_load(filename));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_audio_stream_pause(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
|
||||
audio_stream_pause(audio);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_audio_stream_play(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 3)) { return 0; }
|
||||
|
||||
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
bool restart = smlua_to_boolean(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2"); return 0; }
|
||||
f32 volume = smlua_to_number(L, 3);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 3"); return 0; }
|
||||
|
||||
audio_stream_play(audio, restart, volume);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_audio_stream_set_frequency(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 2)) { return 0; }
|
||||
|
||||
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
f32 freq = smlua_to_number(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2"); return 0; }
|
||||
|
||||
audio_stream_set_frequency(audio, freq);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_audio_stream_set_looping(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 2)) { return 0; }
|
||||
|
||||
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
bool looping = smlua_to_boolean(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2"); return 0; }
|
||||
|
||||
audio_stream_set_looping(audio, looping);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_audio_stream_set_position(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 2)) { return 0; }
|
||||
|
||||
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
f32 pos = smlua_to_number(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2"); return 0; }
|
||||
|
||||
audio_stream_set_position(audio, pos);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_audio_stream_set_speed(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 4)) { return 0; }
|
||||
|
||||
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
f32 initial_freq = smlua_to_number(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2"); return 0; }
|
||||
f32 speed = smlua_to_number(L, 3);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 3"); return 0; }
|
||||
bool pitch = smlua_to_boolean(L, 4);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 4"); return 0; }
|
||||
|
||||
audio_stream_set_speed(audio, initial_freq, speed, pitch);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_audio_stream_set_tempo(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 2)) { return 0; }
|
||||
|
||||
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
f32 tempo = smlua_to_number(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2"); return 0; }
|
||||
|
||||
audio_stream_set_tempo(audio, tempo);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_audio_stream_set_volume(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 2)) { return 0; }
|
||||
|
||||
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
f32 volume = smlua_to_number(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2"); return 0; }
|
||||
|
||||
audio_stream_set_volume(audio, volume);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_audio_stream_stop(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
|
||||
audio_stream_stop(audio);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_smlua_audio_utils_replace_sequence(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 4)) { return 0; }
|
||||
|
||||
|
|
@ -14707,39 +14948,6 @@ int smlua_func_deref_s32_pointer(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_destroy_audio(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
u32 audio_stream = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
|
||||
destroy_audio(audio_stream);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_destroy_sample(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
u32 audio_stream = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
|
||||
destroy_sample(audio_stream);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_get_audio_from_sample(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
u32 sample = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
|
||||
lua_pushinteger(L, get_audio_from_sample(sample));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_get_current_save_file_num(UNUSED lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
|
||||
|
||||
|
|
@ -14760,17 +14968,6 @@ int smlua_func_get_environment_region(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_get_frequency_audio(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
u32 audio_stream = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
|
||||
lua_pushnumber(L, get_frequency_audio(audio_stream));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_get_hand_foot_pos_x(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 2)) { return 0; }
|
||||
|
||||
|
|
@ -14810,17 +15007,6 @@ int smlua_func_get_hand_foot_pos_z(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_get_looping_audio(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
u32 audio_stream = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
|
||||
lua_pushboolean(L, get_looping_audio(audio_stream));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_get_network_area_timer(UNUSED lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
|
||||
|
||||
|
|
@ -14830,17 +15016,6 @@ int smlua_func_get_network_area_timer(UNUSED lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_get_position_audio(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
u32 audio_stream = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
|
||||
lua_pushnumber(L, get_position_audio(audio_stream));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_get_temp_s32_pointer(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
|
|
@ -14852,28 +15027,6 @@ int smlua_func_get_temp_s32_pointer(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_get_tempo_audio(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
u32 audio_stream = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
|
||||
lua_pushnumber(L, get_tempo_audio(audio_stream));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_get_volume_audio(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
u32 audio_stream = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
|
||||
lua_pushnumber(L, get_volume_audio(audio_stream));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_hud_get_value(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
|
|
@ -14935,28 +15088,6 @@ int smlua_func_hud_show(UNUSED lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_load_audio(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
const char* file_name = smlua_to_string(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
|
||||
lua_pushinteger(L, load_audio(file_name));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_load_sample(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
const char* file_name = smlua_to_string(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
|
||||
lua_pushinteger(L, load_sample(file_name));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_movtexqc_register(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 4)) { return 0; }
|
||||
|
||||
|
|
@ -14974,30 +15105,6 @@ int smlua_func_movtexqc_register(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_pause_audio(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
u32 audio_stream = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
|
||||
pause_audio(audio_stream);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_play_audio(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 2)) { return 0; }
|
||||
|
||||
u32 audio_stream = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
bool restart = smlua_to_boolean(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2"); return 0; }
|
||||
|
||||
play_audio(audio_stream, restart);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_play_transition(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 5)) { return 0; }
|
||||
|
||||
|
|
@ -15041,32 +15148,6 @@ int smlua_func_set_environment_region(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_set_frequency_audio(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 2)) { return 0; }
|
||||
|
||||
u32 audio_stream = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
f32 freq = smlua_to_number(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2"); return 0; }
|
||||
|
||||
set_frequency_audio(audio_stream, freq);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_set_looping_audio(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 2)) { return 0; }
|
||||
|
||||
u32 audio_stream = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
bool looping = smlua_to_boolean(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2"); return 0; }
|
||||
|
||||
set_looping_audio(audio_stream, looping);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_set_override_far(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
|
|
@ -15100,73 +15181,6 @@ int smlua_func_set_override_near(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_set_position_audio(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 2)) { return 0; }
|
||||
|
||||
u32 audio_stream = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
f32 pos = smlua_to_number(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2"); return 0; }
|
||||
|
||||
set_position_audio(audio_stream, pos);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_set_speed_audio(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 4)) { return 0; }
|
||||
|
||||
u32 audio_stream = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
f32 initial_freq = smlua_to_number(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2"); return 0; }
|
||||
f32 speed = smlua_to_number(L, 3);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 3"); return 0; }
|
||||
bool pitch = smlua_to_boolean(L, 4);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 4"); return 0; }
|
||||
|
||||
set_speed_audio(audio_stream, initial_freq, speed, pitch);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_set_tempo_audio(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 2)) { return 0; }
|
||||
|
||||
u32 audio_stream = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
f32 tempo = smlua_to_number(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2"); return 0; }
|
||||
|
||||
set_tempo_audio(audio_stream, tempo);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_set_volume_audio(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 2)) { return 0; }
|
||||
|
||||
u32 audio_stream = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
f32 volume = smlua_to_number(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2"); return 0; }
|
||||
|
||||
set_volume_audio(audio_stream, volume);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_stop_audio(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
u32 audio_stream = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
|
||||
stop_audio(audio_stream);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_warp_exit_level(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
|
|
@ -17378,6 +17392,25 @@ void smlua_bind_functions_autogen(void) {
|
|||
smlua_bind_function(L, "save_file_set_flags", smlua_func_save_file_set_flags);
|
||||
|
||||
// smlua_audio_utils.h
|
||||
smlua_bind_function(L, "audio_sample_destroy", smlua_func_audio_sample_destroy);
|
||||
smlua_bind_function(L, "audio_sample_load", smlua_func_audio_sample_load);
|
||||
smlua_bind_function(L, "audio_sample_play", smlua_func_audio_sample_play);
|
||||
smlua_bind_function(L, "audio_stream_destroy", smlua_func_audio_stream_destroy);
|
||||
smlua_bind_function(L, "audio_stream_get_frequency", smlua_func_audio_stream_get_frequency);
|
||||
smlua_bind_function(L, "audio_stream_get_looping", smlua_func_audio_stream_get_looping);
|
||||
smlua_bind_function(L, "audio_stream_get_position", smlua_func_audio_stream_get_position);
|
||||
smlua_bind_function(L, "audio_stream_get_tempo", smlua_func_audio_stream_get_tempo);
|
||||
smlua_bind_function(L, "audio_stream_get_volume", smlua_func_audio_stream_get_volume);
|
||||
smlua_bind_function(L, "audio_stream_load", smlua_func_audio_stream_load);
|
||||
smlua_bind_function(L, "audio_stream_pause", smlua_func_audio_stream_pause);
|
||||
smlua_bind_function(L, "audio_stream_play", smlua_func_audio_stream_play);
|
||||
smlua_bind_function(L, "audio_stream_set_frequency", smlua_func_audio_stream_set_frequency);
|
||||
smlua_bind_function(L, "audio_stream_set_looping", smlua_func_audio_stream_set_looping);
|
||||
smlua_bind_function(L, "audio_stream_set_position", smlua_func_audio_stream_set_position);
|
||||
smlua_bind_function(L, "audio_stream_set_speed", smlua_func_audio_stream_set_speed);
|
||||
smlua_bind_function(L, "audio_stream_set_tempo", smlua_func_audio_stream_set_tempo);
|
||||
smlua_bind_function(L, "audio_stream_set_volume", smlua_func_audio_stream_set_volume);
|
||||
smlua_bind_function(L, "audio_stream_stop", smlua_func_audio_stream_stop);
|
||||
smlua_bind_function(L, "smlua_audio_utils_replace_sequence", smlua_func_smlua_audio_utils_replace_sequence);
|
||||
smlua_bind_function(L, "smlua_audio_utils_reset_all", smlua_func_smlua_audio_utils_reset_all);
|
||||
|
||||
|
|
@ -17391,44 +17424,25 @@ void smlua_bind_functions_autogen(void) {
|
|||
smlua_bind_function(L, "camera_freeze", smlua_func_camera_freeze);
|
||||
smlua_bind_function(L, "camera_unfreeze", smlua_func_camera_unfreeze);
|
||||
smlua_bind_function(L, "deref_s32_pointer", smlua_func_deref_s32_pointer);
|
||||
smlua_bind_function(L, "destroy_audio", smlua_func_destroy_audio);
|
||||
smlua_bind_function(L, "destroy_sample", smlua_func_destroy_sample);
|
||||
smlua_bind_function(L, "get_audio_from_sample", smlua_func_get_audio_from_sample);
|
||||
smlua_bind_function(L, "get_current_save_file_num", smlua_func_get_current_save_file_num);
|
||||
smlua_bind_function(L, "get_environment_region", smlua_func_get_environment_region);
|
||||
smlua_bind_function(L, "get_frequency_audio", smlua_func_get_frequency_audio);
|
||||
smlua_bind_function(L, "get_hand_foot_pos_x", smlua_func_get_hand_foot_pos_x);
|
||||
smlua_bind_function(L, "get_hand_foot_pos_y", smlua_func_get_hand_foot_pos_y);
|
||||
smlua_bind_function(L, "get_hand_foot_pos_z", smlua_func_get_hand_foot_pos_z);
|
||||
smlua_bind_function(L, "get_looping_audio", smlua_func_get_looping_audio);
|
||||
smlua_bind_function(L, "get_network_area_timer", smlua_func_get_network_area_timer);
|
||||
smlua_bind_function(L, "get_position_audio", smlua_func_get_position_audio);
|
||||
smlua_bind_function(L, "get_temp_s32_pointer", smlua_func_get_temp_s32_pointer);
|
||||
smlua_bind_function(L, "get_tempo_audio", smlua_func_get_tempo_audio);
|
||||
smlua_bind_function(L, "get_volume_audio", smlua_func_get_volume_audio);
|
||||
smlua_bind_function(L, "hud_get_value", smlua_func_hud_get_value);
|
||||
smlua_bind_function(L, "hud_hide", smlua_func_hud_hide);
|
||||
smlua_bind_function(L, "hud_render_power_meter", smlua_func_hud_render_power_meter);
|
||||
smlua_bind_function(L, "hud_set_value", smlua_func_hud_set_value);
|
||||
smlua_bind_function(L, "hud_show", smlua_func_hud_show);
|
||||
smlua_bind_function(L, "load_audio", smlua_func_load_audio);
|
||||
smlua_bind_function(L, "load_sample", smlua_func_load_sample);
|
||||
smlua_bind_function(L, "movtexqc_register", smlua_func_movtexqc_register);
|
||||
smlua_bind_function(L, "pause_audio", smlua_func_pause_audio);
|
||||
smlua_bind_function(L, "play_audio", smlua_func_play_audio);
|
||||
smlua_bind_function(L, "play_transition", smlua_func_play_transition);
|
||||
smlua_bind_function(L, "save_file_set_using_backup_slot", smlua_func_save_file_set_using_backup_slot);
|
||||
smlua_bind_function(L, "set_environment_region", smlua_func_set_environment_region);
|
||||
smlua_bind_function(L, "set_frequency_audio", smlua_func_set_frequency_audio);
|
||||
smlua_bind_function(L, "set_looping_audio", smlua_func_set_looping_audio);
|
||||
smlua_bind_function(L, "set_override_far", smlua_func_set_override_far);
|
||||
smlua_bind_function(L, "set_override_fov", smlua_func_set_override_fov);
|
||||
smlua_bind_function(L, "set_override_near", smlua_func_set_override_near);
|
||||
smlua_bind_function(L, "set_position_audio", smlua_func_set_position_audio);
|
||||
smlua_bind_function(L, "set_speed_audio", smlua_func_set_speed_audio);
|
||||
smlua_bind_function(L, "set_tempo_audio", smlua_func_set_tempo_audio);
|
||||
smlua_bind_function(L, "set_volume_audio", smlua_func_set_volume_audio);
|
||||
smlua_bind_function(L, "stop_audio", smlua_func_stop_audio);
|
||||
smlua_bind_function(L, "warp_exit_level", smlua_func_warp_exit_level);
|
||||
smlua_bind_function(L, "warp_restart_level", smlua_func_warp_restart_level);
|
||||
smlua_bind_function(L, "warp_to_castle", smlua_func_warp_to_castle);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,15 @@
|
|||
#include "types.h"
|
||||
#include "audio/external.h"
|
||||
#include "game/camera.h"
|
||||
#include "engine/math_util.h"
|
||||
#include "pc/mods/mods.h"
|
||||
#include "pc/lua/smlua.h"
|
||||
#include "pc/debuglog.h"
|
||||
#include "pc/lua/utils/smlua_audio_utils.h"
|
||||
#include "pc/mods/mods_utils.h"
|
||||
#include "bass_audio/bass_audio_helpers.h"
|
||||
#include "pc/debuglog.h"
|
||||
|
||||
#define MAX_OVERRIDE 64
|
||||
#define MAX_AUDIO_OVERRIDE 64
|
||||
|
||||
struct AudioOverride {
|
||||
bool enabled;
|
||||
|
|
@ -16,7 +20,7 @@ struct AudioOverride {
|
|||
u8* buffer;
|
||||
};
|
||||
|
||||
struct AudioOverride sAudioOverrides[MAX_OVERRIDE] = { 0 };
|
||||
struct AudioOverride sAudioOverrides[MAX_AUDIO_OVERRIDE] = { 0 };
|
||||
|
||||
static void smlua_audio_utils_reset(struct AudioOverride* override) {
|
||||
if (override == NULL) { return; }
|
||||
|
|
@ -39,14 +43,14 @@ static void smlua_audio_utils_reset(struct AudioOverride* override) {
|
|||
}
|
||||
|
||||
void smlua_audio_utils_reset_all(void) {
|
||||
for (s32 i = 0; i < MAX_OVERRIDE; i++) {
|
||||
for (s32 i = 0; i < MAX_AUDIO_OVERRIDE; i++) {
|
||||
if (sAudioOverrides[i].enabled) { sound_reset_background_music_default_volume(i); }
|
||||
smlua_audio_utils_reset(&sAudioOverrides[i]);
|
||||
}
|
||||
}
|
||||
|
||||
bool smlua_audio_utils_override(u8 sequenceId, s32* bankId, void** seqData) {
|
||||
if (sequenceId >= MAX_OVERRIDE) { return false; }
|
||||
if (sequenceId >= MAX_AUDIO_OVERRIDE) { return false; }
|
||||
struct AudioOverride* override = &sAudioOverrides[sequenceId];
|
||||
if (!override->enabled) { return false; }
|
||||
|
||||
|
|
@ -88,7 +92,7 @@ bool smlua_audio_utils_override(u8 sequenceId, s32* bankId, void** seqData) {
|
|||
|
||||
void smlua_audio_utils_replace_sequence(u8 sequenceId, u8 bankId, u8 defaultVolume, const char* m64Name) {
|
||||
if (gLuaActiveMod == NULL) { return; }
|
||||
if (sequenceId >= MAX_OVERRIDE) {
|
||||
if (sequenceId >= MAX_AUDIO_OVERRIDE) {
|
||||
LOG_LUA_LINE("Invalid sequenceId given to smlua_audio_utils_replace_sequence(): %d", sequenceId);
|
||||
return;
|
||||
}
|
||||
|
|
@ -124,3 +128,262 @@ void smlua_audio_utils_replace_sequence(u8 sequenceId, u8 bankId, u8 defaultVolu
|
|||
|
||||
LOG_LUA_LINE("Could not find m64 at path: %s", m64path);
|
||||
}
|
||||
|
||||
//////////
|
||||
// bass //
|
||||
//////////
|
||||
|
||||
#define MAX_BASS_FILES 128
|
||||
struct BassAudio sBassAudio[MAX_BASS_FILES];
|
||||
u32 sBassAudioCount = 0;
|
||||
|
||||
static struct BassAudio* find_bass_audio(struct ModFile* file) {
|
||||
for(u16 i = 0; i < sBassAudioCount; i++) {
|
||||
struct BassAudio* audio = &sBassAudio[i];
|
||||
if (audio->file != file) { continue; }
|
||||
return audio;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static bool audio_sanity_check(struct BassAudio* audio, bool isStream, const char* action) {
|
||||
if (audio == NULL || !audio->loaded || audio->handle == 0) {
|
||||
LOG_LUA_LINE("Tried to %s unloaded audio stream", action);
|
||||
return false;
|
||||
}
|
||||
if (isStream && !audio->isStream) {
|
||||
LOG_LUA_LINE("Tried to %s a sample as a stream", action);
|
||||
return false;
|
||||
}
|
||||
if (!isStream && audio->isStream) {
|
||||
LOG_LUA_LINE("Tried to %s a stream as a sample", action);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
struct BassAudio* audio_load_internal(const char* filename, bool isStream) {
|
||||
// find mod file in mod list
|
||||
bool foundModFile = false;
|
||||
struct ModFile* modFile = NULL;
|
||||
u16 fileCount = gLuaActiveMod->fileCount;
|
||||
for(u16 i = 0; i < fileCount; i++) {
|
||||
struct ModFile* file = &gLuaActiveMod->files[i];
|
||||
if(str_ends_with(file->relativePath, (char*)filename)) {
|
||||
foundModFile = true;
|
||||
modFile = file;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!foundModFile) {
|
||||
LOG_LUA_LINE("Could not find audio file: '%s'", filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// find stream in BassAudio list
|
||||
struct BassAudio* bassAudio = find_bass_audio(modFile);
|
||||
if (bassAudio && bassAudio->loaded) {
|
||||
if (isStream == bassAudio->isStream) {
|
||||
return bassAudio;
|
||||
} else if (isStream) {
|
||||
LOG_LUA_LINE("Tried to load a stream, when a sample already exists for '%s'", filename);
|
||||
return NULL;
|
||||
} else {
|
||||
LOG_LUA_LINE("Tried to load a sample, when a stream already exists for '%s'", filename);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// allocate in BassAudio list
|
||||
if (sBassAudioCount >= MAX_BASS_FILES) {
|
||||
LOG_LUA_LINE("Ran out of available audio slots!");
|
||||
return NULL;
|
||||
}
|
||||
if (bassAudio == NULL) {
|
||||
bassAudio = &sBassAudio[sBassAudioCount++];
|
||||
}
|
||||
|
||||
// remember file
|
||||
bassAudio->file = modFile;
|
||||
|
||||
// copy audio into rawData
|
||||
rewind(modFile->fp);
|
||||
bassAudio->rawData = (char*)malloc(modFile->size * sizeof(char));
|
||||
fread(bassAudio->rawData, modFile->size, 1, modFile->fp);
|
||||
|
||||
// load audio and return it
|
||||
if (isStream) {
|
||||
bassAudio->handle = bassh_create_fx_stream_from_file(bassAudio->rawData, modFile->size, 0);
|
||||
bassAudio->isStream = true;
|
||||
} else {
|
||||
bassAudio->handle = bassh_create_sample_from_file(bassAudio->rawData, modFile->size, 0);
|
||||
bassAudio->isStream = false;
|
||||
}
|
||||
bassAudio->loaded = true;
|
||||
return bassAudio;
|
||||
}
|
||||
|
||||
struct BassAudio* audio_stream_load(const char* filename) {
|
||||
return audio_load_internal(filename, true);
|
||||
}
|
||||
|
||||
void audio_stream_destroy(struct BassAudio* audio) {
|
||||
if (!audio_sanity_check(audio, true, "destroy")) {
|
||||
return;
|
||||
}
|
||||
|
||||
bassh_free_stream(audio->handle);
|
||||
audio->handle = 0;
|
||||
audio->loaded = false;
|
||||
free(audio->rawData);
|
||||
audio->rawData = NULL;
|
||||
}
|
||||
|
||||
void audio_stream_play(struct BassAudio* audio, bool restart, f32 volume) {
|
||||
if (!audio_sanity_check(audio, true, "play")) {
|
||||
return;
|
||||
}
|
||||
f32 masterVolume = (f32)configMasterVolume / 127.0f;
|
||||
f32 musicVolume = (f32)configMusicVolume / 127.0f;
|
||||
bassh_set_stream_volume(audio->handle, masterVolume * musicVolume * volume);
|
||||
bassh_play_stream(audio->handle, restart);
|
||||
}
|
||||
|
||||
void audio_stream_pause(struct BassAudio* audio) {
|
||||
if (!audio_sanity_check(audio, true, "pause")) {
|
||||
return;
|
||||
}
|
||||
bassh_pause_stream(audio->handle);
|
||||
}
|
||||
|
||||
void audio_stream_stop(struct BassAudio* audio) {
|
||||
if (!audio_sanity_check(audio, true, "stop")) {
|
||||
return;
|
||||
}
|
||||
bassh_stop_stream(audio->handle);
|
||||
}
|
||||
|
||||
f32 audio_stream_get_position(struct BassAudio* audio) {
|
||||
if (!audio_sanity_check(audio, true, "getpos")) {
|
||||
return 0;
|
||||
}
|
||||
return (f32)bassh_get_stream_pos(audio->handle);
|
||||
}
|
||||
|
||||
void audio_stream_set_position(struct BassAudio* audio, f32 pos) {
|
||||
if (!audio_sanity_check(audio, true, "setpos")) {
|
||||
return;
|
||||
}
|
||||
bassh_set_stream_pos(audio->handle, (double)pos);
|
||||
}
|
||||
|
||||
bool audio_stream_get_looping(struct BassAudio* audio) {
|
||||
if (!audio_sanity_check(audio, true, "getloop")) {
|
||||
return false;
|
||||
}
|
||||
return bassh_get_looping(audio->handle);
|
||||
}
|
||||
|
||||
void audio_stream_set_looping(struct BassAudio* audio, bool looping) {
|
||||
if (!audio_sanity_check(audio, true, "setloop")) {
|
||||
return;
|
||||
}
|
||||
bassh_set_looping(audio->handle, looping);
|
||||
}
|
||||
|
||||
f32 audio_stream_get_frequency(struct BassAudio* audio) {
|
||||
if (!audio_sanity_check(audio, true, "getfreq")) {
|
||||
return 0;
|
||||
}
|
||||
return bassh_get_frequency(audio->handle);
|
||||
}
|
||||
|
||||
void audio_stream_set_frequency(struct BassAudio* audio, f32 freq) {
|
||||
if (!audio_sanity_check(audio, true, "setfreq")) {
|
||||
return;
|
||||
}
|
||||
bassh_set_frequency(audio->handle, freq);
|
||||
}
|
||||
|
||||
f32 audio_stream_get_tempo(struct BassAudio* audio) {
|
||||
if (!audio_sanity_check(audio, true, "gettempo")) {
|
||||
return 0;
|
||||
}
|
||||
return bassh_get_tempo(audio->handle);
|
||||
}
|
||||
|
||||
void audio_stream_set_tempo(struct BassAudio* audio, f32 tempo) {
|
||||
if (!audio_sanity_check(audio, true, "settempo")) {
|
||||
return;
|
||||
}
|
||||
bassh_set_tempo(audio->handle, tempo);
|
||||
}
|
||||
|
||||
f32 audio_stream_get_volume(struct BassAudio* audio) {
|
||||
if (!audio_sanity_check(audio, true, "getvol")) {
|
||||
return 0;
|
||||
}
|
||||
return bassh_get_stream_volume(audio->handle);
|
||||
}
|
||||
|
||||
void audio_stream_set_volume(struct BassAudio* audio, f32 volume) {
|
||||
if (!audio_sanity_check(audio, true, "setvol")) {
|
||||
return;
|
||||
}
|
||||
f32 masterVolume = (f32)configMasterVolume / 127.0f;
|
||||
f32 musicVolume = (f32)configMusicVolume / 127.0f;
|
||||
bassh_set_stream_volume(audio->handle, masterVolume * musicVolume * volume);
|
||||
}
|
||||
|
||||
void audio_stream_set_speed(struct BassAudio* audio, f32 initial_freq, f32 speed, bool pitch) {
|
||||
if (!audio_sanity_check(audio, true, "setspeed")) {
|
||||
return;
|
||||
}
|
||||
bassh_set_speed(audio->handle, initial_freq, speed, pitch);
|
||||
}
|
||||
|
||||
struct BassAudio* audio_sample_load(const char* filename) {
|
||||
return audio_load_internal(filename, false);
|
||||
}
|
||||
|
||||
void audio_sample_destroy(struct BassAudio* audio) {
|
||||
if (!audio_sanity_check(audio, false, "destroy")) {
|
||||
return;
|
||||
}
|
||||
|
||||
bassh_free_stream(audio->handle);
|
||||
audio->handle = 0;
|
||||
audio->loaded = false;
|
||||
free(audio->rawData);
|
||||
audio->rawData = NULL;
|
||||
}
|
||||
|
||||
void audio_sample_play(struct BassAudio* audio, Vec3f position, f32 volume) {
|
||||
if (!audio_sanity_check(audio, false, "play")) {
|
||||
return;
|
||||
}
|
||||
HSTREAM stream = bassh_sample_get_stream(audio->handle);
|
||||
|
||||
f32 dist = 0;
|
||||
f32 pan = 0;
|
||||
if (gCamera) {
|
||||
f32 dX = position[0] - gCamera->pos[0];
|
||||
f32 dY = position[1] - gCamera->pos[1];
|
||||
f32 dZ = position[2] - gCamera->pos[2];
|
||||
dist = sqrtf(dX * dX + dY * dY + dZ * dZ);
|
||||
|
||||
Mat4 mtx;
|
||||
mtxf_translate(mtx, position);
|
||||
mtxf_mul(mtx, mtx, gCamera->mtx);
|
||||
f32 factor = 5;
|
||||
pan = (get_sound_pan(mtx[3][0] * factor, mtx[3][2] * factor) - 0.5f) * 2.0f;
|
||||
}
|
||||
|
||||
f32 intensity = sound_get_level_intensity(dist);
|
||||
f32 masterVolume = (f32)configMasterVolume / 127.0f;
|
||||
f32 sfxVolume = (f32)configSfxVolume / 127.0f;
|
||||
BASS_ChannelSetAttribute(stream, BASS_ATTRIB_VOL, masterVolume * sfxVolume * volume * intensity);
|
||||
BASS_ChannelSetAttribute(stream, BASS_ATTRIB_PAN, pan);
|
||||
|
||||
bassh_play_stream(stream, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,4 +5,37 @@ void smlua_audio_utils_reset_all(void);
|
|||
bool smlua_audio_utils_override(u8 sequenceId, s32* bankId, void** seqData);
|
||||
void smlua_audio_utils_replace_sequence(u8 sequenceId, u8 bankId, u8 defaultVolume, const char* m64Name);
|
||||
|
||||
//////////
|
||||
// bass //
|
||||
//////////
|
||||
|
||||
struct BassAudio {
|
||||
struct ModFile* file;
|
||||
char* rawData;
|
||||
bool isStream;
|
||||
bool loaded;
|
||||
u32 handle;
|
||||
};
|
||||
|
||||
struct BassAudio* audio_stream_load(const char* filename);
|
||||
void audio_stream_destroy(struct BassAudio* audio);
|
||||
void audio_stream_play(struct BassAudio* audio, bool restart, f32 volume);
|
||||
void audio_stream_pause(struct BassAudio* audio);
|
||||
void audio_stream_stop(struct BassAudio* audio);
|
||||
f32 audio_stream_get_position(struct BassAudio* audio);
|
||||
void audio_stream_set_position(struct BassAudio* audio, f32 pos);
|
||||
bool audio_stream_get_looping(struct BassAudio* audio);
|
||||
void audio_stream_set_looping(struct BassAudio* audio, bool looping);
|
||||
f32 audio_stream_get_frequency(struct BassAudio* audio);
|
||||
void audio_stream_set_frequency(struct BassAudio* audio, f32 freq);
|
||||
f32 audio_stream_get_tempo(struct BassAudio* audio);
|
||||
void audio_stream_set_tempo(struct BassAudio* audio, f32 tempo);
|
||||
f32 audio_stream_get_volume(struct BassAudio* audio);
|
||||
void audio_stream_set_volume(struct BassAudio* audio, f32 volume);
|
||||
void audio_stream_set_speed(struct BassAudio* audio, f32 initial_freq, f32 speed, bool pitch);
|
||||
|
||||
struct BassAudio* audio_sample_load(const char* filename);
|
||||
void audio_sample_destroy(struct BassAudio* audio);
|
||||
void audio_sample_play(struct BassAudio* audio, Vec3f position, f32 volume);
|
||||
|
||||
#endif
|
||||
|
|
@ -16,8 +16,6 @@
|
|||
#include "game/level_update.h"
|
||||
#include "pc/djui/djui_hud_utils.h"
|
||||
|
||||
#include "src/bass_audio/bass_audio_helpers.h"
|
||||
|
||||
u32 get_network_area_timer(void) {
|
||||
return gNetworkAreaTimer;
|
||||
}
|
||||
|
|
@ -181,212 +179,12 @@ f32 get_environment_region(u8 index) {
|
|||
return -11000;
|
||||
}
|
||||
|
||||
u32 load_audio(const char* file_name) {
|
||||
u16 fileCount = gLuaActiveMod->fileCount;
|
||||
BOOL found = FALSE;
|
||||
struct ModFile* file;
|
||||
for(u16 i = 0; i < fileCount; i++) {
|
||||
LOG_INFO("file path %s", gLuaActiveMod->files[i].relativePath);
|
||||
if(str_ends_with(gLuaActiveMod->files[i].relativePath, (char *)file_name)) {
|
||||
// char fullPath[SYS_MAX_PATH] = { 0 };
|
||||
// mod_file_full_path(fullPath, gLuaActiveMod, &(gLuaActiveMod->files[i]));
|
||||
|
||||
file = &gLuaActiveMod->files[i];
|
||||
found = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if(found == FALSE) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
//smh free your stuff first...
|
||||
if(file->audio_stream != 0) {
|
||||
LOG_LUA("You need to destroy your stream/sapmle!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
rewind(file->fp); //seek to the start of the file
|
||||
|
||||
//Allocate a buffer to the data
|
||||
file->data_ptr = (char *)malloc(file->size * sizeof(char));
|
||||
//Read the file data into the buffer
|
||||
fread(file->data_ptr, file->size, 1, file->fp);
|
||||
|
||||
file->audio_stream = bassh_create_fx_stream_from_file(file->data_ptr, file->size, 0);
|
||||
|
||||
return file->audio_stream;
|
||||
|
||||
// return bassh_create_fx_stream_from_file();
|
||||
}
|
||||
|
||||
void destroy_audio(u32 audio_stream) {
|
||||
u16 fileCount = gLuaActiveMod->fileCount;
|
||||
BOOL found = FALSE;
|
||||
struct ModFile* file;
|
||||
for(u16 i = 0; i < fileCount; i++) {
|
||||
if(audio_stream == gLuaActiveMod->files[i].audio_stream) {
|
||||
// char fullPath[SYS_MAX_PATH] = { 0 };
|
||||
// mod_file_full_path(fullPath, gLuaActiveMod, &(gLuaActiveMod->files[i]));
|
||||
|
||||
file = &gLuaActiveMod->files[i];
|
||||
found = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if(found == FALSE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(file->audio_stream == 0) {
|
||||
LOG_LUA("You cant double destroy audio!");
|
||||
return;
|
||||
}
|
||||
|
||||
//This frees the stream
|
||||
bassh_free_stream(audio_stream);
|
||||
|
||||
file->audio_stream = 0;
|
||||
|
||||
//This frees the data the stream uses
|
||||
free(file->data_ptr);
|
||||
}
|
||||
|
||||
void play_audio(u32 audio_stream, bool restart) {
|
||||
bassh_play_stream(audio_stream, restart);
|
||||
}
|
||||
|
||||
void pause_audio(u32 audio_stream) {
|
||||
bassh_pause_stream(audio_stream);
|
||||
}
|
||||
|
||||
void stop_audio(u32 audio_stream) {
|
||||
bassh_stop_stream(audio_stream);
|
||||
}
|
||||
|
||||
f32 get_position_audio(u32 audio_stream) {
|
||||
return (f32)bassh_get_stream_pos(audio_stream);
|
||||
}
|
||||
|
||||
void set_looping_audio(u32 audio_stream, bool looping) {
|
||||
bassh_set_looping(audio_stream, looping);
|
||||
}
|
||||
|
||||
bool get_looping_audio(u32 audio_stream) {
|
||||
return bassh_get_looping(audio_stream);
|
||||
}
|
||||
|
||||
f32 get_frequency_audio(u32 audio_stream) {
|
||||
return bassh_get_frequency(audio_stream);
|
||||
}
|
||||
|
||||
void set_frequency_audio(u32 audio_stream, f32 freq) {
|
||||
bassh_set_frequency(audio_stream, freq);
|
||||
}
|
||||
|
||||
f32 get_tempo_audio(u32 audio_stream) {
|
||||
return bassh_get_tempo(audio_stream);
|
||||
}
|
||||
|
||||
void set_tempo_audio(u32 audio_stream, f32 tempo) {
|
||||
bassh_set_tempo(audio_stream, tempo);
|
||||
}
|
||||
|
||||
void set_speed_audio(u32 audio_stream, f32 initial_freq, f32 speed, bool pitch) {
|
||||
bassh_set_speed(audio_stream, initial_freq, speed, pitch);
|
||||
}
|
||||
|
||||
void set_volume_audio(u32 audio_stream, f32 volume) {
|
||||
bassh_set_stream_volume(audio_stream, volume);
|
||||
}
|
||||
|
||||
f32 get_volume_audio(u32 audio_stream) {
|
||||
return bassh_get_stream_volume(audio_stream);
|
||||
}
|
||||
|
||||
void set_position_audio(u32 audio_stream, f32 pos) {
|
||||
bassh_set_stream_pos(audio_stream, (double)pos);
|
||||
}
|
||||
|
||||
void set_environment_region(u8 index, s32 value) {
|
||||
if (gEnvironmentRegions != NULL && index <= gEnvironmentRegions[0]) {
|
||||
gEnvironmentRegions[6 * (int)index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
u32 load_sample(const char* file_name) {
|
||||
u16 fileCount = gLuaActiveMod->fileCount;
|
||||
BOOL found = FALSE;
|
||||
struct ModFile* file;
|
||||
for(u16 i = 0; i < fileCount; i++) {
|
||||
LOG_INFO("file path %s", gLuaActiveMod->files[i].relativePath);
|
||||
if(str_ends_with(gLuaActiveMod->files[i].relativePath, (char *)file_name)) {
|
||||
// char fullPath[SYS_MAX_PATH] = { 0 };
|
||||
// mod_file_full_path(fullPath, gLuaActiveMod, &(gLuaActiveMod->files[i]));
|
||||
|
||||
file = &gLuaActiveMod->files[i];
|
||||
found = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if(found == FALSE) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
//smh free your stuff first...
|
||||
if(file->audio_stream != 0) {
|
||||
LOG_LUA("You need to destroy your stream/sapmle!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
rewind(file->fp); //seek to the start of the file
|
||||
|
||||
//Allocate a buffer to the data
|
||||
file->data_ptr = (char *)malloc(file->size * sizeof(char));
|
||||
//Read the file data into the buffer
|
||||
fread(file->data_ptr, file->size, 1, file->fp);
|
||||
|
||||
file->audio_stream = bassh_create_sample_from_file(file->data_ptr, file->size, 0);
|
||||
|
||||
return file->audio_stream;
|
||||
}
|
||||
|
||||
void destroy_sample(u32 audio_stream) {
|
||||
u16 fileCount = gLuaActiveMod->fileCount;
|
||||
BOOL found = FALSE;
|
||||
struct ModFile* file;
|
||||
for(u16 i = 0; i < fileCount; i++) {
|
||||
if(audio_stream == gLuaActiveMod->files[i].audio_stream) {
|
||||
// char fullPath[SYS_MAX_PATH] = { 0 };
|
||||
// mod_file_full_path(fullPath, gLuaActiveMod, &(gLuaActiveMod->files[i]));
|
||||
|
||||
file = &gLuaActiveMod->files[i];
|
||||
found = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if(found == FALSE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(file->audio_stream == 0) {
|
||||
LOG_LUA("You cant double destroy audio!");
|
||||
return;
|
||||
}
|
||||
|
||||
//This frees the stream
|
||||
bassh_free_sample(audio_stream);
|
||||
|
||||
file->audio_stream = 0;
|
||||
|
||||
//This frees the data the stream uses
|
||||
free(file->data_ptr);
|
||||
}
|
||||
|
||||
u32 get_audio_from_sample(u32 sample) {
|
||||
return bassh_sample_get_stream(sample);
|
||||
}
|
||||
|
||||
f32 set_override_fov(f32 fov) {
|
||||
gOverrideFOV = fov;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,33 +57,6 @@ void movtexqc_register(const char* name, s16 level, s16 area, s16 type);
|
|||
f32 get_environment_region(u8 index);
|
||||
void set_environment_region(u8 index, s32 value);
|
||||
|
||||
u32 load_audio(const char* file_name);
|
||||
u32 load_sample(const char* file_name);
|
||||
void destroy_audio(u32 audio_stream);
|
||||
void destroy_sample(u32 audio_stream);
|
||||
|
||||
u32 get_audio_from_sample(u32 sample);
|
||||
|
||||
void play_audio(u32 audio_stream, bool restart);
|
||||
void pause_audio(u32 audio_stream);
|
||||
void stop_audio(u32 audio_stream);
|
||||
|
||||
f32 get_position_audio(u32 audio_stream);
|
||||
void set_position_audio(u32 audio_stream, f32 pos);
|
||||
|
||||
bool get_looping_audio(u32 audio_stream);
|
||||
void set_looping_audio(u32 audio_stream, bool looping);
|
||||
|
||||
f32 get_frequency_audio(u32 audio_stream);
|
||||
void set_frequency_audio(u32 audio_stream, f32 freq);
|
||||
f32 get_tempo_audio(u32 audio_stream);
|
||||
void set_tempo_audio(u32 audio_stream, f32 tempo);
|
||||
|
||||
void set_volume_audio(u32 audio_stream, f32 volume);
|
||||
f32 get_volume_audio(u32 audio_stream);
|
||||
|
||||
void set_speed_audio(u32 audio_stream, f32 initial_freq, f32 speed, bool pitch);
|
||||
|
||||
f32 set_override_fov(f32 fov);
|
||||
f32 set_override_near(f32 near);
|
||||
f32 set_override_far(f32 far);
|
||||
|
|
|
|||
|
|
@ -14,10 +14,6 @@ struct ModFile {
|
|||
FILE* fp;
|
||||
u64 curOffset;
|
||||
bool complete;
|
||||
|
||||
//A pointer to a char array of data with size: (ModFile.size * sizeof(char))
|
||||
char* data_ptr;
|
||||
u32 audio_stream;
|
||||
u8 dataHash[16];
|
||||
char* cachedPath;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue