Skip to content

Commit

Permalink
Merge pull request #230 from sylverb/master
Browse files Browse the repository at this point in the history
Fix for issue where silenced channel will continue to play previous content
  • Loading branch information
jtothebell authored Jan 28, 2024
2 parents d52e9ba + ec7a32f commit 723cfa9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions source/Audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ void Audio::set_music_pattern(int pattern) {
bool foundNonLooping = false;
// Find music speed; it’s the speed of the fastest sfx
// While we are looping through this, find the lowest *valid* sfx length
_audioState._musicChannel.master = _audioState._musicChannel.speed = -1;
_audioState._musicChannel.master = -1;
_audioState._musicChannel.speed = 0;
_audioState._musicChannel.length = 32; //as far as i can tell, there is no way to make an sfx longer than 32.
for (int i = 0; i < 4; ++i)
{
Expand Down Expand Up @@ -214,8 +215,11 @@ void Audio::set_music_pattern(int pattern) {
continue;

uint8_t n = channels[i];
if (n & 0x40)
if (n & 0x40) {
// Make sure this channel will be silent
_audioState._sfxChannels[i].sfxId = -1;
continue;
}

_audioState._sfxChannels[i].sfxId = n;
_audioState._sfxChannels[i].offset = 0.f;
Expand Down

0 comments on commit 723cfa9

Please sign in to comment.