removed bass, replaced with miniaudio (#8)

This commit is contained in:
Isaac0-dev 2024-03-24 06:14:53 +10:00 committed by GitHub
parent 663e4549d8
commit 4473bfffe9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
40 changed files with 98728 additions and 2380 deletions

View file

@ -481,7 +481,7 @@ ACTOR_DIR := actors
LEVEL_DIRS := $(patsubst levels/%,%,$(dir $(wildcard levels/*/header.h))) LEVEL_DIRS := $(patsubst levels/%,%,$(dir $(wildcard levels/*/header.h)))
# Directories containing source files # Directories containing source files
SRC_DIRS := src src/engine src/game src/audio src/bass_audio src/menu src/buffers actors levels bin data assets asm lib sound SRC_DIRS := src src/engine src/game src/audio src/menu src/buffers actors levels bin data assets asm lib sound
BIN_DIRS := bin bin/$(VERSION) BIN_DIRS := bin bin/$(VERSION)
# PC files # PC files
@ -584,29 +584,6 @@ ifeq ($(DISCORD_SDK), 1)
endif endif
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 ifeq ($(TARGET_RPI),1)
ifneq (,$(findstring aarch64,$(machine)))
BASS_LIBS := lib/bass/arm/aarch64/libbass.so lib/bass/arm/aarch64/libbass_fx.so
else
BASS_LIBS := lib/bass/arm/libbass.so lib/bass/arm/libbass_fx.so
endif
else
BASS_LIBS := lib/bass/libbass.so lib/bass/libbass_fx.so
endif
LANG_DIR := lang LANG_DIR := lang
# Remove old lang dir # Remove old lang dir
@ -965,23 +942,15 @@ ifeq ($(COOPNET),1)
endif endif
endif endif
# Network/Discord/Bass (ugh, needs cleanup) # Network/Discord (ugh, needs cleanup)
ifeq ($(WINDOWS_BUILD),1) ifeq ($(WINDOWS_BUILD),1)
LDFLAGS += -L"ws2_32" -lwsock32 LDFLAGS += -L"ws2_32" -lwsock32
ifeq ($(DISCORD_SDK),1) ifeq ($(DISCORD_SDK),1)
LDFLAGS += -Wl,-Bdynamic -L./lib/discordsdk/ -L./lib/bass/ -ldiscord_game_sdk -lbass -lbass_fx -Wl,-Bstatic LDFLAGS += -Wl,-Bdynamic -L./lib/discordsdk/ -ldiscord_game_sdk -Wl,-Bstatic
else
LDFLAGS += -Wl,-Bdynamic -L./lib/bass/ -lbass -lbass_fx -Wl,-Bstatic
endif endif
else else
ifeq ($(DISCORD_SDK),1) ifeq ($(DISCORD_SDK),1)
LDFLAGS += -ldiscord_game_sdk -lbass -lbass_fx -Wl,-rpath . -Wl,-rpath lib/discordsdk -Wl,-rpath lib/bass LDFLAGS += -ldiscord_game_sdk -Wl,-rpath . -Wl,-rpath lib/discordsdk
else
ifeq ($(TARGET_RPI),1)
LDFLAGS += -lbass -lbass_fx -Wl,-rpath . -Wl,-rpath lib/bass/arm
else
LDFLAGS += -lbass -lbass_fx -Wl,-rpath . -Wl,-rpath lib/bass
endif
endif endif
endif endif
@ -1151,9 +1120,6 @@ $(BUILD_DIR)/$(RPC_LIBS):
$(BUILD_DIR)/$(DISCORD_SDK_LIBS): $(BUILD_DIR)/$(DISCORD_SDK_LIBS):
@$(CP) -f $(DISCORD_SDK_LIBS) $(BUILD_DIR) @$(CP) -f $(DISCORD_SDK_LIBS) $(BUILD_DIR)
$(BUILD_DIR)/$(BASS_LIBS):
@$(CP) -f $(BASS_LIBS) $(BUILD_DIR)
$(BUILD_DIR)/$(COOPNET_LIBS): $(BUILD_DIR)/$(COOPNET_LIBS):
@$(CP) -f $(COOPNET_LIBS) $(BUILD_DIR) @$(CP) -f $(COOPNET_LIBS) $(BUILD_DIR)
@ -1508,7 +1474,7 @@ ifeq ($(TARGET_N64),1)
$(BUILD_DIR)/$(TARGET).objdump: $(ELF) $(BUILD_DIR)/$(TARGET).objdump: $(ELF)
$(OBJDUMP) -D $< > $@ $(OBJDUMP) -D $< > $@
else 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)/$(BASS_LIBS) $(BUILD_DIR)/$(COOPNET_LIBS) $(BUILD_DIR)/$(LANG_DIR) $(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)/$(COOPNET_LIBS) $(BUILD_DIR)/$(LANG_DIR) $(BUILD_DIR)/$(MOD_DIR)
@$(PRINT) "$(GREEN)Linking executable: $(BLUE)$@ $(NO_COL)\n" @$(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) $(V)$(LD) $(PROF_FLAGS) -L $(BUILD_DIR) -o $@ $(O_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(LDFLAGS)
endif endif

View file

@ -109,7 +109,7 @@ override_disallowed_functions = {
"src/pc/lua/utils/smlua_obj_utils.h": [ "spawn_object_remember_field" ], "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/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/game/behavior_actions.h": [ "bhv_dust_smoke_loop", "bhv_init_room" ],
"src/pc/lua/utils/smlua_audio_utils.h": [ "smlua_audio_utils_override", "audio_custom_shutdown"], "src/pc/lua/utils/smlua_audio_utils.h": [ "smlua_audio_utils_override", "audio_custom_shutdown", "smlua_audio_custom_init", "smlua_audio_custom_deinit", "audio_sample_destroy_pending_copies"],
"src/pc/djui/djui_hud_utils.h": [ "djui_hud_render_texture", "djui_hud_render_texture_raw", "djui_hud_render_texture_tile", "djui_hud_render_texture_tile_raw" ], "src/pc/djui/djui_hud_utils.h": [ "djui_hud_render_texture", "djui_hud_render_texture_raw", "djui_hud_render_texture_tile", "djui_hud_render_texture_tile_raw" ],
"src/pc/lua/utils/smlua_level_utils.h": [ "smlua_level_util_reset" ], "src/pc/lua/utils/smlua_level_utils.h": [ "smlua_level_util_reset" ],
"src/pc/lua/utils/smlua_text_utils.h": [ "smlua_text_utils_init", "smlua_text_utils_reset_all" ], "src/pc/lua/utils/smlua_text_utils.h": [ "smlua_text_utils_init", "smlua_text_utils_reset_all" ],

View file

@ -104,7 +104,6 @@ override_field_immutable = {
"Area": [ "localAreaTimer", "nextSyncID", "unk04", "objectSpawnInfos", "paintingWarpNodes", "warpNodes" ], "Area": [ "localAreaTimer", "nextSyncID", "unk04", "objectSpawnInfos", "paintingWarpNodes", "warpNodes" ],
"Mod": [ "*" ], "Mod": [ "*" ],
"ModFile": [ "*" ], "ModFile": [ "*" ],
"BassAudio": [ "*" ],
"Painting": [ "id", "imageCount", "textureType", "textureWidth", "textureHeight" ], "Painting": [ "id", "imageCount", "textureType", "textureWidth", "textureHeight" ],
"SpawnInfo": [ "syncID", "next", "unk18" ], "SpawnInfo": [ "syncID", "next", "unk18" ],
"CustomLevelInfo": [ "next" ], "CustomLevelInfo": [ "next" ],

View file

@ -8147,19 +8147,19 @@ function smlua_anim_util_set_animation(obj, name)
-- ... -- ...
end end
--- @param audio BassAudio --- @param audio ModAudio
--- @return nil --- @return nil
function audio_sample_destroy(audio) function audio_sample_destroy(audio)
-- ... -- ...
end end
--- @param filename string --- @param filename string
--- @return BassAudio --- @return ModAudio
function audio_sample_load(filename) function audio_sample_load(filename)
-- ... -- ...
end end
--- @param audio BassAudio --- @param audio ModAudio
--- @param position Vec3f --- @param position Vec3f
--- @param volume number --- @param volume number
--- @return nil --- @return nil
@ -8167,67 +8167,55 @@ function audio_sample_play(audio, position, volume)
-- ... -- ...
end end
--- @param audio BassAudio --- @param audio ModAudio
--- @return nil --- @return nil
function audio_sample_stop(audio) function audio_sample_stop(audio)
-- ... -- ...
end end
--- @param audio BassAudio --- @param audio ModAudio
--- @return nil --- @return nil
function audio_stream_destroy(audio) function audio_stream_destroy(audio)
-- ... -- ...
end end
--- @param audio BassAudio --- @param audio ModAudio
--- @return number --- @return number
function audio_stream_get_frequency(audio) function audio_stream_get_frequency(audio)
-- ... -- ...
end end
--- @param audio BassAudio --- @param audio ModAudio
--- @return boolean --- @return boolean
function audio_stream_get_looping(audio) function audio_stream_get_looping(audio)
-- ... -- ...
end end
--- @param audio BassAudio --- @param audio ModAudio
--- @return number --- @return number
function audio_stream_get_position(audio) function audio_stream_get_position(audio)
-- ... -- ...
end end
--- @param audio BassAudio --- @param audio ModAudio
--- @return number
function audio_stream_get_tempo(audio)
-- ...
end
--- @param audio BassAudio
--- @return number --- @return number
function audio_stream_get_volume(audio) function audio_stream_get_volume(audio)
-- ... -- ...
end end
--- @param filename string --- @param filename string
--- @return BassAudio --- @return ModAudio
function audio_stream_load(filename) function audio_stream_load(filename)
-- ... -- ...
end end
--- @param url string --- @param audio ModAudio
--- @return BassAudio
function audio_stream_load_url(url)
-- ...
end
--- @param audio BassAudio
--- @return nil --- @return nil
function audio_stream_pause(audio) function audio_stream_pause(audio)
-- ... -- ...
end end
--- @param audio BassAudio --- @param audio ModAudio
--- @param restart boolean --- @param restart boolean
--- @param volume number --- @param volume number
--- @return nil --- @return nil
@ -8235,51 +8223,35 @@ function audio_stream_play(audio, restart, volume)
-- ... -- ...
end end
--- @param audio BassAudio --- @param audio ModAudio
--- @param freq number --- @param freq number
--- @return nil --- @return nil
function audio_stream_set_frequency(audio, freq) function audio_stream_set_frequency(audio, freq)
-- ... -- ...
end end
--- @param audio BassAudio --- @param audio ModAudio
--- @param looping boolean --- @param looping boolean
--- @return nil --- @return nil
function audio_stream_set_looping(audio, looping) function audio_stream_set_looping(audio, looping)
-- ... -- ...
end end
--- @param audio BassAudio --- @param audio ModAudio
--- @param pos number --- @param pos number
--- @return nil --- @return nil
function audio_stream_set_position(audio, pos) function audio_stream_set_position(audio, pos)
-- ... -- ...
end end
--- @param audio BassAudio --- @param audio ModAudio
--- @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 --- @param volume number
--- @return nil --- @return nil
function audio_stream_set_volume(audio, volume) function audio_stream_set_volume(audio, volume)
-- ... -- ...
end end
--- @param audio BassAudio --- @param audio ModAudio
--- @return nil --- @return nil
function audio_stream_stop(audio) function audio_stream_stop(audio)
-- ... -- ...
@ -8342,6 +8314,34 @@ function smlua_collision_util_get(name)
-- ... -- ...
end end
--- @param audio ModAudio
--- @return number
function audio_stream_get_tempo(audio)
-- ...
end
--- @param url string
--- @return ModAudio
function audio_stream_load_url(url)
-- ...
end
--- @param audio ModAudio
--- @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 ModAudio
--- @param tempo number
--- @return nil
function audio_stream_set_tempo(audio, tempo)
-- ...
end
--- @param enable boolean --- @param enable boolean
--- @return nil --- @return nil
function djui_hud_set_render_behind_hud(enable) function djui_hud_set_render_behind_hud(enable)

View file

@ -49,13 +49,6 @@
--- @field public terrainType integer --- @field public terrainType integer
--- @field public warpNodes ObjectWarpNode --- @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 --- @class BehaviorDialogs
--- @field public BobombBuddyBob1Dialog DialogId --- @field public BobombBuddyBob1Dialog DialogId
--- @field public BobombBuddyBob2Dialog DialogId --- @field public BobombBuddyBob2Dialog DialogId
@ -1065,6 +1058,16 @@
--- @field public renderBehindHud boolean --- @field public renderBehindHud boolean
--- @field public selectable boolean --- @field public selectable boolean
--- @class ModAudio
--- @field public file ModFile
--- @field public isStream boolean
--- @field public sampleCopiesTail ModAudioSampleCopies
--- @class ModAudioSampleCopies
--- @field public next ModAudioSampleCopies
--- @field public parent ModAudio
--- @field public prev ModAudioSampleCopies
--- @class ModFile --- @class ModFile
--- @field public cachedPath string --- @field public cachedPath string
--- @field public relativePath string --- @field public relativePath string

View file

@ -7360,13 +7360,13 @@
### Parameters ### Parameters
| Field | Type | | Field | Type |
| ----- | ---- | | ----- | ---- |
| audio | [BassAudio](structs.md#BassAudio) | | audio | [ModAudio](structs.md#ModAudio) |
### Returns ### Returns
- None - None
### C Prototype ### C Prototype
`void audio_sample_destroy(struct BassAudio* audio);` `void audio_sample_destroy(struct ModAudio* audio);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -7375,7 +7375,7 @@
## [audio_sample_load](#audio_sample_load) ## [audio_sample_load](#audio_sample_load)
### Lua Example ### Lua Example
`local BassAudioValue = audio_sample_load(filename)` `local ModAudioValue = audio_sample_load(filename)`
### Parameters ### Parameters
| Field | Type | | Field | Type |
@ -7383,10 +7383,10 @@
| filename | `string` | | filename | `string` |
### Returns ### Returns
[BassAudio](structs.md#BassAudio) [ModAudio](structs.md#ModAudio)
### C Prototype ### C Prototype
`struct BassAudio* audio_sample_load(const char* filename);` `struct ModAudio* audio_sample_load(const char* filename);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -7400,7 +7400,7 @@
### Parameters ### Parameters
| Field | Type | | Field | Type |
| ----- | ---- | | ----- | ---- |
| audio | [BassAudio](structs.md#BassAudio) | | audio | [ModAudio](structs.md#ModAudio) |
| position | [Vec3f](structs.md#Vec3f) | | position | [Vec3f](structs.md#Vec3f) |
| volume | `number` | | volume | `number` |
@ -7408,7 +7408,7 @@
- None - None
### C Prototype ### C Prototype
`void audio_sample_play(struct BassAudio* audio, Vec3f position, f32 volume);` `void audio_sample_play(struct ModAudio* audio, Vec3f position, f32 volume);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -7422,13 +7422,13 @@
### Parameters ### Parameters
| Field | Type | | Field | Type |
| ----- | ---- | | ----- | ---- |
| audio | [BassAudio](structs.md#BassAudio) | | audio | [ModAudio](structs.md#ModAudio) |
### Returns ### Returns
- None - None
### C Prototype ### C Prototype
`void audio_sample_stop(struct BassAudio* audio);` `void audio_sample_stop(struct ModAudio* audio);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -7442,13 +7442,13 @@
### Parameters ### Parameters
| Field | Type | | Field | Type |
| ----- | ---- | | ----- | ---- |
| audio | [BassAudio](structs.md#BassAudio) | | audio | [ModAudio](structs.md#ModAudio) |
### Returns ### Returns
- None - None
### C Prototype ### C Prototype
`void audio_stream_destroy(struct BassAudio* audio);` `void audio_stream_destroy(struct ModAudio* audio);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -7462,13 +7462,13 @@
### Parameters ### Parameters
| Field | Type | | Field | Type |
| ----- | ---- | | ----- | ---- |
| audio | [BassAudio](structs.md#BassAudio) | | audio | [ModAudio](structs.md#ModAudio) |
### Returns ### Returns
- `number` - `number`
### C Prototype ### C Prototype
`f32 audio_stream_get_frequency(struct BassAudio* audio);` `f32 audio_stream_get_frequency(struct ModAudio* audio);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -7482,13 +7482,13 @@
### Parameters ### Parameters
| Field | Type | | Field | Type |
| ----- | ---- | | ----- | ---- |
| audio | [BassAudio](structs.md#BassAudio) | | audio | [ModAudio](structs.md#ModAudio) |
### Returns ### Returns
- `boolean` - `boolean`
### C Prototype ### C Prototype
`bool audio_stream_get_looping(struct BassAudio* audio);` `bool audio_stream_get_looping(struct ModAudio* audio);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -7502,33 +7502,13 @@
### Parameters ### Parameters
| Field | Type | | Field | Type |
| ----- | ---- | | ----- | ---- |
| audio | [BassAudio](structs.md#BassAudio) | | audio | [ModAudio](structs.md#ModAudio) |
### Returns ### Returns
- `number` - `number`
### C Prototype ### C Prototype
`f32 audio_stream_get_position(struct BassAudio* audio);` `f32 audio_stream_get_position(struct ModAudio* 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:](#) [:arrow_up_small:](#)
@ -7542,13 +7522,13 @@
### Parameters ### Parameters
| Field | Type | | Field | Type |
| ----- | ---- | | ----- | ---- |
| audio | [BassAudio](structs.md#BassAudio) | | audio | [ModAudio](structs.md#ModAudio) |
### Returns ### Returns
- `number` - `number`
### C Prototype ### C Prototype
`f32 audio_stream_get_volume(struct BassAudio* audio);` `f32 audio_stream_get_volume(struct ModAudio* audio);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -7557,7 +7537,7 @@
## [audio_stream_load](#audio_stream_load) ## [audio_stream_load](#audio_stream_load)
### Lua Example ### Lua Example
`local BassAudioValue = audio_stream_load(filename)` `local ModAudioValue = audio_stream_load(filename)`
### Parameters ### Parameters
| Field | Type | | Field | Type |
@ -7565,30 +7545,10 @@
| filename | `string` | | filename | `string` |
### Returns ### Returns
[BassAudio](structs.md#BassAudio) [ModAudio](structs.md#ModAudio)
### C Prototype ### C Prototype
`struct BassAudio* audio_stream_load(const char* filename);` `struct ModAudio* audio_stream_load(const char* filename);`
[:arrow_up_small:](#)
<br />
## [audio_stream_load_url](#audio_stream_load_url)
### Lua Example
`local BassAudioValue = audio_stream_load_url(url)`
### Parameters
| Field | Type |
| ----- | ---- |
| url | `string` |
### Returns
[BassAudio](structs.md#BassAudio)
### C Prototype
`struct BassAudio* audio_stream_load_url(const char* url);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -7602,13 +7562,13 @@
### Parameters ### Parameters
| Field | Type | | Field | Type |
| ----- | ---- | | ----- | ---- |
| audio | [BassAudio](structs.md#BassAudio) | | audio | [ModAudio](structs.md#ModAudio) |
### Returns ### Returns
- None - None
### C Prototype ### C Prototype
`void audio_stream_pause(struct BassAudio* audio);` `void audio_stream_pause(struct ModAudio* audio);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -7622,7 +7582,7 @@
### Parameters ### Parameters
| Field | Type | | Field | Type |
| ----- | ---- | | ----- | ---- |
| audio | [BassAudio](structs.md#BassAudio) | | audio | [ModAudio](structs.md#ModAudio) |
| restart | `boolean` | | restart | `boolean` |
| volume | `number` | | volume | `number` |
@ -7630,7 +7590,7 @@
- None - None
### C Prototype ### C Prototype
`void audio_stream_play(struct BassAudio* audio, bool restart, f32 volume);` `void audio_stream_play(struct ModAudio* audio, bool restart, f32 volume);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -7644,14 +7604,14 @@
### Parameters ### Parameters
| Field | Type | | Field | Type |
| ----- | ---- | | ----- | ---- |
| audio | [BassAudio](structs.md#BassAudio) | | audio | [ModAudio](structs.md#ModAudio) |
| freq | `number` | | freq | `number` |
### Returns ### Returns
- None - None
### C Prototype ### C Prototype
`void audio_stream_set_frequency(struct BassAudio* audio, f32 freq);` `void audio_stream_set_frequency(struct ModAudio* audio, f32 freq);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -7665,14 +7625,14 @@
### Parameters ### Parameters
| Field | Type | | Field | Type |
| ----- | ---- | | ----- | ---- |
| audio | [BassAudio](structs.md#BassAudio) | | audio | [ModAudio](structs.md#ModAudio) |
| looping | `boolean` | | looping | `boolean` |
### Returns ### Returns
- None - None
### C Prototype ### C Prototype
`void audio_stream_set_looping(struct BassAudio* audio, bool looping);` `void audio_stream_set_looping(struct ModAudio* audio, bool looping);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -7686,58 +7646,14 @@
### Parameters ### Parameters
| Field | Type | | Field | Type |
| ----- | ---- | | ----- | ---- |
| audio | [BassAudio](structs.md#BassAudio) | | audio | [ModAudio](structs.md#ModAudio) |
| pos | `number` | | pos | `number` |
### Returns ### Returns
- None - None
### C Prototype ### C Prototype
`void audio_stream_set_position(struct BassAudio* audio, f32 pos);` `void audio_stream_set_position(struct ModAudio* 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:](#) [:arrow_up_small:](#)
@ -7751,14 +7667,14 @@
### Parameters ### Parameters
| Field | Type | | Field | Type |
| ----- | ---- | | ----- | ---- |
| audio | [BassAudio](structs.md#BassAudio) | | audio | [ModAudio](structs.md#ModAudio) |
| volume | `number` | | volume | `number` |
### Returns ### Returns
- None - None
### C Prototype ### C Prototype
`void audio_stream_set_volume(struct BassAudio* audio, f32 volume);` `void audio_stream_set_volume(struct ModAudio* audio, f32 volume);`
[:arrow_up_small:](#) [:arrow_up_small:](#)
@ -7772,13 +7688,13 @@
### Parameters ### Parameters
| Field | Type | | Field | Type |
| ----- | ---- | | ----- | ---- |
| audio | [BassAudio](structs.md#BassAudio) | | audio | [ModAudio](structs.md#ModAudio) |
### Returns ### Returns
- None - None
### C Prototype ### C Prototype
`void audio_stream_stop(struct BassAudio* audio);` `void audio_stream_stop(struct ModAudio* audio);`
[:arrow_up_small:](#) [:arrow_up_small:](#)

View file

@ -1536,17 +1536,13 @@
- [audio_stream_get_frequency](functions-4.md#audio_stream_get_frequency) - [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_looping](functions-4.md#audio_stream_get_looping)
- [audio_stream_get_position](functions-4.md#audio_stream_get_position) - [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_get_volume](functions-4.md#audio_stream_get_volume)
- [audio_stream_load](functions-4.md#audio_stream_load) - [audio_stream_load](functions-4.md#audio_stream_load)
- [audio_stream_load_url](functions-4.md#audio_stream_load_url)
- [audio_stream_pause](functions-4.md#audio_stream_pause) - [audio_stream_pause](functions-4.md#audio_stream_pause)
- [audio_stream_play](functions-4.md#audio_stream_play) - [audio_stream_play](functions-4.md#audio_stream_play)
- [audio_stream_set_frequency](functions-4.md#audio_stream_set_frequency) - [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_looping](functions-4.md#audio_stream_set_looping)
- [audio_stream_set_position](functions-4.md#audio_stream_set_position) - [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_set_volume](functions-4.md#audio_stream_set_volume)
- [audio_stream_stop](functions-4.md#audio_stream_stop) - [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_replace_sequence](functions-4.md#smlua_audio_utils_replace_sequence)

View file

@ -5,7 +5,6 @@
- [Animation](#Animation) - [Animation](#Animation)
- [AnimationTable](#AnimationTable) - [AnimationTable](#AnimationTable)
- [Area](#Area) - [Area](#Area)
- [BassAudio](#BassAudio)
- [BehaviorDialogs](#BehaviorDialogs) - [BehaviorDialogs](#BehaviorDialogs)
- [BehaviorTrajectories](#BehaviorTrajectories) - [BehaviorTrajectories](#BehaviorTrajectories)
- [BehaviorValues](#BehaviorValues) - [BehaviorValues](#BehaviorValues)
@ -43,6 +42,8 @@
- [MarioBodyState](#MarioBodyState) - [MarioBodyState](#MarioBodyState)
- [MarioState](#MarioState) - [MarioState](#MarioState)
- [Mod](#Mod) - [Mod](#Mod)
- [ModAudio](#ModAudio)
- [ModAudioSampleCopies](#ModAudioSampleCopies)
- [ModFile](#ModFile) - [ModFile](#ModFile)
- [ModeTransitionInfo](#ModeTransitionInfo) - [ModeTransitionInfo](#ModeTransitionInfo)
- [NametagsSettings](#NametagsSettings) - [NametagsSettings](#NametagsSettings)
@ -163,20 +164,6 @@
<br /> <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) ## [BehaviorDialogs](#BehaviorDialogs)
| Field | Type | Access | | Field | Type | Access |
@ -1443,6 +1430,30 @@
<br /> <br />
## [ModAudio](#ModAudio)
| Field | Type | Access |
| ----- | ---- | ------ |
| file | [ModFile](structs.md#ModFile) | |
| isStream | `boolean` | |
| sampleCopiesTail | [ModAudioSampleCopies](structs.md#ModAudioSampleCopies) | |
[:arrow_up_small:](#)
<br />
## [ModAudioSampleCopies](#ModAudioSampleCopies)
| Field | Type | Access |
| ----- | ---- | ------ |
| next | [ModAudioSampleCopies](structs.md#ModAudioSampleCopies) | |
| parent | [ModAudio](structs.md#ModAudio) | |
| prev | [ModAudioSampleCopies](structs.md#ModAudioSampleCopies) | |
[:arrow_up_small:](#)
<br />
## [ModFile](#ModFile) ## [ModFile](#ModFile)
| Field | Type | Access | | Field | Type | Access |

File diff suppressed because it is too large Load diff

View file

@ -1,443 +0,0 @@
/*===========================================================================
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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -5,7 +5,7 @@
#include "types.h" #include "types.h"
#include "pc/lua/utils/smlua_audio_utils.h" #define MAX_AUDIO_OVERRIDE 128
// Sequence arguments, passed to seq_player_play_sequence. seqId may be bit-OR'ed with // Sequence arguments, passed to seq_player_play_sequence. seqId may be bit-OR'ed with
// SEQ_VARIATION; this will load the same sequence, but set a variation // SEQ_VARIATION; this will load the same sequence, but set a variation

View file

@ -1,136 +0,0 @@
#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(const 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(const 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_stop_sample(HSAMPLE sample) {
BASS_SampleStop(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(void) {
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(void) {
BASS_Free();
}
int bassh_device_count(void) {
int count = 0;
BASS_DEVICEINFO info;
for(count = 0; BASS_GetDeviceInfo(count, &info); count++) {}
return count;
}

View file

@ -1,35 +0,0 @@
#include "include/bass/bass.h"
#define MAX_SAMPLE_CONCURRENT_PLAYBACKS 32
HSTREAM bassh_create_fx_stream_from_file(const char* data, QWORD length, QWORD offset);
HSAMPLE bassh_create_sample_from_file(const char* data, QWORD length, QWORD offset);
HSTREAM bassh_sample_get_stream(HSAMPLE sample);
void bassh_free_sample(HSAMPLE sample);
void bassh_stop_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();

View file

@ -1,111 +0,0 @@
#include "types.h"
#include "bass/bass.h"
#include "game/camera.h"
#undef min // Redefined in math_util.h, undef it to avoid compiler warnings
#undef max // Redefined in math_util.h, undef it to avoid compiler warnings
#include "engine/math_util.h"
#define H01(s, i, x) (x * 65599u + (u8) s[(i) < sizeof(s) ? (i) : sizeof(s)])
#define H04(s, i, x) H01(s, i, H01(s, i + 1, H01(s, i + 2, H01(s, i + 3, x))))
#define H16(s, i, x) H04(s, i, H04(s, i + 4, H04(s, i + 8, H04(s, i + 12, x))))
#define H64(s, i, x) H16(s, i, H16(s, i + 16, H16(s, i + 32, H16(s, i + 48, x))))
#define CHAR_BASS_MAGIC 0xFF000000u
#define CHAR_BASS_SOUND_ID(name) (H64(#name "________________________________________________________________", 0, 0) & ~CHAR_BASS_MAGIC)
#define CHAR_BASS_SOUND(name) (CHAR_BASS_MAGIC | CHAR_BASS_SOUND_ID(name))
#define CHAR_BASS_SOUND_NOT_LOADED 0xFFFFFFFFu
#define DECL_CHAR_BASS_SOUND_RAW(name, ...) static const u8 sCharacterBassSoundRaw_##name[] =
#define DECL_CHAR_BASS_SOUND(name) { CHAR_BASS_SOUND(name), (s32) sizeof(sCharacterBassSoundRaw_##name), sCharacterBassSoundRaw_##name, CHAR_BASS_SOUND_NOT_LOADED, 0.f }
// Undef these to avoid naming issues
#undef SOUND_MARIO_LETS_A_GO
#undef SOUND_LUIGI_LETS_A_GO
#undef SOUND_WARIO_LETS_A_GO
#undef SOUND_TOAD_LETS_A_GO
#undef SOUND_MARIO_OKEY_DOKEY
#undef SOUND_LUIGI_OKEY_DOKEY
#undef SOUND_WARIO_OKEY_DOKEY
#undef SOUND_TOAD_OKEY_DOKEY
/////////////////
// Bass sounds //
/////////////////
DECL_CHAR_BASS_SOUND_RAW(SOUND_MARIO_LETS_A_GO) {
#include "sound/samples/sfx_mario/1A_mario_lets_a_go.table.inc.c"
};
DECL_CHAR_BASS_SOUND_RAW(SOUND_LUIGI_LETS_A_GO) {
#include "sound/samples/sfx_custom_luigi/1A.table.inc.c"
};
DECL_CHAR_BASS_SOUND_RAW(SOUND_WARIO_LETS_A_GO) {
#include "sound/samples/sfx_custom_wario/1A.table.inc.c"
};
DECL_CHAR_BASS_SOUND_RAW(SOUND_TOAD_LETS_A_GO) {
#include "sound/samples/sfx_custom_toad/1A.table.inc.c"
};
DECL_CHAR_BASS_SOUND_RAW(SOUND_MARIO_OKEY_DOKEY) {
#include "sound/samples/sfx_mario_peach/0B_mario_okey_dokey.table.inc.c"
};
DECL_CHAR_BASS_SOUND_RAW(SOUND_LUIGI_OKEY_DOKEY) {
#include "sound/samples/sfx_custom_luigi_peach/0B.table.inc.c"
};
DECL_CHAR_BASS_SOUND_RAW(SOUND_WARIO_OKEY_DOKEY) {
#include "sound/samples/sfx_custom_wario_peach/0B.table.inc.c"
};
DECL_CHAR_BASS_SOUND_RAW(SOUND_TOAD_OKEY_DOKEY) {
#include "sound/samples/sfx_custom_toad_peach/0B.table.inc.c"
};
///////////////////////
// Bass sounds table //
///////////////////////
typedef struct { s32 sound; s32 size; const u8 *raw; HSAMPLE sample; f32 freq; } CharacterBassSound;
static CharacterBassSound sCharacterBassSounds[] = {
DECL_CHAR_BASS_SOUND(SOUND_MARIO_LETS_A_GO),
DECL_CHAR_BASS_SOUND(SOUND_LUIGI_LETS_A_GO),
DECL_CHAR_BASS_SOUND(SOUND_WARIO_LETS_A_GO),
DECL_CHAR_BASS_SOUND(SOUND_TOAD_LETS_A_GO),
DECL_CHAR_BASS_SOUND(SOUND_MARIO_OKEY_DOKEY),
DECL_CHAR_BASS_SOUND(SOUND_LUIGI_OKEY_DOKEY),
DECL_CHAR_BASS_SOUND(SOUND_WARIO_OKEY_DOKEY),
DECL_CHAR_BASS_SOUND(SOUND_TOAD_OKEY_DOKEY),
{ 0, 0, NULL, CHAR_BASS_SOUND_NOT_LOADED, 0.f },
};
///////////////////////////
// Bass sounds functions //
///////////////////////////
static CharacterBassSound *get_character_bass_sound(s32 sound) {
for (CharacterBassSound *cbs = sCharacterBassSounds; cbs->raw != NULL; cbs++) {
if (cbs->sound == sound) {
return cbs;
}
}
return NULL;
}
static void play_character_bass_sound(CharacterBassSound *cbs, f32 *pos, f32 freqScale) {
if (cbs->sample == CHAR_BASS_SOUND_NOT_LOADED) {
cbs->sample = BASS_SampleLoad(TRUE, cbs->raw, 0, cbs->size, 32, BASS_SAMPLE_OVER_POS);
BASS_SAMPLE info; BASS_SampleGetInfo(cbs->sample, &info);
cbs->freq = info.freq;
}
DWORD handle = BASS_SampleGetChannel(cbs->sample, 0);
f32 dist = vec3f_length(pos);
f32 pan = (get_sound_pan(pos[0], pos[2]) - 0.5f) * 2.f;
f32 intensity = sound_get_level_intensity(dist);
f32 masterVolume = (f32) configMasterVolume / 127.f;
f32 sfxVolume = (f32) configSfxVolume / 127.f;
BASS_ChannelSetAttribute(handle, BASS_ATTRIB_VOL, masterVolume * sfxVolume * intensity * 0.75f);
BASS_ChannelSetAttribute(handle, BASS_ATTRIB_PAN, pan);
BASS_ChannelSetAttribute(handle, BASS_ATTRIB_FREQ, cbs->freq * freqScale);
BASS_ChannelPlay(handle, TRUE);
}

View file

@ -289,6 +289,8 @@ void smlua_update(void) {
lua_State* L = gLuaState; lua_State* L = gLuaState;
if (L == NULL) { return; } if (L == NULL) { return; }
audio_sample_destroy_pending_copies();
smlua_call_event_hooks(HOOK_UPDATE); smlua_call_event_hooks(HOOK_UPDATE);
// Collect our garbage after calling our hooks. // Collect our garbage after calling our hooks.
// If we don't, Lag can quickly build up from our mods. // If we don't, Lag can quickly build up from our mods.

View file

@ -87,15 +87,6 @@ static struct LuaObjectField sAreaFields[LUA_AREA_FIELD_COUNT] = {
// { "whirlpools", LOT_???, offsetof(struct Area, whirlpools), false, LOT_??? }, <--- UNIMPLEMENTED // { "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 #define LUA_BEHAVIOR_DIALOGS_FIELD_COUNT 84
static struct LuaObjectField sBehaviorDialogsFields[LUA_BEHAVIOR_DIALOGS_FIELD_COUNT] = { static struct LuaObjectField sBehaviorDialogsFields[LUA_BEHAVIOR_DIALOGS_FIELD_COUNT] = {
{ "BobombBuddyBob1Dialog", LVT_S32, offsetof(struct BehaviorDialogs, BobombBuddyBob1Dialog), false, LOT_NONE }, { "BobombBuddyBob1Dialog", LVT_S32, offsetof(struct BehaviorDialogs, BobombBuddyBob1Dialog), false, LOT_NONE },
@ -1195,6 +1186,22 @@ static struct LuaObjectField sModFields[LUA_MOD_FIELD_COUNT] = {
// { "size", LVT_???, offsetof(struct Mod, size), true, LOT_??? }, <--- UNIMPLEMENTED // { "size", LVT_???, offsetof(struct Mod, size), true, LOT_??? }, <--- UNIMPLEMENTED
}; };
#define LUA_MOD_AUDIO_FIELD_COUNT 3
static struct LuaObjectField sModAudioFields[LUA_MOD_AUDIO_FIELD_COUNT] = {
{ "file", LVT_COBJECT_P, offsetof(struct ModAudio, file), false, LOT_MODFILE },
{ "isStream", LVT_BOOL, offsetof(struct ModAudio, isStream), false, LOT_NONE },
{ "sampleCopiesTail", LVT_COBJECT_P, offsetof(struct ModAudio, sampleCopiesTail), false, LOT_MODAUDIOSAMPLECOPIES },
// { "sound", LVT_???, offsetof(struct ModAudio, sound), false, LOT_??? }, <--- UNIMPLEMENTED
};
#define LUA_MOD_AUDIO_SAMPLE_COPIES_FIELD_COUNT 3
static struct LuaObjectField sModAudioSampleCopiesFields[LUA_MOD_AUDIO_SAMPLE_COPIES_FIELD_COUNT] = {
{ "next", LVT_COBJECT_P, offsetof(struct ModAudioSampleCopies, next), false, LOT_MODAUDIOSAMPLECOPIES },
{ "parent", LVT_COBJECT_P, offsetof(struct ModAudioSampleCopies, parent), false, LOT_MODAUDIO },
{ "prev", LVT_COBJECT_P, offsetof(struct ModAudioSampleCopies, prev), false, LOT_MODAUDIOSAMPLECOPIES },
// { "sound", LVT_???, offsetof(struct ModAudioSampleCopies, sound), false, LOT_??? }, <--- UNIMPLEMENTED
};
#define LUA_MOD_FILE_FIELD_COUNT 3 #define LUA_MOD_FILE_FIELD_COUNT 3
static struct LuaObjectField sModFileFields[LUA_MOD_FILE_FIELD_COUNT] = { static struct LuaObjectField sModFileFields[LUA_MOD_FILE_FIELD_COUNT] = {
{ "cachedPath", LVT_STRING_P, offsetof(struct ModFile, cachedPath), true, LOT_NONE }, { "cachedPath", LVT_STRING_P, offsetof(struct ModFile, cachedPath), true, LOT_NONE },
@ -2410,7 +2417,6 @@ struct LuaObjectTable sLuaObjectAutogenTable[LOT_AUTOGEN_MAX - LOT_AUTOGEN_MIN]
{ LOT_ANIMATION, sAnimationFields, LUA_ANIMATION_FIELD_COUNT }, { LOT_ANIMATION, sAnimationFields, LUA_ANIMATION_FIELD_COUNT },
{ LOT_ANIMATIONTABLE, sAnimationTableFields, LUA_ANIMATION_TABLE_FIELD_COUNT }, { LOT_ANIMATIONTABLE, sAnimationTableFields, LUA_ANIMATION_TABLE_FIELD_COUNT },
{ LOT_AREA, sAreaFields, LUA_AREA_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_BEHAVIORDIALOGS, sBehaviorDialogsFields, LUA_BEHAVIOR_DIALOGS_FIELD_COUNT },
{ LOT_BEHAVIORTRAJECTORIES, sBehaviorTrajectoriesFields, LUA_BEHAVIOR_TRAJECTORIES_FIELD_COUNT }, { LOT_BEHAVIORTRAJECTORIES, sBehaviorTrajectoriesFields, LUA_BEHAVIOR_TRAJECTORIES_FIELD_COUNT },
{ LOT_BEHAVIORVALUES, sBehaviorValuesFields, LUA_BEHAVIOR_VALUES_FIELD_COUNT }, { LOT_BEHAVIORVALUES, sBehaviorValuesFields, LUA_BEHAVIOR_VALUES_FIELD_COUNT },
@ -2446,6 +2452,8 @@ struct LuaObjectTable sLuaObjectAutogenTable[LOT_AUTOGEN_MAX - LOT_AUTOGEN_MIN]
{ LOT_MARIOBODYSTATE, sMarioBodyStateFields, LUA_MARIO_BODY_STATE_FIELD_COUNT }, { LOT_MARIOBODYSTATE, sMarioBodyStateFields, LUA_MARIO_BODY_STATE_FIELD_COUNT },
{ LOT_MARIOSTATE, sMarioStateFields, LUA_MARIO_STATE_FIELD_COUNT }, { LOT_MARIOSTATE, sMarioStateFields, LUA_MARIO_STATE_FIELD_COUNT },
{ LOT_MOD, sModFields, LUA_MOD_FIELD_COUNT }, { LOT_MOD, sModFields, LUA_MOD_FIELD_COUNT },
{ LOT_MODAUDIO, sModAudioFields, LUA_MOD_AUDIO_FIELD_COUNT },
{ LOT_MODAUDIOSAMPLECOPIES, sModAudioSampleCopiesFields, LUA_MOD_AUDIO_SAMPLE_COPIES_FIELD_COUNT },
{ LOT_MODFILE, sModFileFields, LUA_MOD_FILE_FIELD_COUNT }, { LOT_MODFILE, sModFileFields, LUA_MOD_FILE_FIELD_COUNT },
{ LOT_MODETRANSITIONINFO, sModeTransitionInfoFields, LUA_MODE_TRANSITION_INFO_FIELD_COUNT }, { LOT_MODETRANSITIONINFO, sModeTransitionInfoFields, LUA_MODE_TRANSITION_INFO_FIELD_COUNT },
{ LOT_NAMETAGSSETTINGS, sNametagsSettingsFields, LUA_NAMETAGS_SETTINGS_FIELD_COUNT }, { LOT_NAMETAGSSETTINGS, sNametagsSettingsFields, LUA_NAMETAGS_SETTINGS_FIELD_COUNT },

View file

@ -9,7 +9,6 @@ enum LuaObjectAutogenType {
LOT_ANIMATION, LOT_ANIMATION,
LOT_ANIMATIONTABLE, LOT_ANIMATIONTABLE,
LOT_AREA, LOT_AREA,
LOT_BASSAUDIO,
LOT_BEHAVIORDIALOGS, LOT_BEHAVIORDIALOGS,
LOT_BEHAVIORTRAJECTORIES, LOT_BEHAVIORTRAJECTORIES,
LOT_BEHAVIORVALUES, LOT_BEHAVIORVALUES,
@ -45,6 +44,8 @@ enum LuaObjectAutogenType {
LOT_MARIOBODYSTATE, LOT_MARIOBODYSTATE,
LOT_MARIOSTATE, LOT_MARIOSTATE,
LOT_MOD, LOT_MOD,
LOT_MODAUDIO,
LOT_MODAUDIOSAMPLECOPIES,
LOT_MODFILE, LOT_MODFILE,
LOT_MODETRANSITIONINFO, LOT_MODETRANSITIONINFO,
LOT_NAMETAGSSETTINGS, LOT_NAMETAGSSETTINGS,

View file

@ -27197,7 +27197,7 @@ int smlua_func_audio_sample_destroy(lua_State* L) {
return 0; return 0;
} }
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO); struct ModAudio* audio = (struct ModAudio*)smlua_to_cobject(L, 1, LOT_MODAUDIO);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_sample_destroy"); return 0; } if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_sample_destroy"); return 0; }
audio_sample_destroy(audio); audio_sample_destroy(audio);
@ -27217,7 +27217,7 @@ int smlua_func_audio_sample_load(lua_State* L) {
const char* filename = smlua_to_string(L, 1); const char* filename = smlua_to_string(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_sample_load"); return 0; } if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_sample_load"); return 0; }
smlua_push_object(L, LOT_BASSAUDIO, audio_sample_load(filename)); smlua_push_object(L, LOT_MODAUDIO, audio_sample_load(filename));
return 1; return 1;
} }
@ -27231,7 +27231,7 @@ int smlua_func_audio_sample_play(lua_State* L) {
return 0; return 0;
} }
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO); struct ModAudio* audio = (struct ModAudio*)smlua_to_cobject(L, 1, LOT_MODAUDIO);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_sample_play"); return 0; } if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_sample_play"); return 0; }
f32* position = smlua_get_vec3f_from_buffer(); f32* position = smlua_get_vec3f_from_buffer();
@ -27260,7 +27260,7 @@ int smlua_func_audio_sample_stop(lua_State* L) {
return 0; return 0;
} }
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO); struct ModAudio* audio = (struct ModAudio*)smlua_to_cobject(L, 1, LOT_MODAUDIO);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_sample_stop"); return 0; } if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_sample_stop"); return 0; }
audio_sample_stop(audio); audio_sample_stop(audio);
@ -27277,7 +27277,7 @@ int smlua_func_audio_stream_destroy(lua_State* L) {
return 0; return 0;
} }
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO); struct ModAudio* audio = (struct ModAudio*)smlua_to_cobject(L, 1, LOT_MODAUDIO);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_destroy"); return 0; } if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_destroy"); return 0; }
audio_stream_destroy(audio); audio_stream_destroy(audio);
@ -27294,7 +27294,7 @@ int smlua_func_audio_stream_get_frequency(lua_State* L) {
return 0; return 0;
} }
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO); struct ModAudio* audio = (struct ModAudio*)smlua_to_cobject(L, 1, LOT_MODAUDIO);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_get_frequency"); return 0; } if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_get_frequency"); return 0; }
lua_pushnumber(L, audio_stream_get_frequency(audio)); lua_pushnumber(L, audio_stream_get_frequency(audio));
@ -27311,7 +27311,7 @@ int smlua_func_audio_stream_get_looping(lua_State* L) {
return 0; return 0;
} }
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO); struct ModAudio* audio = (struct ModAudio*)smlua_to_cobject(L, 1, LOT_MODAUDIO);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_get_looping"); return 0; } if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_get_looping"); return 0; }
lua_pushboolean(L, audio_stream_get_looping(audio)); lua_pushboolean(L, audio_stream_get_looping(audio));
@ -27328,7 +27328,7 @@ int smlua_func_audio_stream_get_position(lua_State* L) {
return 0; return 0;
} }
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO); struct ModAudio* audio = (struct ModAudio*)smlua_to_cobject(L, 1, LOT_MODAUDIO);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_get_position"); return 0; } if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_get_position"); return 0; }
lua_pushnumber(L, audio_stream_get_position(audio)); lua_pushnumber(L, audio_stream_get_position(audio));
@ -27336,23 +27336,6 @@ int smlua_func_audio_stream_get_position(lua_State* L) {
return 1; return 1;
} }
int smlua_func_audio_stream_get_tempo(lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 1) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "audio_stream_get_tempo", 1, top);
return 0;
}
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_get_tempo"); return 0; }
lua_pushnumber(L, audio_stream_get_tempo(audio));
return 1;
}
int smlua_func_audio_stream_get_volume(lua_State* L) { int smlua_func_audio_stream_get_volume(lua_State* L) {
if (L == NULL) { return 0; } if (L == NULL) { return 0; }
@ -27362,7 +27345,7 @@ int smlua_func_audio_stream_get_volume(lua_State* L) {
return 0; return 0;
} }
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO); struct ModAudio* audio = (struct ModAudio*)smlua_to_cobject(L, 1, LOT_MODAUDIO);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_get_volume"); return 0; } if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_get_volume"); return 0; }
lua_pushnumber(L, audio_stream_get_volume(audio)); lua_pushnumber(L, audio_stream_get_volume(audio));
@ -27382,24 +27365,7 @@ int smlua_func_audio_stream_load(lua_State* L) {
const char* filename = smlua_to_string(L, 1); const char* filename = smlua_to_string(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_load"); return 0; } if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_load"); return 0; }
smlua_push_object(L, LOT_BASSAUDIO, audio_stream_load(filename)); smlua_push_object(L, LOT_MODAUDIO, audio_stream_load(filename));
return 1;
}
int smlua_func_audio_stream_load_url(lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 1) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "audio_stream_load_url", 1, top);
return 0;
}
const char* url = smlua_to_string(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_load_url"); return 0; }
smlua_push_object(L, LOT_BASSAUDIO, audio_stream_load_url(url));
return 1; return 1;
} }
@ -27413,7 +27379,7 @@ int smlua_func_audio_stream_pause(lua_State* L) {
return 0; return 0;
} }
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO); struct ModAudio* audio = (struct ModAudio*)smlua_to_cobject(L, 1, LOT_MODAUDIO);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_pause"); return 0; } if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_pause"); return 0; }
audio_stream_pause(audio); audio_stream_pause(audio);
@ -27430,7 +27396,7 @@ int smlua_func_audio_stream_play(lua_State* L) {
return 0; return 0;
} }
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO); struct ModAudio* audio = (struct ModAudio*)smlua_to_cobject(L, 1, LOT_MODAUDIO);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_play"); return 0; } if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_play"); return 0; }
bool restart = smlua_to_boolean(L, 2); bool restart = smlua_to_boolean(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "audio_stream_play"); return 0; } if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "audio_stream_play"); return 0; }
@ -27451,7 +27417,7 @@ int smlua_func_audio_stream_set_frequency(lua_State* L) {
return 0; return 0;
} }
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO); struct ModAudio* audio = (struct ModAudio*)smlua_to_cobject(L, 1, LOT_MODAUDIO);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_set_frequency"); return 0; } if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_set_frequency"); return 0; }
f32 freq = smlua_to_number(L, 2); f32 freq = smlua_to_number(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "audio_stream_set_frequency"); return 0; } if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "audio_stream_set_frequency"); return 0; }
@ -27470,7 +27436,7 @@ int smlua_func_audio_stream_set_looping(lua_State* L) {
return 0; return 0;
} }
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO); struct ModAudio* audio = (struct ModAudio*)smlua_to_cobject(L, 1, LOT_MODAUDIO);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_set_looping"); return 0; } if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_set_looping"); return 0; }
bool looping = smlua_to_boolean(L, 2); bool looping = smlua_to_boolean(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "audio_stream_set_looping"); return 0; } if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "audio_stream_set_looping"); return 0; }
@ -27489,7 +27455,7 @@ int smlua_func_audio_stream_set_position(lua_State* L) {
return 0; return 0;
} }
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO); struct ModAudio* audio = (struct ModAudio*)smlua_to_cobject(L, 1, LOT_MODAUDIO);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_set_position"); return 0; } if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_set_position"); return 0; }
f32 pos = smlua_to_number(L, 2); f32 pos = smlua_to_number(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "audio_stream_set_position"); return 0; } if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "audio_stream_set_position"); return 0; }
@ -27499,48 +27465,6 @@ int smlua_func_audio_stream_set_position(lua_State* L) {
return 1; return 1;
} }
int smlua_func_audio_stream_set_speed(lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 4) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "audio_stream_set_speed", 4, top);
return 0;
}
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_set_speed"); return 0; }
f32 initial_freq = smlua_to_number(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "audio_stream_set_speed"); return 0; }
f32 speed = smlua_to_number(L, 3);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "audio_stream_set_speed"); return 0; }
bool pitch = smlua_to_boolean(L, 4);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "audio_stream_set_speed"); return 0; }
audio_stream_set_speed(audio, initial_freq, speed, pitch);
return 1;
}
int smlua_func_audio_stream_set_tempo(lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 2) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "audio_stream_set_tempo", 2, top);
return 0;
}
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_set_tempo"); return 0; }
f32 tempo = smlua_to_number(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "audio_stream_set_tempo"); return 0; }
audio_stream_set_tempo(audio, tempo);
return 1;
}
int smlua_func_audio_stream_set_volume(lua_State* L) { int smlua_func_audio_stream_set_volume(lua_State* L) {
if (L == NULL) { return 0; } if (L == NULL) { return 0; }
@ -27550,7 +27474,7 @@ int smlua_func_audio_stream_set_volume(lua_State* L) {
return 0; return 0;
} }
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO); struct ModAudio* audio = (struct ModAudio*)smlua_to_cobject(L, 1, LOT_MODAUDIO);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_set_volume"); return 0; } if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_set_volume"); return 0; }
f32 volume = smlua_to_number(L, 2); f32 volume = smlua_to_number(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "audio_stream_set_volume"); return 0; } if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "audio_stream_set_volume"); return 0; }
@ -27569,7 +27493,7 @@ int smlua_func_audio_stream_stop(lua_State* L) {
return 0; return 0;
} }
struct BassAudio* audio = (struct BassAudio*)smlua_to_cobject(L, 1, LOT_BASSAUDIO); struct ModAudio* audio = (struct ModAudio*)smlua_to_cobject(L, 1, LOT_MODAUDIO);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_stop"); return 0; } if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_stop"); return 0; }
audio_stream_stop(audio); audio_stream_stop(audio);
@ -27739,6 +27663,82 @@ int smlua_func_smlua_collision_util_get(lua_State* L) {
// smlua_deprecated.h // // smlua_deprecated.h //
//////////////////////// ////////////////////////
int smlua_func_audio_stream_get_tempo(lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 1) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "audio_stream_get_tempo", 1, top);
return 0;
}
struct ModAudio* audio = (struct ModAudio*)smlua_to_cobject(L, 1, LOT_MODAUDIO);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_get_tempo"); return 0; }
lua_pushnumber(L, audio_stream_get_tempo(audio));
return 1;
}
int smlua_func_audio_stream_load_url(lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 1) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "audio_stream_load_url", 1, top);
return 0;
}
const char* url = smlua_to_string(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_load_url"); return 0; }
smlua_push_object(L, LOT_MODAUDIO, audio_stream_load_url(url));
return 1;
}
int smlua_func_audio_stream_set_speed(lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 4) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "audio_stream_set_speed", 4, top);
return 0;
}
struct ModAudio* audio = (struct ModAudio*)smlua_to_cobject(L, 1, LOT_MODAUDIO);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_set_speed"); return 0; }
f32 initial_freq = smlua_to_number(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "audio_stream_set_speed"); return 0; }
f32 speed = smlua_to_number(L, 3);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "audio_stream_set_speed"); return 0; }
bool pitch = smlua_to_boolean(L, 4);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "audio_stream_set_speed"); return 0; }
audio_stream_set_speed(audio, initial_freq, speed, pitch);
return 1;
}
int smlua_func_audio_stream_set_tempo(lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 2) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "audio_stream_set_tempo", 2, top);
return 0;
}
struct ModAudio* audio = (struct ModAudio*)smlua_to_cobject(L, 1, LOT_MODAUDIO);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_set_tempo"); return 0; }
f32 tempo = smlua_to_number(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "audio_stream_set_tempo"); return 0; }
audio_stream_set_tempo(audio, tempo);
return 1;
}
int smlua_func_djui_hud_set_render_behind_hud(lua_State* L) { int smlua_func_djui_hud_set_render_behind_hud(lua_State* L) {
if (L == NULL) { return 0; } if (L == NULL) { return 0; }
@ -32875,17 +32875,13 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "audio_stream_get_frequency", smlua_func_audio_stream_get_frequency); 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_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_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_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_load", smlua_func_audio_stream_load);
smlua_bind_function(L, "audio_stream_load_url", smlua_func_audio_stream_load_url);
smlua_bind_function(L, "audio_stream_pause", smlua_func_audio_stream_pause); 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_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_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_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_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_set_volume", smlua_func_audio_stream_set_volume);
smlua_bind_function(L, "audio_stream_stop", smlua_func_audio_stream_stop); 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_replace_sequence", smlua_func_smlua_audio_utils_replace_sequence);
@ -32900,6 +32896,10 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "smlua_collision_util_get", smlua_func_smlua_collision_util_get); smlua_bind_function(L, "smlua_collision_util_get", smlua_func_smlua_collision_util_get);
// smlua_deprecated.h // smlua_deprecated.h
smlua_bind_function(L, "audio_stream_get_tempo", smlua_func_audio_stream_get_tempo);
smlua_bind_function(L, "audio_stream_load_url", smlua_func_audio_stream_load_url);
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, "djui_hud_set_render_behind_hud", smlua_func_djui_hud_set_render_behind_hud); smlua_bind_function(L, "djui_hud_set_render_behind_hud", smlua_func_djui_hud_set_render_behind_hud);
smlua_bind_function(L, "network_discord_id_from_local_index", smlua_func_network_discord_id_from_local_index); smlua_bind_function(L, "network_discord_id_from_local_index", smlua_func_network_discord_id_from_local_index);

View file

@ -1,3 +1,9 @@
#define MINIAUDIO_IMPLEMENTATION // required by miniaudio
// enable Vorbis decoding (provides ogg audio decoding support) for miniaudio
#define STB_VORBIS_HEADER_ONLY
#include "pc/utils/stb_vorbis.c"
#include "types.h" #include "types.h"
#include "seq_ids.h" #include "seq_ids.h"
#include "audio/external.h" #include "audio/external.h"
@ -7,8 +13,9 @@
#include "pc/lua/smlua.h" #include "pc/lua/smlua.h"
#include "pc/lua/utils/smlua_audio_utils.h" #include "pc/lua/utils/smlua_audio_utils.h"
#include "pc/mods/mods_utils.h" #include "pc/mods/mods_utils.h"
#include "bass_audio/bass_audio_helpers.h" #include "pc/utils/misc.h"
#include "pc/debuglog.h" #include "pc/debuglog.h"
#include "audio/external.h"
struct AudioOverride { struct AudioOverride {
bool enabled; bool enabled;
@ -144,25 +151,30 @@ void smlua_audio_utils_replace_sequence(u8 sequenceId, u8 bankId, u8 defaultVolu
LOG_LUA_LINE("Could not find m64 at path: %s", m64path); LOG_LUA_LINE("Could not find m64 at path: %s", m64path);
} }
////////// ///////////////
// bass // // mod audio //
////////// ///////////////
#define MAX_BASS_FILES 256 // Optimization: disable spatialization for everything as it's not used
struct BassAudio sBassAudio[MAX_BASS_FILES]; #define MA_SOUND_STREAM_FLAGS (MA_SOUND_FLAG_NO_SPATIALIZATION | MA_SOUND_FLAG_STREAM)
u32 sBassAudioCount = 0; #define MA_SOUND_SAMPLE_FLAGS (MA_SOUND_FLAG_NO_SPATIALIZATION | MA_SOUND_FLAG_NO_PITCH | MA_SOUND_FLAG_DECODE) // No pitch, pre-decode audio samples
static struct BassAudio* find_bass_audio(struct ModFile* file) { struct DynamicPool *sModAudio;
for(u16 i = 0; i < sBassAudioCount; i++) { ma_engine gModAudioEngine;
struct BassAudio* audio = &sBassAudio[i];
if (audio->file != file) { continue; } static struct ModAudio* find_mod_audio(struct ModFile* file) {
return audio; struct DynamicPoolNode* node = sModAudio->tail;
while (node) {
struct DynamicPoolNode* prev = node->prev;
struct ModAudio* audio = node->ptr;
if (audio->file == file) { return audio; }
node = prev;
} }
return NULL; return NULL;
} }
static bool audio_sanity_check(struct BassAudio* audio, bool isStream, const char* action) { static bool audio_sanity_check(struct ModAudio* audio, bool isStream, const char* action) {
if (audio == NULL || !audio->loaded || audio->handle == 0) { if (audio == NULL) {
LOG_LUA_LINE("Tried to %s unloaded audio stream", action); LOG_LUA_LINE("Tried to %s unloaded audio stream", action);
return false; return false;
} }
@ -177,7 +189,7 @@ static bool audio_sanity_check(struct BassAudio* audio, bool isStream, const cha
return true; return true;
} }
struct BassAudio* audio_load_internal(const char* filename, bool isStream) { struct ModAudio* audio_load_internal(const char* filename, bool isStream) {
// check file type // check file type
bool validFileType = false; bool validFileType = false;
const char* fileTypes[] = { ".mp3", ".aiff", ".ogg", NULL }; const char* fileTypes[] = { ".mp3", ".aiff", ".ogg", NULL };
@ -211,11 +223,11 @@ struct BassAudio* audio_load_internal(const char* filename, bool isStream) {
return NULL; return NULL;
} }
// find stream in BassAudio list // find stream in ModAudio list
struct BassAudio* bassAudio = find_bass_audio(modFile); struct ModAudio* audio = find_mod_audio(modFile);
if (bassAudio && bassAudio->loaded) { if (audio) {
if (isStream == bassAudio->isStream) { if (isStream == audio->isStream) {
return bassAudio; return audio;
} else if (isStream) { } else if (isStream) {
LOG_LUA_LINE("Tried to load a stream, when a sample already exists for '%s'", filename); LOG_LUA_LINE("Tried to load a stream, when a sample already exists for '%s'", filename);
return NULL; return NULL;
@ -225,218 +237,264 @@ struct BassAudio* audio_load_internal(const char* filename, bool isStream) {
} }
} }
// allocate in BassAudio list // allocate in ModAudio pool
if (sBassAudioCount >= MAX_BASS_FILES) { if (audio == NULL) {
LOG_LUA_LINE("Ran out of available audio slots!"); audio = dynamic_pool_alloc(sModAudio, sizeof(struct ModAudio));
if (!audio) {
LOG_LUA_LINE("Could not allocate space for new mod audio!");
return NULL; return NULL;
} }
if (bassAudio == NULL) {
bassAudio = &sBassAudio[sBassAudioCount++];
} }
// remember file // remember file
bassAudio->file = modFile; audio->file = modFile;
// open file pointer // load audio
bool opened = false; ma_result result = ma_sound_init_from_file(
if (modFile->fp == NULL) { &gModAudioEngine, modFile->cachedPath,
modFile->fp = fopen(modFile->cachedPath, "rb"); isStream ? MA_SOUND_STREAM_FLAGS : MA_SOUND_SAMPLE_FLAGS,
if (modFile->fp == NULL) { NULL, NULL, &audio->sound
LOG_ERROR("Could not open mod file: %s", modFile->cachedPath); );
if (result != MA_SUCCESS) {
LOG_ERROR("failed to load audio file '%s': %d", filename, result);
return NULL; return NULL;
} }
opened = true;
audio->isStream = isStream;
return audio;
} }
// copy data struct ModAudio* audio_stream_load(const char* filename) {
rewind(modFile->fp);
bassAudio->rawData = (char*)malloc(modFile->size * sizeof(char));
fread(bassAudio->rawData, modFile->size, 1, modFile->fp);
// close file pointer
if (opened) {
fclose(modFile->fp);
modFile->fp = NULL;
}
// 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); return audio_load_internal(filename, true);
} }
struct BassAudio* audio_stream_load_url(const char* url) { void audio_stream_destroy(struct ModAudio* audio) {
if (url == NULL || strlen(url) == 0) {
LOG_LUA_LINE("Failed to load url");
return NULL;
}
HSTREAM stream = BASS_StreamCreateURL(url, 0, 0, NULL, NULL);
struct BassAudio* res = malloc(sizeof(struct BassAudio));
res->handle = stream;
res->rawData = NULL;
return res;
}
void audio_stream_destroy(struct BassAudio* audio) {
if (!audio_sanity_check(audio, true, "destroy")) { if (!audio_sanity_check(audio, true, "destroy")) {
return; return;
} }
bassh_free_stream(audio->handle); ma_sound_uninit(&audio->sound);
audio->handle = 0;
audio->loaded = false;
if (audio->rawData != NULL) {
free(audio->rawData);
}
audio->rawData = NULL;
} }
void audio_stream_play(struct BassAudio* audio, bool restart, f32 volume) { void audio_stream_play(struct ModAudio* audio, bool restart, f32 volume) {
if (!audio_sanity_check(audio, true, "play")) { if (!audio_sanity_check(audio, true, "play")) {
return; return;
} }
f32 masterVolume = (f32)configMasterVolume / 127.0f; f32 masterVolume = (f32)configMasterVolume / 127.0f;
f32 musicVolume = (f32)configMusicVolume / 127.0f; f32 musicVolume = (f32)configMusicVolume / 127.0f;
bassh_set_stream_volume(audio->handle, masterVolume * musicVolume * volume); ma_sound_set_volume(&audio->sound, masterVolume * musicVolume * volume);
bassh_play_stream(audio->handle, restart); if (restart || !ma_sound_is_playing(&audio->sound)) { ma_sound_seek_to_pcm_frame(&audio->sound, 0); }
ma_sound_start(&audio->sound);
} }
void audio_stream_pause(struct BassAudio* audio) { void audio_stream_pause(struct ModAudio* audio) {
if (!audio_sanity_check(audio, true, "pause")) { if (!audio_sanity_check(audio, true, "pause")) {
return; return;
} }
bassh_pause_stream(audio->handle); ma_sound_stop(&audio->sound);
} }
void audio_stream_stop(struct BassAudio* audio) { void audio_stream_stop(struct ModAudio* audio) {
if (!audio_sanity_check(audio, true, "stop")) { if (!audio_sanity_check(audio, true, "stop")) {
return; return;
} }
bassh_stop_stream(audio->handle); ma_sound_stop(&audio->sound);
ma_sound_seek_to_pcm_frame(&audio->sound, 0);
} }
f32 audio_stream_get_position(struct BassAudio* audio) { f32 audio_stream_get_position(struct ModAudio* audio) {
if (!audio_sanity_check(audio, true, "getpos")) { if (!audio_sanity_check(audio, true, "getpos")) {
return 0; return 0;
} }
return (f32)bassh_get_stream_pos(audio->handle); // ! This gets the time that the audio has been playing for, but is not reset when the stream loops
return (f32)ma_sound_get_time_in_milliseconds(&audio->sound) / 1000;
} }
void audio_stream_set_position(struct BassAudio* audio, f32 pos) { void audio_stream_set_position(struct ModAudio* audio, f32 pos) {
if (!audio_sanity_check(audio, true, "setpos")) { if (!audio_sanity_check(audio, true, "setpos")) {
return; return;
} }
bassh_set_stream_pos(audio->handle, (double)pos); u64 length;
ma_sound_get_length_in_pcm_frames(&audio->sound, &length);
ma_sound_seek_to_pcm_frame(&audio->sound, (u64)(length * pos));
} }
bool audio_stream_get_looping(struct BassAudio* audio) { bool audio_stream_get_looping(struct ModAudio* audio) {
if (!audio_sanity_check(audio, true, "getloop")) { if (!audio_sanity_check(audio, true, "getloop")) {
return false; return false;
} }
return bassh_get_looping(audio->handle); return ma_sound_is_looping(&audio->sound);
} }
void audio_stream_set_looping(struct BassAudio* audio, bool looping) { void audio_stream_set_looping(struct ModAudio* audio, bool looping) {
if (!audio_sanity_check(audio, true, "setloop")) { if (!audio_sanity_check(audio, true, "setloop")) {
return; return;
} }
bassh_set_looping(audio->handle, looping); ma_sound_set_looping(&audio->sound, looping);
} }
f32 audio_stream_get_frequency(struct BassAudio* audio) { f32 audio_stream_get_frequency(struct ModAudio* audio) {
if (!audio_sanity_check(audio, true, "getfreq")) { if (!audio_sanity_check(audio, true, "getfreq")) {
return 0; return 0;
} }
return bassh_get_frequency(audio->handle); return ma_sound_get_pitch(&audio->sound);
} }
void audio_stream_set_frequency(struct BassAudio* audio, f32 freq) { void audio_stream_set_frequency(struct ModAudio* audio, f32 freq) {
if (!audio_sanity_check(audio, true, "setfreq")) { if (!audio_sanity_check(audio, true, "setfreq")) {
return; return;
} }
bassh_set_frequency(audio->handle, freq); ma_sound_set_pitch(&audio->sound, freq);
} }
f32 audio_stream_get_tempo(struct BassAudio* audio) { // f32 audio_stream_get_tempo(struct ModAudio* audio) {
if (!audio_sanity_check(audio, true, "gettempo")) { // if (!audio_sanity_check(audio, true, "gettempo")) {
return 0; // return 0;
} // }
return bassh_get_tempo(audio->handle); // return bassh_get_tempo(audio->handle);
} // }
void audio_stream_set_tempo(struct BassAudio* audio, f32 tempo) { // void audio_stream_set_tempo(struct ModAudio* audio, f32 tempo) {
if (!audio_sanity_check(audio, true, "settempo")) { // if (!audio_sanity_check(audio, true, "settempo")) {
return; // return;
} // }
bassh_set_tempo(audio->handle, tempo); // bassh_set_tempo(audio->handle, tempo);
} // }
f32 audio_stream_get_volume(struct BassAudio* audio) { f32 audio_stream_get_volume(struct ModAudio* audio) {
if (!audio_sanity_check(audio, true, "getvol")) { if (!audio_sanity_check(audio, true, "getvol")) {
return 0; return 0;
} }
return bassh_get_stream_volume(audio->handle); return ma_sound_get_volume(&audio->sound);
} }
void audio_stream_set_volume(struct BassAudio* audio, f32 volume) { void audio_stream_set_volume(struct ModAudio* audio, f32 volume) {
if (!audio_sanity_check(audio, true, "setvol")) { if (!audio_sanity_check(audio, true, "setvol")) {
return; return;
} }
f32 masterVolume = (f32)configMasterVolume / 127.0f; f32 masterVolume = (f32)configMasterVolume / 127.0f;
f32 musicVolume = (f32)configMusicVolume / 127.0f; f32 musicVolume = (f32)configMusicVolume / 127.0f;
bassh_set_stream_volume(audio->handle, masterVolume * musicVolume * volume); ma_sound_set_volume(&audio->sound, masterVolume * musicVolume * volume);
} }
void audio_stream_set_speed(struct BassAudio* audio, f32 initial_freq, f32 speed, bool pitch) { // void audio_stream_set_speed(struct ModAudio* audio, f32 initial_freq, f32 speed, bool pitch) {
if (!audio_sanity_check(audio, true, "setspeed")) { // if (!audio_sanity_check(audio, true, "setspeed")) {
return; // return;
// }
// bassh_set_speed(audio->handle, initial_freq, speed, pitch);
// }
//////////////////////////////////////
// MA calls the end callback from it's audio thread
// Use mutexes to be sure we don't try to delete the same memory at the same time
#include <pthread.h>
static pthread_mutex_t sSampleCopyMutex = PTHREAD_MUTEX_INITIALIZER;
static struct ModAudioSampleCopies *sSampleCopiesPendingUninitTail = NULL;
// Called whenever a sample copy finishes playback (called from the miniaudio thread)
// removes the copy from it's linked list, and adds it to the pending list
static void audio_sample_copy_end_callback(void* userData, UNUSED ma_sound* sound) {
pthread_mutex_lock(&sSampleCopyMutex);
struct ModAudioSampleCopies *copy = userData;
if (copy->next) { copy->next->prev = copy->prev; }
if (copy->prev) { copy->prev->next = copy->next; }
if (!copy->next && !copy->prev) {
copy->parent->sampleCopiesTail = NULL; // Clear the pointer to this copy
} }
bassh_set_speed(audio->handle, initial_freq, speed, pitch); copy->next = NULL;
copy->prev = NULL;
// add copy to list
if (!sSampleCopiesPendingUninitTail) {
sSampleCopiesPendingUninitTail = copy;
} else {
copy->prev = sSampleCopiesPendingUninitTail;
sSampleCopiesPendingUninitTail->next = copy;
sSampleCopiesPendingUninitTail = copy;
}
pthread_mutex_unlock(&sSampleCopyMutex);
} }
struct BassAudio* audio_sample_load(const char* filename) { // Called every frame in the main thread from smlua_update()
// Frees all audio sample copies that are in the pending list
void audio_sample_destroy_pending_copies(void) {
if (sSampleCopiesPendingUninitTail) {
pthread_mutex_lock(&sSampleCopyMutex);
for (struct ModAudioSampleCopies *node = sSampleCopiesPendingUninitTail; node;) {
struct ModAudioSampleCopies *prev = node->prev;
ma_sound_uninit(&node->sound);
free(node);
node = prev;
}
sSampleCopiesPendingUninitTail = NULL;
pthread_mutex_unlock(&sSampleCopyMutex);
}
}
static void audio_sample_destroy_copies(struct ModAudio* audio) {
pthread_mutex_lock(&sSampleCopyMutex);
for (struct ModAudioSampleCopies* node = audio->sampleCopiesTail; node;) {
struct ModAudioSampleCopies* prev = node->prev;
ma_sound_uninit(&node->sound);
free(node);
node = prev;
}
audio->sampleCopiesTail = NULL;
pthread_mutex_unlock(&sSampleCopyMutex);
}
struct ModAudio* audio_sample_load(const char* filename) {
return audio_load_internal(filename, false); return audio_load_internal(filename, false);
} }
void audio_sample_destroy(struct BassAudio* audio) { void audio_sample_destroy(struct ModAudio* audio) {
if (!audio_sanity_check(audio, false, "destroy")) { if (!audio_sanity_check(audio, false, "destroy")) {
return; return;
} }
bassh_free_stream(audio->handle); if (audio->sampleCopiesTail) {
audio->handle = 0; audio_sample_destroy_copies(audio);
audio->loaded = false;
if (audio->rawData) {
free(audio->rawData);
} }
audio->rawData = NULL; ma_sound_uninit(&audio->sound);
} }
void audio_sample_stop(struct BassAudio* audio) { void audio_sample_stop(struct ModAudio* audio) {
if (!audio_sanity_check(audio, false, "stop")) { if (!audio_sanity_check(audio, false, "stop")) {
return; return;
} }
bassh_stop_sample(audio->handle); if (audio->sampleCopiesTail) {
audio_sample_destroy_copies(audio);
}
ma_sound_stop(&audio->sound);
ma_sound_seek_to_pcm_frame(&audio->sound, 0);
} }
void audio_sample_play(struct BassAudio* audio, Vec3f position, f32 volume) { void audio_sample_play(struct ModAudio* audio, Vec3f position, f32 volume) {
if (!audio_sanity_check(audio, false, "play")) { if (!audio_sanity_check(audio, false, "play")) {
return; return;
} }
HSTREAM stream = bassh_sample_get_stream(audio->handle);
ma_sound *sound = &audio->sound;
if (ma_sound_is_playing(sound)) {
struct ModAudioSampleCopies* copy = calloc(1, sizeof(struct ModAudioSampleCopies));
ma_sound_init_copy(&gModAudioEngine, sound, MA_SOUND_SAMPLE_FLAGS, NULL, &copy->sound);
copy->parent = audio;
if (!audio->sampleCopiesTail) {
audio->sampleCopiesTail = copy;
} else {
copy->prev = audio->sampleCopiesTail;
audio->sampleCopiesTail->next = copy;
audio->sampleCopiesTail = copy;
}
sound = &copy->sound;
ma_sound_set_end_callback(sound, audio_sample_copy_end_callback, copy);
}
f32 dist = 0; f32 dist = 0;
f32 pan = 0; f32 pan = 0.5f;
if (gCamera) { if (gCamera) {
f32 dX = position[0] - gCamera->pos[0]; f32 dX = position[0] - gCamera->pos[0];
f32 dY = position[1] - gCamera->pos[1]; f32 dY = position[1] - gCamera->pos[1];
@ -453,21 +511,39 @@ void audio_sample_play(struct BassAudio* audio, Vec3f position, f32 volume) {
f32 intensity = sound_get_level_intensity(dist); f32 intensity = sound_get_level_intensity(dist);
f32 masterVolume = (f32)configMasterVolume / 127.0f; f32 masterVolume = (f32)configMasterVolume / 127.0f;
f32 sfxVolume = (f32)configSfxVolume / 127.0f; f32 sfxVolume = (f32)configSfxVolume / 127.0f;
BASS_ChannelSetAttribute(stream, BASS_ATTRIB_VOL, masterVolume * sfxVolume * volume * intensity); ma_sound_set_volume(sound, masterVolume * sfxVolume * volume * intensity);
BASS_ChannelSetAttribute(stream, BASS_ATTRIB_PAN, pan); ma_sound_set_pan(sound, pan);
bassh_play_stream(stream, true); ma_sound_start(sound);
} }
void audio_custom_shutdown(void) { void audio_custom_shutdown(void) {
for(u16 i = 0; i < sBassAudioCount; i++) { if (!sModAudio) { return; }
struct BassAudio* audio = &sBassAudio[i]; struct DynamicPoolNode* node = sModAudio->tail;
if (!audio->loaded) { continue; } while (node) {
struct DynamicPoolNode* prev = node->prev;
struct ModAudio* audio = node->ptr;
if (audio->isStream) { if (audio->isStream) {
audio_stream_destroy(audio); audio_stream_destroy(audio);
} else { } else {
audio_sample_destroy(audio); audio_sample_destroy(audio);
} }
node = prev;
} }
sBassAudioCount = 0; dynamic_pool_free_pool(sModAudio);
}
void smlua_audio_custom_init(void) {
sModAudio = dynamic_pool_init();
ma_result result = ma_engine_init(NULL, &gModAudioEngine);
if (result != MA_SUCCESS) {
LOG_ERROR("failed to init miniaudio: %d", result);
}
}
void smlua_audio_custom_deinit(void) {
audio_custom_shutdown();
free(sModAudio);
ma_engine_uninit(&gModAudioEngine);
} }

View file

@ -1,47 +1,53 @@
#ifndef SMLUA_AUDIO_UTILS_H #ifndef SMLUA_AUDIO_UTILS_H
#define SMLUA_AUDIO_UTILS_H #define SMLUA_AUDIO_UTILS_H
#define MAX_AUDIO_OVERRIDE 128 #include "pc/utils/miniaudio.h"
void smlua_audio_utils_reset_all(void); void smlua_audio_utils_reset_all(void);
bool smlua_audio_utils_override(u8 sequenceId, s32* bankId, void** seqData); 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); void smlua_audio_utils_replace_sequence(u8 sequenceId, u8 bankId, u8 defaultVolume, const char* m64Name);
////////// ////////////////
// bass // // mod sounds //
////////// ////////////////
struct BassAudio { struct ModAudioSampleCopies {
struct ModFile* file; ma_sound sound;
char* rawData; struct ModAudioSampleCopies *next;
bool isStream; struct ModAudioSampleCopies *prev;
bool loaded; struct ModAudio *parent;
u32 handle;
}; };
struct BassAudio* audio_stream_load(const char* filename); struct ModAudio {
struct BassAudio* audio_stream_load_url(const char* url); struct ModFile* file;
void audio_stream_destroy(struct BassAudio* audio); ma_sound sound;
void audio_stream_play(struct BassAudio* audio, bool restart, f32 volume); struct ModAudioSampleCopies* sampleCopiesTail;
void audio_stream_pause(struct BassAudio* audio); bool isStream;
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); struct ModAudio* audio_stream_load(const char* filename);
void audio_sample_destroy(struct BassAudio* audio); void audio_stream_destroy(struct ModAudio* audio);
void audio_sample_stop(struct BassAudio* audio); void audio_stream_play(struct ModAudio* audio, bool restart, f32 volume);
void audio_sample_play(struct BassAudio* audio, Vec3f position, f32 volume); void audio_stream_pause(struct ModAudio* audio);
void audio_stream_stop(struct ModAudio* audio);
f32 audio_stream_get_position(struct ModAudio* audio);
void audio_stream_set_position(struct ModAudio* audio, f32 pos);
bool audio_stream_get_looping(struct ModAudio* audio);
void audio_stream_set_looping(struct ModAudio* audio, bool looping);
f32 audio_stream_get_frequency(struct ModAudio* audio);
void audio_stream_set_frequency(struct ModAudio* audio, f32 freq);
f32 audio_stream_get_volume(struct ModAudio* audio);
void audio_stream_set_volume(struct ModAudio* audio, f32 volume);
void audio_sample_destroy_pending_copies(void);
struct ModAudio* audio_sample_load(const char* filename);
void audio_sample_destroy(struct ModAudio* audio);
void audio_sample_stop(struct ModAudio* audio);
void audio_sample_play(struct ModAudio* audio, Vec3f position, f32 volume);
void audio_custom_shutdown(void); void audio_custom_shutdown(void);
void smlua_audio_custom_init(void);
void smlua_audio_custom_deinit(void);
#endif #endif

View file

@ -20,3 +20,17 @@ void djui_hud_set_render_behind_hud(bool enable) {
if (!gLuaActiveMod) { return; } if (!gLuaActiveMod) { return; }
gLuaActiveMod->renderBehindHud = enable; gLuaActiveMod->renderBehindHud = enable;
} }
struct ModAudio* audio_stream_load_url(UNUSED const char* url) {
return NULL;
}
f32 audio_stream_get_tempo(UNUSED struct ModAudio* audio) {
return 1;
}
void audio_stream_set_tempo(UNUSED struct ModAudio* audio, UNUSED f32 tempo) {
}
void audio_stream_set_speed(UNUSED struct ModAudio* audio, UNUSED f32 initial_freq, UNUSED f32 speed, UNUSED bool pitch) {
}

View file

@ -3,3 +3,7 @@
char* network_discord_id_from_local_index(u8 localIndex); char* network_discord_id_from_local_index(u8 localIndex);
void djui_hud_set_render_behind_hud(bool enable); void djui_hud_set_render_behind_hud(bool enable);
struct ModAudio* audio_stream_load_url(const char* url);
f32 audio_stream_get_tempo(struct ModAudio* audio);
void audio_stream_set_tempo(struct ModAudio* audio, f32 tempo);
void audio_stream_set_speed(struct ModAudio* audio, f32 initial_freq, f32 speed, bool pitch);

View file

@ -33,9 +33,6 @@
#include "game/main.h" #include "game/main.h"
#include "game/rumble_init.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" #include "pc/lua/utils/smlua_audio_utils.h"
#include "pc/network/version.h" #include "pc/network/version.h"
@ -297,6 +294,7 @@ void game_deinit(void) {
gfx_shutdown(); gfx_shutdown();
network_shutdown(true, true, false, false); network_shutdown(true, true, false, false);
smlua_shutdown(); smlua_shutdown();
smlua_audio_custom_deinit();
mods_shutdown(); mods_shutdown();
djui_shutdown(); djui_shutdown();
gGameInited = false; gGameInited = false;
@ -359,7 +357,7 @@ void* main_game_init(void* isThreaded) {
audio_init(); audio_init();
sound_init(); sound_init();
bassh_init(); smlua_audio_custom_init();
network_player_init(); network_player_init();
gGameInited = true; gGameInited = true;
@ -455,6 +453,5 @@ int main(int argc, char *argv[]) {
CTX_END(CTX_FRAME); CTX_END(CTX_FRAME);
} }
bassh_deinit();
return 0; return 0;
} }

92621
src/pc/utils/miniaudio.h Normal file

File diff suppressed because it is too large Load diff

5584
src/pc/utils/stb_vorbis.c Normal file

File diff suppressed because it is too large Load diff