[Scummvm-git-logs] scummvm master -> 69a372672e48f570aa89cd03261c76339f2ea471
sev-
noreply at scummvm.org
Tue Jun 6 17:44:04 UTC 2023
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
69a372672e DIRECTOR: Properly set volume on starting sound. Store sound volume defaults.
Commit: 69a372672e48f570aa89cd03261c76339f2ea471
https://github.com/scummvm/scummvm/commit/69a372672e48f570aa89cd03261c76339f2ea471
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-06-06T19:43:32+02:00
Commit Message:
DIRECTOR: Properly set volume on starting sound. Store sound volume defaults.
Changed paths:
engines/director/director.cpp
engines/director/director.h
engines/director/sound.cpp
engines/director/sound.h
diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index 7732d2f79b3..4dc2cd96287 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -69,6 +69,7 @@ DirectorEngine::DirectorEngine(OSystem *syst, const DirectorGameDescription *gam
// Setup mixer
syncSoundSettings();
+ _defaultVolume = _mixer->getVolumeForSoundType(Audio::Mixer::kSFXSoundType);
// Load Palettes
loadDefaultPalettes();
diff --git a/engines/director/director.h b/engines/director/director.h
index 3967903f10b..fcec6af0440 100644
--- a/engines/director/director.h
+++ b/engines/director/director.h
@@ -230,6 +230,7 @@ public:
Graphics::PixelFormat _pixelformat;
uint32 _debugDraw = 0;
+ int _defaultVolume = 255;
public:
int _colorDepth;
diff --git a/engines/director/sound.cpp b/engines/director/sound.cpp
index 52bf73b158b..f4bc277f289 100644
--- a/engines/director/sound.cpp
+++ b/engines/director/sound.cpp
@@ -87,6 +87,8 @@ void DirectorSound::playFile(Common::String filename, uint8 soundChannel) {
cancelFade(soundChannel);
stopSound(soundChannel);
+
+ setChannelDefaultVolume(soundChannel);
_mixer->playStream(Audio::Mixer::kSFXSoundType, &_channels[soundChannel]->handle, sound, -1, getChannelVolume(soundChannel));
// Set the last played sound so that cast member 0 in the sound channel doesn't stop this file.
@@ -109,6 +111,12 @@ uint8 DirectorSound::getChannelVolume(uint8 soundChannel) {
return _enable ? _channels[soundChannel]->volume : 0;
}
+void DirectorSound::setChannelDefaultVolume(int soundChannel) {
+ int vol = _volumes.getValOrDefault(soundChannel, g_director->_defaultVolume);
+
+ _channels[soundChannel]->volume = vol;
+}
+
void DirectorSound::playStream(Audio::AudioStream &stream, uint8 soundChannel) {
if (!assertChannel(soundChannel))
return;
@@ -116,6 +124,9 @@ void DirectorSound::playStream(Audio::AudioStream &stream, uint8 soundChannel) {
cancelFade(soundChannel);
_mixer->stopHandle(_channels[soundChannel]->handle);
+
+ setChannelDefaultVolume(soundChannel);
+
_mixer->playStream(Audio::Mixer::kSFXSoundType, &_channels[soundChannel]->handle, &stream, -1, getChannelVolume(soundChannel));
}
@@ -623,6 +634,8 @@ void DirectorSound::playFPlaySound(const Common::Array<Common::String> &fplayLis
void DirectorSound::setSoundLevelInternal(uint8 soundChannel, uint8 soundLevel) {
// we have 8 level of sounds, and in ScummVM, we have range 0 to 255, thus 1 level represent 32
_channels[soundChannel]->volume = soundLevel * 32;
+ _volumes[soundChannel] = soundLevel * 32;
+
if (_enable && isChannelActive(soundChannel))
_mixer->setChannelVolume(_channels[soundChannel]->handle, _channels[soundChannel]->volume);
}
diff --git a/engines/director/sound.h b/engines/director/sound.h
index 5d1ec9b014d..2e2afbdd6db 100644
--- a/engines/director/sound.h
+++ b/engines/director/sound.h
@@ -158,6 +158,7 @@ class DirectorSound {
private:
Window *_window;
Common::HashMap<int, SoundChannel *> _channels;
+ Common::HashMap<int, int> _volumes;
Audio::SoundHandle _scriptSound;
Audio::Mixer *_mixer;
Audio::PCSpeaker *_speaker;
@@ -208,6 +209,7 @@ public:
uint8 getChannelVolume(uint8 soundChannel);
void stopSound(uint8 soundChannel);
void stopSound();
+ void setChannelDefaultVolume(int soundChannel);
private:
void setLastPlayedSound(uint8 soundChannel, SoundID soundId, bool stopOnZero = true);
More information about the Scummvm-git-logs
mailing list