From: <sag...@us...> - 2013-07-03 19:56:52
|
Revision: 2483 http://sourceforge.net/p/modplug/code/2483 Author: saga-games Date: 2013-07-03 19:56:44 +0000 (Wed, 03 Jul 2013) Log Message: ----------- [Imp] Import PTM as IT instead of S3M, so that effect memory works more reliably. [Imp] Handle PTM command 8xx (panning) more correctly [Imp] Pattern Editor: Also show name of unsupported commands in status text [Ref] Unify CSoundFile::GetBestSaveFormat and format conversion in CModDoc::OnOpenDocument [Mod] OpenMPT: Version is now 1.22.03.09 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/mptrack/Draw_pat.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moptions.cpp trunk/OpenMPT/soundlib/Load_ptm.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.cpp Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2013-07-03 18:40:57 UTC (rev 2482) +++ trunk/OpenMPT/common/versionNumber.h 2013-07-03 19:56:44 UTC (rev 2483) @@ -17,7 +17,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 22 #define VER_MINOR 03 -#define VER_MINORMINOR 08 +#define VER_MINORMINOR 09 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR)"."VER_STRINGIZE(VER_MAJOR)"."VER_STRINGIZE(VER_MINOR)"."VER_STRINGIZE(VER_MINORMINOR) Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Draw_pat.cpp 2013-07-03 18:40:57 UTC (rev 2482) +++ trunk/OpenMPT/mptrack/Draw_pat.cpp 2013-07-03 19:56:44 UTC (rev 2483) @@ -1648,7 +1648,7 @@ } else { // "normal" volume command - if (!effectInfo.GetVolCmdInfo(effectInfo.GetIndexFromVolCmd(m->volcmd), s)) s[0] = 0; + effectInfo.GetVolCmdInfo(effectInfo.GetIndexFromVolCmd(m->volcmd), s); } break; @@ -1657,7 +1657,7 @@ // display effect command if(!m->IsPcNote()) { - if (!effectInfo.GetEffectName(s, m->command, m->param, false, nChn)) s[0] = 0; + effectInfo.GetEffectName(s, m->command, m->param, false, nChn); } break; } Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-07-03 18:40:57 UTC (rev 2482) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-07-03 19:56:44 UTC (rev 2483) @@ -379,42 +379,8 @@ case MOD_TYPE_MPT: bModified = FALSE; break; - case MOD_TYPE_AMF0: - case MOD_TYPE_DIGI: - m_SndFile.ChangeModTypeTo(MOD_TYPE_MOD); - break; - case MOD_TYPE_MED: - m_SndFile.ChangeModTypeTo(MOD_TYPE_XM); - if ((m_SndFile.m_nDefaultTempo == 125) && (m_SndFile.m_nDefaultSpeed == 6) && (!m_SndFile.m_nInstruments)) - { - m_SndFile.m_nType = MOD_TYPE_MOD; - for (UINT i=0; i<m_SndFile.Patterns.Size(); i++) - if ((m_SndFile.Patterns[i]) && (m_SndFile.Patterns[i].GetNumRows() != 64)) - m_SndFile.m_nType = MOD_TYPE_XM; - } - break; - case MOD_TYPE_669: - case MOD_TYPE_FAR: - case MOD_TYPE_PTM: - case MOD_TYPE_STM: - case MOD_TYPE_DSM: - case MOD_TYPE_AMF: - case MOD_TYPE_MTM: - m_SndFile.ChangeModTypeTo(MOD_TYPE_S3M); - break; - case MOD_TYPE_AMS: - case MOD_TYPE_AMS2: - case MOD_TYPE_DMF: - case MOD_TYPE_DBM: - case MOD_TYPE_IMF: - case MOD_TYPE_PSM: - case MOD_TYPE_J2B: - case MOD_TYPE_ULT: - case MOD_TYPE_OKT: - case MOD_TYPE_MT2: - case MOD_TYPE_MDL: default: - m_SndFile.ChangeModTypeTo(MOD_TYPE_IT); + m_SndFile.ChangeModTypeTo(m_SndFile.GetBestSaveFormat()); } // -> CODE#0015 @@ -2286,16 +2252,16 @@ switch(m_SndFile.m_nTempoMode) { - case tempo_mode_alternative: + case tempo_mode_alternative: Message.Format("Using alternative tempo interpretation.\n\nAssuming:\n. %d ticks per second\n. %d ticks per row\n. %d rows per beat\nthe tempo is approximately: %.8g BPM", m_SndFile.m_nMusicTempo, m_SndFile.m_nMusicSpeed, m_SndFile.m_nCurrentRowsPerBeat, bpm); break; - case tempo_mode_modern: + case tempo_mode_modern: Message.Format("Using modern tempo interpretation.\n\nThe tempo is: %.8g BPM", bpm); break; - case tempo_mode_classic: + case tempo_mode_classic: default: Message.Format("Using standard tempo interpretation.\n\nAssuming:\n. A mod tempo (tick duration factor) of %d\n. %d ticks per row\n. %d rows per beat\nthe tempo is approximately: %.8g BPM", m_SndFile.m_nMusicTempo, m_SndFile.m_nMusicSpeed, m_SndFile.m_nCurrentRowsPerBeat, bpm); Modified: trunk/OpenMPT/mptrack/Moptions.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moptions.cpp 2013-07-03 18:40:57 UTC (rev 2482) +++ trunk/OpenMPT/mptrack/Moptions.cpp 2013-07-03 19:56:44 UTC (rev 2483) @@ -553,7 +553,7 @@ {PATTERN_FLATBUTTONS, "Flat Buttons", "Use flat buttons in toolbars"}, {PATTERN_SINGLEEXPAND, "Single click to expand tree", "Single-clicking in the left tree view will expand a node."}, {PATTERN_MUTECHNMODE, "Ignored muted channels", "Notes will not be played on muted channels (unmuting will only start on a new note)."}, - {PATTERN_NOEXTRALOUD, "No loud sample preview", "Disable loud playback of samples in the sample/instrument editor. Sample volume depends on the sample volume slider on the general tab when activated (if disabled, a sample volume of 256 is used)."}, + {PATTERN_NOEXTRALOUD, "No loud sample preview", "Disable loud playback of samples in the sample/instrument editor. Sample volume depends on the sample volume slider on the general tab when activated (if disabled, samples are previewed at 0 dB)."}, {PATTERN_SHOWPREVIOUS, "Show Prev/Next patterns", "Displays grayed-out version of the previous/next patterns in the pattern editor. Does not work if \"always center active row\" is disabled."}, {PATTERN_CONTSCROLL, "Continuous scroll", "Jumps to the next pattern when moving past the end of a pattern"}, {PATTERN_KBDNOTEOFF, "Record note off", "Record note off when a key is released on the PC keyboard."}, @@ -564,7 +564,7 @@ {PATTERN_AUTODELAY, "Automatic delay commands", "Automatically insert appropriate note-delay commands when recording notes during live playback."}, {PATTERN_NOTEFADE, "Note fade on key up", "Enable to fade / stop notes on key up in pattern tab."}, {PATTERN_OVERFLOWPASTE, "Overflow paste mode", "Wrap pasted pattern data into next pattern. This is useful for creating echo channels."}, - {PATTERN_RESETCHANNELS, "Reset channels on loop", "If enabled, channels will be reset to their initial state when song looping is enabled.\nNote: This does not affect manual song loops (i.e. triggered by pattern commands) and is recommended to be enabled."}, + {PATTERN_RESETCHANNELS, "Reset channels on loop", "If enabled, channels will be reset to their initial state when song looping is enabled.\nNote: This does not affect manual song loops (i.e. triggered by pattern commands) and is not recommended to be enabled."}, {PATTERN_LIVEUPDATETREE,"Update sample status in tree", "If enabled, active samples and instruments will be indicated by a different icon in the treeview."}, {PATTERN_NOCLOSEDIALOG, "Disable modern close dialog", "When closing the main window, a confirmation window is shown for every unsaved document instead of one single window with a list of unsaved documents."}, {PATTERN_DBLCLICKSELECT, "Double-click to select channel", "Instead of showing the note properties, double-clicking a pattern cell selects the whole channel."}, Modified: trunk/OpenMPT/soundlib/Load_ptm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_ptm.cpp 2013-07-03 18:40:57 UTC (rev 2482) +++ trunk/OpenMPT/soundlib/Load_ptm.cpp 2013-07-03 19:56:44 UTC (rev 2483) @@ -106,6 +106,8 @@ mptSmp.nLength = length; mptSmp.nLoopStart = loopStart; mptSmp.nLoopEnd = loopEnd; + if(mptSmp.nLoopEnd > mptSmp.nLoopStart) + mptSmp.nLoopEnd--; if(flags & smpLoop) mptSmp.uFlags.set(CHN_LOOP); if(flags & smpPingPong) mptSmp.uFlags.set(CHN_PINGPONGLOOP); @@ -157,6 +159,8 @@ InitializeGlobals(); madeWithTracker = mpt::String::Format("PolyTracker %d.%02x", fileHeader.versionHi, fileHeader.versionLo); m_nType = MOD_TYPE_PTM; + SetModFlag(MSF_COMPATIBLE_PLAY, true); + m_SongFlags = SONG_ITCOMPATGXX | SONG_ITOLDEFFECTS; m_nChannels = fileHeader.numChannels; m_nSamples = std::min<SAMPLEINDEX>(fileHeader.numSamples, MAX_SAMPLES - 1); Order.ReadFromArray(fileHeader.orders, fileHeader.numOrders); @@ -242,6 +246,26 @@ { m.command = CMD_NONE; } + switch(m.command) + { + case CMD_PANNING8: + // My observations of this weird command... + // 800...80F and 880...88F are panned dead centre. + // 810...87F and 890...8FF pan from hard left to hard right. + // A default center panning or using 800 is a bit louder than using 848, for whatever reason. + m.param &= 0x7F; + if(m.param < 0x10) + { + m.param = 0x80; + } else + { + m.param = (m.param - 0x10) * 0xFF / 0x6F; + } + break; + case CMD_GLOBALVOLUME: + m.param = std::min(m.param, uint8(0x40)) * 2u; + break; + } } if(b & 0x80) { Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-07-03 18:40:57 UTC (rev 2482) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-07-03 19:56:44 UTC (rev 2483) @@ -27,6 +27,10 @@ #endif +// Formats which have 7-bit (0...128) instead of 6-bit (0...64) global volume commands, or which are imported to this range (mostly formats which are converted to IT internally) +#define GLOBALVOL_7BIT_FORMATS (MOD_TYPE_IT | MOD_TYPE_MPT | MOD_TYPE_MT2 | MOD_TYPE_IMF | MOD_TYPE_J2B | MOD_TYPE_MID | MOD_TYPE_AMS | MOD_TYPE_AMS2 | MOD_TYPE_DBM | MOD_TYPE_PTM) + + //////////////////////////////////////////////////////////// // Length @@ -466,7 +470,7 @@ // break; // } - if(!(GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT | MOD_TYPE_MT2 | MOD_TYPE_IMF | MOD_TYPE_J2B | MOD_TYPE_MID | MOD_TYPE_AMS | MOD_TYPE_AMS2 | MOD_TYPE_DBM))) param <<= 1; + if(!(GetType() & GLOBALVOL_7BIT_FORMATS)) param <<= 1; // IT compatibility 16. FT2, ST3 and IT ignore out-of-range values if(param <= 128) { @@ -486,25 +490,25 @@ if (((param & 0x0F) == 0x0F) && (param & 0xF0)) { param >>= 4; - if (!(GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT | MOD_TYPE_IMF | MOD_TYPE_J2B | MOD_TYPE_MID | MOD_TYPE_AMS | MOD_TYPE_AMS2 | MOD_TYPE_DBM))) param <<= 1; + if (!(GetType() & GLOBALVOL_7BIT_FORMATS)) param <<= 1; memory.glbVol += param << 1; } else if (((param & 0xF0) == 0xF0) && (param & 0x0F)) { param = (param & 0x0F) << 1; - if (!(GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT | MOD_TYPE_IMF | MOD_TYPE_J2B | MOD_TYPE_MID | MOD_TYPE_AMS | MOD_TYPE_AMS2 | MOD_TYPE_DBM))) param <<= 1; + if (!(GetType() & GLOBALVOL_7BIT_FORMATS)) param <<= 1; memory.glbVol -= param; } else if (param & 0xF0) { param >>= 4; param <<= 1; - if (!(GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT | MOD_TYPE_IMF | MOD_TYPE_J2B | MOD_TYPE_MID | MOD_TYPE_AMS | MOD_TYPE_AMS2 | MOD_TYPE_DBM))) param <<= 1; + if (!(GetType() & GLOBALVOL_7BIT_FORMATS)) param <<= 1; memory.glbVol += param * memory.musicSpeed; } else { param = (param & 0x0F) << 1; - if (!(GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT | MOD_TYPE_IMF | MOD_TYPE_J2B | MOD_TYPE_MID | MOD_TYPE_AMS | MOD_TYPE_AMS2 | MOD_TYPE_DBM))) param <<= 1; + if (!(GetType() & GLOBALVOL_7BIT_FORMATS)) param <<= 1; memory.glbVol -= param * memory.musicSpeed; } memory.glbVol = CLAMP(memory.glbVol, 0, 256); @@ -2388,7 +2392,7 @@ // break; // } - if (!(GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT | MOD_TYPE_MT2 | MOD_TYPE_IMF | MOD_TYPE_J2B | MOD_TYPE_MID | MOD_TYPE_AMS | MOD_TYPE_AMS2 | MOD_TYPE_DBM))) param *= 2; + if (!(GetType() & GLOBALVOL_7BIT_FORMATS)) param *= 2; // IT compatibility 16. FT2, ST3 and IT ignore out-of-range values. // Test case: globalvol-invalid.it @@ -2419,7 +2423,7 @@ { pChn->dwFlags.reset(CHN_SURROUND); } - if(!(GetType() & (MOD_TYPE_S3M | MOD_TYPE_PTM | MOD_TYPE_DSM | MOD_TYPE_AMF | MOD_TYPE_MTM))) + if(!(GetType() & (MOD_TYPE_S3M | MOD_TYPE_DSM | MOD_TYPE_AMF | MOD_TYPE_MTM))) { // Real 8-bit panning pChn->nPan = param; Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-07-03 18:40:57 UTC (rev 2482) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-07-03 19:56:44 UTC (rev 2483) @@ -1334,16 +1334,50 @@ MODTYPE CSoundFile::GetBestSaveFormat() const //------------------------------------------- { - if ((!m_nSamples) || (!m_nChannels) || GetType() == MOD_TYPE_NONE) return MOD_TYPE_NONE; - if (GetType() & (MOD_TYPE_MOD|MOD_TYPE_DIGI)) + switch(GetType()) + { + case MOD_TYPE_MOD: + case MOD_TYPE_S3M: + case MOD_TYPE_XM: + case MOD_TYPE_IT: + case MOD_TYPE_MPT: + return GetType(); + case MOD_TYPE_AMF0: + case MOD_TYPE_DIGI: return MOD_TYPE_MOD; - if (GetType() & (MOD_TYPE_S3M|MOD_TYPE_STM|MOD_TYPE_ULT|MOD_TYPE_FAR|MOD_TYPE_PTM|MOD_TYPE_MTM)) + case MOD_TYPE_MED: + if(m_nDefaultTempo == 125 && m_nDefaultSpeed == 6 && !m_nInstruments) + { + for(PATTERNINDEX i = 0; i < Patterns.Size(); i++) + { + if(Patterns.IsValidPat(i) && Patterns[i].GetNumRows() != 64) + return MOD_TYPE_XM; + } + return MOD_TYPE_MOD; + } + return MOD_TYPE_XM; + case MOD_TYPE_669: + case MOD_TYPE_FAR: + case MOD_TYPE_STM: + case MOD_TYPE_DSM: + case MOD_TYPE_AMF: + case MOD_TYPE_MTM: return MOD_TYPE_S3M; - if (GetType() & (MOD_TYPE_XM|MOD_TYPE_MED/*|MOD_TYPE_MT2*/)) - return MOD_TYPE_XM; - if(GetType() & MOD_TYPE_MPT) - return MOD_TYPE_MPT; - return MOD_TYPE_IT; + case MOD_TYPE_AMS: + case MOD_TYPE_AMS2: + case MOD_TYPE_DMF: + case MOD_TYPE_DBM: + case MOD_TYPE_IMF: + case MOD_TYPE_PSM: + case MOD_TYPE_J2B: + case MOD_TYPE_ULT: + case MOD_TYPE_OKT: + case MOD_TYPE_MT2: + case MOD_TYPE_MDL: + case MOD_TYPE_PTM: + default: + return MOD_TYPE_IT; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |