Deprecate sBackgroundMusicDefaultVolume

This commit is contained in:
gheskett
2022-02-24 02:07:39 -05:00
parent 25951363b7
commit fe8384a440
3 changed files with 24 additions and 8 deletions

View File

@@ -259,7 +259,12 @@ u16 sLevelAcousticReaches[LEVEL_COUNT] = {
#define VOLUME_RANGE_UNK2 0.8f
#endif
// Default volume for background music sequences (playing on player 0).
// sBackgroundMusicDefaultVolume represents the default volume for background music sequences using the level player (deprecated).
// This code block is simply commented out for now as to not destroy compatibility with any streamed audio tools.
// TODO: Delete this entirely once the unsupporting streamed tools or their builds are outdated.
/*
u8 sBackgroundMusicDefaultVolume[] = {
127, // SEQ_SOUND_PLAYER
80, // SEQ_EVENT_CUTSCENE_COLLECT_STAR
@@ -301,6 +306,8 @@ u8 sBackgroundMusicDefaultVolume[] = {
STATIC_ASSERT(ARRAY_COUNT(sBackgroundMusicDefaultVolume) == SEQ_COUNT,
"change this array if you are adding sequences");
*/
u8 sCurrentBackgroundMusicSeqId = SEQUENCE_NONE;
u8 sMusicDynamicDelay = 0;
u8 sSoundBankUsedListBack[SOUND_BANK_COUNT] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
@@ -1885,7 +1892,7 @@ static u8 begin_background_music_fade(u16 fadeDuration) {
targetVolume = 40;
}
if (sSoundBanksThatLowerBackgroundMusic != 0 && targetVolume > 20) {
if (sSoundBanksThatLowerBackgroundMusic && targetVolume > 20) {
targetVolume = 20;
}
@@ -1894,8 +1901,7 @@ static u8 begin_background_music_fade(u16 fadeDuration) {
seq_player_fade_to_target_volume(SEQ_PLAYER_LEVEL, fadeDuration, targetVolume);
} else {
#if defined(VERSION_JP) || defined(VERSION_US)
gSequencePlayers[SEQ_PLAYER_LEVEL].volume =
sBackgroundMusicDefaultVolume[sCurrentBackgroundMusicSeqId] / 127.0f;
gSequencePlayers[SEQ_PLAYER_LEVEL].volume = gSequencePlayers[SEQ_PLAYER_LEVEL].volumeDefault;
#endif
seq_player_fade_to_normal_volume(SEQ_PLAYER_LEVEL, fadeDuration);
}

View File

@@ -300,7 +300,7 @@ struct SequencePlayer {
/* , 0x028, 0x02C*/ f32 fadeVolumeScale;
/* , 0x02C*/ f32 appliedFadeVolume;
#else
/* */ u8 pad2[4];
/*0x028, */ f32 volumeDefault;
#endif
/*0x02C, 0x030, 0x034*/ struct SequenceChannel *channels[CHANNELS_MAX];
/*0x06C, 0x070*/ struct M64ScriptState scriptState;

View File

@@ -2493,6 +2493,10 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) {
#else
case 0xdb: // seq_setvol
cmd = m64_read_u8(state);
seqPlayer->volumeDefault = FLOAT_CAST(cmd) / 127.0f;
if (seqPlayer->volumeDefault >= 1.0f)
seqPlayer->volumeDefault = 1.0f;
switch (seqPlayer->state) {
case SEQUENCE_PLAYER_STATE_2:
if (seqPlayer->fadeRemainingFrames != 0) {
@@ -2513,9 +2517,14 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) {
break;
case 0xda: // seq_changevol
temp = m64_read_u8(state);
seqPlayer->fadeVolume =
seqPlayer->fadeVolume + (f32)(s8) temp / 127.0f;
temp = (f32)(s8) m64_read_u8(state) / 127.0f;
seqPlayer->fadeVolume += temp;
seqPlayer->volumeDefault += temp;
if (seqPlayer->volumeDefault > 1.0f)
seqPlayer->volumeDefault = 1.0f;
else if (seqPlayer->volumeDefault < 0.0f)
seqPlayer->volumeDefault = 0.0f;
break;
#endif
@@ -2707,6 +2716,7 @@ void init_sequence_player(u32 player) {
seqPlayer->state = 1;
#else
seqPlayer->state = SEQUENCE_PLAYER_STATE_0;
seqPlayer->volumeDefault = 1.0f;
#endif
seqPlayer->fadeRemainingFrames = 0;
#if defined(VERSION_EU) || defined(VERSION_SH)