SHERLOCK: RT: Implemented setMusicVolume, cleanup of sound code

This commit is contained in:
Paul Gilbert 2015-08-15 12:30:04 -04:00
parent 5deb896890
commit 21028131cf
7 changed files with 12 additions and 20 deletions

View File

@ -574,8 +574,9 @@ bool Music::waitUntilMSec(uint32 msecTarget, uint32 msecMax, uint32 additionalDe
}
}
void Music::setMIDIVolume(int volume) {
warning("TODO: Music::setMIDIVolume");
void Music::setMusicVolume(int volume) {
_musicVolume = volume;
_vm->_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, volume);
}
} // End of namespace Sherlock

View File

@ -120,7 +120,7 @@ public:
/**
* Sets the volume of the MIDI music with a value ranging from 0 to 127
*/
void setMIDIVolume(int volume);
void setMusicVolume(int volume);
};
} // End of namespace Sherlock

View File

@ -142,7 +142,7 @@ bool Sound::playSound(const Common::String &name, WaitType waitType, int priorit
}
Audio::SoundHandle soundHandle = (IS_SERRATED_SCALPEL) ? _scalpelEffectsHandle : getFreeSoundHandle();
if (!playSoundResource(filename, libraryFilename, Audio::Mixer::kPlainSoundType, soundHandle, Audio::Mixer::kMaxChannelVolume))
if (!playSoundResource(filename, libraryFilename, Audio::Mixer::kSFXSoundType, soundHandle))
error("Could not find sound resource - %s", filename.c_str());
_soundPlaying = true;
@ -194,11 +194,6 @@ void Sound::stopSound() {
}
}
void Sound::stopSndFuncPtr(int v1, int v2) {
// TODO
warning("TODO: Sound::stopSndFuncPtr");
}
void Sound::freeDigiSound() {
_soundPlaying = false;
}
@ -240,7 +235,7 @@ void Sound::playSpeech(const Common::String &name) {
// Ensure the given library is in the cache
res.addToCache(libraryName);
if (playSoundResource(name, libraryName, Audio::Mixer::kSpeechSoundType, _speechHandle, Audio::Mixer::kMaxChannelVolume))
if (playSoundResource(name, libraryName, Audio::Mixer::kSpeechSoundType, _speechHandle))
_speechPlaying = true;
}
@ -255,7 +250,7 @@ bool Sound::isSpeechPlaying() {
}
bool Sound::playSoundResource(const Common::String &name, const Common::String &libFilename,
Audio::Mixer::SoundType soundType, Audio::SoundHandle &handle, int volume) {
Audio::Mixer::SoundType soundType, Audio::SoundHandle &handle) {
Resources &res = *_vm->_res;
Common::SeekableReadStream *stream = libFilename.empty() ? res.load(name) : res.load(name, libFilename, true);
if (!stream)
@ -300,7 +295,7 @@ bool Sound::playSoundResource(const Common::String &name, const Common::String &
if (!audioStream)
return false;
_mixer->playStream(soundType, &handle, audioStream, -1, volume);
_mixer->playStream(soundType, &handle, audioStream, -1, Audio::Mixer::kMaxChannelVolume);
return true;
}

View File

@ -59,7 +59,7 @@ private:
* Handle playing a sound or speech
*/
bool playSoundResource(const Common::String &name, const Common::String &libFilename,
Audio::Mixer::SoundType soundType, Audio::SoundHandle &handle, int volume);
Audio::Mixer::SoundType soundType, Audio::SoundHandle &handle);
public:
bool _digitized;
int _voices;
@ -103,7 +103,6 @@ public:
*/
void stopSound();
void stopSndFuncPtr(int v1, int v2);
void freeDigiSound();
Audio::SoundHandle getFreeSoundHandle();

View File

@ -81,7 +81,6 @@ int TattooMap::show() {
song = "Cue7";
if (music.loadSong(song)) {
music.setMIDIVolume(music._musicVolume);
if (music._musicOn)
music.startSong();
}

View File

@ -94,7 +94,6 @@ bool TattooScene::loadScene(const Common::String &filename) {
// If it's a new song, then start it up
if (music._currentSongName.compareToIgnoreCase(music._nextSongName)) {
if (music.loadSong(music._nextSongName)) {
music.setMIDIVolume(music._musicVolume);
if (music._musicOn)
music.startSong();
}

View File

@ -112,10 +112,9 @@ void WidgetOptions::handleEvents() {
if (_midiSliderX > _bounds.width() - _surface.widestChar())
_midiSliderX = _bounds.width() - _surface.widestChar();
int temp = music._musicVolume;
music._musicVolume = (_midiSliderX - _surface.widestChar()) * 255 / (_bounds.width() - _surface.widestChar() * 2);
if (music._musicVolume != temp) {
music.setMIDIVolume(music._musicVolume);
int newVolume = (_midiSliderX - _surface.widestChar()) * 255 / (_bounds.width() - _surface.widestChar() * 2);
if (newVolume != music._musicVolume) {
music.setMusicVolume(newVolume);
vm.saveConfig();
}