From d556dcc57bf50a03d81ab7a1ef59a9e5758465bf Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Fri, 16 Jun 2017 16:32:16 -0500 Subject: SCI: Switch SCI2 games to use Audio32 Upon investigation of Sound code across SCI32 games, it was determined that there are actually (at least) 3 different revisions, not just a single SCI2.1 version. This patch only changes the parts of Sound code that are relevant to the correct use of Audio32. Fixes Trac#9736, Trac#9756, Trac#9767, Trac#9791. --- engines/sci/sound/audio32.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'engines/sci/sound/audio32.cpp') diff --git a/engines/sci/sound/audio32.cpp b/engines/sci/sound/audio32.cpp index 5e75095e5a..cfbab8b055 100644 --- a/engines/sci/sound/audio32.cpp +++ b/engines/sci/sound/audio32.cpp @@ -114,7 +114,9 @@ Audio32::Audio32(ResourceManager *resMan) : _monitoredBufferSize(0), _numMonitoredSamples(0) { - if (getSciVersion() < SCI_VERSION_3) { + if (getSciVersion() < SCI_VERSION_2_1_EARLY) { + _channels.resize(10); + } else if (getSciVersion() < SCI_VERSION_3) { _channels.resize(5); } else { _channels.resize(8); @@ -311,7 +313,22 @@ int Audio32::readBuffer(Audio::st_sample_t *const buffer, const int numSamples) Audio::st_volume_t leftVolume, rightVolume; if (channel.pan == -1 || !isStereo()) { - leftVolume = rightVolume = channel.volume * Audio::Mixer::kMaxChannelVolume / kMaxVolume; + int volume = channel.volume; + if (getSciVersion() == SCI_VERSION_2) { + // NOTE: In SSCI, audio is decompressed into a temporary + // buffer, then the samples in that buffer are looped over, + // shifting each sample right 3, 2, or 1 bits to reduce the + // volume. + if (volume > 0 && volume <= 42) { + volume = 15; + } else if (volume > 42 && volume <= 84) { + volume = 31; + } else if (volume > 84 && volume < kMaxVolume) { + volume = 63; + } + } + + leftVolume = rightVolume = volume * Audio::Mixer::kMaxChannelVolume / kMaxVolume; } else { // TODO: This should match the SCI3 algorithm, // which seems to halve the volume of each -- cgit v1.2.3