From: <sag...@us...> - 2011-06-24 13:00:38
|
Revision: 905 http://modplug.svn.sourceforge.net/modplug/?rev=905&view=rev Author: saga-games Date: 2011-06-24 13:00:31 +0000 (Fri, 24 Jun 2011) Log Message: ----------- [Imp] Added TBPM (Song beats per minute) frame to ID3v2 tags (doesn't change the fact that the mp3 writer still stack overflows, though) [Ref] Little refactoring here and there. Modified Paths: -------------- trunk/OpenMPT/mptrack/Draw_pat.cpp trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/tagging.cpp trunk/OpenMPT/mptrack/tagging.h trunk/OpenMPT/mptrack/test/test.cpp trunk/OpenMPT/soundlib/Load_itp.cpp Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Draw_pat.cpp 2011-06-23 14:46:38 UTC (rev 904) +++ trunk/OpenMPT/mptrack/Draw_pat.cpp 2011-06-24 13:00:31 UTC (rev 905) @@ -211,10 +211,10 @@ POINT pt; int xofs = GetXScrollPos(); int yofs = GetYScrollPos(); - pt.x = (((dwPos >> 3) & 0xFF) - xofs) * GetColumnWidth(); - UINT imax = (dwPos & 7); - if (imax > 5) imax = 5; - if (imax > m_nDetailLevel+1) imax = m_nDetailLevel+1; + pt.x = (GetChanFromCursor(dwPos) - xofs) * GetColumnWidth(); + UINT imax = GetColTypeFromCursor(dwPos); + if (imax > LAST_COLUMN + 1) imax = LAST_COLUMN + 1; + if (imax > m_nDetailLevel + 1) imax = m_nDetailLevel + 1; for (UINT i=0; i<imax; i++) { pt.x += pfnt->nEltWidths[i]; Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp 2011-06-23 14:46:38 UTC (rev 904) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2011-06-24 13:00:31 UTC (rev 905) @@ -123,7 +123,7 @@ SetDlgItemInt(IDC_EDIT4, m_nMaxOrder); - for (UINT i=0; i<NUMMIXRATE; i++) + for (size_t i = 0; i < CountOf(nMixingRates); i++) { UINT n = nMixingRates[i]; wsprintf(s, "%d Hz", n); @@ -531,7 +531,7 @@ void CLayer3Convert::OnOK() //------------------------- { - CHAR sText[256] = {0}; + CHAR sText[256] = ""; if (m_dwFileLimit) m_dwFileLimit = GetDlgItemInt(IDC_EDIT1, NULL, FALSE); if (m_dwSongLimit) m_dwSongLimit = GetDlgItemInt(IDC_EDIT2, NULL, FALSE); @@ -581,6 +581,9 @@ m_FileTags.comments = ""; } + wsprintf(sText, "%d", (int)m_pSndFile->GetCurrentBPM()); + m_FileTags.bpm = sText; + CDialog::OnOK(); } @@ -983,7 +986,7 @@ _splitpath(m_lpszFileName, NULL, NULL, NULL, fext); if (((m_bSaveInfoField) && (m_pwfx->wFormatTag != WAVE_FORMAT_MPEGLAYER3)) || (!lstrcmpi(fext, ".wav"))) bSaveWave = TRUE; - memset(&wfxSrc, 0, sizeof(wfxSrc)); + MemsetZero(wfxSrc); wfxSrc.wFormatTag = WAVE_FORMAT_PCM; wfxSrc.nSamplesPerSec = m_pwfx->nSamplesPerSec; if (wfxSrc.nSamplesPerSec < 11025) wfxSrc.nSamplesPerSec = 11025; @@ -1001,7 +1004,7 @@ pcmBuffer = (LPBYTE)GlobalAllocPtr(GHND, WAVECONVERTBUFSIZE); dstBuffer = (LPBYTE)GlobalAllocPtr(GHND, dwDstBufSize); if ((!dstBuffer) || (!pcmBuffer)) goto OnError; - memset(&ash, 0, sizeof(ash)); + MemsetZero(ash); ash.cbStruct = sizeof(ash); ash.pbSrc = pcmBuffer; ash.cbSrcLength = WAVECONVERTBUFSIZE; @@ -1010,7 +1013,8 @@ if (theApp.AcmStreamPrepareHeader(has, &ash, 0L) != MMSYSERR_NOERROR) goto OnError; bPrepared = TRUE; // Creating the output file - if ((f = fopen(m_lpszFileName, "wb")) == NULL) { + if ((f = fopen(m_lpszFileName, "wb")) == NULL) + { ::AfxMessageBox("Could not open file for writing. Is it open in another application?"); goto OnError; } @@ -1158,7 +1162,7 @@ fseek(f, data_ofs, SEEK_SET); fwrite(&wdh, 1, sizeof(wdh), f); } - } else + } fclose(f); if (!m_bAbort) retval = IDOK; OnError: Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2011-06-23 14:46:38 UTC (rev 904) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2011-06-24 13:00:31 UTC (rev 905) @@ -65,8 +65,8 @@ if (pPluginManager) { pPluginManager->AddPlugin(lpszPathName); + return NULL; } - return NULL; } } @@ -1614,6 +1614,8 @@ "http://www.hermannseib.com/english/vsthost.htm|" "Ian Luck for UNMO3|" "http://www.un4seen.com/mo3.html|" + "Jean-loup Gailly and Mark Adler for zlib|" + "http://zlib.net/|" "coda for sample drawing code|" "http://coda.s3m.us/|" "Storlek for all the IT compatibility hints and testcases|" @@ -1626,10 +1628,10 @@ "|The people at ModPlug forums for crucial contribution|" "in the form of ideas, testing and support; thanks|" "particularly to:|" - "LPChip, Ganja, Diamond, Nofold, Goor00, Georg|" - "Skilletaudio, Squirrel Havoc, Snu, Anboi|" - "Sam Zen, BooT-SectoR-ViruZ, 33, Waxhead|" - "KrazyKatz, Bvanoudtshoorn, Skaven|" + "33, Anboi, BooT-SectoR-ViruZ, Bvanoudtshoorn|" + "christofori, Diamond, Ganja, Georg, Goor00|" + "KrazyKatz, LPChip, Nofold, Rakib, Sam Zen|" + "Skaven, Skilletaudio, Snu, Squirrel Havoc, Waxhead|" "|||||||" "VST PlugIn Technology by Steinberg Media Technologies GmbH|" "ASIO Technology by Steinberg Media Technologies GmbH|" Modified: trunk/OpenMPT/mptrack/tagging.cpp =================================================================== --- trunk/OpenMPT/mptrack/tagging.cpp 2011-06-23 14:46:38 UTC (rev 904) +++ trunk/OpenMPT/mptrack/tagging.cpp 2011-06-24 13:00:31 UTC (rev 905) @@ -67,6 +67,7 @@ WriteID3v2Frame("WXXX", url, f); WriteID3v2Frame("TENC", encoder, f); WriteID3v2Frame("COMM", comments, f); + WriteID3v2Frame("TBPM", bpm, f); // Write Padding for(size_t i = 0; i < ID3v2_PADDING; i++) Modified: trunk/OpenMPT/mptrack/tagging.h =================================================================== --- trunk/OpenMPT/mptrack/tagging.h 2011-06-23 14:46:38 UTC (rev 904) +++ trunk/OpenMPT/mptrack/tagging.h 2011-06-24 13:00:31 UTC (rev 905) @@ -100,7 +100,7 @@ void WriteWaveTags(WAVEDATAHEADER *wdh, WAVEFILEHEADER *wfh, FILE *f); // Tag data - string title, artist, album, year, comments, genre, url, encoder; + string title, artist, album, year, comments, genre, url, encoder, bpm; CFileTagging(); Modified: trunk/OpenMPT/mptrack/test/test.cpp =================================================================== --- trunk/OpenMPT/mptrack/test/test.cpp 2011-06-23 14:46:38 UTC (rev 904) +++ trunk/OpenMPT/mptrack/test/test.cpp 2011-06-24 13:00:31 UTC (rev 905) @@ -421,8 +421,8 @@ TestLoadFile(pModDoc); // Test file saving - theFile += ".saved"; - pModDoc->GetSoundFile()->SaveIT(theFile); + theFile.Replace(".mptm", ".saved.mptm"); + pModDoc->DoSave(theFile); pModDoc->OnCloseDocument(); // Reload the saved file and test if everything is still working correctly. Modified: trunk/OpenMPT/soundlib/Load_itp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_itp.cpp 2011-06-23 14:46:38 UTC (rev 904) +++ trunk/OpenMPT/soundlib/Load_itp.cpp 2011-06-24 13:00:31 UTC (rev 905) @@ -60,10 +60,11 @@ // name string ASSERT_CAN_READ(len); - if (len<=sizeof(m_szNames[0])) { + if (len<=sizeof(m_szNames[0])) + { memcpy(m_szNames[0],lpStream+dwMemPos,len); dwMemPos += len; - m_szNames[0][sizeof(m_szNames[0])-1] = '\0'; + SetNullTerminator(m_szNames[0]); } else return false; @@ -330,7 +331,7 @@ dwMemPos += sizeof(DWORD); if(dwMemPos >= dwMemLength || len > dwMemLength - dwMemPos) return false; - // Copy sample struct data + // Copy sample struct data (ut-oh... this code looks very familiar!) if(pis.id == LittleEndian(IT_IMPS)) { MODSAMPLE *pSmp = &Samples[nsmp]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |