From: <sag...@us...> - 2014-02-08 22:36:38
|
Revision: 3672 http://sourceforge.net/p/modplug/code/3672 Author: saga-games Date: 2014-02-08 22:36:26 +0000 (Sat, 08 Feb 2014) Log Message: ----------- [Imp] Mod Conversion: When converting to MOD, try to compensate for the lack of sample tranpose by transposing pattern notes. [Fix] Mod Conversion: When converting from XM to MOD, the sample transpose wasn't reset. Modified Paths: -------------- trunk/OpenMPT/mptrack/ModConvert.cpp trunk/OpenMPT/soundlib/ModSample.cpp Modified: trunk/OpenMPT/mptrack/ModConvert.cpp =================================================================== --- trunk/OpenMPT/mptrack/ModConvert.cpp 2014-02-07 18:59:41 UTC (rev 3671) +++ trunk/OpenMPT/mptrack/ModConvert.cpp 2014-02-08 22:36:26 UTC (rev 3672) @@ -171,6 +171,15 @@ ///////////////////////////// // Converting pattern data + // When converting to MOD, get the new sample transpose setting right here so that we can compensate notes in the pattern. + if(newTypeIsMOD && !oldTypeIsXM) + { + for(SAMPLEINDEX smp = 1; smp <= m_SndFile.GetNumSamples(); smp++) + { + m_SndFile.GetSample(smp).FrequencyToTranspose(); + } + } + for(PATTERNINDEX pat = 0; pat < m_SndFile.Patterns.Size(); pat++) if (m_SndFile.Patterns[pat]) { ModCommand *m = m_SndFile.Patterns[pat]; @@ -178,6 +187,7 @@ // This is used for -> MOD/XM conversion std::vector<std::vector<ModCommand::PARAM> > effMemory(GetNumChannels()); std::vector<ModCommand::VOL> volMemory(GetNumChannels(), 0); + std::vector<ModCommand::INSTR> instrMemory(GetNumChannels(), 0); for(size_t i = 0; i < GetNumChannels(); i++) { effMemory[i].resize(MAX_EFFECTS, 0); @@ -195,6 +205,10 @@ row++; } + ModCommand::INSTR instr = m->instr; + if(m->instr) instrMemory[chn] = instr; + else instr = instrMemory[chn]; + // Deal with volume column slide memory (it's not shared with the effect column) if(oldTypeIsIT_MPT && (newTypeIsMOD_XM || newTypeIsS3M)) { @@ -247,6 +261,13 @@ break; } + + // Compensate for loss of transpose information + if(m->IsNote() && instr && instr <= GetNumSamples()) + { + const int newNote = m->note + m_SndFile.GetSample(instr).RelativeTone; + m->note = static_cast<uint8>(Clamp(newNote, specs.noteMin, specs.noteMax)); + } } m->Convert(nOldType, nNewType); Modified: trunk/OpenMPT/soundlib/ModSample.cpp =================================================================== --- trunk/OpenMPT/soundlib/ModSample.cpp 2014-02-07 18:59:41 UTC (rev 3671) +++ trunk/OpenMPT/soundlib/ModSample.cpp 2014-02-08 22:36:26 UTC (rev 3672) @@ -29,21 +29,19 @@ } else if((toType & (MOD_TYPE_MOD | MOD_TYPE_XM)) && (!(fromType & (MOD_TYPE_MOD | MOD_TYPE_XM)))) { FrequencyToTranspose(); - if(toType & MOD_TYPE_MOD) - { - RelativeTone = 0; - } } // No ping-pong loop, panning and auto-vibrato for MOD / S3M samples if(toType & (MOD_TYPE_MOD | MOD_TYPE_S3M)) { - uFlags &= ~(CHN_PINGPONGLOOP | CHN_PANNING); + uFlags.reset(CHN_PINGPONGLOOP | CHN_PANNING); nVibDepth = 0; nVibRate = 0; nVibSweep = 0; nVibType = VIB_SINE; + + RelativeTone = 0; } // No global volume sustain loops for MOD/S3M/XM @@ -51,30 +49,24 @@ { nGlobalVol = 64; // Sustain loops - convert to normal loops - if((uFlags & CHN_SUSTAINLOOP) != 0) + if(uFlags[CHN_SUSTAINLOOP]) { // We probably overwrite a normal loop here, but since sustain loops are evaluated before normal loops, this is just correct. nLoopStart = nSustainStart; nLoopEnd = nSustainEnd; - uFlags |= CHN_LOOP; - if(uFlags & CHN_PINGPONGSUSTAIN) - { - uFlags |= CHN_PINGPONGLOOP; - } else - { - uFlags &= ~CHN_PINGPONGLOOP; - } + uFlags.set(CHN_LOOP); + uFlags.set(CHN_PINGPONGLOOP, uFlags[CHN_PINGPONGSUSTAIN]); } nSustainStart = nSustainEnd = 0; - uFlags &= ~(CHN_SUSTAINLOOP|CHN_PINGPONGSUSTAIN); + uFlags.reset(CHN_SUSTAINLOOP|CHN_PINGPONGSUSTAIN); } // All XM samples have default panning, and XM's autovibrato settings are rather limited. if(toType & MOD_TYPE_XM) { - if(!(uFlags & CHN_PANNING)) + if(!uFlags[CHN_PANNING]) { - uFlags |= CHN_PANNING; + uFlags.set(CHN_PANNING); nPan = 128; } @@ -302,7 +294,7 @@ int ModSample::FrequencyToTranspose(uint32 freq) //---------------------------------------------- { - const float inv_log_2 = 1.44269504089f; // 1.0f/std::log(2.0f) + const float inv_log_2 = 1.44269504089f; // 1.0f/std::log(2.0f) return Util::Round<int>(std::log(freq * (1.0f / 8363.0f)) * (12.0f * 128.0f * inv_log_2)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |