aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Kohaut2019-02-10 16:53:25 +0100
committerPeter Kohaut2019-02-10 16:55:38 +0100
commit1384afd0f6151e5c39e8f4234fd3a3730ef46f49 (patch)
treea85a1224ca5e8142b83868e7941b92d085ba1823
parentf104cf5903ebdac4b1eba6e6eab67b237a7caa24 (diff)
downloadscummvm-rg350-1384afd0f6151e5c39e8f4234fd3a3730ef46f49.tar.gz
scummvm-rg350-1384afd0f6151e5c39e8f4234fd3a3730ef46f49.tar.bz2
scummvm-rg350-1384afd0f6151e5c39e8f4234fd3a3730ef46f49.zip
BLADERUNNER: Use ScummVM functionality for audio volume management
-rw-r--r--engines/bladerunner/ambient_sounds.cpp5
-rw-r--r--engines/bladerunner/audio_player.cpp6
-rw-r--r--engines/bladerunner/audio_player.h3
-rw-r--r--engines/bladerunner/audio_speech.cpp4
-rw-r--r--engines/bladerunner/bladerunner.h1
-rw-r--r--engines/bladerunner/music.cpp2
-rw-r--r--engines/bladerunner/ui/kia_section_settings.cpp62
-rw-r--r--engines/bladerunner/ui/kia_section_settings.h6
-rw-r--r--gui/options.cpp2
9 files changed, 72 insertions, 19 deletions
diff --git a/engines/bladerunner/ambient_sounds.cpp b/engines/bladerunner/ambient_sounds.cpp
index 9485de339e..81f4c7caeb 100644
--- a/engines/bladerunner/ambient_sounds.cpp
+++ b/engines/bladerunner/ambient_sounds.cpp
@@ -37,7 +37,8 @@ AmbientSounds::AmbientSounds(BladeRunnerEngine *vm) {
_vm = vm;
_nonLoopingSounds = new NonLoopingSound[kNonLoopingSounds];
_loopingSounds = new LoopingSound[kLoopingSounds];
- _ambientVolume = 65;
+
+ _ambientVolume = BLADERUNNER_ORIGINAL_SETTINGS ? 65 : 100;
for (int i = 0; i != kNonLoopingSounds; ++i) {
NonLoopingSound &track = _nonLoopingSounds[i];
@@ -119,7 +120,7 @@ void AmbientSounds::playSound(int sfxId, int volume, int panStart, int panEnd, i
void AmbientSounds::playSpeech(int actorId, int sentenceId, int volume, int panStart, int panEnd, int priority) {
Common::String name = Common::String::format( "%02d-%04d%s.AUD", actorId, sentenceId, _vm->_languageCode.c_str());
- _vm->_audioPlayer->playAud(name, volume * _ambientVolume / 100, panStart, panEnd, priority, kAudioPlayerOverrideVolume);
+ _vm->_audioPlayer->playAud(name, volume * _ambientVolume / 100, panStart, panEnd, priority, kAudioPlayerOverrideVolume, Audio::Mixer::kSpeechSoundType);
}
void AmbientSounds::addLoopingSound(int sfxId, int volume, int pan, int delay) {
diff --git a/engines/bladerunner/audio_player.cpp b/engines/bladerunner/audio_player.cpp
index 2c4b75cc13..4493a02f59 100644
--- a/engines/bladerunner/audio_player.cpp
+++ b/engines/bladerunner/audio_player.cpp
@@ -136,7 +136,7 @@ AudioPlayer::AudioPlayer(BladeRunnerEngine *vm) {
_tracks[i].stream = nullptr;
}
- _sfxVolume = 65;
+ _sfxVolume =BLADERUNNER_ORIGINAL_SETTINGS ? 65 : 100;
}
AudioPlayer::~AudioPlayer() {
@@ -221,7 +221,7 @@ void AudioPlayer::mixerChannelEnded(int channel, void *data) {
audioPlayer->remove(channel);
}
-int AudioPlayer::playAud(const Common::String &name, int volume, int panFrom, int panTo, int priority, byte flags) {
+int AudioPlayer::playAud(const Common::String &name, int volume, int panFrom, int panTo, int priority, byte flags, Audio::Mixer::SoundType type) {
/* Find first available track or, alternatively, the lowest priority playing track */
int track = -1;
int lowestPriority = 1000000;
@@ -279,7 +279,7 @@ int AudioPlayer::playAud(const Common::String &name, int volume, int panFrom, in
}
int channel = _vm->_audioMixer->play(
- Audio::Mixer::kPlainSoundType,
+ type,
audioStream,
priority,
flags & kAudioPlayerLoop,
diff --git a/engines/bladerunner/audio_player.h b/engines/bladerunner/audio_player.h
index 07bfb56461..34059e33f3 100644
--- a/engines/bladerunner/audio_player.h
+++ b/engines/bladerunner/audio_player.h
@@ -28,6 +28,7 @@
#include "common/str.h"
#include "audio/audiostream.h"
+#include "audio/mixer.h"
namespace BladeRunner {
@@ -100,7 +101,7 @@ public:
AudioPlayer(BladeRunnerEngine *vm);
~AudioPlayer();
- int playAud(const Common::String &name, int volume, int panStart, int panEnd, int priority, byte flags = 0);
+ int playAud(const Common::String &name, int volume, int panStart, int panEnd, int priority, byte flags = 0, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType);
bool isActive(int track) const;
void stop(int track, bool immediately);
void stopAll();
diff --git a/engines/bladerunner/audio_speech.cpp b/engines/bladerunner/audio_speech.cpp
index 5ffde9db6c..ce8c632655 100644
--- a/engines/bladerunner/audio_speech.cpp
+++ b/engines/bladerunner/audio_speech.cpp
@@ -48,7 +48,7 @@ void AudioSpeech::mixerChannelEnded(int channel, void *data) {
AudioSpeech::AudioSpeech(BladeRunnerEngine *vm) {
_vm = vm;
- _speechVolume = 50;
+ _speechVolume = BLADERUNNER_ORIGINAL_SETTINGS ? 50 : 100;
_isActive = false;
_data = new byte[kBufferSize];
_channel = -1;
@@ -118,7 +118,7 @@ bool AudioSpeech::isPlaying() const {
bool AudioSpeech::playSpeechLine(int actorId, int sentenceId, int volume, int a4, int priority) {
int balance = _vm->_actors[actorId]->soundBalance();
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);
+ return _vm->_audioPlayer->playAud(name, _speechVolume * volume / 100, balance, balance, priority, kAudioPlayerOverrideVolume, Audio::Mixer::kSpeechSoundType);
}
void AudioSpeech::setVolume(int volume) {
diff --git a/engines/bladerunner/bladerunner.h b/engines/bladerunner/bladerunner.h
index 3f9b33dcb2..10aaf37bff 100644
--- a/engines/bladerunner/bladerunner.h
+++ b/engines/bladerunner/bladerunner.h
@@ -37,6 +37,7 @@
//TODO: change this to debugflag
#define BLADERUNNER_DEBUG_CONSOLE 0
+#define BLADERUNNER_ORIGINAL_SETTINGS 0
namespace Common {
struct Event;
diff --git a/engines/bladerunner/music.cpp b/engines/bladerunner/music.cpp
index 05412dd8e0..61326b6bb1 100644
--- a/engines/bladerunner/music.cpp
+++ b/engines/bladerunner/music.cpp
@@ -35,7 +35,7 @@ namespace BladeRunner {
Music::Music(BladeRunnerEngine *vm) {
_vm = vm;
_channel = -1;
- _musicVolume = 65;
+ _musicVolume = BLADERUNNER_ORIGINAL_SETTINGS ? 65 : 100;
_isPlaying = false;
_isPaused = false;
_current.loop = false;
diff --git a/engines/bladerunner/ui/kia_section_settings.cpp b/engines/bladerunner/ui/kia_section_settings.cpp
index 294571262f..ce2832c1f0 100644
--- a/engines/bladerunner/ui/kia_section_settings.cpp
+++ b/engines/bladerunner/ui/kia_section_settings.cpp
@@ -40,6 +40,7 @@
#include "bladerunner/ui/ui_image_picker.h"
#include "bladerunner/ui/ui_slider.h"
+#include "audio/mixer.h"
#include "common/keyboard.h"
namespace BladeRunner {
@@ -50,20 +51,30 @@ KIASectionSettings::KIASectionSettings(BladeRunnerEngine *vm)
: KIASectionBase(vm) {
_uiContainer = new UIContainer(_vm);
+
+#if BLADERUNNER_ORIGINAL_SETTINGS
_musicVolume = new UISlider(_vm, sliderCallback, this, Common::Rect(180, 160, 460, 170), 101, 0);
- _soundEffectVolume = new UISlider(_vm, sliderCallback, this, Common::Rect( 180, 185, 460, 195), 101, 0);
+ _soundEffectVolume = new UISlider(_vm, sliderCallback, this, Common::Rect(180, 185, 460, 195), 101, 0);
_ambientSoundVolume = new UISlider(_vm, sliderCallback, this, Common::Rect(180, 210, 460, 220), 101, 0);
_speechVolume = new UISlider(_vm, sliderCallback, this, Common::Rect(180, 235, 460, 245), 101, 0);
_gammaCorrection = new UISlider(_vm, sliderCallback, this, Common::Rect(180, 260, 460, 270), 101, 0);
+#else
+ _musicVolume = new UISlider(_vm, sliderCallback, this, Common::Rect(180, 160, 460, 170), _vm->_mixer->kMaxMixerVolume, 0);
+ _soundEffectVolume = new UISlider(_vm, sliderCallback, this, Common::Rect(180, 185, 460, 195), _vm->_mixer->kMaxMixerVolume, 0);
+ _speechVolume = new UISlider(_vm, sliderCallback, this, Common::Rect(180, 210, 460, 220), _vm->_mixer->kMaxMixerVolume, 0);
+#endif
+
_directorsCut = new UICheckBox(_vm, checkBoxCallback, this, Common::Rect(180, 364, 270, 374), 0, false);
_subtitlesEnable = new UICheckBox(_vm, checkBoxCallback, this, Common::Rect(311, 364, 380, 374), 0, false); // moved further to the right to avoid overlap with 'Designer's Cut' in some language versions (ESP)
_playerAgendaSelector = new UIImagePicker(_vm, 5);
_uiContainer->add(_musicVolume);
_uiContainer->add(_soundEffectVolume);
- _uiContainer->add(_ambientSoundVolume);
_uiContainer->add(_speechVolume);
+#if BLADERUNNER_ORIGINAL_SETTINGS
+ _uiContainer->add(_ambientSoundVolume);
_uiContainer->add(_gammaCorrection);
+#endif
_uiContainer->add(_directorsCut);
_uiContainer->add(_subtitlesEnable);
@@ -74,9 +85,11 @@ KIASectionSettings::~KIASectionSettings() {
delete _uiContainer;
delete _musicVolume;
delete _soundEffectVolume;
- delete _ambientSoundVolume;
delete _speechVolume;
+#if BLADERUNNER_ORIGINAL_SETTINGS
+ delete _ambientSoundVolume;
delete _gammaCorrection;
+#endif
delete _directorsCut;
delete _subtitlesEnable;
delete _playerAgendaSelector;
@@ -102,11 +115,18 @@ void KIASectionSettings::close() {
}
void KIASectionSettings::draw(Graphics::Surface &surface) {
+#if BLADERUNNER_ORIGINAL_SETTINGS
_musicVolume->setValue(_vm->_music->getVolume());
_soundEffectVolume->setValue(_vm->_audioPlayer->getVolume());
_ambientSoundVolume->setValue(_vm->_ambientSounds->getVolume());
_speechVolume->setValue(_vm->_audioSpeech->getVolume());
_gammaCorrection->setValue(100.0f);
+#else
+ _musicVolume->setValue(_vm->_mixer->getVolumeForSoundType(_vm->_mixer->kMusicSoundType));
+ _soundEffectVolume->setValue(_vm->_mixer->getVolumeForSoundType(_vm->_mixer->kSFXSoundType));
+ _speechVolume->setValue(_vm->_mixer->getVolumeForSoundType(_vm->_mixer->kSpeechSoundType));
+#endif
+
_directorsCut->setChecked(_vm->_gameFlags->query(kFlagDirectorsCut));
_subtitlesEnable->setChecked(_vm->isSubtitlesEnabled());
@@ -114,14 +134,16 @@ void KIASectionSettings::draw(Graphics::Surface &surface) {
const char *textConversationChoices = _vm->_textOptions->getText(0);
const char *textMusic = _vm->_textOptions->getText(2);
const char *textSoundEffects = _vm->_textOptions->getText(3);
- const char *textAmbientSound = _vm->_textOptions->getText(4);
const char *textSpeech = _vm->_textOptions->getText(5);
- const char *textGammaCorrection = _vm->_textOptions->getText(7);
const char *textSoft = _vm->_textOptions->getText(10);
const char *textLoud = _vm->_textOptions->getText(11);
+ const char *textDesignersCut = _vm->_textOptions->getText(18);
+#if BLADERUNNER_ORIGINAL_SETTINGS
+ const char *textAmbientSound = _vm->_textOptions->getText(4);
+ const char *textGammaCorrection = _vm->_textOptions->getText(7);
const char *textDark = _vm->_textOptions->getText(14);
const char *textLight = _vm->_textOptions->getText(15);
- const char *textDesignersCut = _vm->_textOptions->getText(18);
+#endif
// Allow this to be loading as an extra text item in the resource for text options
const char *subtitlesTranslation = "Subtitles";
@@ -149,11 +171,13 @@ void KIASectionSettings::draw(Graphics::Surface &surface) {
int posConversationChoices = 320 - _vm->_mainFont->getTextWidth(textConversationChoices) / 2;
int posMusic = 320 - _vm->_mainFont->getTextWidth(textMusic) / 2;
int posSoundEffects = 320 - _vm->_mainFont->getTextWidth(textSoundEffects) / 2;
- int posAmbientSound = 320 - _vm->_mainFont->getTextWidth(textAmbientSound) / 2;
int posSpeech = 320 - _vm->_mainFont->getTextWidth(textSpeech) / 2;
- int posGammaCorrection = 320 - _vm->_mainFont->getTextWidth(textGammaCorrection) / 2;
int posSoft = 178 - _vm->_mainFont->getTextWidth(textSoft);
+#if BLADERUNNER_ORIGINAL_SETTINGS
+ int posAmbientSound = 320 - _vm->_mainFont->getTextWidth(textAmbientSound) / 2;
+ int posGammaCorrection = 320 - _vm->_mainFont->getTextWidth(textGammaCorrection) / 2;
int posDark = 178 - _vm->_mainFont->getTextWidth(textDark);
+#endif
_uiContainer->draw(surface);
_playerAgendaSelector->draw(surface);
@@ -168,6 +192,7 @@ void KIASectionSettings::draw(Graphics::Surface &surface) {
_vm->_mainFont->drawColor(textSoft, surface, posSoft, 186, 0x6EEE);
_vm->_mainFont->drawColor(textLoud, surface, 462, 186, 0x6EEE);
+#if BLADERUNNER_ORIGINAL_SETTINGS
_vm->_mainFont->drawColor(textAmbientSound, surface, posAmbientSound, 200, 0x7751);
_vm->_mainFont->drawColor(textSoft, surface, posSoft, 211, 0x6EEE);
_vm->_mainFont->drawColor(textLoud, surface, 462, 211, 0x6EEE);
@@ -179,6 +204,11 @@ void KIASectionSettings::draw(Graphics::Surface &surface) {
_vm->_mainFont->drawColor(textGammaCorrection, surface, posGammaCorrection, 250, 0x7751);
_vm->_mainFont->drawColor(textDark, surface, posDark, 261, 0x6EEE);
_vm->_mainFont->drawColor(textLight, surface, 462, 261, 0x6EEE);
+#else
+ _vm->_mainFont->drawColor(textSpeech, surface, posSpeech, 200, 0x7751);
+ _vm->_mainFont->drawColor(textSoft, surface, posSoft, 211, 0x6EEE);
+ _vm->_mainFont->drawColor(textLoud, surface, 462, 211, 0x6EEE);
+#endif
_vm->_mainFont->drawColor(textDesignersCut, surface, 192, 365, 0x7751);
_vm->_mainFont->drawColor(textSubtitles, surface, 323, 365, 0x7751); // moved further to the right to avoid overlap with 'Designer's Cut' in some language versions (ESP)
@@ -225,6 +255,7 @@ void KIASectionSettings::handleMouseUp(bool mainButton) {
void KIASectionSettings::sliderCallback(void *callbackData, void *source) {
KIASectionSettings *self = (KIASectionSettings *)callbackData;
+#if BLADERUNNER_ORIGINAL_SETTINGS
if (source == self->_musicVolume) {
self->_vm->_music->setVolume(self->_musicVolume->_value);
self->_vm->_music->playSample();
@@ -246,6 +277,21 @@ void KIASectionSettings::sliderCallback(void *callbackData, void *source) {
// Palette_copy(Palette);
// kia::resume(KIA);
}
+#else
+ if (source == self->_musicVolume) {
+ self->_vm->_mixer->setVolumeForSoundType(self->_vm->_mixer->kMusicSoundType, self->_musicVolume->_value);
+ self->_vm->_music->playSample();
+ ConfMan.setInt("music_volume", self->_musicVolume->_value);
+ } else if (source == self->_soundEffectVolume) {
+ self->_vm->_mixer->setVolumeForSoundType(self->_vm->_mixer->kSFXSoundType, self->_soundEffectVolume->_value);
+ self->_vm->_audioPlayer->playSample();
+ ConfMan.setInt("sfx_volume", self->_soundEffectVolume->_value);
+ } else if (source == self->_speechVolume) {
+ self->_vm->_mixer->setVolumeForSoundType(self->_vm->_mixer->kSpeechSoundType, self->_speechVolume->_value);
+ self->_vm->_audioSpeech->playSample();
+ ConfMan.setInt("speech_volume", self->_speechVolume->_value);
+ }
+#endif
}
void KIASectionSettings::checkBoxCallback(void *callbackData, void *source) {
diff --git a/engines/bladerunner/ui/kia_section_settings.h b/engines/bladerunner/ui/kia_section_settings.h
index e93a67641e..985b778f5d 100644
--- a/engines/bladerunner/ui/kia_section_settings.h
+++ b/engines/bladerunner/ui/kia_section_settings.h
@@ -25,6 +25,8 @@
#include "bladerunner/ui/kia_section_base.h"
+#include "common/config-manager.h"
+
namespace BladeRunner {
class BladeRunnerEngine;
@@ -39,9 +41,11 @@ class KIASectionSettings : public KIASectionBase {
UIContainer *_uiContainer;
UISlider *_musicVolume;
UISlider *_soundEffectVolume;
- UISlider *_ambientSoundVolume;
UISlider *_speechVolume;
+#if BLADERUNNER_ORIGINAL_SETTINGS
+ UISlider *_ambientSoundVolume;
UISlider *_gammaCorrection;
+#endif
UICheckBox *_directorsCut;
UICheckBox *_subtitlesEnable;
UIImagePicker *_playerAgendaSelector;
diff --git a/gui/options.cpp b/gui/options.cpp
index 8d2bda5af0..4c0d8d5741 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -1235,7 +1235,7 @@ void OptionsDialog::addMT32Controls(GuiObject *boss, const Common::String &prefi
if (!_domain.equals(Common::ConfigManager::kApplicationDomain)) {
_mt32DevicePopUpDesc->setEnabled(false);
_mt32DevicePopUp->setEnabled(false);
- }
+ }
_enableMT32Settings = true;
}