From: <sv...@op...> - 2024-05-30 21:16:44
|
Author: sagamusix Date: Thu May 30 23:16:31 2024 New Revision: 20870 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20870 Log: [Ref] Turn a few ModChannel/ModChannelSettings members into 8-bit members. Modified: trunk/OpenMPT/libopenmpt/libopenmpt_ext_impl.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/soundlib/Load_itp.cpp trunk/OpenMPT/soundlib/ModChannel.cpp trunk/OpenMPT/soundlib/ModChannel.h trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.cpp Modified: trunk/OpenMPT/libopenmpt/libopenmpt_ext_impl.cpp ============================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_ext_impl.cpp Thu May 30 22:56:07 2024 (r20869) +++ trunk/OpenMPT/libopenmpt/libopenmpt_ext_impl.cpp Thu May 30 23:16:31 2024 (r20870) @@ -183,7 +183,7 @@ if ( volume < 0.0 || volume > 1.0 ) { throw openmpt::exception("invalid global volume"); } - m_sndFile->m_PlayState.Chn[channel].nGlobalVol = mpt::saturate_round<std::int32_t>(volume * 64.0); + m_sndFile->m_PlayState.Chn[channel].nGlobalVol = mpt::saturate_round<std::uint8_t>(volume * 64.0); } double module_ext_impl::get_channel_volume( std::int32_t channel ) const { Modified: trunk/OpenMPT/mptrack/Moddoc.cpp ============================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp Thu May 30 22:56:07 2024 (r20869) +++ trunk/OpenMPT/mptrack/Moddoc.cpp Thu May 30 23:16:31 2024 (r20870) @@ -1472,11 +1472,11 @@ if(nChn >= m_SndFile.GetNumChannels() || nVolume > 64) return false; if(m_SndFile.ChnSettings[nChn].nVolume != nVolume) { - m_SndFile.ChnSettings[nChn].nVolume = nVolume; + m_SndFile.ChnSettings[nChn].nVolume = static_cast<uint8>(nVolume); if(m_SndFile.GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) SetModified(); ok = true; } - m_SndFile.m_PlayState.Chn[nChn].nGlobalVol = nVolume; + m_SndFile.m_PlayState.Chn[nChn].nGlobalVol = static_cast<uint8>(nVolume); return ok; } Modified: trunk/OpenMPT/soundlib/Load_itp.cpp ============================================================================== --- trunk/OpenMPT/soundlib/Load_itp.cpp Thu May 30 22:56:07 2024 (r20869) +++ trunk/OpenMPT/soundlib/Load_itp.cpp Thu May 30 23:16:31 2024 (r20870) @@ -212,7 +212,7 @@ uint32 flags = file.ReadUint32LE(); if(flags & 0x100) ChnSettings[chn].dwFlags.set(CHN_MUTE); if(flags & 0x800) ChnSettings[chn].dwFlags.set(CHN_SURROUND); - ChnSettings[chn].nVolume = std::min(static_cast<uint16>(file.ReadUint32LE()), uint16(64)); + ChnSettings[chn].nVolume = std::min(static_cast<uint8>(file.ReadUint32LE()), uint8(64)); file.ReadString<mpt::String::maybeNullTerminated>(ChnSettings[chn].szName, size); } Modified: trunk/OpenMPT/soundlib/ModChannel.cpp ============================================================================== --- trunk/OpenMPT/soundlib/ModChannel.cpp Thu May 30 22:56:07 2024 (r20869) +++ trunk/OpenMPT/soundlib/ModChannel.cpp Thu May 30 23:16:31 2024 (r20870) @@ -125,9 +125,9 @@ { nInsVol = 64; if(smp != nullptr) - nInsVol = smp->nGlobalVol; + nInsVol = static_cast<uint8>(smp->nGlobalVol); if(ins != nullptr) - nInsVol = (nInsVol * ins->nGlobalVol) / 64; + nInsVol = static_cast<uint8>((nInsVol * ins->nGlobalVol) / 64); } Modified: trunk/OpenMPT/soundlib/ModChannel.h ============================================================================== --- trunk/OpenMPT/soundlib/ModChannel.h Thu May 30 22:56:07 2024 (r20869) +++ trunk/OpenMPT/soundlib/ModChannel.h Thu May 30 23:16:31 2024 (r20870) @@ -98,14 +98,11 @@ int32 cachedPeriod, glissandoPeriod; int32 nCalcVolume; // Calculated channel volume, 14-Bit (without global volume, pre-amp etc applied) - for MIDI macros EnvInfo VolEnv, PanEnv, PitchEnv; // Envelope playback info - int32 nGlobalVol; // Channel volume (CV in ITTECH.TXT) 0...64 - int32 nInsVol; // Sample / Instrument volume (SV * IV in ITTECH.TXT) 0...64 int32 nAutoVibDepth; uint32 nEFxOffset; // Offset memory for Invert Loop (EFx, .MOD only) ROWINDEX nPatternLoop; AutoSlideStatus autoSlide; uint16 portamentoSlide; - int16 nTranspose; int16 nFineTune; int16 microTuning; // Micro-tuning / MIDI pitch wheel command int16 nVolSwing, nPanSwing; @@ -115,6 +112,9 @@ CHANNELINDEX nMasterChn; ModCommand rowCommand; // 8-bit members + uint8 nGlobalVol; // Channel volume (CV in ITTECH.TXT) 0...64 + uint8 nInsVol; // Sample / Instrument volume (SV * IV in ITTECH.TXT) 0...64 + int8 nTranspose; ResamplingMode resamplingMode; uint8 nRestoreResonanceOnNewNote; // See nRestorePanOnNewNote uint8 nRestoreCutoffOnNewNote; // ditto @@ -246,7 +246,7 @@ #endif // MODPLUG_TRACKER FlagSet<ChannelFlags> dwFlags; // Channel flags uint16 nPan = 128; // Initial pan (0...256) - uint16 nVolume = 64; // Initial channel volume (0...64) + uint8 nVolume = 64; // Initial channel volume (0...64) PLUGINDEX nMixPlugin = 0; // Assigned plugin mpt::charbuf<MAX_CHANNELNAME> szName; // Channel name Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp ============================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp Thu May 30 22:56:07 2024 (r20869) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp Thu May 30 23:16:31 2024 (r20870) @@ -888,7 +888,7 @@ else // Up volume += ((param & 0xF0) >> 4) * nonRowTicks; Limit(volume, 0, 64); - chn.nGlobalVol = volume; + chn.nGlobalVol = static_cast<uint8>(volume); } break; case CMD_PANNING8: @@ -3573,7 +3573,7 @@ if(!m_PlayState.m_flags[SONG_FIRSTTICK]) break; if (param <= 64) { - chn.nGlobalVol = param; + chn.nGlobalVol = static_cast<uint8>(param); chn.dwFlags.set(CHN_FASTVOLRAMP); } break; @@ -4812,8 +4812,8 @@ if (nChnSlide) { nChnSlide += chn.nGlobalVol; - nChnSlide = Clamp(nChnSlide, 0, 64); - chn.nGlobalVol = nChnSlide; + Limit(nChnSlide, 0, 64); + chn.nGlobalVol = static_cast<uint8>(nChnSlide); } } Modified: trunk/OpenMPT/soundlib/Sndfile.cpp ============================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp Thu May 30 22:56:07 2024 (r20869) +++ trunk/OpenMPT/soundlib/Sndfile.cpp Thu May 30 23:16:31 2024 (r20870) @@ -585,7 +585,7 @@ const auto muteFlag = GetChannelMuteFlag(); for(CHANNELINDEX chn = 0; chn < MAX_BASECHANNELS; chn++) { - LimitMax(ChnSettings[chn].nVolume, uint16(64)); + LimitMax(ChnSettings[chn].nVolume, uint8(64)); if(ChnSettings[chn].nPan > 256) ChnSettings[chn].nPan = 128; if(ChnSettings[chn].nMixPlugin > MAX_MIXPLUGINS) |