Change Lua volume control to 0-127 instead of 0.0-1.0
This commit is contained in:
parent
a638c4725c
commit
8bae9e2ec7
|
@ -281,8 +281,8 @@ void audio_stream_play(struct ModAudio* audio, bool restart, f32 volume) {
|
|||
if (!audio_sanity_check(audio, true, "play")) {
|
||||
return;
|
||||
}
|
||||
f32 masterVolume = (f32)configMasterVolume / 127.0f * gLuaVolumeMaster;
|
||||
f32 musicVolume = (f32)configMusicVolume / 127.0f * gLuaVolumeLevel;
|
||||
f32 masterVolume = (f32)configMasterVolume / 127.0f * (f32)gLuaVolumeMaster / 127.0f;
|
||||
f32 musicVolume = (f32)configMusicVolume / 127.0f * (f32)gLuaVolumeLevel / 127.0f;
|
||||
ma_sound_set_volume(&audio->sound, masterVolume * musicVolume * volume);
|
||||
audio->baseVolume = volume;
|
||||
if (restart || !ma_sound_is_playing(&audio->sound)) { ma_sound_seek_to_pcm_frame(&audio->sound, 0); }
|
||||
|
@ -511,8 +511,8 @@ void audio_sample_play(struct ModAudio* audio, Vec3f position, f32 volume) {
|
|||
}
|
||||
|
||||
f32 intensity = sound_get_level_intensity(dist);
|
||||
f32 masterVolume = (f32)configMasterVolume / 127.0f * gLuaVolumeMaster;
|
||||
f32 sfxVolume = (f32)configSfxVolume / 127.0f * gLuaVolumeSfx;
|
||||
f32 masterVolume = (f32)configMasterVolume / 127.0f * (f32)gLuaVolumeMaster / 127.0f;
|
||||
f32 sfxVolume = (f32)configSfxVolume / 127.0f * (f32)gLuaVolumeSfx / 127.0f;
|
||||
ma_sound_set_volume(sound, masterVolume * sfxVolume * volume * intensity);
|
||||
ma_sound_set_pan(sound, pan);
|
||||
audio->baseVolume = volume;
|
||||
|
@ -525,8 +525,8 @@ void audio_custom_update_volume(void) {
|
|||
while (node) {
|
||||
struct DynamicPoolNode* prev = node->prev;
|
||||
struct ModAudio* audio = node->ptr;
|
||||
f32 masterVolume = (f32)configMasterVolume / 127.0f;
|
||||
f32 musicVolume = (f32)configMusicVolume / 127.0f;
|
||||
f32 masterVolume = (f32)configMasterVolume / 127.0f * (f32)gLuaVolumeMaster / 127.0f;
|
||||
f32 musicVolume = (f32)configMusicVolume / 127.0f * (f32)gLuaVolumeLevel / 127.0f;
|
||||
if (audio->isStream) {
|
||||
ma_sound_set_volume(&audio->sound, masterVolume * musicVolume * audio->baseVolume);
|
||||
}
|
||||
|
|
|
@ -674,22 +674,22 @@ f32 get_volume_env(void) {
|
|||
}
|
||||
|
||||
void set_volume_master(f32 volume) {
|
||||
gLuaVolumeMaster = clampf(volume, 0.0f, 1.0f);
|
||||
gLuaVolumeMaster = MIN(volume, 127);
|
||||
audio_custom_update_volume();
|
||||
}
|
||||
|
||||
void set_volume_level(f32 volume) {
|
||||
gLuaVolumeLevel = clampf(volume, 0.0f, 1.0f);
|
||||
gLuaVolumeLevel = MIN(volume, 127);
|
||||
audio_custom_update_volume();
|
||||
}
|
||||
|
||||
void set_volume_sfx(f32 volume) {
|
||||
gLuaVolumeSfx = clampf(volume, 0.0f, 1.0f);
|
||||
gLuaVolumeSfx = MIN(volume, 127);
|
||||
audio_custom_update_volume();
|
||||
}
|
||||
|
||||
void set_volume_env(f32 volume) {
|
||||
gLuaVolumeEnv = clampf(volume, 0.0f, 1.0f);
|
||||
gLuaVolumeEnv = MIN(volume, 127);
|
||||
audio_custom_update_volume();
|
||||
}
|
||||
|
||||
|
|
|
@ -700,10 +700,10 @@ void network_shutdown(bool sendLeaving, bool exiting, bool popup, bool reconnect
|
|||
gOverrideDialogColor = 0;
|
||||
gDialogMinWidth = 0;
|
||||
gOverrideAllowToxicGasCamera = FALSE;
|
||||
gLuaVolumeMaster = 1.0f;
|
||||
gLuaVolumeLevel = 1.0f;
|
||||
gLuaVolumeSfx = 1.0f;
|
||||
gLuaVolumeEnv = 1.0f;
|
||||
gLuaVolumeMaster = 127;
|
||||
gLuaVolumeLevel = 127;
|
||||
gLuaVolumeSfx = 127;
|
||||
gLuaVolumeEnv = 127;
|
||||
|
||||
struct Controller* cnt = gPlayer1Controller;
|
||||
cnt->rawStickX = 0;
|
||||
|
|
|
@ -88,10 +88,10 @@ static f64 sFrameTimeStart;
|
|||
bool gGameInited = false;
|
||||
bool gGfxInited = false;
|
||||
|
||||
f32 gLuaVolumeMaster = 1.0f;
|
||||
f32 gLuaVolumeLevel = 1.0f;
|
||||
f32 gLuaVolumeSfx = 1.0f;
|
||||
f32 gLuaVolumeEnv = 1.0f;
|
||||
u8 gLuaVolumeMaster = 127;
|
||||
u8 gLuaVolumeLevel = 127;
|
||||
u8 gLuaVolumeSfx = 127;
|
||||
u8 gLuaVolumeEnv = 127;
|
||||
|
||||
static struct AudioAPI *audio_api;
|
||||
struct GfxWindowManagerAPI *wm_api = &WAPI;
|
||||
|
@ -222,10 +222,10 @@ void produce_interpolation_frames_and_delay(void) {
|
|||
}
|
||||
|
||||
inline static void buffer_audio(void) {
|
||||
const f32 masterMod = (f32)configMasterVolume / 127.0f * gLuaVolumeMaster;
|
||||
set_sequence_player_volume(SEQ_PLAYER_LEVEL, (f32)configMusicVolume / 127.0f * gLuaVolumeLevel * masterMod);
|
||||
set_sequence_player_volume(SEQ_PLAYER_SFX, (f32)configSfxVolume / 127.0f * gLuaVolumeSfx * masterMod);
|
||||
set_sequence_player_volume(SEQ_PLAYER_ENV, (f32)configEnvVolume / 127.0f * gLuaVolumeEnv * masterMod);
|
||||
const f32 masterMod = (f32)configMasterVolume / 127.0f * (f32)gLuaVolumeMaster / 127.0f;
|
||||
set_sequence_player_volume(SEQ_PLAYER_LEVEL, (f32)configMusicVolume / 127.0f * (f32)gLuaVolumeLevel / 127.0f * masterMod);
|
||||
set_sequence_player_volume(SEQ_PLAYER_SFX, (f32)configSfxVolume / 127.0f * (f32)gLuaVolumeSfx / 127.0f * masterMod);
|
||||
set_sequence_player_volume(SEQ_PLAYER_ENV, (f32)configEnvVolume / 127.0f * (f32)gLuaVolumeEnv / 127.0f * masterMod);
|
||||
|
||||
int samplesLeft = audio_api->buffered();
|
||||
u32 numAudioSamples = samplesLeft < audio_api->get_desired_buffered() ? SAMPLES_HIGH : SAMPLES_LOW;
|
||||
|
|
|
@ -64,10 +64,10 @@ extern "C" {
|
|||
extern bool gGameInited;
|
||||
extern bool gGfxInited;
|
||||
|
||||
extern f32 gLuaVolumeMaster;
|
||||
extern f32 gLuaVolumeLevel;
|
||||
extern f32 gLuaVolumeSfx;
|
||||
extern f32 gLuaVolumeEnv;
|
||||
extern u8 gLuaVolumeMaster;
|
||||
extern u8 gLuaVolumeLevel;
|
||||
extern u8 gLuaVolumeSfx;
|
||||
extern u8 gLuaVolumeEnv;
|
||||
|
||||
extern struct GfxWindowManagerAPI* wm_api;
|
||||
void produce_one_dummy_frame(void (*callback)());
|
||||
|
|
Loading…
Reference in New Issue