diff --git a/soundlib/Load_dtm.cpp b/soundlib/Load_dtm.cpp index 065d1368f98..bec918f0fd3 100644 --- a/soundlib/Load_dtm.cpp +++ b/soundlib/Load_dtm.cpp @@ -97,7 +97,12 @@ struct DTMSample // 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 @@ bool CSoundFile::ReadDTM(FileReader &file, ModLoadingFlags loadFlags) { m->note = note + NOTE_MIN + 12; if(position.rem) - { - m->command = CMD_MODCMDEX; - m->param = 0xD0 | static_cast(std::min(position.rem, 15)); - } + m->SetEffectCommand(CMD_MODCMDEX, static_cast(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(std::min(position.rem, 15)); - } else - { + m->SetEffectCommand(CMD_MODCMDEX, static_cast(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) { diff --git a/soundlib/Snd_fx.cpp b/soundlib/Snd_fx.cpp index 90ca9a260df..ad7284d9821 100644 --- a/soundlib/Snd_fx.cpp +++ b/soundlib/Snd_fx.cpp @@ -5990,11 +5990,16 @@ uint32 CSoundFile::GetPeriodFromNote(uint32 note, int32 nFineTune, uint32 nC5Spe 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 @@ uint32 CSoundFile::GetFreqFromPeriod(uint32 period, uint32 c5speed, int32 nPerio { // 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 @@ uint32 CSoundFile::GetFreqFromPeriod(uint32 period, uint32 c5speed, int32 nPerio // 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;