diff options
author | Peter Kohaut | 2019-03-06 20:32:45 +0100 |
---|---|---|
committer | Peter Kohaut | 2019-03-06 20:41:02 +0100 |
commit | d4e7e957b0ec43168e2bf663fb53bbbdf7752fcb (patch) | |
tree | e55f5c9a31069046c256fb9de44f04c8b2329a99 | |
parent | b8966ff1ad4fe95cdb7be33e94d18d757031f03a (diff) | |
download | scummvm-rg350-d4e7e957b0ec43168e2bf663fb53bbbdf7752fcb.tar.gz scummvm-rg350-d4e7e957b0ec43168e2bf663fb53bbbdf7752fcb.tar.bz2 scummvm-rg350-d4e7e957b0ec43168e2bf663fb53bbbdf7752fcb.zip |
BLADERUNNER: Fixed panning of speech
Cleanup of other sound pannings
-rw-r--r-- | engines/bladerunner/actor.cpp | 13 | ||||
-rw-r--r-- | engines/bladerunner/actor.h | 2 | ||||
-rw-r--r-- | engines/bladerunner/actor_combat.cpp | 2 | ||||
-rw-r--r-- | engines/bladerunner/audio_mixer.cpp | 4 | ||||
-rw-r--r-- | engines/bladerunner/audio_speech.cpp | 4 | ||||
-rw-r--r-- | engines/bladerunner/audio_speech.h | 2 | ||||
-rw-r--r-- | engines/bladerunner/bladerunner.cpp | 4 | ||||
-rw-r--r-- | engines/bladerunner/bladerunner.h | 2 | ||||
-rw-r--r-- | engines/bladerunner/item_pickup.cpp | 2 | ||||
-rw-r--r-- | engines/bladerunner/script/script.cpp | 8 |
10 files changed, 21 insertions, 22 deletions
diff --git a/engines/bladerunner/actor.cpp b/engines/bladerunner/actor.cpp index f616614ee0..44dd3a603e 100644 --- a/engines/bladerunner/actor.cpp +++ b/engines/bladerunner/actor.cpp @@ -1142,17 +1142,16 @@ int Actor::getGoal() const { void Actor::speechPlay(int sentenceId, bool voiceOver) { Common::String name = Common::String::format( "%02d-%04d%s.AUD", _id, sentenceId, _vm->_languageCode.c_str()); - int balance = 0; + int pan = 0; if (!voiceOver && _id != BladeRunnerEngine::kActorVoiceOver) { Vector3 screenPosition = _vm->_view->calculateScreenPosition(_position); - balance = (127 * (2 * screenPosition.x - 640)) / 640; - balance = CLIP<int>(balance, -127, 127); + pan = (75 * (2 * CLIP<int>(screenPosition.x, 0, 640) - 640)) / 640; // map [0..640] to [-75..75] } _vm->_subtitles->getInGameSubsText(_id, sentenceId); _vm->_subtitles->show(); - _vm->_audioSpeech->playSpeech(name, balance); + _vm->_audioSpeech->playSpeech(name, pan); } void Actor::speechStop() { @@ -1215,12 +1214,12 @@ void Actor::acquireCluesByRelations() { int Actor::soundVolume() const { float dist = distanceFromView(_vm->_view); - return 35.0f * CLIP(1.0f - (dist / 1200.0f), 0.0f, 1.0f); + return (35 * CLIP<int>(100 - (dist / 12), 0, 100)) / 100; // map [0..1200] to [35..0] } -int Actor::soundBalance() const { +int Actor::soundPan() const { Vector3 screenPosition = _vm->_view->calculateScreenPosition(_position); - return 35.0f * (CLIP(screenPosition.x / 640.0f, 0.0f, 1.0f) * 2.0f - 1.0f); + return (35 * (2 * CLIP<int>(screenPosition.x, 0, 640) - 640)) / 640; // map [0..640] to [-35..35] } bool Actor::isObstacleBetween(const Vector3 &target) { diff --git a/engines/bladerunner/actor.h b/engines/bladerunner/actor.h index 62c7a284aa..806130365c 100644 --- a/engines/bladerunner/actor.h +++ b/engines/bladerunner/actor.h @@ -255,7 +255,7 @@ public: void acquireCluesByRelations(); int soundVolume() const; - int soundBalance() const; + int soundPan() const; bool isObstacleBetween(const Vector3 &target); diff --git a/engines/bladerunner/actor_combat.cpp b/engines/bladerunner/actor_combat.cpp index 727174943b..47c575f7c1 100644 --- a/engines/bladerunner/actor_combat.cpp +++ b/engines/bladerunner/actor_combat.cpp @@ -287,7 +287,7 @@ void ActorCombat::hitAttempt() { sentenceId += 900; } - _vm->_audioSpeech->playSpeechLine(_enemyId, sentenceId, 75, enemy->soundBalance(), 99); + _vm->_audioSpeech->playSpeechLine(_enemyId, sentenceId, 75, enemy->soundPan(), 99); } } diff --git a/engines/bladerunner/audio_mixer.cpp b/engines/bladerunner/audio_mixer.cpp index eb2214e84b..b1562f33f8 100644 --- a/engines/bladerunner/audio_mixer.cpp +++ b/engines/bladerunner/audio_mixer.cpp @@ -171,7 +171,7 @@ void AudioMixer::tick() { channel->volumeDelta = 0.0f; } - _vm->_mixer->setChannelVolume(channel->handle, channel->volume * 255 / 100); + _vm->_mixer->setChannelVolume(channel->handle, (channel->volume * Audio::Mixer::kMaxChannelVolume) / 100); // map [0..100] to [0..kMaxChannelVolume] if (channel->volume <= 0.0f) { stop(i, 0); @@ -185,7 +185,7 @@ void AudioMixer::tick() { channel->panDelta = 0.0f; } - _vm->_mixer->setChannelBalance(channel->handle, channel->pan * 127 / 100); + _vm->_mixer->setChannelBalance(channel->handle, (channel->pan * 127) / 100); // map [-100..100] to [-127..127] } if (!_vm->_mixer->isSoundHandleActive(channel->handle) || channel->stream->endOfStream()) { diff --git a/engines/bladerunner/audio_speech.cpp b/engines/bladerunner/audio_speech.cpp index aa8b0f419b..2370a7b1d3 100644 --- a/engines/bladerunner/audio_speech.cpp +++ b/engines/bladerunner/audio_speech.cpp @@ -124,9 +124,9 @@ bool AudioSpeech::isPlaying() const { } bool AudioSpeech::playSpeechLine(int actorId, int sentenceId, int volume, int a4, int priority) { - int balance = _vm->_actors[actorId]->soundBalance(); + int pan = _vm->_actors[actorId]->soundPan(); Common::String name = Common::String::format("%02d-%04d%s.AUD", actorId, sentenceId, _vm->_languageCode.c_str()); - return _vm->_audioPlayer->playAud(name, _speechVolume * volume / 100, balance, balance, priority, kAudioPlayerOverrideVolume, Audio::Mixer::kSpeechSoundType); + return _vm->_audioPlayer->playAud(name, _speechVolume * volume / 100, pan, pan, priority, kAudioPlayerOverrideVolume, Audio::Mixer::kSpeechSoundType); } void AudioSpeech::setVolume(int volume) { diff --git a/engines/bladerunner/audio_speech.h b/engines/bladerunner/audio_speech.h index 5406f1d8e5..180995ce4f 100644 --- a/engines/bladerunner/audio_speech.h +++ b/engines/bladerunner/audio_speech.h @@ -45,7 +45,7 @@ public: AudioSpeech(BladeRunnerEngine *vm); ~AudioSpeech(); - bool playSpeech(const Common::String &name, int balance = 0); + bool playSpeech(const Common::String &name, int pan = 0); void stopSpeech(); bool isPlaying() const; diff --git a/engines/bladerunner/bladerunner.cpp b/engines/bladerunner/bladerunner.cpp index 059323e70f..793939df9a 100644 --- a/engines/bladerunner/bladerunner.cpp +++ b/engines/bladerunner/bladerunner.cpp @@ -126,7 +126,7 @@ BladeRunnerEngine::BladeRunnerEngine(OSystem *syst, const ADGameDescription *des _walkSoundId = -1; _walkSoundVolume = 0; - _walkSoundBalance = 0; + _walkSoundPan = 0; _crimesDatabase = nullptr; @@ -955,7 +955,7 @@ void BladeRunnerEngine::gameTick() { _mouse->draw(_surfaceFront, p.x, p.y); if (_walkSoundId >= 0) { - _audioPlayer->playAud(_gameInfo->getSfxTrack(_walkSoundId), _walkSoundVolume, _walkSoundBalance, _walkSoundBalance, 50, 0); + _audioPlayer->playAud(_gameInfo->getSfxTrack(_walkSoundId), _walkSoundVolume, _walkSoundPan, _walkSoundPan, 50, 0); _walkSoundId = -1; } diff --git a/engines/bladerunner/bladerunner.h b/engines/bladerunner/bladerunner.h index 816ae6c020..cee0804cd4 100644 --- a/engines/bladerunner/bladerunner.h +++ b/engines/bladerunner/bladerunner.h @@ -202,7 +202,7 @@ public: int _walkSoundId; int _walkSoundVolume; - int _walkSoundBalance; + int _walkSoundPan; int _runningActorId; int _mouseClickTimeLast; diff --git a/engines/bladerunner/item_pickup.cpp b/engines/bladerunner/item_pickup.cpp index 4991828d1d..cab75b28c1 100644 --- a/engines/bladerunner/item_pickup.cpp +++ b/engines/bladerunner/item_pickup.cpp @@ -54,7 +54,7 @@ void ItemPickup::setup(int animationId, int screenX, int screenY) { _screenRect.top = _screenY - 40; _screenRect.bottom = _screenY + 40; - int pan = (150 * _screenX - 48000) / 640; + int pan = (75 * (2 * _screenX - 640)) / 640; // map [0..640] to [-75..75] _vm->_audioPlayer->playAud(_vm->_gameInfo->getSfxTrack(335), 80, pan, pan, 50, 0); _timeLast = _vm->_time->currentSystem(); diff --git a/engines/bladerunner/script/script.cpp b/engines/bladerunner/script/script.cpp index e38477d03f..aa7308bd46 100644 --- a/engines/bladerunner/script/script.cpp +++ b/engines/bladerunner/script/script.cpp @@ -963,7 +963,7 @@ void ScriptBase::Sound_Left_Footstep_Walk(int actorId) { _vm->_walkSoundId = _vm->_scene->_set->getWalkboxSoundWalkLeft(walkboxId); _vm->_walkSoundVolume = _vm->_actors[actorId]->soundVolume(); - _vm->_walkSoundBalance = _vm->_actors[actorId]->soundBalance(); + _vm->_walkSoundPan = _vm->_actors[actorId]->soundPan(); } void ScriptBase::Sound_Right_Footstep_Walk(int actorId) { @@ -975,7 +975,7 @@ void ScriptBase::Sound_Right_Footstep_Walk(int actorId) { _vm->_walkSoundId = _vm->_scene->_set->getWalkboxSoundWalkRight(walkboxId); _vm->_walkSoundVolume = _vm->_actors[actorId]->soundVolume(); - _vm->_walkSoundBalance = _vm->_actors[actorId]->soundBalance(); + _vm->_walkSoundPan = _vm->_actors[actorId]->soundPan(); } void ScriptBase::Sound_Left_Footstep_Run(int actorId) { @@ -987,7 +987,7 @@ void ScriptBase::Sound_Left_Footstep_Run(int actorId) { _vm->_walkSoundId = _vm->_scene->_set->getWalkboxSoundRunLeft(walkboxId); _vm->_walkSoundVolume = _vm->_actors[actorId]->soundVolume(); - _vm->_walkSoundBalance = _vm->_actors[actorId]->soundBalance(); + _vm->_walkSoundPan = _vm->_actors[actorId]->soundPan(); } void ScriptBase::Sound_Right_Footstep_Run(int actorId) { @@ -999,7 +999,7 @@ void ScriptBase::Sound_Right_Footstep_Run(int actorId) { _vm->_walkSoundId = _vm->_scene->_set->getWalkboxSoundRunRight(walkboxId); _vm->_walkSoundVolume = _vm->_actors[actorId]->soundVolume(); - _vm->_walkSoundBalance = _vm->_actors[actorId]->soundBalance(); + _vm->_walkSoundPan = _vm->_actors[actorId]->soundPan(); } // ScriptBase::Sound_Walk_Shuffle_Stop |