Author: sagamusix
Date: Sat Jun 8 23:25:51 2024
New Revision: 20978
URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20978
Log:
Merged revision(s) 20957 from trunk/OpenMPT:
[Fix] DTM: Finetune needs to be handled separately for correct period calculation. Fixes the slides in AMAI.DTM by Yerzmyey (libopenmpt only).
........
Modified:
branches/OpenMPT-1.30/ (props changed)
branches/OpenMPT-1.30/soundlib/Load_dtm.cpp
branches/OpenMPT-1.30/soundlib/Snd_fx.cpp
Modified: branches/OpenMPT-1.30/soundlib/Load_dtm.cpp
==============================================================================
--- branches/OpenMPT-1.30/soundlib/Load_dtm.cpp Sat Jun 8 23:25:08 2024 (r20977)
+++ branches/OpenMPT-1.30/soundlib/Load_dtm.cpp Sat Jun 8 23:25:51 2024 (r20978)
@@ -97,7 +97,12 @@
// In revolution to come.dtm, the file header says samples rate is 24512 Hz, but samples say it's 50000 Hz
// Digital Home Studio ignores the header setting in 2.04-/2.06-style modules
mptSmp.nC5Speed = (formatVersion == DTM_PT_PATTERN_FORMAT && forcedSampleRate > 0) ? forcedSampleRate : sampleRate;
- int32 transposeAmount = MOD2XMFineTune(finetune);
+ int32 transposeAmount = 0;
+#ifdef MODPLUG_TRACKER
+ transposeAmount = MOD2XMFineTune(finetune);
+#else
+ mptSmp.nFineTune = MOD2XMFineTune(finetune);
+#endif
if(formatVersion == DTM_206_PATTERN_FORMAT && transpose > 0 && transpose != 48)
{
// Digital Home Studio applies this unconditionally, but some old songs sound wrong then (delirium.dtm).
@@ -437,26 +442,18 @@
{
m->note = note + NOTE_MIN + 12;
if(position.rem)
- {
- m->command = CMD_MODCMDEX;
- m->param = 0xD0 | static_cast<ModCommand::PARAM>(std::min(position.rem, 15));
- }
+ m->SetEffectCommand(CMD_MODCMDEX, static_cast<ModCommand::PARAM>(0xD0 | std::min(position.rem, 15)));
} else if(note & 0x80)
{
// Lower 7 bits contain note, probably intended for MIDI-like note-on/note-off events
if(position.rem)
- {
- m->command = CMD_MODCMDEX;
- m->param = 0xC0 | static_cast<ModCommand::PARAM>(std::min(position.rem, 15));
- } else
- {
+ m->SetEffectCommand(CMD_MODCMDEX, static_cast<ModCommand::PARAM>(0xC0 |std::min(position.rem, 15)));
+ else
m->note = NOTE_NOTECUT;
- }
}
if(volume)
{
- m->volcmd = VOLCMD_VOLUME;
- m->vol = std::min(volume, uint8(64)); // Volume can go up to 255, but we do not support over-amplification at the moment.
+ m->SetVolumeCommand(VOLCMD_VOLUME, std::min(volume, uint8(64))); // Volume can go up to 255, but we do not support over-amplification at the moment.
}
if(instr)
{
Modified: branches/OpenMPT-1.30/soundlib/Snd_fx.cpp
==============================================================================
--- branches/OpenMPT-1.30/soundlib/Snd_fx.cpp Sat Jun 8 23:25:08 2024 (r20977)
+++ branches/OpenMPT-1.30/soundlib/Snd_fx.cpp Sat Jun 8 23:25:51 2024 (r20978)
@@ -5990,11 +5990,16 @@
note -= NOTE_MIN;
if(!UseFinetuneAndTranspose())
{
- if(GetType() & (MOD_TYPE_MDL | MOD_TYPE_DTM))
+ if(GetType() == MOD_TYPE_MDL)
{
// MDL uses non-linear slides, but their effectiveness does not depend on the middle-C frequency.
MPT_ASSERT(!PeriodsAreFrequencies());
return (FreqS3MTable[note % 12u] << 4) >> (note / 12);
+ } else if(GetType() == MOD_TYPE_DTM)
+ {
+ // Similar to MDL, but finetune is factored in and we don't transpose everything by an octave
+ MPT_ASSERT(!PeriodsAreFrequencies());
+ return (ProTrackerTunedPeriods[XM2MODFineTune(nFineTune) * 12u + note % 12u] << 5) >> (note / 12u);
}
if(!nC5Speed)
nC5Speed = 8363;
@@ -6110,7 +6115,7 @@
{
// We only really use c5speed for the finetune pattern command. All samples in 669 files have the same middle-C speed (imported as 8363 Hz).
return (period + c5speed - 8363) << FREQ_FRACBITS;
- } else if(GetType() & (MOD_TYPE_MDL | MOD_TYPE_DTM))
+ } else if(GetType() == MOD_TYPE_MDL)
{
MPT_ASSERT(!PeriodsAreFrequencies());
LimitMax(period, Util::MaxValueOfType(period) >> 8);
@@ -6124,7 +6129,7 @@
// Input is already a frequency in Hertz, not a period.
static_assert(FREQ_FRACBITS <= 8, "Check this shift operator");
return uint32(((uint64(period) << 8) + nPeriodFrac) >> (8 - FREQ_FRACBITS));
- } else if(m_SongFlags[SONG_LINEARSLIDES])
+ } else if(m_SongFlags[SONG_LINEARSLIDES] || GetType() == MOD_TYPE_DTM)
{
if(!c5speed)
c5speed = 8363;
|