Implemented audio sliders

This commit is contained in:
KiritoDv
2024-11-30 22:46:29 -06:00
parent 5e2c338fc7
commit 1bcfb17f8b
7 changed files with 74 additions and 56 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ void sequence_channel_process_sound(struct SequenceChannel* seqChannel, s32 reca
s32 i;
if (seqChannel->changes.as_bitfields.volume || recalculateVolume) {
channelVolume = seqChannel->volume * seqChannel->volumeScale * seqChannel->seqPlayer->appliedFadeVolume;
channelVolume = (seqChannel->volume * (seqChannel->volumeScale * seqChannel->seqPlayer->fadeVolume)) * seqChannel->seqPlayer->gameVolume;
if (seqChannel->seqPlayer->muted && (seqChannel->muteBehavior & MUTE_BEHAVIOR_SOFTEN) != 0) {
channelVolume = seqChannel->seqPlayer->muteVolumeScale * channelVolume;
}
+5
View File
@@ -3547,6 +3547,11 @@ void func_800CB14C() {
}
}
void audio_set_player_volume(u8 player, f32 volume) {
gSequencePlayers[player].gameVolume = volume;
gSequencePlayers[player].recalculateVolume = 1;
}
// run audio?
void func_800CB2C4() {
func_800C1F8C();
+2
View File
@@ -322,6 +322,8 @@ void func_800CB14C(void);
void func_800CB2C4(void);
void func_800CBC24(void);
extern void audio_set_player_volume(u8 player, f32 volume);
// This is some from other file, its definitely not part of audio's data/bss
extern s8 D_801657E5;
+1
View File
@@ -228,6 +228,7 @@ struct SequencePlayer {
/*0x130, 0x13C*/ u8* bankDmaCurrMemAddr;
/*0x138, 0x140*/ uintptr_t bankDmaCurrDevAddr;
/*0x13C, 0x144*/ size_t bankDmaRemaining;
f32 gameVolume;
}; // size = 0x140, 0x148 on EU, 0x14C on SH
struct AdsrSettings {
+6
View File
@@ -5,6 +5,7 @@
#include "audio/data.h"
#include "audio/heap.h"
#include "audio/internal.h"
#include "audio/external.h"
#include "audio/playback.h"
#include "audio/synthesis.h"
#include "audio/seqplayer.h"
@@ -803,6 +804,11 @@ void audio_init(void) {
sound_alloc_pool_init(&gUnkPool1.pool, soundAlloc(&gAudioInitPool, (u32) D_800EA5D8), (u32) D_800EA5D8);
init_sequence_players();
gAudioLoadLock = 0x76557364;
audio_set_player_volume(SEQ_PLAYER_LEVEL, CVarGetFloat("gMainMusicVolume", 1.0f));
audio_set_player_volume(SEQ_PLAYER_ENV, CVarGetFloat("gEnvironmentVolume", 1.0f));
audio_set_player_volume(SEQ_PLAYER_SFX, CVarGetFloat("gSFXMusicVolume", 1.0f));
}
#else
#ifdef VERSION_EU
+4
View File
@@ -71,6 +71,10 @@ void note_set_vel_pan_reverb(struct Note* note, f32 velocity, u8 pan, u8 reverbV
velocity = 1.0f;
}
float master_vol = CVarGetFloat("gGameMasterVolume", 1.0f);
volLeft *= master_vol;
volRight *= master_vol;
sub->targetVolLeft = ((s32) (velocity * volLeft * 4095.999f));
sub->targetVolRight = ((s32) (velocity * volRight * 4095.999f));