From: <sag...@us...> - 2009-11-01 16:27:20
|
Revision: 409 http://modplug.svn.sourceforge.net/modplug/?rev=409&view=rev Author: saga-games Date: 2009-11-01 16:27:14 +0000 (Sun, 01 Nov 2009) Log Message: ----------- [Fix] Pitch shift: Was slightly broken for 8-bit samples. [Fix] Sample editor: Time Stretch / Pitch Shift button's caption was not updated properly. [Imp] Sample undo limitation: Slightly improved handling of INI value Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mptrack.cpp Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2009-11-01 13:53:08 UTC (rev 408) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2009-11-01 16:27:14 UTC (rev 409) @@ -306,9 +306,6 @@ // Stretch ratio SetDlgItemInt(IDC_EDIT6,100,FALSE); - // Processing state text label - SetDlgItemText(IDC_STATIC1,""); - // Stretch to size check box OnEnableStretchToSize(); @@ -1686,7 +1683,7 @@ GetDlgItem(IDC_EDIT_STRETCHPARAMS)->ShowWindow(bTimeStretch ? SW_SHOW : SW_HIDE); GetDlgItem(IDC_TEXT_PITCH)->ShowWindow(bTimeStretch ? SW_HIDE : SW_SHOW); GetDlgItem(IDC_COMBO4)->ShowWindow(bTimeStretch ? SW_HIDE : SW_SHOW); - SetDlgItemText(IDC_BUTTON1, "Time Stretch"); + SetDlgItemText(IDC_BUTTON1, bTimeStretch ? "Time Stretch" : "Pitch Shift"); if(bTimeStretch) UpdateTimeStretchParameterString(); } @@ -1700,7 +1697,7 @@ //Ensure m_dTimeStretchRatio is up-to-date with textbox content UpdateData(TRUE); - //Calculate/verify samplerate at C4. + //Calculate/verify samplerate at C5. long lSampleRate = pSmp->nC5Speed; if(m_pSndFile->m_nType & (MOD_TYPE_MOD|MOD_TYPE_XM)) lSampleRate = (double)CSoundFile::TransposeToFrequency(pSmp->RelativeTone, pSmp->nFineTune); @@ -1801,18 +1798,6 @@ const uint32 nSampleRate = pSmp->GetSampleRate(m_pSndFile->GetType()); - // SoundTouch(v1.4.0) documentation says that sample rates 8000-48000 are supported. - // Check whether sample rate is within that range, and if not, - // ask user whether to proceed. - if(nSampleRate < 8000 || nSampleRate > 48000) - { - CString str; - str.Format(TEXT(GetStrI18N("Current samplerate, %u Hz, is not in the supported samplerate range 8000 Hz - 48000 Hz. Continue?")), nSampleRate); - if(AfxMessageBox(str, MB_ICONQUESTION|MB_YESNO) != IDYES) - return -1; - - } - // SoundTouch(1.3.1) seems to crash with short samples. Don't know what // the actual limit or whether it depends on sample rate, // but simply set some semiarbitrary threshold here. @@ -1850,6 +1835,18 @@ smpsize = pSmp->GetElementarySampleSize(); } + // SoundTouch(v1.4.0) documentation says that sample rates 8000-48000 are supported. + // Check whether sample rate is within that range, and if not, + // ask user whether to proceed. + if(nSampleRate < 8000 || nSampleRate > 48000) + { + CString str; + str.Format(TEXT(GetStrI18N("Current samplerate, %u Hz, is not in the supported samplerate range 8000 Hz - 48000 Hz. Continue?")), nSampleRate); + if(AfxMessageBox(str, MB_ICONQUESTION|MB_YESNO) != IDYES) + return -1; + + } + // Allocate new sample. Returned sample may not be exactly the size what ratio would suggest // so allocate a bit more(1.03*). const DWORD nNewSampleLength = (DWORD)(1.03 * ratio * (double)pSmp->nLength); @@ -1881,7 +1878,6 @@ // Show wait mouse cursor BeginWaitCursor(); - SetDlgItemText(IDC_STATIC1, "Stretching..."); UINT pos = 0; UINT len = 0; //To contain length of processing step. @@ -1981,7 +1977,6 @@ SetDlgItemText(IDC_BUTTON1, oldText); // Restore mouse cursor - SetDlgItemText(IDC_STATIC1,""); EndWaitCursor(); return 0; @@ -2011,14 +2006,6 @@ UINT fft = 1 << (combo->GetCurSel() + 8); while(fft > MAX_BUFFER_LENGTH) fft >>= 1; - // Get original sample rate - long lSampleRate = pSmp->nC5Speed; - if(m_pSndFile->m_nType & (MOD_TYPE_MOD|MOD_TYPE_XM)) lSampleRate = CSoundFile::TransposeToFrequency(pSmp->RelativeTone, pSmp->nFineTune); - if(lSampleRate <= 0) lSampleRate = 8363; - - // Deduce max sample value (float conversion step) - float maxSampleValue = ( 1 << (smpsize * 8 - 1) ) - 1; - // Save process button text (to be used as "progress bar" indicator while processing) CHAR oldText[255]; GetDlgItemText(IDC_BUTTON1, oldText, 255); @@ -2039,7 +2026,6 @@ // Show wait mouse cursor BeginWaitCursor(); - SetDlgItemText(IDC_STATIC1,"Pitch shifting..."); // PitchShift seems to work only with 16-bit samples. @@ -2050,6 +2036,12 @@ smpsize = pSmp->GetElementarySampleSize(); } + // Get original sample rate + long lSampleRate = pSmp->GetSampleRate(m_pSndFile->GetType()); + + // Deduce max sample value (float conversion step) + float maxSampleValue = ( 1 << (smpsize * 8 - 1) ) - 1; + // Allocate working buffers float * buffer = new float[MAX_BUFFER_LENGTH + fft]; float * outbuf = new float[MAX_BUFFER_LENGTH + fft]; @@ -2159,7 +2151,6 @@ SetDlgItemText(IDC_BUTTON1, oldText); // Restore mouse cursor - SetDlgItemText(IDC_STATIC1,""); EndWaitCursor(); return 0; Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2009-11-01 13:53:08 UTC (rev 408) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2009-11-01 16:27:14 UTC (rev 409) @@ -204,7 +204,7 @@ | PATTERN_SHOWPREVIOUS | PATTERN_CONTSCROLL | PATTERN_SYNCMUTE | PATTERN_AUTODELAY | PATTERN_NOTEFADE; DWORD CMainFrame::m_nRowSpacing = 16; DWORD CMainFrame::m_nRowSpacing2 = 4; -UINT CMainFrame::m_nSampleUndoMaxBuffer = 100; +UINT CMainFrame::m_nSampleUndoMaxBuffer = 100 << 20; // GDI HICON CMainFrame::m_hIcon = NULL; @@ -444,7 +444,8 @@ CSoundFile::s_DefaultPlugVolumeHandling = static_cast<uint8>(GetPrivateProfileInt("Misc", "DefaultPlugVolumeHandling", PLUGIN_VOLUMEHANDLING_IGNORE, iniFile)); if(CSoundFile::s_DefaultPlugVolumeHandling > 2) CSoundFile::s_DefaultPlugVolumeHandling = PLUGIN_VOLUMEHANDLING_IGNORE; - m_nSampleUndoMaxBuffer = GetPrivateProfileLong("Sample Editor" , "UndoBufferSize", m_nSampleUndoMaxBuffer, iniFile) << 20; + m_nSampleUndoMaxBuffer = GetPrivateProfileLong("Sample Editor" , "UndoBufferSize", m_nSampleUndoMaxBuffer, iniFile); + m_nSampleUndoMaxBuffer = max(1, m_nSampleUndoMaxBuffer) << 20; TCHAR szPath[_MAX_PATH] = ""; GetPrivateProfileString("Paths", "Songs_Directory", GetDefaultDirectory(DIR_MODS), szPath, INIBUFFERSIZE, iniFile); Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2009-11-01 13:53:08 UTC (rev 408) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2009-11-01 16:27:14 UTC (rev 409) @@ -829,7 +829,7 @@ if (gMemStatus.dwTotalPhys < 16*1024*1024) gMemStatus.dwTotalPhys = 16*1024*1024; CMainFrame::m_nSampleUndoMaxBuffer = gMemStatus.dwTotalPhys / 10; // set sample undo buffer size - if(CMainFrame::m_nSampleUndoMaxBuffer < 1) CMainFrame::m_nSampleUndoMaxBuffer = 1; + if(CMainFrame::m_nSampleUndoMaxBuffer < (1 << 20)) CMainFrame::m_nSampleUndoMaxBuffer = (1 << 20); ASSERT(NULL == m_pDocManager); m_pDocManager = new CModDocManager(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |