From: <sag...@us...> - 2012-04-18 22:26:07
|
Revision: 1248 http://modplug.svn.sourceforge.net/modplug/?rev=1248&view=rev Author: saga-games Date: 2012-04-18 22:26:00 +0000 (Wed, 18 Apr 2012) Log Message: ----------- [Fix] WAV Loading / Writing didn't consider word padding since... forever. Not it should work as intended (and still load old broken samples). [Mod] Updated list of file extensions to display in tree view and to scan for in archives. By default, all known module types are now shown in the treeview, not only when "Show All Files" is active. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/soundlib/Sampleio.cpp trunk/OpenMPT/soundlib/Sndfile.cpp Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp 2012-04-13 22:44:17 UTC (rev 1247) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2012-04-18 22:26:00 UTC (rev 1248) @@ -1157,6 +1157,15 @@ CMainFrame::UpdateAudioParameters(TRUE); // Success + + if((wdh.length % 2) != 0) + { + // Write padding byte if sample size is odd. + int8 padding = 0; + fwrite(&padding, 1, 1, f); + wfh.filesize++; + } + if (bSaveWave) { if (m_bSaveInfoField) Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2012-04-13 22:44:17 UTC (rev 1247) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2012-04-18 22:26:00 UTC (rev 1248) @@ -1702,44 +1702,42 @@ } } else // Songs - if ((!lstrcmpi(s, ".mod")) - || (!lstrcmpi(s, ".s3m")) - || (!lstrcmpi(s, ".xm")) - || (!lstrcmpi(s, ".it")) - || (!lstrcmpi(s, ".mptm")) -// -> CODE#0023 -// -> DESC="IT project files (.itp)" -// || (!lstrcmpi(s, ".itp")) ericus 03/03/2005 : temporarily deactivated 03/03/2005 -// -! NEW_FEATURE#0023 - || ((m_bShowAllFiles) - && ((!lstrcmpi(s, ".mdz")) - || (!lstrcmpi(s, ".s3z")) - || (!lstrcmpi(s, ".xmz")) - || (!lstrcmpi(s, ".itz")) - || (!lstrcmpi(s, ".669")) - || (!lstrcmpi(s, ".ams")) - || (!lstrcmpi(s, ".amf")) - || (!lstrcmpi(s, ".mdz")) - || (!lstrcmpi(s, ".dsm")) - || (!lstrcmpi(s, ".far")) - || (!lstrcmpi(s, ".mdl")) - || (!lstrcmpi(s, ".mtm")) - || (!lstrcmpi(s, ".nst")) - || (!lstrcmpi(s, ".okt")) - || (!lstrcmpi(s, ".stm")) - || (!lstrcmpi(s, ".ult")) - || (!lstrcmpi(s, ".psm")) - || (!lstrcmpi(s, ".dmf")) - || (!lstrcmpi(s, ".mt2")) - || (!lstrcmpi(s, ".med")) - || (!lstrcmpi(s, ".wow")) - || (!lstrcmpi(s, ".gdm")) - || (!lstrcmpi(s, ".imf")) - || (!lstrcmpi(s, ".j2b")) + if(!lstrcmpi(s, ".mod") + || !lstrcmpi(s, ".s3m") + || !lstrcmpi(s, ".xm") + || !lstrcmpi(s, ".it") + || !lstrcmpi(s, ".mptm") + || !lstrcmpi(s, ".itp") + || !lstrcmpi(s, ".mdz") + || !lstrcmpi(s, ".s3z") + || !lstrcmpi(s, ".xmz") + || !lstrcmpi(s, ".itz") + || !lstrcmpi(s, ".669") + || !lstrcmpi(s, ".ams") + || !lstrcmpi(s, ".amf") + || !lstrcmpi(s, ".mdz") + || !lstrcmpi(s, ".dsm") + || !lstrcmpi(s, ".far") + || !lstrcmpi(s, ".mdl") + || !lstrcmpi(s, ".mtm") + || !lstrcmpi(s, ".nst") + || !lstrcmpi(s, ".okt") + || !lstrcmpi(s, ".stm") + || !lstrcmpi(s, ".ult") + || !lstrcmpi(s, ".psm") + || !lstrcmpi(s, ".dmf") + || !lstrcmpi(s, ".mt2") + || !lstrcmpi(s, ".med") + || !lstrcmpi(s, ".wow") + || !lstrcmpi(s, ".gdm") + || !lstrcmpi(s, ".imf") + || !lstrcmpi(s, ".j2b") + || !lstrcmpi(s, ".umx") + || !lstrcmpi(s, ".uax") #ifndef NO_MO3_SUPPORT - || (!lstrcmpi(s, ".mo3")) -#endif - ))) + || !lstrcmpi(s, ".mo3") +#endif // NO_MO3_SUPPORT + ) { if (m_pDataTree) { @@ -1748,34 +1746,34 @@ } } else // Samples - if ((!lstrcmpi(s, ".wav")) - || (!lstrcmpi(s, ".smp")) - || (!lstrcmpi(s, ".raw")) - || (!lstrcmpi(s, ".s3i")) - || (!lstrcmpi(s, ".its")) - || (!lstrcmpi(s, ".aif")) - || (!lstrcmpi(s, ".aiff")) - || (!lstrcmpi(s, ".snd")) - || (!lstrcmpi(s, ".svx")) - || (!lstrcmpi(s, ".voc")) - || (!lstrcmpi(s, ".8sv")) - || (!lstrcmpi(s, ".8svx")) - || (!lstrcmpi(s, ".16sv")) - || (!lstrcmpi(s, ".16svx")) - || ((m_bShowAllFiles) // Exclude the extensions below - && (lstrcmpi(s, ".txt")) - && (lstrcmpi(s, ".diz")) - && (lstrcmpi(s, ".nfo")) - && (lstrcmpi(s, ".doc")) - && (lstrcmpi(s, ".ini")) - && (lstrcmpi(s, ".pdf")) - && (lstrcmpi(s, ".zip")) - && (lstrcmpi(s, ".rar")) - && (lstrcmpi(s, ".lha")) - && (lstrcmpi(s, ".exe")) - && (lstrcmpi(s, ".dll")) - && (lstrcmpi(s, ".mol"))) - ) + if(!lstrcmpi(s, ".wav") + || !lstrcmpi(s, ".smp") + || !lstrcmpi(s, ".raw") + || !lstrcmpi(s, ".s3i") + || !lstrcmpi(s, ".its") + || !lstrcmpi(s, ".aif") + || !lstrcmpi(s, ".aiff") + || !lstrcmpi(s, ".snd") + || !lstrcmpi(s, ".svx") + || !lstrcmpi(s, ".voc") + || !lstrcmpi(s, ".8sv") + || !lstrcmpi(s, ".8svx") + || !lstrcmpi(s, ".16sv") + || !lstrcmpi(s, ".16svx") + || (m_bShowAllFiles // Exclude the extensions below + && lstrcmpi(s, ".txt") + && lstrcmpi(s, ".diz") + && lstrcmpi(s, ".nfo") + && lstrcmpi(s, ".doc") + && lstrcmpi(s, ".ini") + && lstrcmpi(s, ".pdf") + && lstrcmpi(s, ".zip") + && lstrcmpi(s, ".rar") + && lstrcmpi(s, ".lha") + && lstrcmpi(s, ".exe") + && lstrcmpi(s, ".dll") + && lstrcmpi(s, ".mol")) + ) { if (!m_pDataTree) { Modified: trunk/OpenMPT/soundlib/Sampleio.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sampleio.cpp 2012-04-13 22:44:17 UTC (rev 1247) +++ trunk/OpenMPT/soundlib/Sampleio.cpp 2012-04-18 22:26:00 UTC (rev 1248) @@ -393,6 +393,19 @@ break; } dwMemPos += dwLen + 8; + + if((dwLen % 2) != 0 && dwMemPos < dwFileLength) + { + // Ignore the padding byte. Problem: Old versions of OpenMPT didn't write padding. -_- + // We will just do a heuristic check here: As OpenMPT always writes the "smpl" chunk after the "data" chunk + // (which happens to be the only chunk that has to be padded in OpenMPT's case), we just check if we can read "smpl" + // without incrementing the position. + if((dwMemPos + 8 < dwFileLength) && LittleEndian(*reinterpret_cast<uint32 *>(lpMemFile + dwMemPos)) == 0x6C706D73) + { + continue; + } + dwMemPos++; + } } if (!pdata || !pfmt || pdata->length < 4) return false; @@ -655,6 +668,11 @@ } header.filesize += data.length; + if((data.length % 2) != 0) + { + // Write padding byte if sample size is odd. + header.filesize++; + } // "smpl" field smpl.wsiHdr.smpl_id = LittleEndian(IFFID_smpl); @@ -688,6 +706,12 @@ fwrite(&format, 1, sizeof(format), f); fwrite(&data, 1, sizeof(data), f); WriteSample(f, &sample, nType); + if((data.length % 2) != 0) + { + // Write padding byte if sample size is odd. + int8 padding = 0; + fwrite(&padding, 1, 1, f); + } fwrite(&smpl, 1, smpl.wsiHdr.smpl_len + 8, f); // "LIST" field Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2012-04-13 22:44:17 UTC (rev 1247) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2012-04-18 22:26:00 UTC (rev 1248) @@ -35,7 +35,7 @@ #define UNLHA_SUPPORT #define UNGZIP_SUPPORT #define ZIPPED_MOD_SUPPORT -LPCSTR glpszModExtensions = "mod|s3m|xm|it|stm|nst|ult|669|wow|mtm|med|far|mdl|ams|dsm|amf|okt|dmf|ptm|psm|mt2|umx|gdm|imf|j2b" +LPCSTR glpszModExtensions = "mod|s3m|xm|it|itp|mptm|stm|nst|ult|669|wow|mtm|med|far|mdl|ams|dsm|amf|okt|dmf|ptm|psm|mt2|umx|uax|gdm|imf|j2b" #ifndef NO_UNMO3_SUPPORT "|mo3" #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |