Skip to content

Commit

Permalink
BLADERUNNER: Fix missing sound effects in some occassions
Browse files Browse the repository at this point in the history
LABBUZZ sound for the maze and Animoid sounds

Moved lab buzz in next scene's (PS10) init, and increased size of track buffer to compensate for frequently dropping sounds in places with mayne sound effects (eg Animoid Row, Izo's door and trapdoor)
  • Loading branch information
antoniou79 committed Mar 27, 2019
1 parent 5795e25 commit bb719ba
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 7 deletions.
3 changes: 3 additions & 0 deletions engines/bladerunner/audio_mixer.cpp
Expand Up @@ -28,6 +28,7 @@
#include "audio/mixer.h"

#include "common/timer.h"
//#include "common/debug.h"

namespace BladeRunner {

Expand Down Expand Up @@ -64,8 +65,10 @@ int AudioMixer::play(Audio::Mixer::SoundType type, Audio::RewindableAudioStream
}
if (channel == -1) {
if (priority < lowestPriority) {
//debug("No available audio channel found - giving up");
return -1;
}
//debug("Stopping lowest priority channel %d with lower prio %d!", lowestPriorityChannel, lowestPriority);
stop(lowestPriorityChannel, 0);
channel = lowestPriorityChannel;
}
Expand Down
6 changes: 3 additions & 3 deletions engines/bladerunner/audio_mixer.h
Expand Up @@ -33,9 +33,9 @@ namespace BladeRunner {
class BladeRunnerEngine;

class AudioMixer {
static const int kChannels = 9;
static const int kUsableChannels = 8;
static const int kMusicChannel = 8;
static const int kChannels = 15; // original was 9;
static const int kUsableChannels = 14; // original was 8;
static const int kMusicChannel = 14; // original was 8;
static const int kUpdatesPerSecond = 40;

struct Channel {
Expand Down
10 changes: 8 additions & 2 deletions engines/bladerunner/audio_player.cpp
Expand Up @@ -41,7 +41,7 @@ namespace BladeRunner {
AudioPlayer::AudioPlayer(BladeRunnerEngine *vm) {
_vm = vm;

for (int i = 0; i != 6; ++i) {
for (int i = 0; i != kTracks; ++i) {
_tracks[i].priority = 0;
_tracks[i].isActive = false;
_tracks[i].channel = -1;
Expand Down Expand Up @@ -138,8 +138,9 @@ int AudioPlayer::playAud(const Common::String &name, int volume, int panFrom, in
int lowestPriority = 1000000;
int lowestPriorityTrack = -1;

for (int i = 0; i != 6; ++i) {
for (int i = 0; i != kTracks; ++i) {
if (!isActive(i)) {
//debug ("Assigned track %i to %s", i, name.c_str());
track = i;
break;
}
Expand All @@ -154,12 +155,14 @@ int AudioPlayer::playAud(const Common::String &name, int volume, int panFrom, in
* the new priority
*/
if (track == -1 && lowestPriority < priority) {
//debug ("Stop lowest priority track (with lower prio: %d %d), for %s %d!", lowestPriorityTrack, lowestPriority, name.c_str(), priority);
stop(lowestPriorityTrack, true);
track = lowestPriorityTrack;
}

/* If there's still no available track, give up */
if (track == -1) {
//debug ("No available track for %s %d - giving up", name.c_str(), priority);
return -1;
}

Expand All @@ -168,13 +171,15 @@ int AudioPlayer::playAud(const Common::String &name, int volume, int panFrom, in
if (!_vm->_audioCache->findByHash(hash)) {
Common::SeekableReadStream *r = _vm->getResourceStream(name);
if (!r) {
//debug ("Could not get stream for %s %d - giving up", name.c_str(), priority);
return -1;
}

int32 size = r->size();
while (!_vm->_audioCache->canAllocate(size)) {
if (!_vm->_audioCache->dropOldest()) {
delete r;
//debug ("No available mem in cache for %s %d - giving up", name.c_str(), priority);
return -1;
}
}
Expand All @@ -201,6 +206,7 @@ int AudioPlayer::playAud(const Common::String &name, int volume, int panFrom, in

if (channel == -1) {
delete audioStream;
//debug ("No available channel for %s %d - giving up", name.c_str(), priority);
return -1;
}

Expand Down
2 changes: 1 addition & 1 deletion engines/bladerunner/audio_player.h
Expand Up @@ -41,7 +41,7 @@ enum AudioPlayerFlags {
};

class AudioPlayer {
static const int kTracks = 6;
static const int kTracks = 12; // original was 6

struct Track {
bool isActive;
Expand Down
5 changes: 5 additions & 0 deletions engines/bladerunner/script/scene/ps10.cpp
Expand Up @@ -416,6 +416,11 @@ void SceneScriptPS10::InitializeScene() {
Ambient_Sounds_Add_Sound(306, 5, 100, 17, 27, -100, 100, -101, -101, 0, 0);
Ambient_Sounds_Add_Sound(307, 5, 100, 17, 27, -100, 100, -101, -101, 0, 0);
Ambient_Sounds_Add_Sound(308, 5, 100, 17, 27, -100, 100, -101, -101, 0, 0);
#if BLADERUNNER_ORIGINAL_BUGS
#else
// Moved here from PS15
Sound_Play(155, 90, 0, 0, 50); // LABBUZZ1.AUD
#endif // BLADERUNNER_ORIGINAL_BUGS
}

void SceneScriptPS10::SceneLoaded() {
Expand Down
7 changes: 6 additions & 1 deletion engines/bladerunner/script/scene/ps15.cpp
Expand Up @@ -123,7 +123,12 @@ bool SceneScriptPS15::ClickedOnExit(int exitId) {
if (!Loop_Actor_Walk_To_XYZ(kActorMcCoy, -183.58f, -113.43f, 91.7f, 0, true, false, 0)) {
Actor_Says(kActorMcCoy, 4440, 18);
Actor_Says(kActorSergeantWalls, 150, 17);
Sound_Play(155, 90, 0, 0, 50);
#if BLADERUNNER_ORIGINAL_BUGS
// Sometimes the scene transition code (or the Ambient_Sounds_Remove_All_Non_Looping_Sounds)
// would stop this from playing (rare occasions)
// Solution: moved into PS10 code
Sound_Play(155, 90, 0, 0, 50); // LABBUZZ1.AUD
#endif // BLADERUNNER_ORIGINAL_BUGS
Ambient_Sounds_Remove_All_Non_Looping_Sounds(true);
Ambient_Sounds_Remove_All_Looping_Sounds(1);
Set_Enter(kSetPS10_PS11_PS12_PS13, kScenePS10);
Expand Down

0 comments on commit bb719ba

Please sign in to comment.