Skip to content

Commit

Permalink
fix(zc): set volume correctly when music changes with only fading in …
Browse files Browse the repository at this point in the history
…or out

For example, if the new music has a fade in frame duration of 0, and the
old music has a fade out frame duration of >0, then the new music would
incorrectly have its volume stuck at 0%.
  • Loading branch information
connorjclark committed Dec 2, 2023
1 parent 9ee5c4b commit 9274a67
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/music_playback.cpp
Expand Up @@ -93,10 +93,6 @@ bool play_enh_music_crossfade(char* name, char* path, int32_t track, int32_t vol
// If new music was found
if (ret)
{
// New music fades in
if (zcmusic != NULL)
zcmusic->fadevolume = 0;

zcmixer->newtrack = zcmusic;
zcmixer->fadeinframes = fadeinframes;
zcmixer->fadeinmaxframes = fadeinframes;
Expand All @@ -115,9 +111,9 @@ bool play_enh_music_crossfade(char* name, char* path, int32_t track, int32_t vol
if (startpos > 0)
zcmusic_set_curpos(zcmixer->newtrack, startpos);
if (zcmixer->oldtrack != NULL)
zcmixer->oldtrack->fadevolume = 10000;
zcmixer->oldtrack->fadevolume = fadeoutframes > 0 ? 10000 : 0;
if (zcmixer->newtrack != NULL)
zcmixer->newtrack->fadevolume = 0;
zcmixer->newtrack->fadevolume = fadeinframes > 0 ? 0 : 10000;
}
else if (revertonfail)
{
Expand Down

0 comments on commit 9274a67

Please sign in to comment.