From: <sv...@op...> - 2024-04-26 20:06:22
|
Author: sagamusix Date: Fri Apr 26 22:06:14 2024 New Revision: 20660 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20660 Log: [Fix] S3M: In mono mode, the ratio between sample and OPL volume was incorrect (https://bugs.openmpt.org/view.php?id=1774). Modified: trunk/OpenMPT/soundlib/Load_s3m.cpp Modified: trunk/OpenMPT/soundlib/Load_s3m.cpp ============================================================================== --- trunk/OpenMPT/soundlib/Load_s3m.cpp Fri Apr 26 19:21:20 2024 (r20659) +++ trunk/OpenMPT/soundlib/Load_s3m.cpp Fri Apr 26 22:06:14 2024 (r20660) @@ -435,15 +435,18 @@ else m_nSamplePreAmp = std::max(fileHeader.masterVolume & 0x7F, 0x10); // Bit 7 = Stereo (we always use stereo) - const bool isStereo = (fileHeader.masterVolume & 0x80) != 0 || m_dwLastSavedWithVersion; - if(!isStereo) - m_nSamplePreAmp = Util::muldivr_unsigned(m_nSamplePreAmp, 8, 11); - // Approximately as loud as in DOSBox and a real SoundBlaster 16 m_nVSTiVolume = 36; if(isSchism && schismDateVersion < SchismVersionFromDate<2018, 11, 12>::date) m_nVSTiVolume = 64; + const bool isStereo = (fileHeader.masterVolume & 0x80) != 0 || m_dwLastSavedWithVersion; + if(!isStereo) + { + m_nSamplePreAmp = Util::muldivr_unsigned(m_nSamplePreAmp, 8, 11); + m_nVSTiVolume = Util::muldivr_unsigned(m_nVSTiVolume, 8, 11); + } + // Channel setup m_nChannels = 4; std::bitset<32> isAdlibChannel; @@ -488,8 +491,7 @@ if(fileHeader.usePanningTable == S3MFileHeader::idPanning) { bool hasChannelsWithoutPanning = false; - uint8 pan[32]; - file.ReadArray(pan); + const auto pan = file.ReadArray<uint8, 32>(); for(CHANNELINDEX i = 0; i < 32; i++) { if((pan[i] & 0x20) != 0 && (!isST3 || !isAdlibChannel[i])) @@ -847,7 +849,8 @@ // Write patterns enum class S3MChannelType : uint8 { kUnused = 0, kPCM = 1, kAdlib = 2 }; - FlagSet<S3MChannelType> channelType[32] = { S3MChannelType::kUnused }; + std::array<FlagSet<S3MChannelType>, 32> channelType; + channelType.fill(S3MChannelType::kUnused); bool globalCmdOnMutedChn = false; for(PATTERNINDEX pat = 0; pat < writePatterns; pat++) { |