mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-22 03:55:11 +00:00
Merge branch 'audio' into unstable
This commit is contained in:
commit
c7cfa1be54
42 changed files with 3177 additions and 178 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -87,6 +87,8 @@ sm64config.txt
|
|||
!/assets/**/*custom*/**/*.bin
|
||||
!/lib/discordsdk/*.*
|
||||
!/lib/discordsdk/x86/*.*
|
||||
!/lib/bass/**
|
||||
!/lib/bass/x86/**
|
||||
!/lib/lua/**/*.*
|
||||
|
||||
# visual studio
|
||||
|
|
29
Makefile
29
Makefile
|
@ -494,7 +494,7 @@ ACTOR_DIR := actors
|
|||
LEVEL_DIRS := $(patsubst levels/%,%,$(dir $(wildcard levels/*/header.h)))
|
||||
|
||||
# Directories containing source files
|
||||
SRC_DIRS := src src/engine src/game src/audio src/menu src/buffers actors levels bin data assets asm lib sound
|
||||
SRC_DIRS := src src/engine src/game src/audio src/bass_audio src/menu src/buffers actors levels bin data assets asm lib sound
|
||||
BIN_DIRS := bin bin/$(VERSION)
|
||||
|
||||
# PC files
|
||||
|
@ -607,6 +607,23 @@ ifeq ($(DISCORD_SDK), 1)
|
|||
endif
|
||||
endif
|
||||
|
||||
BASS_LIBS :=
|
||||
ifeq ($(WINDOWS_BUILD),1)
|
||||
ifeq ($(TARGET_BITS), 32)
|
||||
BASS_LIBS := lib/bass/x86/bass.dll lib/bass/x86/bass_fx.dll
|
||||
else
|
||||
BASS_LIBS := lib/bass/bass.dll lib/bass/bass_fx.dll
|
||||
endif
|
||||
else ifeq ($(OSX_BUILD),1)
|
||||
# needs testing
|
||||
# HACKY! Instead of figuring out all of the dynamic library linking madness...
|
||||
# I copied the library and gave it two names.
|
||||
# This really shouldn't be required, but I got tired of trying to do it the "right way"
|
||||
BASS_LIBS := lib/bass/bass.dylib lib/bass/libbass.dylib lib/bass/bass_fx.dylib lib/bass/libbass_fx.dylib
|
||||
else
|
||||
BASS_LIBS := lib/bass/libbass.so lib/bass/libbass_fx.so
|
||||
endif
|
||||
|
||||
MOD_DIR := mods
|
||||
|
||||
# Remove old mod dir
|
||||
|
@ -893,14 +910,13 @@ endif
|
|||
ifeq ($(WINDOWS_BUILD),1)
|
||||
LDFLAGS += -L"ws2_32" -lwsock32
|
||||
ifeq ($(DISCORD_SDK),1)
|
||||
LDFLAGS += -Wl,-Bdynamic -L./lib/discordsdk/ -ldiscord_game_sdk -Wl,-Bstatic
|
||||
LDFLAGS += -Wl,-Bdynamic -L./lib/discordsdk/ -L./lib/bass/ -ldiscord_game_sdk -lbass -lbass_fx -Wl,-Bstatic
|
||||
endif
|
||||
else
|
||||
ifeq ($(DISCORD_SDK),1)
|
||||
LDFLAGS += -ldiscord_game_sdk -Wl,-rpath . -Wl,-rpath lib/discordsdk
|
||||
LDFLAGS += -ldiscord_game_sdk -lbass -lbass_fx -Wl,-rpath . -Wl,-rpath lib/discordsdk -Wl,-rpath lib/bass
|
||||
endif
|
||||
endif
|
||||
|
||||
# Prevent a crash with -sopt
|
||||
export LANG := C
|
||||
|
||||
|
@ -1142,6 +1158,9 @@ $(BUILD_DIR)/$(RPC_LIBS):
|
|||
$(BUILD_DIR)/$(DISCORD_SDK_LIBS):
|
||||
@$(CP) -f $(DISCORD_SDK_LIBS) $(BUILD_DIR)
|
||||
|
||||
$(BUILD_DIR)/$(BASS_LIBS):
|
||||
@$(CP) -f $(BASS_LIBS) $(BUILD_DIR)
|
||||
|
||||
$(BUILD_DIR)/$(MOD_DIR):
|
||||
@$(CP) -f -r $(MOD_DIR) $(BUILD_DIR)
|
||||
|
||||
|
@ -1504,7 +1523,7 @@ ifeq ($(TARGET_N64),1)
|
|||
$(BUILD_DIR)/$(TARGET).objdump: $(ELF)
|
||||
$(OBJDUMP) -D $< > $@
|
||||
else
|
||||
$(EXE): $(O_FILES) $(MIO0_FILES:.mio0=.o) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(BUILD_DIR)/$(RPC_LIBS) $(BUILD_DIR)/$(DISCORD_SDK_LIBS) $(BUILD_DIR)/$(MOD_DIR)
|
||||
$(EXE): $(O_FILES) $(MIO0_FILES:.mio0=.o) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(BUILD_DIR)/$(RPC_LIBS) $(BUILD_DIR)/$(DISCORD_SDK_LIBS) $(BUILD_DIR)/$(BASS_LIBS) $(BUILD_DIR)/$(MOD_DIR)
|
||||
@$(PRINT) "$(GREEN)Linking executable: $(BLUE)$@ $(NO_COL)\n"
|
||||
$(V)$(LD) $(PROF_FLAGS) -L $(BUILD_DIR) -o $@ $(O_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(LDFLAGS) $(EXTRA_INCLUDES)
|
||||
endif
|
||||
|
|
|
@ -86,7 +86,7 @@ override_disallowed_functions = {
|
|||
"src/pc/lua/utils/smlua_obj_utils.h": [ "spawn_object_remember_field" ],
|
||||
"src/game/camera.h": [ "update_camera", "init_camera", "stub_camera", "^reset_camera", "move_point_along_spline" ],
|
||||
"src/game/behavior_actions.h": [ "bhv_dust_smoke_loop", "bhv_init_room" ],
|
||||
"src/pc/lua/utils/smlua_audio_utils.h": [ "smlua_audio_utils_override"],
|
||||
"src/pc/lua/utils/smlua_audio_utils.h": [ "smlua_audio_utils_override", "audio_custom_shutdown"],
|
||||
"src/pc/djui/djui_hud_utils.h": [ "djui_hud_render_texture", "djui_hud_render_texture_raw" ],
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
@ -705,6 +712,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
|
||||
|
|
61
docs/lua/examples/audio-test/main.lua
Normal file
61
docs/lua/examples/audio-test/main.lua
Normal file
|
@ -0,0 +1,61 @@
|
|||
-- name: Audio Test
|
||||
-- description: Testing out the custom audio system
|
||||
-- incompatible:
|
||||
|
||||
audioStream = nil;
|
||||
audioSample = nil;
|
||||
|
||||
function on_stream_play(msg)
|
||||
if(msg == "load") then
|
||||
audioStream = audio_stream_load("music.mp3")
|
||||
audio_stream_set_looping(audioStream, true)
|
||||
djui_chat_message_create("audio audioStream:" .. tostring(audioStream));
|
||||
end
|
||||
|
||||
if(msg == "play") then
|
||||
audio_stream_play(audioStream, true, 1);
|
||||
djui_chat_message_create("playing audio");
|
||||
end
|
||||
|
||||
if(msg == "resume") then
|
||||
audio_stream_play(audioStream, false, 1);
|
||||
djui_chat_message_create("resuming audio");
|
||||
end
|
||||
|
||||
if(msg == "pause") then
|
||||
audio_stream_pause(audioStream);
|
||||
djui_chat_message_create("pausing audio");
|
||||
end
|
||||
|
||||
if(msg == "stop") then
|
||||
audio_stream_stop(audioStream);
|
||||
djui_chat_message_create("stopping audio");
|
||||
end
|
||||
|
||||
if(msg == "destroy") then
|
||||
audio_stream_destroy(audioStream);
|
||||
djui_chat_message_create("destroyed audio");
|
||||
end
|
||||
|
||||
if(msg == "getpos") then
|
||||
djui_chat_message_create("pos: " .. tostring(audio_stream_get_position(audioStream)));
|
||||
end
|
||||
|
||||
return true;
|
||||
end
|
||||
|
||||
function on_sample_play(msg)
|
||||
if(msg == "load") then
|
||||
audioSample = audio_sample_load("sample.mp3");
|
||||
|
||||
djui_chat_message_create("audio audioStream:" .. tostring(audioSample));
|
||||
|
||||
return true;
|
||||
end
|
||||
|
||||
audio_sample_play(audioSample, gMarioStates[0].pos, 1);
|
||||
return true;
|
||||
end
|
||||
|
||||
hook_chat_command('stream', "[load|play|resume|pause|stop|destroy|getpos]", on_stream_play)
|
||||
hook_chat_command('sample', "[load|play]", on_sample_play)
|
BIN
docs/lua/examples/audio-test/sound/music.mp3
Normal file
BIN
docs/lua/examples/audio-test/sound/music.mp3
Normal file
Binary file not shown.
BIN
docs/lua/examples/audio-test/sound/sample.mp3
Normal file
BIN
docs/lua/examples/audio-test/sound/sample.mp3
Normal file
Binary file not shown.
|
@ -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
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
- [network_send_object](#network_send_object)
|
||||
- [network_send_to](#network_send_to)
|
||||
- [network_send](#network_send)
|
||||
- [djui_hud_render_texture](#djui_hud_render_texture)
|
||||
- [get_texture_info](#get_texture_info)
|
||||
|
||||
<br />
|
||||
|
||||
|
@ -1320,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)
|
||||
|
||||
|
@ -1574,6 +1595,54 @@ The `reliable` field will ensure that the packet arrives, but should be used spa
|
|||
|
||||
<br />
|
||||
|
||||
## [djui_hud_render_texture](#djui_hud_render_texture)
|
||||
|
||||
Renders a texture to the screen.
|
||||
|
||||
### Lua Example
|
||||
`djui_hud_render_texture(texInfo, x, y, scaleW, scaleH)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| texInfo | [TextureInfo](structs.md#TextureInfo) |
|
||||
| x | `number` |
|
||||
| y | `number` |
|
||||
| scaleW | `number` |
|
||||
| scaleH | `number` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void djui_hud_render_texture(struct TextureInfo* texInfo, f32 x, f32 y, f32 scaleW, f32 scaleH);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [get_texture_info](#get_texture_info)
|
||||
|
||||
Retrieves a texture by name.
|
||||
|
||||
### Lua Example
|
||||
`get_texture_info(textureName)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| textureName | `string` |
|
||||
|
||||
### Returns
|
||||
- [TextureInfo](structs.md#TextureInfo)
|
||||
|
||||
### C Prototype
|
||||
`N/A`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
---
|
||||
|
||||
1 | [2](functions-2.md) | [3](functions-3.md) | [4](functions-4.md) | [next >](functions-2.md)]
|
||||
|
|
|
@ -42,7 +42,7 @@ All of this is a holdover from when there were only two players. It was a reason
|
|||
<br />
|
||||
|
||||
## Example Lua mods (small)
|
||||
- [Low Gravity](examples/mods/low-gravity.lua)
|
||||
- [Low Gravity](examples/low-gravity.lua)
|
||||
- [Faster Swimming](../../mods/faster-swimming.lua)
|
||||
- [Mario Run](examples/Mario-Run.lua)
|
||||
- [HUD Rendering](examples/hud.lua)
|
||||
|
@ -59,6 +59,7 @@ All of this is a holdover from when there were only two players. It was a reason
|
|||
- [Water Height Changer](examples/water-level.lua)
|
||||
- [Custom Level](examples/custom-level)
|
||||
- [Custom HUD Texture](examples/custom-hud-texture)
|
||||
- [Custom Audio Test](examples/audio-test)
|
||||
|
||||
## Example Lua mods (large)
|
||||
- [Extended Moveset](../../mods/extended-moveset.lua)
|
||||
|
|
|
@ -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 |
|
||||
|
@ -1007,6 +1023,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 |
|
||||
|
|
1131
include/bass/bass.h
Normal file
1131
include/bass/bass.h
Normal file
File diff suppressed because it is too large
Load diff
443
include/bass/bass_fx.h
Normal file
443
include/bass/bass_fx.h
Normal file
|
@ -0,0 +1,443 @@
|
|||
/*===========================================================================
|
||||
BASS_FX 2.4 - Copyright (c) 2002-2018 (: JOBnik! :) [Arthur Aminov, ISRAEL]
|
||||
[http://www.jobnik.org]
|
||||
|
||||
bugs/suggestions/questions:
|
||||
forum : http://www.un4seen.com/forum/?board=1
|
||||
http://www.jobnik.org/forums
|
||||
e-mail : bass_fx@jobnik.org
|
||||
--------------------------------------------------
|
||||
|
||||
NOTE: This header will work only with BASS_FX version 2.4.12
|
||||
Check www.un4seen.com or www.jobnik.org for any later versions.
|
||||
|
||||
* Requires BASS 2.4 (available at http://www.un4seen.com)
|
||||
===========================================================================*/
|
||||
|
||||
#ifndef BASS_FX_H
|
||||
#define BASS_FX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef BASS_FXDEF
|
||||
#define BASS_FXDEF(f) WINAPI f
|
||||
#endif
|
||||
|
||||
// BASS_CHANNELINFO types
|
||||
#define BASS_CTYPE_STREAM_TEMPO 0x1f200
|
||||
#define BASS_CTYPE_STREAM_REVERSE 0x1f201
|
||||
|
||||
// Tempo / Reverse / BPM / Beat flag
|
||||
#define BASS_FX_FREESOURCE 0x10000 // Free the source handle as well?
|
||||
|
||||
// BASS_FX Version
|
||||
DWORD BASS_FXDEF(BASS_FX_GetVersion)();
|
||||
|
||||
/*===========================================================================
|
||||
DSP (Digital Signal Processing)
|
||||
===========================================================================*/
|
||||
|
||||
/*
|
||||
Multi-channel order of each channel is as follows:
|
||||
3 channels left-front, right-front, center.
|
||||
4 channels left-front, right-front, left-rear/side, right-rear/side.
|
||||
5 channels left-front, right-front, center, left-rear/side, right-rear/side.
|
||||
6 channels (5.1) left-front, right-front, center, LFE, left-rear/side, right-rear/side.
|
||||
8 channels (7.1) left-front, right-front, center, LFE, left-rear/side, right-rear/side, left-rear center, right-rear center.
|
||||
*/
|
||||
|
||||
// DSP channels flags
|
||||
#define BASS_BFX_CHANALL -1 // all channels at once (as by default)
|
||||
#define BASS_BFX_CHANNONE 0 // disable an effect for all channels
|
||||
#define BASS_BFX_CHAN1 1 // left-front channel
|
||||
#define BASS_BFX_CHAN2 2 // right-front channel
|
||||
#define BASS_BFX_CHAN3 4 // see above info
|
||||
#define BASS_BFX_CHAN4 8 // see above info
|
||||
#define BASS_BFX_CHAN5 16 // see above info
|
||||
#define BASS_BFX_CHAN6 32 // see above info
|
||||
#define BASS_BFX_CHAN7 64 // see above info
|
||||
#define BASS_BFX_CHAN8 128 // see above info
|
||||
|
||||
// if you have more than 8 channels (7.1), use this macro
|
||||
#define BASS_BFX_CHANNEL_N(n) (1<<((n)-1))
|
||||
|
||||
// DSP effects
|
||||
enum {
|
||||
BASS_FX_BFX_ROTATE = 0x10000, // A channels volume ping-pong / multi channel
|
||||
BASS_FX_BFX_ECHO, // Echo / 2 channels max (deprecated)
|
||||
BASS_FX_BFX_FLANGER, // Flanger / multi channel (deprecated)
|
||||
BASS_FX_BFX_VOLUME, // Volume / multi channel
|
||||
BASS_FX_BFX_PEAKEQ, // Peaking Equalizer / multi channel
|
||||
BASS_FX_BFX_REVERB, // Reverb / 2 channels max (deprecated)
|
||||
BASS_FX_BFX_LPF, // Low Pass Filter 24dB / multi channel (deprecated)
|
||||
BASS_FX_BFX_MIX, // Swap, remap and mix channels / multi channel
|
||||
BASS_FX_BFX_DAMP, // Dynamic Amplification / multi channel
|
||||
BASS_FX_BFX_AUTOWAH, // Auto Wah / multi channel
|
||||
BASS_FX_BFX_ECHO2, // Echo 2 / multi channel (deprecated)
|
||||
BASS_FX_BFX_PHASER, // Phaser / multi channel
|
||||
BASS_FX_BFX_ECHO3, // Echo 3 / multi channel (deprecated)
|
||||
BASS_FX_BFX_CHORUS, // Chorus/Flanger / multi channel
|
||||
BASS_FX_BFX_APF, // All Pass Filter / multi channel (deprecated)
|
||||
BASS_FX_BFX_COMPRESSOR, // Compressor / multi channel (deprecated)
|
||||
BASS_FX_BFX_DISTORTION, // Distortion / multi channel
|
||||
BASS_FX_BFX_COMPRESSOR2, // Compressor 2 / multi channel
|
||||
BASS_FX_BFX_VOLUME_ENV, // Volume envelope / multi channel
|
||||
BASS_FX_BFX_BQF, // BiQuad filters / multi channel
|
||||
BASS_FX_BFX_ECHO4, // Echo 4 / multi channel
|
||||
BASS_FX_BFX_PITCHSHIFT, // Pitch shift using FFT / multi channel (not available on mobile)
|
||||
BASS_FX_BFX_FREEVERB // Reverb using "Freeverb" algo / multi channel
|
||||
};
|
||||
|
||||
/*
|
||||
Deprecated effects in 2.4.10 version:
|
||||
------------------------------------
|
||||
BASS_FX_BFX_ECHO -> use BASS_FX_BFX_ECHO4
|
||||
BASS_FX_BFX_ECHO2 -> use BASS_FX_BFX_ECHO4
|
||||
BASS_FX_BFX_ECHO3 -> use BASS_FX_BFX_ECHO4
|
||||
BASS_FX_BFX_REVERB -> use BASS_FX_BFX_FREEVERB
|
||||
BASS_FX_BFX_FLANGER -> use BASS_FX_BFX_CHORUS
|
||||
BASS_FX_BFX_COMPRESSOR -> use BASS_FX_BFX_COMPRESSOR2
|
||||
BASS_FX_BFX_APF -> use BASS_FX_BFX_BQF with BASS_BFX_BQF_ALLPASS filter
|
||||
BASS_FX_BFX_LPF -> use 2x BASS_FX_BFX_BQF with BASS_BFX_BQF_LOWPASS filter and appropriate fQ values
|
||||
*/
|
||||
|
||||
// Rotate
|
||||
typedef struct {
|
||||
float fRate; // rotation rate/speed in Hz (A negative rate can be used for reverse direction)
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s (supported only even number of channels)
|
||||
} BASS_BFX_ROTATE;
|
||||
|
||||
// Echo (deprecated)
|
||||
typedef struct {
|
||||
float fLevel; // [0....1....n] linear
|
||||
int lDelay; // [1200..30000]
|
||||
} BASS_BFX_ECHO;
|
||||
|
||||
// Flanger (deprecated)
|
||||
typedef struct {
|
||||
float fWetDry; // [0....1....n] linear
|
||||
float fSpeed; // [0......0.09]
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_FLANGER;
|
||||
|
||||
// Volume
|
||||
typedef struct {
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s or 0 for global volume control
|
||||
float fVolume; // [0....1....n] linear
|
||||
} BASS_BFX_VOLUME;
|
||||
|
||||
// Peaking Equalizer
|
||||
typedef struct {
|
||||
int lBand; // [0...............n] more bands means more memory & cpu usage
|
||||
float fBandwidth; // [0.1...........<10] in octaves - fQ is not in use (Bandwidth has a priority over fQ)
|
||||
float fQ; // [0...............1] the EE kinda definition (linear) (if Bandwidth is not in use)
|
||||
float fCenter; // [1Hz..<info.freq/2] in Hz
|
||||
float fGain; // [-15dB...0...+15dB] in dB (can be above/below these limits)
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_PEAKEQ;
|
||||
|
||||
// Reverb (deprecated)
|
||||
typedef struct {
|
||||
float fLevel; // [0....1....n] linear
|
||||
int lDelay; // [1200..10000]
|
||||
} BASS_BFX_REVERB;
|
||||
|
||||
// Low Pass Filter (deprecated)
|
||||
typedef struct {
|
||||
float fResonance; // [0.01...........10]
|
||||
float fCutOffFreq; // [1Hz...info.freq/2] cutoff frequency
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_LPF;
|
||||
|
||||
// Swap, remap and mix
|
||||
typedef struct {
|
||||
const int *lChannel; // an array of channels to mix using BASS_BFX_CHANxxx flag/s (lChannel[0] is left channel...)
|
||||
} BASS_BFX_MIX;
|
||||
|
||||
// Dynamic Amplification
|
||||
typedef struct {
|
||||
float fTarget; // target volume level [0<......1] linear
|
||||
float fQuiet; // quiet volume level [0.......1] linear
|
||||
float fRate; // amp adjustment rate [0.......1] linear
|
||||
float fGain; // amplification level [0...1...n] linear
|
||||
float fDelay; // delay in seconds before increasing level [0.......n] linear
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_DAMP;
|
||||
|
||||
// Auto Wah
|
||||
typedef struct {
|
||||
float fDryMix; // dry (unaffected) signal mix [-2......2]
|
||||
float fWetMix; // wet (affected) signal mix [-2......2]
|
||||
float fFeedback; // output signal to feed back into input [-1......1]
|
||||
float fRate; // rate of sweep in cycles per second [0<....<10]
|
||||
float fRange; // sweep range in octaves [0<....<10]
|
||||
float fFreq; // base frequency of sweep Hz [0<...1000]
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_AUTOWAH;
|
||||
|
||||
// Echo 2 (deprecated)
|
||||
typedef struct {
|
||||
float fDryMix; // dry (unaffected) signal mix [-2......2]
|
||||
float fWetMix; // wet (affected) signal mix [-2......2]
|
||||
float fFeedback; // output signal to feed back into input [-1......1]
|
||||
float fDelay; // delay sec [0<......n]
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_ECHO2;
|
||||
|
||||
// Phaser
|
||||
typedef struct {
|
||||
float fDryMix; // dry (unaffected) signal mix [-2......2]
|
||||
float fWetMix; // wet (affected) signal mix [-2......2]
|
||||
float fFeedback; // output signal to feed back into input [-1......1]
|
||||
float fRate; // rate of sweep in cycles per second [0<....<10]
|
||||
float fRange; // sweep range in octaves [0<....<10]
|
||||
float fFreq; // base frequency of sweep [0<...1000]
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_PHASER;
|
||||
|
||||
// Echo 3 (deprecated)
|
||||
typedef struct {
|
||||
float fDryMix; // dry (unaffected) signal mix [-2......2]
|
||||
float fWetMix; // wet (affected) signal mix [-2......2]
|
||||
float fDelay; // delay sec [0<......n]
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_ECHO3;
|
||||
|
||||
// Chorus/Flanger
|
||||
typedef struct {
|
||||
float fDryMix; // dry (unaffected) signal mix [-2......2]
|
||||
float fWetMix; // wet (affected) signal mix [-2......2]
|
||||
float fFeedback; // output signal to feed back into input [-1......1]
|
||||
float fMinSweep; // minimal delay ms [0<...6000]
|
||||
float fMaxSweep; // maximum delay ms [0<...6000]
|
||||
float fRate; // rate ms/s [0<...1000]
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_CHORUS;
|
||||
|
||||
// All Pass Filter (deprecated)
|
||||
typedef struct {
|
||||
float fGain; // reverberation time [-1=<..<=1]
|
||||
float fDelay; // delay sec [0<....<=n]
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_APF;
|
||||
|
||||
// Compressor (deprecated)
|
||||
typedef struct {
|
||||
float fThreshold; // compressor threshold [0<=...<=1]
|
||||
float fAttacktime; // attack time ms [0<.<=1000]
|
||||
float fReleasetime; // release time ms [0<.<=5000]
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_COMPRESSOR;
|
||||
|
||||
// Distortion
|
||||
typedef struct {
|
||||
float fDrive; // distortion drive [0<=...<=5]
|
||||
float fDryMix; // dry (unaffected) signal mix [-5<=..<=5]
|
||||
float fWetMix; // wet (affected) signal mix [-5<=..<=5]
|
||||
float fFeedback; // output signal to feed back into input [-1<=..<=1]
|
||||
float fVolume; // distortion volume [0=<...<=2]
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_DISTORTION;
|
||||
|
||||
// Compressor 2
|
||||
typedef struct {
|
||||
float fGain; // output gain of signal after compression [-60....60] in dB
|
||||
float fThreshold; // point at which compression begins [-60.....0] in dB
|
||||
float fRatio; // compression ratio [1.......n]
|
||||
float fAttack; // attack time in ms [0.01.1000]
|
||||
float fRelease; // release time in ms [0.01.5000]
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_COMPRESSOR2;
|
||||
|
||||
// Volume envelope
|
||||
typedef struct {
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
int lNodeCount; // number of nodes
|
||||
const struct BASS_BFX_ENV_NODE *pNodes; // the nodes
|
||||
BOOL bFollow; // follow source position
|
||||
} BASS_BFX_VOLUME_ENV;
|
||||
|
||||
#pragma pack(push,4)
|
||||
typedef struct BASS_BFX_ENV_NODE {
|
||||
double pos; // node position in seconds (1st envelope node must be at position 0)
|
||||
float val; // node value
|
||||
} BASS_BFX_ENV_NODE;
|
||||
#pragma pack(pop)
|
||||
|
||||
// BiQuad Filters
|
||||
enum {
|
||||
BASS_BFX_BQF_LOWPASS,
|
||||
BASS_BFX_BQF_HIGHPASS,
|
||||
BASS_BFX_BQF_BANDPASS, // constant 0 dB peak gain
|
||||
BASS_BFX_BQF_BANDPASS_Q, // constant skirt gain, peak gain = Q
|
||||
BASS_BFX_BQF_NOTCH,
|
||||
BASS_BFX_BQF_ALLPASS,
|
||||
BASS_BFX_BQF_PEAKINGEQ,
|
||||
BASS_BFX_BQF_LOWSHELF,
|
||||
BASS_BFX_BQF_HIGHSHELF
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int lFilter; // BASS_BFX_BQF_xxx filter types
|
||||
float fCenter; // [1Hz..<info.freq/2] Cutoff (central) frequency in Hz
|
||||
float fGain; // [-15dB...0...+15dB] Used only for PEAKINGEQ and Shelving filters in dB (can be above/below these limits)
|
||||
float fBandwidth; // [0.1...........<10] Bandwidth in octaves (fQ is not in use (fBandwidth has a priority over fQ))
|
||||
// (between -3 dB frequencies for BANDPASS and NOTCH or between midpoint
|
||||
// (fGgain/2) gain frequencies for PEAKINGEQ)
|
||||
float fQ; // [0.1.............1] The EE kinda definition (linear) (if fBandwidth is not in use)
|
||||
float fS; // [0.1.............1] A "shelf slope" parameter (linear) (used only with Shelving filters)
|
||||
// when fS = 1, the shelf slope is as steep as you can get it and remain monotonically
|
||||
// increasing or decreasing gain with frequency.
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_BQF;
|
||||
|
||||
// Echo 4
|
||||
typedef struct {
|
||||
float fDryMix; // dry (unaffected) signal mix [-2.......2]
|
||||
float fWetMix; // wet (affected) signal mix [-2.......2]
|
||||
float fFeedback; // output signal to feed back into input [-1.......1]
|
||||
float fDelay; // delay sec [0<.......n]
|
||||
BOOL bStereo; // echo adjoining channels to each other [TRUE/FALSE]
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_ECHO4;
|
||||
|
||||
// Pitch shift (not available on mobile)
|
||||
typedef struct {
|
||||
float fPitchShift; // A factor value which is between 0.5 (one octave down) and 2 (one octave up) (1 won't change the pitch) [1 default]
|
||||
// (fSemitones is not in use, fPitchShift has a priority over fSemitones)
|
||||
float fSemitones; // Semitones (0 won't change the pitch) [0 default]
|
||||
long lFFTsize; // Defines the FFT frame size used for the processing. Typical values are 1024, 2048 and 4096 [2048 default]
|
||||
// It may be any value <= 8192 but it MUST be a power of 2
|
||||
long lOsamp; // Is the STFT oversampling factor which also determines the overlap between adjacent STFT frames [8 default]
|
||||
// It should at least be 4 for moderate scaling ratios. A value of 32 is recommended for best quality (better quality = higher CPU usage)
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_PITCHSHIFT;
|
||||
|
||||
// Freeverb
|
||||
#define BASS_BFX_FREEVERB_MODE_FREEZE 1
|
||||
|
||||
typedef struct {
|
||||
float fDryMix; // dry (unaffected) signal mix [0........1], def. 0
|
||||
float fWetMix; // wet (affected) signal mix [0........3], def. 1.0f
|
||||
float fRoomSize; // room size [0........1], def. 0.5f
|
||||
float fDamp; // damping [0........1], def. 0.5f
|
||||
float fWidth; // stereo width [0........1], def. 1
|
||||
DWORD lMode; // 0 or BASS_BFX_FREEVERB_MODE_FREEZE, def. 0 (no freeze)
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_FREEVERB;
|
||||
|
||||
/*===========================================================================
|
||||
set dsp fx - BASS_ChannelSetFX
|
||||
remove dsp fx - BASS_ChannelRemoveFX
|
||||
set parameters - BASS_FXSetParameters
|
||||
retrieve parameters - BASS_FXGetParameters
|
||||
reset the state - BASS_FXReset
|
||||
===========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
Tempo, Pitch scaling and Sample rate changers
|
||||
===========================================================================*/
|
||||
|
||||
// NOTE: Enable Tempo supported flags in BASS_FX_TempoCreate and the others to source handle.
|
||||
|
||||
// tempo attributes (BASS_ChannelSet/GetAttribute)
|
||||
enum {
|
||||
BASS_ATTRIB_TEMPO = 0x10000,
|
||||
BASS_ATTRIB_TEMPO_PITCH,
|
||||
BASS_ATTRIB_TEMPO_FREQ
|
||||
};
|
||||
|
||||
// tempo attributes options
|
||||
enum {
|
||||
BASS_ATTRIB_TEMPO_OPTION_USE_AA_FILTER = 0x10010, // TRUE (default) / FALSE (default for multi-channel on mobile devices for lower CPU usage)
|
||||
BASS_ATTRIB_TEMPO_OPTION_AA_FILTER_LENGTH, // 32 default (8 .. 128 taps)
|
||||
BASS_ATTRIB_TEMPO_OPTION_USE_QUICKALGO, // TRUE (default on mobile devices for lower CPU usage) / FALSE (default)
|
||||
BASS_ATTRIB_TEMPO_OPTION_SEQUENCE_MS, // 82 default, 0 = automatic
|
||||
BASS_ATTRIB_TEMPO_OPTION_SEEKWINDOW_MS, // 28 default, 0 = automatic
|
||||
BASS_ATTRIB_TEMPO_OPTION_OVERLAP_MS, // 8 default
|
||||
BASS_ATTRIB_TEMPO_OPTION_PREVENT_CLICK // TRUE / FALSE (default)
|
||||
};
|
||||
|
||||
// tempo algorithm flags
|
||||
#define BASS_FX_TEMPO_ALGO_LINEAR 0x200
|
||||
#define BASS_FX_TEMPO_ALGO_CUBIC 0x400 // default
|
||||
#define BASS_FX_TEMPO_ALGO_SHANNON 0x800
|
||||
|
||||
HSTREAM BASS_FXDEF(BASS_FX_TempoCreate)(DWORD chan, DWORD flags);
|
||||
DWORD BASS_FXDEF(BASS_FX_TempoGetSource)(HSTREAM chan);
|
||||
float BASS_FXDEF(BASS_FX_TempoGetRateRatio)(HSTREAM chan);
|
||||
|
||||
/*===========================================================================
|
||||
Reverse playback
|
||||
===========================================================================*/
|
||||
|
||||
// NOTES: 1. MODs won't load without BASS_MUSIC_PRESCAN flag.
|
||||
// 2. Enable Reverse supported flags in BASS_FX_ReverseCreate and the others to source handle.
|
||||
|
||||
// reverse attribute (BASS_ChannelSet/GetAttribute)
|
||||
#define BASS_ATTRIB_REVERSE_DIR 0x11000
|
||||
|
||||
// playback directions
|
||||
#define BASS_FX_RVS_REVERSE -1
|
||||
#define BASS_FX_RVS_FORWARD 1
|
||||
|
||||
HSTREAM BASS_FXDEF(BASS_FX_ReverseCreate)(DWORD chan, float dec_block, DWORD flags);
|
||||
DWORD BASS_FXDEF(BASS_FX_ReverseGetSource)(HSTREAM chan);
|
||||
|
||||
/*===========================================================================
|
||||
BPM (Beats Per Minute)
|
||||
===========================================================================*/
|
||||
|
||||
// bpm flags
|
||||
#define BASS_FX_BPM_BKGRND 1 // if in use, then you can do other processing while detection's in progress. Available only in Windows platforms (BPM/Beat)
|
||||
#define BASS_FX_BPM_MULT2 2 // if in use, then will auto multiply bpm by 2 (if BPM < minBPM*2)
|
||||
|
||||
// translation options (deprecated)
|
||||
enum {
|
||||
BASS_FX_BPM_TRAN_X2, // multiply the original BPM value by 2 (may be called only once & will change the original BPM as well!)
|
||||
BASS_FX_BPM_TRAN_2FREQ, // BPM value to Frequency
|
||||
BASS_FX_BPM_TRAN_FREQ2, // Frequency to BPM value
|
||||
BASS_FX_BPM_TRAN_2PERCENT, // BPM value to Percents
|
||||
BASS_FX_BPM_TRAN_PERCENT2 // Percents to BPM value
|
||||
};
|
||||
|
||||
typedef void (CALLBACK BPMPROC)(DWORD chan, float bpm, void *user);
|
||||
typedef void (CALLBACK BPMPROGRESSPROC)(DWORD chan, float percent, void *user);
|
||||
typedef BPMPROGRESSPROC BPMPROCESSPROC; // back-compatibility
|
||||
|
||||
float BASS_FXDEF(BASS_FX_BPM_DecodeGet)(DWORD chan, double startSec, double endSec, DWORD minMaxBPM, DWORD flags, BPMPROGRESSPROC *proc, void *user);
|
||||
BOOL BASS_FXDEF(BASS_FX_BPM_CallbackSet)(DWORD handle, BPMPROC *proc, double period, DWORD minMaxBPM, DWORD flags, void *user);
|
||||
BOOL BASS_FXDEF(BASS_FX_BPM_CallbackReset)(DWORD handle);
|
||||
float BASS_FXDEF(BASS_FX_BPM_Translate)(DWORD handle, float val2tran, DWORD trans); // deprecated
|
||||
BOOL BASS_FXDEF(BASS_FX_BPM_Free)(DWORD handle);
|
||||
|
||||
/*===========================================================================
|
||||
Beat position trigger
|
||||
===========================================================================*/
|
||||
|
||||
typedef void (CALLBACK BPMBEATPROC)(DWORD chan, double beatpos, void *user);
|
||||
|
||||
BOOL BASS_FXDEF(BASS_FX_BPM_BeatCallbackSet)(DWORD handle, BPMBEATPROC *proc, void *user);
|
||||
BOOL BASS_FXDEF(BASS_FX_BPM_BeatCallbackReset)(DWORD handle);
|
||||
BOOL BASS_FXDEF(BASS_FX_BPM_BeatDecodeGet)(DWORD chan, double startSec, double endSec, DWORD flags, BPMBEATPROC *proc, void *user);
|
||||
BOOL BASS_FXDEF(BASS_FX_BPM_BeatSetParameters)(DWORD handle, float bandwidth, float centerfreq, float beat_rtime);
|
||||
BOOL BASS_FXDEF(BASS_FX_BPM_BeatGetParameters)(DWORD handle, float *bandwidth, float *centerfreq, float *beat_rtime);
|
||||
BOOL BASS_FXDEF(BASS_FX_BPM_BeatFree)(DWORD handle);
|
||||
|
||||
/*===========================================================================
|
||||
Macros
|
||||
===========================================================================*/
|
||||
|
||||
// translate linear level to logarithmic dB
|
||||
#define BASS_BFX_Linear2dB(level) (20*log10(level))
|
||||
|
||||
// translate logarithmic dB level to linear
|
||||
#define BASS_BFX_dB2Linear(dB) pow(10,(dB)/20)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
BIN
lib/bass/bass.dll
Normal file
BIN
lib/bass/bass.dll
Normal file
Binary file not shown.
BIN
lib/bass/bass.dylib
Normal file
BIN
lib/bass/bass.dylib
Normal file
Binary file not shown.
BIN
lib/bass/bass_fx.dll
Normal file
BIN
lib/bass/bass_fx.dll
Normal file
Binary file not shown.
BIN
lib/bass/bass_fx.dylib
Normal file
BIN
lib/bass/bass_fx.dylib
Normal file
Binary file not shown.
BIN
lib/bass/libbass.dylib
Normal file
BIN
lib/bass/libbass.dylib
Normal file
Binary file not shown.
BIN
lib/bass/libbass.so
Normal file
BIN
lib/bass/libbass.so
Normal file
Binary file not shown.
BIN
lib/bass/libbass_fx.dylib
Normal file
BIN
lib/bass/libbass_fx.dylib
Normal file
Binary file not shown.
BIN
lib/bass/libbass_fx.so
Normal file
BIN
lib/bass/libbass_fx.so
Normal file
Binary file not shown.
BIN
lib/bass/x86/bass.dll
Normal file
BIN
lib/bass/x86/bass.dll
Normal file
Binary file not shown.
BIN
lib/bass/x86/bass_fx.dll
Normal file
BIN
lib/bass/x86/bass_fx.dll
Normal file
Binary file not shown.
|
@ -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;
|
||||
|
@ -2767,3 +2767,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
|
||||
|
|
132
src/bass_audio/bass_audio_helpers.c
Normal file
132
src/bass_audio/bass_audio_helpers.c
Normal file
|
@ -0,0 +1,132 @@
|
|||
#include "include/bass/bass.h"
|
||||
#include "include/bass/bass_fx.h"
|
||||
#include "pc/debuglog.h"
|
||||
|
||||
#include "bass_audio_helpers.h"
|
||||
|
||||
HSTREAM bassh_create_fx_stream_from_file(char* data, QWORD length, QWORD offset) {
|
||||
HSTREAM raw_stream = BASS_StreamCreateFile(TRUE, data, offset, length, BASS_STREAM_PRESCAN | BASS_STREAM_DECODE);
|
||||
|
||||
HSTREAM stream = BASS_FX_TempoCreate(raw_stream, BASS_STREAM_PRESCAN);
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
HSAMPLE bassh_create_sample_from_file(char* data, QWORD length, QWORD offset) {
|
||||
return BASS_SampleLoad(TRUE, data, offset, length, MAX_SAMPLE_CONCURRENT_PLAYBACKS, BASS_SAMPLE_OVER_POS);
|
||||
}
|
||||
|
||||
HSTREAM bassh_sample_get_stream(HSAMPLE sample) {
|
||||
return BASS_SampleGetChannel(sample, 0);
|
||||
}
|
||||
|
||||
void bassh_free_sample(HSAMPLE sample) {
|
||||
BASS_SampleFree(sample);
|
||||
}
|
||||
|
||||
void bassh_set_looping(HSTREAM stream, BOOL loop) {
|
||||
BASS_ChannelFlags(stream, loop == TRUE ? BASS_SAMPLE_LOOP : 0, BASS_SAMPLE_LOOP);
|
||||
}
|
||||
|
||||
BOOL bassh_get_looping(HSTREAM stream) {
|
||||
return (BASS_ChannelFlags(stream, 0, 0) & BASS_SAMPLE_LOOP) > 0;
|
||||
}
|
||||
|
||||
void bassh_set_frequency(HSTREAM stream, float frequency) {
|
||||
BASS_ChannelSetAttribute(stream, BASS_ATTRIB_FREQ, frequency);
|
||||
}
|
||||
|
||||
float bassh_get_frequency(HSTREAM stream) {
|
||||
float val;
|
||||
BASS_ChannelGetAttribute(stream, BASS_ATTRIB_FREQ, &val);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
void bassh_set_tempo(HSTREAM stream, float tempo) {
|
||||
BASS_ChannelSetAttribute(stream, BASS_ATTRIB_TEMPO, tempo);
|
||||
}
|
||||
|
||||
float bassh_get_tempo(HSTREAM stream) {
|
||||
float val;
|
||||
BASS_ChannelGetAttribute(stream, BASS_ATTRIB_TEMPO, &val);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
double bassh_get_stream_pos(HSTREAM stream) {
|
||||
DWORD pos_b = BASS_ChannelGetPosition(stream, BASS_POS_BYTE);
|
||||
return BASS_ChannelBytes2Seconds(stream, pos_b);
|
||||
}
|
||||
|
||||
void bassh_set_stream_pos(HSTREAM stream, double pos) {
|
||||
BASS_ChannelSetPosition(stream, BASS_ChannelSeconds2Bytes(stream, pos), BASS_POS_BYTE);
|
||||
}
|
||||
|
||||
void bassh_set_speed(HSTREAM stream, float initial_freq, float speed, BOOL pitch) {
|
||||
if (pitch) {
|
||||
BASS_ChannelSetAttribute(stream, BASS_ATTRIB_FREQ, initial_freq * speed);
|
||||
BASS_ChannelSetAttribute(stream, BASS_ATTRIB_TEMPO, 0);
|
||||
}
|
||||
else {
|
||||
BASS_ChannelSetAttribute(stream, BASS_ATTRIB_FREQ, initial_freq);
|
||||
BASS_ChannelSetAttribute(stream, BASS_ATTRIB_TEMPO, speed * 100 - 100);
|
||||
}
|
||||
}
|
||||
|
||||
void bassh_set_stream_volume(HSTREAM stream, float volume) {
|
||||
BASS_ChannelSetAttribute(stream, BASS_ATTRIB_VOL, volume);
|
||||
BASS_ChannelSetAttribute(stream, BASS_ATTRIB_MUSIC_VOL_CHAN, volume);
|
||||
}
|
||||
|
||||
float bassh_get_stream_volume(HSTREAM stream) {
|
||||
float volume;
|
||||
|
||||
BASS_ChannelGetAttribute(stream, BASS_ATTRIB_MUSIC_VOL_CHAN, &volume);
|
||||
|
||||
return volume;
|
||||
}
|
||||
|
||||
void bassh_play_stream(HSTREAM stream, BOOL restart) {
|
||||
BASS_ChannelPlay(stream, restart);
|
||||
}
|
||||
|
||||
void bassh_pause_stream(HSTREAM stream) {
|
||||
BASS_ChannelPause(stream);
|
||||
}
|
||||
|
||||
void bassh_stop_stream(HSTREAM stream) {
|
||||
BASS_ChannelStop(stream);
|
||||
}
|
||||
|
||||
void bassh_free_stream(HSTREAM stream) {
|
||||
BASS_ChannelFree(stream);
|
||||
}
|
||||
|
||||
void bassh_init() {
|
||||
BOOL success = BASS_Init(-1, 44100, 0, 0, 0);
|
||||
|
||||
if(success == FALSE) {
|
||||
//error handling? fucking nerd shit
|
||||
LOG_ERROR("Bass init failed!");
|
||||
return;
|
||||
}
|
||||
|
||||
BASS_DEVICEINFO info;
|
||||
BASS_GetDeviceInfo(BASS_GetDevice(), &info);
|
||||
|
||||
LOG_INFO("Bass Initialized on device: %s, with driver: %s", info.name, info.driver);
|
||||
}
|
||||
|
||||
void bassh_deinit() {
|
||||
BASS_Free();
|
||||
}
|
||||
|
||||
int bassh_device_count() {
|
||||
int count = 0;
|
||||
|
||||
BASS_DEVICEINFO info;
|
||||
for(count = 0; BASS_GetDeviceInfo(count, &info); count++) {}
|
||||
|
||||
return count;
|
||||
}
|
34
src/bass_audio/bass_audio_helpers.h
Normal file
34
src/bass_audio/bass_audio_helpers.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
#include "include/bass/bass.h"
|
||||
|
||||
#define MAX_SAMPLE_CONCURRENT_PLAYBACKS 32
|
||||
|
||||
HSTREAM bassh_create_fx_stream_from_file(char* data, QWORD length, QWORD offset);
|
||||
HSAMPLE bassh_create_sample_from_file(char* data, QWORD length, QWORD offset);
|
||||
|
||||
HSTREAM bassh_sample_get_stream(HSAMPLE sample);
|
||||
void bassh_free_sample(HSAMPLE sample);
|
||||
void bassh_set_looping(HSTREAM stream, BOOL loop);
|
||||
|
||||
void bassh_set_stream_volume(HSTREAM stream, float volume);
|
||||
float bassh_get_stream_volume(HSTREAM stream);
|
||||
void bassh_set_looping(HSTREAM stream, BOOL loop);
|
||||
BOOL bassh_get_looping(HSTREAM stream);
|
||||
void bassh_set_frequency(HSTREAM stream, float frequency);
|
||||
float bassh_get_frequency(HSTREAM stream);
|
||||
void bassh_set_tempo(HSTREAM stream, float tempo);
|
||||
float bassh_get_tempo(HSTREAM stream);
|
||||
|
||||
void bassh_set_speed(HSTREAM stream, float initial_freq, float speed, BOOL pitch);
|
||||
|
||||
double bassh_get_stream_pos(HSTREAM stream);
|
||||
void bassh_set_stream_pos(HSTREAM stream, double pos);
|
||||
|
||||
void bassh_play_stream(HSTREAM stream, BOOL restart);
|
||||
void bassh_pause_stream(HSTREAM stream);
|
||||
void bassh_stop_stream(HSTREAM stream);
|
||||
void bassh_free_stream(HSTREAM stream);
|
||||
|
||||
int bassh_device_count();
|
||||
|
||||
void bassh_init();
|
||||
void bassh_deinit();
|
|
@ -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 },
|
||||
|
@ -819,6 +830,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 },
|
||||
|
@ -1908,6 +1930,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 },
|
||||
|
@ -1938,6 +1961,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; }
|
||||
|
||||
|
@ -17151,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);
|
||||
|
||||
|
|
|
@ -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,275 @@ 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 = 10;
|
||||
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);
|
||||
}
|
||||
|
||||
void audio_custom_shutdown(void) {
|
||||
for(u16 i = 0; i < sBassAudioCount; i++) {
|
||||
struct BassAudio* audio = &sBassAudio[i];
|
||||
if (!audio->loaded) { continue; }
|
||||
if (audio->isStream) {
|
||||
audio_stream_destroy(audio);
|
||||
} else {
|
||||
audio_sample_destroy(audio);
|
||||
}
|
||||
}
|
||||
sBassAudioCount = 0;
|
||||
}
|
|
@ -5,4 +5,39 @@ 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);
|
||||
|
||||
void audio_custom_shutdown(void);
|
||||
|
||||
#endif
|
|
@ -7,6 +7,10 @@
|
|||
#include "pc/lua/smlua.h"
|
||||
#include "smlua_misc_utils.h"
|
||||
#include "pc/debuglog.h"
|
||||
#include "pc/mods/mod.h"
|
||||
#include "pc/mods/mods.h"
|
||||
#include "pc/mods/mods_utils.h"
|
||||
|
||||
#include "game/object_list_processor.h"
|
||||
#include "game/rendering_graph_node.h"
|
||||
#include "game/level_update.h"
|
||||
|
@ -191,4 +195,4 @@ f32 set_override_near(f32 near) {
|
|||
|
||||
f32 set_override_far(f32 far) {
|
||||
gOverrideFar = far;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -201,6 +201,61 @@ static struct ModFile* mod_allocate_file(struct Mod* mod, char* relativePath) {
|
|||
return file;
|
||||
}
|
||||
|
||||
static bool mod_load_files_dir(struct Mod* mod, char* fullPath, const char* subDir, const char** fileTypes) {
|
||||
|
||||
// concat directory
|
||||
char dirPath[SYS_MAX_PATH] = { 0 };
|
||||
if (!concat_path(dirPath, fullPath, (char*)subDir)) {
|
||||
LOG_ERROR("Could not concat directory '%s' + '%s'", fullPath, subDir);
|
||||
return false;
|
||||
}
|
||||
|
||||
// open subdirectory
|
||||
struct dirent* dir = NULL;
|
||||
DIR* d = opendir(dirPath);
|
||||
if (!d) { return true; }
|
||||
|
||||
// iterate subdirectory
|
||||
char path[SYS_MAX_PATH] = { 0 };
|
||||
char relativePath[SYS_MAX_PATH] = { 0 };
|
||||
while ((dir = readdir(d)) != NULL) {
|
||||
// sanity check / fill path[]
|
||||
if (!directory_sanity_check(dir, dirPath, path)) { continue; }
|
||||
|
||||
if (strlen(subDir) > 0) {
|
||||
if (snprintf(relativePath, SYS_MAX_PATH - 1, "%s/%s", subDir, dir->d_name) < 0) {
|
||||
LOG_ERROR("Could not concat %s path!", subDir);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (snprintf(relativePath, SYS_MAX_PATH - 1, "%s", dir->d_name) < 0) {
|
||||
LOG_ERROR("Could not concat %s path!", subDir);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// only consider certain file types
|
||||
bool fileTypeMatch = false;
|
||||
const char** ft = fileTypes;
|
||||
while (*ft != NULL) {
|
||||
if (str_ends_with(path, (char*)*ft)) {
|
||||
fileTypeMatch = true;
|
||||
}
|
||||
ft++;
|
||||
}
|
||||
if (!fileTypeMatch) { continue; }
|
||||
|
||||
// allocate file
|
||||
struct ModFile* file = mod_allocate_file(mod, relativePath);
|
||||
if (file == NULL) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
closedir(d);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool mod_load_files(struct Mod* mod, char* modName, char* fullPath) {
|
||||
// read single lua file
|
||||
if (!mod->isDirectory) {
|
||||
|
@ -209,184 +264,34 @@ static bool mod_load_files(struct Mod* mod, char* modName, char* fullPath) {
|
|||
|
||||
// deal with mod directory
|
||||
{
|
||||
// open mod directory
|
||||
struct dirent* dir = NULL;
|
||||
DIR* d = opendir(fullPath);
|
||||
if (!d) {
|
||||
LOG_ERROR("Could not open directory '%s'", fullPath);
|
||||
return false;
|
||||
}
|
||||
|
||||
// iterate mod directory
|
||||
char path[SYS_MAX_PATH] = { 0 };
|
||||
while ((dir = readdir(d)) != NULL) {
|
||||
// sanity check / fill path[]
|
||||
if (!directory_sanity_check(dir, fullPath, path)) { continue; }
|
||||
|
||||
// only consider lua files
|
||||
if (!str_ends_with(path, ".lua")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// allocate file
|
||||
struct ModFile* file = mod_allocate_file(mod, dir->d_name);
|
||||
if (file == NULL) { return false; }
|
||||
}
|
||||
|
||||
closedir(d);
|
||||
const char* fileTypes[] = { ".lua", NULL };
|
||||
if (!mod_load_files_dir(mod, fullPath, "", fileTypes)) { return false; }
|
||||
}
|
||||
|
||||
// deal with actors directory
|
||||
{
|
||||
// concat actors directory
|
||||
char actorsPath[SYS_MAX_PATH] = { 0 };
|
||||
if (!concat_path(actorsPath, fullPath, "actors")) {
|
||||
LOG_ERROR("Could not concat directory '%s' + '%s'", fullPath, "actors");
|
||||
return false;
|
||||
}
|
||||
|
||||
// open actors directory
|
||||
struct dirent* dir = NULL;
|
||||
DIR* d = opendir(actorsPath);
|
||||
if (d) {
|
||||
// iterate mod directory
|
||||
char path[SYS_MAX_PATH] = { 0 };
|
||||
char relativePath[SYS_MAX_PATH] = { 0 };
|
||||
while ((dir = readdir(d)) != NULL) {
|
||||
// sanity check / fill path[]
|
||||
if (!directory_sanity_check(dir, actorsPath, path)) { continue; }
|
||||
if (snprintf(relativePath, SYS_MAX_PATH - 1, "actors/%s", dir->d_name) < 0) {
|
||||
LOG_ERROR("Could not concat actor path!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// only consider bin, and col files
|
||||
if (!str_ends_with(path, ".bin") && !str_ends_with(path, ".col")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// allocate file
|
||||
struct ModFile* file = mod_allocate_file(mod, relativePath);
|
||||
if (file == NULL) { return false; }
|
||||
}
|
||||
|
||||
closedir(d);
|
||||
}
|
||||
const char* fileTypes[] = { ".bin", ".col", NULL };
|
||||
if (!mod_load_files_dir(mod, fullPath, "actors", fileTypes)) { return false; }
|
||||
}
|
||||
|
||||
// deal with textures directory
|
||||
{
|
||||
// concat textures directory
|
||||
char texturesPath[SYS_MAX_PATH] = { 0 };
|
||||
if (!concat_path(texturesPath, fullPath, "textures")) {
|
||||
LOG_ERROR("Could not concat directory '%s' + '%s'", fullPath, "textures");
|
||||
return false;
|
||||
}
|
||||
|
||||
// open textures directory
|
||||
struct dirent* dir = NULL;
|
||||
DIR* d = opendir(texturesPath);
|
||||
if (d) {
|
||||
// iterate mod directory
|
||||
char path[SYS_MAX_PATH] = { 0 };
|
||||
char relativePath[SYS_MAX_PATH] = { 0 };
|
||||
while ((dir = readdir(d)) != NULL) {
|
||||
// sanity check / fill path[]
|
||||
if (!directory_sanity_check(dir, texturesPath, path)) { continue; }
|
||||
if (snprintf(relativePath, SYS_MAX_PATH - 1, "textures/%s", dir->d_name) < 0) {
|
||||
LOG_ERROR("Could not concat textures path!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// only consider tex files
|
||||
if (!str_ends_with(path, ".tex")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// allocate file
|
||||
struct ModFile* file = mod_allocate_file(mod, relativePath);
|
||||
if (file == NULL) { return false; }
|
||||
}
|
||||
|
||||
closedir(d);
|
||||
}
|
||||
const char* fileTypes[] = { ".tex", NULL };
|
||||
if (!mod_load_files_dir(mod, fullPath, "textures", fileTypes)) { return false; }
|
||||
}
|
||||
|
||||
// deal with levels directory
|
||||
{
|
||||
// concat levels directory
|
||||
char levelsPath[SYS_MAX_PATH] = { 0 };
|
||||
if (!concat_path(levelsPath, fullPath, "levels")) {
|
||||
LOG_ERROR("Could not concat directory '%s' + '%s'", fullPath, "levels");
|
||||
return false;
|
||||
}
|
||||
|
||||
// open levels directory
|
||||
struct dirent* dir = NULL;
|
||||
DIR* d = opendir(levelsPath);
|
||||
if (d) {
|
||||
// iterate mod directory
|
||||
char path[SYS_MAX_PATH] = { 0 };
|
||||
char relativePath[SYS_MAX_PATH] = { 0 };
|
||||
while ((dir = readdir(d)) != NULL) {
|
||||
// sanity check / fill path[]
|
||||
if (!directory_sanity_check(dir, levelsPath, path)) { continue; }
|
||||
if (snprintf(relativePath, SYS_MAX_PATH - 1, "levels/%s", dir->d_name) < 0) {
|
||||
LOG_ERROR("Could not concat level path!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// only consider lvl files
|
||||
if (!str_ends_with(path, ".lvl")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// allocate file
|
||||
struct ModFile* file = mod_allocate_file(mod, relativePath);
|
||||
if (file == NULL) { return false; }
|
||||
}
|
||||
|
||||
closedir(d);
|
||||
}
|
||||
const char* fileTypes[] = { ".lvl", NULL };
|
||||
if (!mod_load_files_dir(mod, fullPath, "levels", fileTypes)) { return false; }
|
||||
}
|
||||
|
||||
// deal with sound directory
|
||||
{
|
||||
// concat sound directory
|
||||
char soundPath[SYS_MAX_PATH] = { 0 };
|
||||
if (!concat_path(soundPath, fullPath, "sound")) {
|
||||
LOG_ERROR("Could not concat directory '%s' + '%s'", fullPath, "sound");
|
||||
return false;
|
||||
}
|
||||
|
||||
// open sound directory
|
||||
struct dirent* dir = NULL;
|
||||
DIR* d = opendir(soundPath);
|
||||
if (d) {
|
||||
// iterate mod directory
|
||||
char path[SYS_MAX_PATH] = { 0 };
|
||||
char relativePath[SYS_MAX_PATH] = { 0 };
|
||||
while ((dir = readdir(d)) != NULL) {
|
||||
// sanity check / fill path[]
|
||||
if (!directory_sanity_check(dir, soundPath, path)) { continue; }
|
||||
if (snprintf(relativePath, SYS_MAX_PATH - 1, "sound/%s", dir->d_name) < 0) {
|
||||
LOG_ERROR("Could not concat sound path!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// only consider m64 files
|
||||
if (!str_ends_with(path, ".m64")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// allocate file
|
||||
struct ModFile* file = mod_allocate_file(mod, relativePath);
|
||||
if (file == NULL) { return false; }
|
||||
}
|
||||
|
||||
closedir(d);
|
||||
}
|
||||
const char* fileTypes[] = { ".m64", ".mp3", ".aiff", ".ogg", NULL };
|
||||
if (!mod_load_files_dir(mod, fullPath, "levels", fileTypes)) { return false; }
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ struct ModFile {
|
|||
FILE* fp;
|
||||
u64 curOffset;
|
||||
bool complete;
|
||||
|
||||
u8 dataHash[16];
|
||||
char* cachedPath;
|
||||
};
|
||||
|
|
|
@ -42,12 +42,18 @@
|
|||
#include "game/main.h"
|
||||
#include "game/rumble_init.h"
|
||||
|
||||
#include "include/bass/bass.h"
|
||||
#include "include/bass/bass_fx.h"
|
||||
#include "src/bass_audio/bass_audio_helpers.h"
|
||||
#include "pc/lua/utils/smlua_audio_utils.h"
|
||||
|
||||
#ifdef DISCORDRPC
|
||||
#include "pc/discord/discordrpc.h"
|
||||
#endif
|
||||
#include "pc/network/version.h"
|
||||
#include "pc/network/network_player.h"
|
||||
#include "pc/djui/djui.h"
|
||||
#include "pc/debuglog.h"
|
||||
#include "pc/utils/misc.h"
|
||||
|
||||
#include "pc/mods/mods.h"
|
||||
|
@ -236,6 +242,7 @@ void produce_one_frame(void) {
|
|||
}
|
||||
|
||||
void audio_shutdown(void) {
|
||||
audio_custom_shutdown();
|
||||
if (audio_api) {
|
||||
if (audio_api->shutdown) audio_api->shutdown();
|
||||
audio_api = NULL;
|
||||
|
@ -248,6 +255,7 @@ void game_deinit(void) {
|
|||
#endif
|
||||
configfile_save(configfile_name());
|
||||
controller_shutdown();
|
||||
audio_custom_shutdown();
|
||||
audio_shutdown();
|
||||
gfx_shutdown();
|
||||
network_shutdown(true);
|
||||
|
@ -388,6 +396,7 @@ void main_func(void) {
|
|||
|
||||
audio_init();
|
||||
sound_init();
|
||||
bassh_init();
|
||||
network_player_init();
|
||||
|
||||
thread5_game_loop(NULL);
|
||||
|
@ -422,6 +431,8 @@ void main_func(void) {
|
|||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
bassh_deinit();
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
|
Loading…
Reference in a new issue