From: <sag...@us...> - 2013-03-22 20:59:17
|
Revision: 1626 http://sourceforge.net/p/modplug/code/1626 Author: saga-games Date: 2013-03-22 20:59:07 +0000 (Fri, 22 Mar 2013) Log Message: ----------- [Imp] Sample Editor: Context menu paste is now greyed out if there's no wave data in the clipboard. (Also updated code for VST editor to not open the clipboard to query this information) [Imp] VST preset saving: If the plugin delivers invalid chunk data for some reason, fall back to parameter saving. [Mod] MIDI Input / Output plugin: Program name is now also restored properly when loading chunk. [Mod] OpenMPT: Version is now 1.21.01.24 Modified Paths: -------------- trunk/OpenMPT/common/version.h trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/VstPresets.cpp trunk/OpenMPT/plugins/MidiInOut/MidiInOut.cpp Modified: trunk/OpenMPT/common/version.h =================================================================== --- trunk/OpenMPT/common/version.h 2013-03-22 20:54:36 UTC (rev 1625) +++ trunk/OpenMPT/common/version.h 2013-03-22 20:59:07 UTC (rev 1626) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 21 #define VER_MINOR 01 -#define VER_MINORMINOR 23 +#define VER_MINORMINOR 24 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2013-03-22 20:54:36 UTC (rev 1625) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2013-03-22 20:59:07 UTC (rev 1626) @@ -179,6 +179,7 @@ { pModDoc->SetModified(); } + UpdatePresetField(); } else { Reporting::Error(VSTPresets::GetErrorMessage(error)); @@ -450,11 +451,7 @@ { case 0: // Grey out paste menu item. - if(CMainFrame::GetMainFrame() && CMainFrame::GetMainFrame()->OpenClipboard()) - { - m_pMenu->EnableMenuItem(ID_EDIT_PASTE, MF_BYCOMMAND | (::GetClipboardData(clipboardFormat) != nullptr ? 0 : MF_GRAYED)); - CloseClipboard(); - } + m_pMenu->EnableMenuItem(ID_EDIT_PASTE, MF_BYCOMMAND | (IsClipboardFormatAvailable(clipboardFormat) ? 0 : MF_GRAYED)); break; case 1: // Generate preset menu on click. Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2013-03-22 20:54:36 UTC (rev 1625) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2013-03-22 20:59:07 UTC (rev 1626) @@ -124,8 +124,8 @@ m_dwStatus = 0; m_nScrollFactor = 0; m_nBtnMouseOver = 0xFFFF; - memset(m_dwNotifyPos, 0, sizeof(m_dwNotifyPos)); - memset(m_NcButtonState, 0, sizeof(m_NcButtonState)); + MemsetZero(m_dwNotifyPos); + MemsetZero(m_NcButtonState); m_bmpEnvBar.Create(IDB_SMPTOOLBAR, 20, 0, RGB(192,192,192)); m_lastDrawPoint.SetPoint(-1, -1); } @@ -1246,7 +1246,7 @@ //--------------------------------------------------------- { STATIC_ASSERT(sizeof(T) == sizeof(uT) && sizeof(T) <= 2); - int value = (std::numeric_limits<T>::max)() - (std::numeric_limits<uT>::max)() * point.y / (m_rcClient.bottom - m_rcClient.top); + int value = (std::numeric_limits<T>::max)() - (std::numeric_limits<uT>::max)() * point.y / m_rcClient.Height(); Limit(value, (std::numeric_limits<T>::min)(), (std::numeric_limits<T>::max)()); return static_cast<T>(value); } @@ -1440,8 +1440,7 @@ InvalidateSample(); pModDoc->SetModified(); - } - else + } else { // ctrl + click = play from cursor pos if(CMainFrame::GetInputHandler()->CtrlPressed()) @@ -1565,7 +1564,7 @@ ::AppendMenu(hMenu, MF_STRING, ID_EDIT_CUT, "Cu&t\t" + ih->GetKeyTextFromCommand(kcEditCut)); ::AppendMenu(hMenu, MF_STRING, ID_EDIT_COPY, "&Copy\t" + ih->GetKeyTextFromCommand(kcEditCopy)); } - ::AppendMenu(hMenu, MF_STRING, ID_EDIT_PASTE, "&Paste\t" + ih->GetKeyTextFromCommand(kcEditPaste)); + ::AppendMenu(hMenu, MF_STRING | (IsClipboardFormatAvailable(CF_WAVE) ? 0 : MF_GRAYED), ID_EDIT_PASTE, "&Paste\t" + ih->GetKeyTextFromCommand(kcEditPaste)); ::AppendMenu(hMenu, MF_STRING | (pModDoc->GetSampleUndo().CanUndo(m_nSample) ? 0 : MF_GRAYED), ID_EDIT_UNDO, "&Undo\t" + ih->GetKeyTextFromCommand(kcEditUndo)); ClientToScreen(&pt); ::TrackPopupMenu(hMenu, TPM_LEFTALIGN|TPM_RIGHTBUTTON, pt.x, pt.y, 0, m_hWnd, NULL); @@ -2043,7 +2042,7 @@ { p[i] = (signed char) ((*((short int *)(p+i*2))) / 256); } - sample.uFlags &= ~(CHN_16BIT); + sample.uFlags.reset(CHN_16BIT); for (UINT j=0; j<MAX_CHANNELS; j++) if (pSndFile->Chn[j].pSample == sample.pSample) { pSndFile->Chn[j].dwFlags.reset(CHN_16BIT); @@ -2180,12 +2179,12 @@ if (sample.nLoopStart >= sample.nLoopEnd) { sample.nLoopStart = sample.nLoopEnd = 0; - sample.uFlags &= ~(CHN_LOOP|CHN_PINGPONGLOOP); + sample.uFlags.reset(CHN_LOOP|CHN_PINGPONGLOOP); } if (sample.nSustainStart >= sample.nSustainEnd) { sample.nSustainStart = sample.nSustainEnd = 0; - sample.uFlags &= ~(CHN_SUSTAINLOOP|CHN_PINGPONGSUSTAIN); + sample.uFlags.reset(CHN_SUSTAINLOOP|CHN_PINGPONGSUSTAIN); } sample.nLength = nEnd; @@ -2205,6 +2204,7 @@ { } + void CViewSample::PlayNote(UINT note, const uint32 nStartPos) //----------------------------------------------------------- { @@ -2225,7 +2225,7 @@ pModDoc->NoteOff(0, true); SmpLength loopstart = m_dwBeginSel, loopend = m_dwEndSel; - if (loopend - loopstart < (UINT)(4 << m_nZoom)) + if (loopend - loopstart < (SmpLength)(4 << m_nZoom)) loopend = loopstart = 0; // selection is too small -> no loop pModDoc->PlayNote(note, 0, m_nSample, false, -1, loopstart, loopend, CHANNELINDEX_INVALID, nStartPos); Modified: trunk/OpenMPT/mptrack/VstPresets.cpp =================================================================== --- trunk/OpenMPT/mptrack/VstPresets.cpp 2013-03-22 20:54:36 UTC (rev 1625) +++ trunk/OpenMPT/mptrack/VstPresets.cpp 2013-03-22 20:59:07 UTC (rev 1626) @@ -125,10 +125,9 @@ SaveProgram(f, plugin); } else { - const bool writeChunk = plugin.ProgramsAreChunks(); + bool writeChunk = plugin.ProgramsAreChunks(); ChunkHeader header; header.chunkMagic = cMagic; - header.fxMagic = writeChunk ? chunkBankMagic : bankMagic; header.version = 2; header.fxID = plugin.GetUID(); header.fxVersion = plugin.GetVersion(); @@ -136,7 +135,7 @@ // Write unfinished header... We need to update the size once we're done writing. Write(header, f); - uint32 numProgs = plugin.GetNumPrograms(), curProg = plugin.GetCurrentProgram(); + uint32 numProgs = Util::Max(plugin.GetNumPrograms(), VstInt32(1)), curProg = plugin.GetCurrentProgram(); WriteBE(numProgs, f); WriteBE(curProg, f); char reserved[124]; @@ -151,8 +150,13 @@ { WriteBE(chunkSize, f); f.write(chunk, chunkSize); + } else + { + // The plugin returned no chunk! Gracefully go back and save parameters instead... + writeChunk = false; } - } else + } + if(!writeChunk) { for(uint32 p = 0; p < numProgs; p++) { @@ -165,6 +169,7 @@ // Now we know the correct chunk size. std::streamoff end = f.tellp(); header.byteSize = static_cast<VstInt32>(end - 8); + header.fxMagic = writeChunk ? chunkBankMagic : bankMagic; header.ConvertEndianness(); f.seekp(0); Write(header, f); @@ -177,10 +182,9 @@ void VSTPresets::SaveProgram(std::ostream &f, CVstPlugin &plugin) //--------------------------------------------------------------- { - const bool writeChunk = plugin.ProgramsAreChunks(); + bool writeChunk = plugin.ProgramsAreChunks(); ChunkHeader header; header.chunkMagic = cMagic; - header.fxMagic = writeChunk ? chunkPresetMagic : fMagic; header.version = 1; header.fxID = plugin.GetUID(); header.fxVersion = plugin.GetVersion(); @@ -204,8 +208,13 @@ { WriteBE(chunkSize, f); f.write(chunk, chunkSize); + } else + { + // The plugin returned no chunk! Gracefully go back and save parameters instead... + writeChunk = false; } - } else + } + if(!writeChunk) { for(uint32 p = 0; p < numParams; p++) { @@ -216,6 +225,7 @@ // Now we know the correct chunk size. std::streamoff end = f.tellp(); header.byteSize = static_cast<VstInt32>(end - start - 8); + header.fxMagic = writeChunk ? chunkPresetMagic : fMagic; header.ConvertEndianness(); f.seekp(start); Write(header, f); Modified: trunk/OpenMPT/plugins/MidiInOut/MidiInOut.cpp =================================================================== --- trunk/OpenMPT/plugins/MidiInOut/MidiInOut.cpp 2013-03-22 20:54:36 UTC (rev 1625) +++ trunk/OpenMPT/plugins/MidiInOut/MidiInOut.cpp 2013-03-22 20:59:07 UTC (rev 1626) @@ -132,11 +132,15 @@ VstInt32 nameStrSize = std::min(header[2], byteSize - VstInt32(8 * sizeof(VstInt32))); VstInt32 inStrSize = std::min(header[4], byteSize - VstInt32(8 * sizeof(VstInt32) - nameStrSize)); VstInt32 outStrSize = std::min(header[6], byteSize - VstInt32(8 * sizeof(VstInt32) - nameStrSize - inStrSize)); + + const char *nameStr = reinterpret_cast<const char *>(data) + 8 * sizeof(VstInt32); + const char *inStr = reinterpret_cast<const char *>(data) + 8 * sizeof(VstInt32) + nameStrSize; + const char *outStr = reinterpret_cast<const char *>(data) + 8 * sizeof(VstInt32) + nameStrSize + inStrSize; + PmDeviceID inID = header[3]; PmDeviceID outID = header[5]; - const char *inStr = reinterpret_cast<const char *>(data) + 8 * sizeof(VstInt32) + header[2]; - const char *outStr = reinterpret_cast<const char *>(data) + 8 * sizeof(VstInt32) + header[2] + inStrSize; + vst_strncpy(programName, nameStr, std::min(nameStrSize, VstInt32(kVstMaxProgNameLen))); if(strncmp(inStr, GetDeviceName(inID), inStrSize)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-03-23 16:22:35
|
Revision: 1640 http://sourceforge.net/p/modplug/code/1640 Author: saga-games Date: 2013-03-23 16:22:25 +0000 (Sat, 23 Mar 2013) Log Message: ----------- [Ref] Converted CHAR m_szInstrumentPath[MAX_INSTRUMENTS][_MAX_PATH] into mpt::String array to reduce memory usage. Maybe we should also make it a vector instead of an array later... Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/view_com.cpp trunk/OpenMPT/soundlib/Load_itp.cpp trunk/OpenMPT/soundlib/SampleFormats.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2013-03-23 16:14:44 UTC (rev 1639) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2013-03-23 16:22:25 UTC (rev 1640) @@ -1469,9 +1469,7 @@ m_pModDoc->UpdateAllViews(NULL, HINT_SAMPLEINFO | HINT_MODTYPE, NULL); // -> CODE#0023 // -> DESC="IT project files (.itp)" - const size_t n = max(strlen(lpszFileName), size_t(_MAX_PATH - 1)); - strncpy(m_pSndFile->m_szInstrumentPath[m_nInstrument - 1], lpszFileName, n); - m_pSndFile->m_szInstrumentPath[m_nInstrument-1][n] = '\0'; + m_pSndFile->m_szInstrumentPath[m_nInstrument - 1] = lpszFileName; SetInstrumentModified(false); // -! NEW_FEATURE#0023 bOk = TRUE; @@ -1836,9 +1834,7 @@ // -> CODE#0023 // -> DESC="IT project files (.itp)" - int n = strlen(files.first_file.c_str()); - if(n > _MAX_PATH) n = _MAX_PATH; - strncpy(m_pSndFile->m_szInstrumentPath[m_nInstrument-1], files.first_file.c_str(),n); + m_pSndFile->m_szInstrumentPath[m_nInstrument - 1] = files.first_file; SetInstrumentModified(false); // -! NEW_FEATURE#0023 Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-03-23 16:14:44 UTC (rev 1639) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-03-23 16:22:25 UTC (rev 1640) @@ -488,33 +488,24 @@ { if((m_SndFile.GetType() & MOD_TYPE_IT) && m_SndFile.m_SongFlags[SONG_ITPROJECT] && !m_SndFile.m_SongFlags[SONG_ITPEMBEDIH]) { - bool unsavedInstrument = false; - for(INSTRUMENTINDEX i = 0 ; i < m_SndFile.GetNumInstruments() ; i++) + for(INSTRUMENTINDEX i = 0 ; i < m_SndFile.GetNumInstruments(); i++) { if(m_bsInstrumentModified[i]) { unsavedInstrument = true; - break; + break; } } if(unsavedInstrument && Reporting::Confirm("Do you want to save modified instruments?") == cnfYes) { - - for(INSTRUMENTINDEX i = 0 ; i < m_SndFile.m_nInstruments ; i++) + for(INSTRUMENTINDEX i = 0; i < m_SndFile.GetNumInstruments(); i++) { - if(m_SndFile.m_szInstrumentPath[i][0] != '\0') + if(m_bsInstrumentModified[i]) { - const size_t len = strlen(m_SndFile.m_szInstrumentPath[i]); - const bool iti = _stricmp(&m_SndFile.m_szInstrumentPath[i][len - 3],"iti") == 0; - const bool xi = _stricmp(&m_SndFile.m_szInstrumentPath[i][len - 2],"xi") == 0; - - if(iti || (!iti && !xi && m_SndFile.m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT))) - m_SndFile.SaveITIInstrument(i+1, m_SndFile.m_szInstrumentPath[i], false); - if(xi || (!xi && !iti && m_SndFile.m_nType == MOD_TYPE_XM)) - m_SndFile.SaveXIInstrument(i+1, m_SndFile.m_szInstrumentPath[i]); + SaveInstrument(i + 1); } } } @@ -522,6 +513,31 @@ return CDocument::SaveModified(); } + + +bool CModDoc::SaveInstrument(INSTRUMENTINDEX instr) +//------------------------------------------------- +{ + if(instr > 0 && instr <= GetNumInstruments()) + { + instr--; + if(!m_SndFile.m_szInstrumentPath[instr].IsEmpty()) + { + const size_t len = m_SndFile.m_szInstrumentPath[instr].length(); + const bool iti = _stricmp(&m_SndFile.m_szInstrumentPath[instr][len - 3], "iti") == 0; + const bool xi = _stricmp(&m_SndFile.m_szInstrumentPath[instr][len - 2], "xi") == 0; + + if(iti || (!iti && !xi && m_SndFile.GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT))) + m_SndFile.SaveITIInstrument(instr + 1, m_SndFile.m_szInstrumentPath[instr], false); + if(xi || (!xi && !iti && m_SndFile.GetType() == MOD_TYPE_XM)) + m_SndFile.SaveXIInstrument(instr + 1, m_SndFile.m_szInstrumentPath[instr]); + m_bsInstrumentModified.reset(instr); + return true; + } + } + return false; +} + // -! NEW_FEATURE#0023 Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2013-03-23 16:14:44 UTC (rev 1639) +++ trunk/OpenMPT/mptrack/Moddoc.h 2013-03-23 16:22:25 UTC (rev 1640) @@ -340,6 +340,7 @@ // -> CODE#0023 // -> DESC="IT project files (.itp)" virtual BOOL SaveModified(); + bool SaveInstrument(INSTRUMENTINDEX instr); // -! NEW_FEATURE#0023 virtual BOOL DoSave(LPCSTR lpszPathName, BOOL bSaveAs=TRUE); Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2013-03-23 16:14:44 UTC (rev 1639) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2013-03-23 16:22:25 UTC (rev 1640) @@ -738,7 +738,7 @@ *pIns = *pDup; // -> CODE#0023 // -> DESC="IT project files (.itp)" - strcpy(m_SndFile.m_szInstrumentPath[newins - 1], m_SndFile.m_szInstrumentPath[nDuplicate - 1]); + m_SndFile.m_szInstrumentPath[newins - 1] = m_SndFile.m_szInstrumentPath[nDuplicate - 1]; m_bsInstrumentModified.reset(newins - 1); // -! NEW_FEATURE#0023 } Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2013-03-23 16:14:44 UTC (rev 1639) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2013-03-23 16:22:25 UTC (rev 1640) @@ -993,7 +993,7 @@ if(sndFile.m_SongFlags[SONG_ITPROJECT]) { // path info for ITP instruments - const bool pathOk = sndFile.m_szInstrumentPath[nIns - 1][0] != '\0'; + const bool pathOk = !sndFile.m_szInstrumentPath[nIns - 1].IsEmpty(); const bool instMod = pDoc->m_bsInstrumentModified.test(nIns - 1); wsprintf(s, pathOk ? (instMod ? "%3d: * %s" : "%3d: %s") : "%3d: ? %s", nIns, (LPCTSTR)sndFile.GetInstrumentName(nIns)); } else @@ -3157,7 +3157,7 @@ "All files(*.*)|*.*||"); if(files.abort) return; - strcpy(pSndFile->m_szInstrumentPath[modItemID - 1], files.first_file.c_str()); + pSndFile->m_szInstrumentPath[modItemID - 1] = files.first_file; OnRefreshTree(); } } @@ -3173,9 +3173,10 @@ //const uint32 modItemType = GetModItemType(modItem); const uint32 modItemID = GetModItemID(modItem); - if(pSndFile && modItemID){ + if(pSndFile && modItemID) + { - if(pSndFile->m_szInstrumentPath[modItemID - 1][0] == '\0') + if(pSndFile->m_szInstrumentPath[modItemID - 1].IsEmpty()) { FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(false, (pSndFile->GetType() == MOD_TYPE_XM) ? "xi" : "iti", "", (pSndFile->GetType() == MOD_TYPE_XM) ? @@ -3185,23 +3186,11 @@ "FastTracker II Instruments (*.xi)|*.xi||"); if(files.abort) return; - strcpy(pSndFile->m_szInstrumentPath[modItemID - 1], files.first_file.c_str()); + pSndFile->m_szInstrumentPath[modItemID - 1] = files.first_file; } - if(pSndFile->m_szInstrumentPath[modItemID - 1][0] != '\0') - { - int size = strlen(pSndFile->m_szInstrumentPath[modItemID - 1]); - BOOL iti = _stricmp(&pSndFile->m_szInstrumentPath[modItemID - 1][size-3],"iti") == 0; - BOOL xi = _stricmp(&pSndFile->m_szInstrumentPath[modItemID - 1][size-2],"xi") == 0; + pModDoc->SaveInstrument(modItemID); - if(iti || (!iti && !xi && pSndFile->m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT))) - pSndFile->SaveITIInstrument((INSTRUMENTINDEX)modItemID, pSndFile->m_szInstrumentPath[modItemID - 1], false); - if(xi || (!xi && !iti && pSndFile->m_nType == MOD_TYPE_XM)) - pSndFile->SaveXIInstrument((INSTRUMENTINDEX)modItemID, pSndFile->m_szInstrumentPath[modItemID - 1]); - - pModDoc->m_bsInstrumentModified.reset(modItemID - 1); - } - if(pModDoc) pModDoc->UpdateAllViews(NULL, HINT_MODTYPE); OnRefreshTree(); } Modified: trunk/OpenMPT/mptrack/view_com.cpp =================================================================== --- trunk/OpenMPT/mptrack/view_com.cpp 2013-03-23 16:14:44 UTC (rev 1639) +++ trunk/OpenMPT/mptrack/view_com.cpp 2013-03-23 16:22:25 UTC (rev 1640) @@ -416,7 +416,7 @@ case INSLIST_PATH: if (pIns) { - memcpy(s, pSndFile->m_szInstrumentPath[iIns], _MAX_PATH); + strncpy(s, pSndFile->m_szInstrumentPath[iIns], _MAX_PATH); s[_MAX_PATH] = 0; } break; Modified: trunk/OpenMPT/soundlib/Load_itp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_itp.cpp 2013-03-23 16:14:44 UTC (rev 1639) +++ trunk/OpenMPT/soundlib/Load_itp.cpp 2013-03-23 16:22:25 UTC (rev 1640) @@ -109,7 +109,9 @@ size = file.ReadUint32LE(); // path string length for(INSTRUMENTINDEX ins = 0; ins < GetNumInstruments(); ins++) { - file.ReadString<StringFixer::maybeNullTerminated>(m_szInstrumentPath[ins], size); + char path[_MAX_PATH]; + file.ReadString<StringFixer::maybeNullTerminated>(path, size); + m_szInstrumentPath[ins] = path; } // Song Orders @@ -199,7 +201,7 @@ for(INSTRUMENTINDEX ins = 0; ins < GetNumInstruments(); ins++) { - if(m_szInstrumentPath[ins][0] == '\0' || !f.Open(m_szInstrumentPath[ins])) continue; + if(m_szInstrumentPath[ins].IsEmpty() || !f.Open(m_szInstrumentPath[ins])) continue; size = f.GetLength(); LPBYTE lpFile = f.Lock(size); @@ -263,7 +265,7 @@ if(!m_SongFlags[SONG_ITPROJECT]) return false; UINT i,j = 0; - for(i = 0 ; i < m_nInstruments ; i++) { if(m_szInstrumentPath[i][0] != '\0' || !Instruments[i+1]) j++; } + for(i = 0 ; i < m_nInstruments ; i++) { if(!m_szInstrumentPath[i].IsEmpty() || !Instruments[i+1]) j++; } if(m_nInstruments && j != m_nInstruments) return false; // Open file @@ -363,7 +365,13 @@ fwrite(&id, 1, sizeof(id), f); // instruments' path - for(i=0; i<m_nInstruments; i++) fwrite(&m_szInstrumentPath[i][0], 1, _MAX_PATH, f); + for(i = 0; i < m_nInstruments; i++) + { + char path[_MAX_PATH]; + MemsetZero(path); + strncpy(path, m_szInstrumentPath[i], _MAX_PATH); + fwrite(path, 1, _MAX_PATH, f); + } // Song Orders @@ -419,26 +427,21 @@ id = m_nSamples; fwrite(&id, 1, sizeof(id), f); - vector<bool> sampleUsed(m_nSamples, false); + vector<bool> sampleUsed(GetNumSamples() + 1, false); // Mark samples used in instruments - for(i=0; i<m_nInstruments; i++) + for(i = 0; i < m_nInstruments; i++) { if(Instruments[i + 1] != nullptr) { - ModInstrument *p = Instruments[i + 1]; - for(j = 0; j < 128; j++) - { - if(p->Keyboard[j] > 0 && p->Keyboard[j] <= m_nSamples) - sampleUsed[p->Keyboard[j] - 1] = true; - } + Instruments[i + 1]->GetSamples(sampleUsed); } } // Count samples not used in any instrument i = 0; for(j = 1; j <= m_nSamples; j++) - if(!sampleUsed[j - 1] && Samples[j].pSample) i++; + if(!sampleUsed[j] && Samples[j].pSample) i++; id = i; fwrite(&id, 1, sizeof(id), f); @@ -446,7 +449,7 @@ // Write samples not used in any instrument (help, this looks like duplicate code!) for(UINT nsmp=1; nsmp<=m_nSamples; nsmp++) { - if(!sampleUsed[nsmp - 1] && Samples[nsmp].pSample) + if(!sampleUsed[nsmp] && Samples[nsmp].pSample) { ITSample itss; itss.ConvertToIT(Samples[nsmp], GetType(), false, false); Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-03-23 16:14:44 UTC (rev 1639) +++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-03-23 16:22:25 UTC (rev 1640) @@ -150,7 +150,7 @@ // -> CODE#0023 // -> DESC="IT project files (.itp)" - m_szInstrumentPath[nInstr - 1][0] = '\0'; + m_szInstrumentPath[nInstr - 1].Empty(); #ifdef MODPLUG_TRACKER if(GetpModDoc()) { Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-03-23 16:14:44 UTC (rev 1639) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-03-23 16:22:25 UTC (rev 1640) @@ -454,15 +454,6 @@ m_dwCreatedWithVersion=0; m_bChannelMuteTogglePending.reset(); - -// -> CODE#0023 -// -> DESC="IT project files (.itp)" - for(UINT i = 0; i < MAX_INSTRUMENTS; i++) - { - MemsetZero(m_szInstrumentPath[i]); - } -// -! NEW_FEATURE#0023 - MemsetZero(ChnMix); MemsetZero(Instruments); MemsetZero(m_szNames); Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-03-23 16:14:44 UTC (rev 1639) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-03-23 16:22:25 UTC (rev 1640) @@ -313,7 +313,7 @@ // -> CODE#0023 // -> DESC="IT project files (.itp)" - CHAR m_szInstrumentPath[MAX_INSTRUMENTS][_MAX_PATH]; + mpt::String m_szInstrumentPath[MAX_INSTRUMENTS]; // -! NEW_FEATURE#0023 public: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-03-25 14:00:35
|
Revision: 1666 http://sourceforge.net/p/modplug/code/1666 Author: manxorist Date: 2013-03-25 14:00:25 +0000 (Mon, 25 Mar 2013) Log Message: ----------- [Ref] Move class mpt::String from soundlib/snd_defs.h to common/mptString.h. Modified Paths: -------------- trunk/OpenMPT/common/stdafx.h trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/soundlib/Snd_defs.h Added Paths: ----------- trunk/OpenMPT/common/mptString.h Added: trunk/OpenMPT/common/mptString.h =================================================================== --- trunk/OpenMPT/common/mptString.h (rev 0) +++ trunk/OpenMPT/common/mptString.h 2013-03-25 14:00:25 UTC (rev 1666) @@ -0,0 +1,102 @@ +/* + * mptString.h + * ---------- + * Purpose: A wrapper around std::string implemeting the CString interface. + * Notes : Should be removed somewhen in the future when all uses of CString have been converted to std::string. + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#pragma once + +#include <string> + +namespace mpt +{ + // Quick and incomplete string class to be used as a replacement for + // CString and std::string in soundlib. + class String : public std::string + { + public: + typedef std::string BaseClass; + typedef char CharT; + + String() {} + String(const CharT* psz) : BaseClass(psz) {} + String(const std::string& other) : BaseClass(other) {} + + // Move constructors and move assignments. + #if (_MSC_VER >= MSVC_VER_2010) + String(BaseClass&& str) : BaseClass(std::move(str)) {} + String(String&& other) : BaseClass(std::move(static_cast<BaseClass&>(other))) {} + String& operator=(BaseClass&& str) {BaseClass::operator=(std::move(str)); return *this;} + String& operator=(String&& other) {BaseClass::operator=(std::move(static_cast<BaseClass&>(other))); return *this;} + #endif + + String& operator=(const CharT* psz) {BaseClass::operator=(psz); return *this;} + + #ifdef MODPLUG_TRACKER + String(const CString& str) {(*this) = str.GetString();} + String& operator=(const CString& str) {return operator=(str.GetString());} + #endif // MODPLUG_TRACKER + + // To allow easy assignment to CString in GUI side. + operator const CharT*() const {return c_str();} + + // Clears string. + void Empty() {clear();} + + // Tests whether string is empty. + bool IsEmpty() const {return empty();} + + // See std::string::compare. + int Compare(const CharT* psz) const {return compare(psz);} + + // Equivalent to Empty(); Append(psz, nCount); + void SetString(const CharT* psz, const size_t nCount) + { + Empty(); + Append(psz, nCount); + } + + // Append string to this. + void Append(const CharT* psz) {append(psz);} + + // Appends given string to this. Stops after 'nCount' chars if null terminator + // hasn't been encountered before that. + void Append(const CharT* psz, const size_t nCount) {append(psz, nCount);} + + // Appends single character to string. + void AppendChar(const CharT c) {append(1, c);} + + // Difference between Append and AppendChars is that latter can be used to add + // potentially non-null terminated char array. + template <size_t N> + void AppendChars(const CharT (&arr)[N]) + { + append(arr, arr + N); + } + + // Reserves store for the string without resizing. + void Reserve(size_t nSize) {reserve(nSize);} + + // Formats this string, like CString::Format. + void Format(const CharT* pszFormat, ...) + { + va_list argList; + va_start( argList, pszFormat ); + + // Count the needed array size. + const size_t nCount = _vscprintf(pszFormat, argList); // null character not included. + resize(nCount + 1); // + 1 is for null terminator. + + // Hack: directly modify the std::string's string. + // In C++11 std::string is guaranteed to be contiguous. + const int nCount2 = vsprintf_s(&*begin(), size(), pszFormat, argList); + resize(nCount2); // Removes the null character that vsprintf_s adds. + + va_end( argList ); + } + }; +} Property changes on: trunk/OpenMPT/common/mptString.h ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-chdr \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/OpenMPT/common/stdafx.h =================================================================== --- trunk/OpenMPT/common/stdafx.h 2013-03-25 13:47:27 UTC (rev 1665) +++ trunk/OpenMPT/common/stdafx.h 2013-03-25 14:00:25 UTC (rev 1666) @@ -121,6 +121,8 @@ #include "../common/typedefs.h" +#include "../common/mptString.h" + // Exception type that is used to catch "operator new" exceptions. //typedef std::bad_alloc & MPTMemoryException; typedef CMemoryException * MPTMemoryException; Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-03-25 13:47:27 UTC (rev 1665) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-03-25 14:00:25 UTC (rev 1666) @@ -1079,6 +1079,10 @@ > </File> <File + RelativePath="..\common\mptString.h" + > + </File> + <File RelativePath=".\Undo.h" > </File> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-03-25 13:47:27 UTC (rev 1665) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-03-25 14:00:25 UTC (rev 1666) @@ -400,6 +400,7 @@ <ClInclude Include="..\common\AudioCriticalSection.h" /> <ClInclude Include="..\common\FlagSet.h" /> <ClInclude Include="..\common\misc_util.h" /> + <ClInclude Include="..\common\mptString.h" /> <ClInclude Include="..\common\Reporting.h" /> <ClInclude Include="..\common\StringFixer.h" /> <ClInclude Include="..\common\typedefs.h" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-03-25 13:47:27 UTC (rev 1665) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-03-25 14:00:25 UTC (rev 1666) @@ -762,6 +762,9 @@ <ClInclude Include="..\soundlib\snd_rvb.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="..\common\mptString.h"> + <Filter>Header Files</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="res\bitmap1.bmp"> Modified: trunk/OpenMPT/soundlib/Snd_defs.h =================================================================== --- trunk/OpenMPT/soundlib/Snd_defs.h 2013-03-25 13:47:27 UTC (rev 1665) +++ trunk/OpenMPT/soundlib/Snd_defs.h 2013-03-25 14:00:25 UTC (rev 1666) @@ -381,92 +381,3 @@ VIB_RAMP_DOWN, VIB_RANDOM }; - -namespace mpt -{ - // Quick and incomplete string class to be used as a replacement for - // CString and std::string in soundlib. - class String : public std::string - { - public: - typedef std::string BaseClass; - typedef char CharT; - - String() {} - String(const CharT* psz) : BaseClass(psz) {} - String(const std::string& other) : BaseClass(other) {} - - // Move constructors and move assignments. - #if (_MSC_VER >= MSVC_VER_2010) - String(BaseClass&& str) : BaseClass(std::move(str)) {} - String(String&& other) : BaseClass(std::move(static_cast<BaseClass&>(other))) {} - String& operator=(BaseClass&& str) {BaseClass::operator=(std::move(str)); return *this;} - String& operator=(String&& other) {BaseClass::operator=(std::move(static_cast<BaseClass&>(other))); return *this;} - #endif - - String& operator=(const CharT* psz) {BaseClass::operator=(psz); return *this;} - - #ifdef MODPLUG_TRACKER - String(const CString& str) {(*this) = str.GetString();} - String& operator=(const CString& str) {return operator=(str.GetString());} - #endif // MODPLUG_TRACKER - - // To allow easy assignment to CString in GUI side. - operator const CharT*() const {return c_str();} - - // Clears string. - void Empty() {clear();} - - // Tests whether string is empty. - bool IsEmpty() const {return empty();} - - // See std::string::compare. - int Compare(const CharT* psz) const {return compare(psz);} - - // Equivalent to Empty(); Append(psz, nCount); - void SetString(const CharT* psz, const size_t nCount) - { - Empty(); - Append(psz, nCount); - } - - // Append string to this. - void Append(const CharT* psz) {append(psz);} - - // Appends given string to this. Stops after 'nCount' chars if null terminator - // hasn't been encountered before that. - void Append(const CharT* psz, const size_t nCount) {append(psz, nCount);} - - // Appends single character to string. - void AppendChar(const CharT c) {append(1, c);} - - // Difference between Append and AppendChars is that latter can be used to add - // potentially non-null terminated char array. - template <size_t N> - void AppendChars(const CharT (&arr)[N]) - { - append(arr, arr + N); - } - - // Reserves store for the string without resizing. - void Reserve(size_t nSize) {reserve(nSize);} - - // Formats this string, like CString::Format. - void Format(const CharT* pszFormat, ...) - { - va_list argList; - va_start( argList, pszFormat ); - - // Count the needed array size. - const size_t nCount = _vscprintf(pszFormat, argList); // null character not included. - resize(nCount + 1); // + 1 is for null terminator. - - // Hack: directly modify the std::string's string. - // In C++11 std::string is guaranteed to be contiguous. - const int nCount2 = vsprintf_s(&*begin(), size(), pszFormat, argList); - resize(nCount2); // Removes the null character that vsprintf_s adds. - - va_end( argList ); - } - }; -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-03-25 15:03:48
|
Revision: 1668 http://sourceforge.net/p/modplug/code/1668 Author: manxorist Date: 2013-03-25 15:03:37 +0000 (Mon, 25 Mar 2013) Log Message: ----------- [Ref] Start splitting DSP and EQ stuff from soundlib. Move soundlib/snd_dsp.cpp and soundlib/snd_eq.cpp to their own directory sounddsp/. Modified Paths: -------------- trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters Added Paths: ----------- trunk/OpenMPT/sounddsp/ trunk/OpenMPT/sounddsp/DSP.cpp trunk/OpenMPT/sounddsp/EQ.cpp Removed Paths: ------------- trunk/OpenMPT/soundlib/Snd_dsp.cpp trunk/OpenMPT/soundlib/Snd_eq.cpp Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-03-25 14:43:07 UTC (rev 1667) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-03-25 15:03:37 UTC (rev 1668) @@ -493,11 +493,11 @@ > </File> <File - RelativePath="..\soundlib\snd_dsp.cpp" + RelativePath="..\sounddsp\DSP.cpp" > </File> <File - RelativePath="..\soundlib\snd_eq.cpp" + RelativePath="..\sounddsp\EQ.cpp" > </File> <File Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-03-25 14:43:07 UTC (rev 1667) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-03-25 15:03:37 UTC (rev 1668) @@ -247,6 +247,8 @@ <ClCompile Include="..\common\AudioCriticalSection.cpp" /> <ClCompile Include="..\common\misc_util.cpp" /> <ClCompile Include="..\common\Reporting.cpp" /> + <ClCompile Include="..\sounddsp\DSP.cpp" /> + <ClCompile Include="..\sounddsp\EQ.cpp" /> <ClCompile Include="..\soundlib\ITCompression.cpp" /> <ClCompile Include="..\soundlib\ITTools.cpp" /> <ClCompile Include="..\soundlib\MIDIEvents.cpp" /> @@ -326,8 +328,6 @@ <ClCompile Include="ScaleEnvPointsDlg.cpp" /> <ClCompile Include="SelectPluginDialog.cpp" /> <ClCompile Include="..\common\serialization_utils.cpp" /> - <ClCompile Include="..\soundlib\snd_dsp.cpp" /> - <ClCompile Include="..\soundlib\snd_eq.cpp" /> <ClCompile Include="..\soundlib\snd_flt.cpp" /> <ClCompile Include="..\soundlib\Snd_fx.cpp" /> <ClCompile Include="..\Soundlib\Snd_rvb.cpp" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-03-25 14:43:07 UTC (rev 1667) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-03-25 15:03:37 UTC (rev 1668) @@ -259,12 +259,6 @@ <ClCompile Include="..\soundlib\snd_flt.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="..\soundlib\snd_eq.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\soundlib\snd_dsp.cpp"> - <Filter>Source Files</Filter> - </ClCompile> <ClCompile Include="..\common\serialization_utils.cpp"> <Filter>Source Files</Filter> </ClCompile> @@ -427,6 +421,12 @@ <ClCompile Include="..\soundlib\ITCompression.cpp"> <Filter>Source Files</Filter> </ClCompile> + <ClCompile Include="..\sounddsp\DSP.cpp"> + <Filter>Source Files\sounddsp</Filter> + </ClCompile> + <ClCompile Include="..\sounddsp\EQ.cpp"> + <Filter>Source Files\sounddsp</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="AbstractVstEditor.h"> @@ -871,6 +871,12 @@ <UniqueIdentifier>{5a7bae01-9526-4d85-9c00-0a280e22ad0b}</UniqueIdentifier> <Extensions>ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe</Extensions> </Filter> + <Filter Include="Source Files\sounddsp"> + <UniqueIdentifier>{ad75f592-baa3-4f6a-b4fe-496e1fad42e1}</UniqueIdentifier> + </Filter> + <Filter Include="Header Files\sounddsp"> + <UniqueIdentifier>{2174b62f-1cac-4ad9-9db3-e3447eaa1bd0}</UniqueIdentifier> + </Filter> </ItemGroup> <ItemGroup> <ResourceCompile Include="mptrack.rc"> Index: trunk/OpenMPT/sounddsp =================================================================== --- trunk/OpenMPT/sounddsp 2013-03-25 14:43:07 UTC (rev 1667) +++ trunk/OpenMPT/sounddsp 2013-03-25 15:03:37 UTC (rev 1668) Property changes on: trunk/OpenMPT/sounddsp ___________________________________________________________________ Added: tsvn:logminsize ## -0,0 +1 ## +10 \ No newline at end of property Copied: trunk/OpenMPT/sounddsp/DSP.cpp (from rev 1664, trunk/OpenMPT/soundlib/Snd_dsp.cpp) =================================================================== --- trunk/OpenMPT/sounddsp/DSP.cpp (rev 0) +++ trunk/OpenMPT/sounddsp/DSP.cpp 2013-03-25 15:03:37 UTC (rev 1668) @@ -0,0 +1,521 @@ +/* + * DSP.cpp + * ----------- + * Purpose: Mixing code for various DSPs (EQ, Mega-Bass, ...) + * Notes : Ugh... This should really be removed at some point. + * Authors: Olivier Lapicque + * OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#include "stdafx.h" +#include "../soundlib/sndfile.h" +#include <math.h> + + +// Bass Expansion +#define DEFAULT_XBASS_RANGE 14 // (x+2)*20 Hz (320Hz) +#define DEFAULT_XBASS_DEPTH 6 // 1+(3>>(x-4)) (+6dB) + +// Buffer Sizes +#define XBASSBUFFERSIZE 64 // 2 ms at 50KHz +#define SURROUNDBUFFERSIZE 2048 // 50ms @ 48kHz + + +// DSP Effects: PUBLIC members +UINT CSoundFile::m_nXBassDepth = DEFAULT_XBASS_DEPTH; +UINT CSoundFile::m_nXBassRange = DEFAULT_XBASS_RANGE; +UINT CSoundFile::gnReverbType = 0; +UINT CSoundFile::m_nReverbDepth = 8; // 50% +UINT CSoundFile::m_nProLogicDepth = 12; +UINT CSoundFile::m_nProLogicDelay = 20; + +//////////////////////////////////////////////////////////////////// +// DSP Effects internal state + +// Noise Reduction: simple low-pass filter +static LONG nLeftNR = 0; +static LONG nRightNR = 0; + +// Surround Encoding: 1 delay line + low-pass filter + high-pass filter +static LONG nSurroundSize = 0; +static LONG nSurroundPos = 0; +static LONG nDolbyDepth = 0; +// Surround Biquads +static LONG nDolbyHP_Y1 = 0; +static LONG nDolbyHP_X1 = 0; +static LONG nDolbyLP_Y1 = 0; +static LONG nDolbyHP_B0 = 0; +static LONG nDolbyHP_B1 = 0; +static LONG nDolbyHP_A1 = 0; +static LONG nDolbyLP_B0 = 0; +static LONG nDolbyLP_B1 = 0; +static LONG nDolbyLP_A1 = 0; + +// Bass Expansion: low-pass filter +static LONG nXBassFlt_Y1 = 0; +static LONG nXBassFlt_X1 = 0; +static LONG nXBassFlt_B0 = 0; +static LONG nXBassFlt_B1 = 0; +static LONG nXBassFlt_A1 = 0; + +// DC Removal Biquad +static LONG nDCRFlt_Y1l = 0; +static LONG nDCRFlt_X1l = 0; +static LONG nDCRFlt_Y1r = 0; +static LONG nDCRFlt_X1r = 0; + + +static LONG SurroundBuffer[SURROUNDBUFFERSIZE]; + + +// Access the main temporary mix buffer directly: avoids an extra pointer +extern int MixSoundBuffer[MIXBUFFERSIZE * 4]; +extern int MixRearBuffer[MIXBUFFERSIZE * 2]; + +extern VOID InitializeReverb(BOOL bReset); +extern VOID ProcessReverb(UINT nSamples); +extern VOID MPPASMCALL X86_InitMixBuffer(int *pBuffer, UINT nSamples); +extern VOID MPPASMCALL X86_StereoFill(int *pBuffer, UINT nSamples, LPLONG lpROfs, LPLONG lpLOfs); +extern VOID MPPASMCALL X86_StereoDCRemoval(int *, UINT count); +extern VOID MPPASMCALL X86_MonoDCRemoval(int *, UINT count); + +/////////////////////////////////////////////////////////////////////////////////// +// +// Biquad setup +// + + +#define PI 3.14159265358979323f +inline FLOAT Sgn(FLOAT x) { return (x >= 0) ? 1.0f : -1.0f; } +VOID ShelfEQ(LONG scale, + LONG *outA1, LONG *outB0, LONG *outB1, + LONG F_c, LONG F_s, FLOAT gainDC, FLOAT gainFT, FLOAT gainPI) +{ + FLOAT a1, b0, b1; + FLOAT gainFT2, gainDC2, gainPI2; + FLOAT alpha, beta0, beta1, rho; + FLOAT wT, quad; + + _asm { + // wT = PI*Fc/Fs + fild F_c + fldpi + fmulp ST(1), ST(0) + fild F_s + fdivp ST(1), ST(0) + fstp wT + // gain^2 + fld gainDC + fld gainFT + fld gainPI + fmul ST(0), ST(0) + fstp gainPI2 + fmul ST(0), ST(0) + fstp gainFT2 + fmul ST(0), ST(0) + fstp gainDC2 + } + + quad = gainPI2 + gainDC2 - (gainFT2*2); + + alpha = 0; + + if (quad != 0) + { + FLOAT lambda = (gainPI2 - gainDC2) / quad; + alpha = (FLOAT)(lambda - Sgn(lambda)*sqrt(lambda*lambda - 1.0f)); + } + + beta0 = 0.5f * ((gainDC + gainPI) + (gainDC - gainPI) * alpha); + beta1 = 0.5f * ((gainDC - gainPI) + (gainDC + gainPI) * alpha); + rho = (FLOAT)((sin((wT*0.5f) - (PI/4.0f))) / (sin((wT*0.5f) + (PI/4.0f)))); + + quad = 1.0f / (1.0f + rho*alpha); + + b0 = ((beta0 + rho*beta1) * quad); + b1 = ((beta1 + rho*beta0) * quad); + a1 = - ((rho + alpha) * quad); + + _asm { + fild scale + fld a1 + mov eax, outA1 + fmul ST(0), ST(1) + fistp dword ptr [eax] + fld b0 + mov eax, outB0 + fmul ST(0), ST(1) + fistp dword ptr [eax] + fld b1 + mov eax, outB1 + fmul ST(0), ST(1) + fistp dword ptr [eax] + fstp rho + } +} + + +void CSoundFile::InitializeDSP(BOOL bReset) +//----------------------------------------- +{ + if (gnReverbType >= NUM_REVERBTYPES) gnReverbType = 0; + if (!m_nProLogicDelay) m_nProLogicDelay = 20; + if (bReset) + { + // Noise Reduction + nLeftNR = nRightNR = 0; + } + // Pro-Logic Surround + nSurroundPos = nSurroundSize = 0; + if (gdwSoundSetup & SNDMIX_SURROUND) + { + memset(SurroundBuffer, 0, sizeof(SurroundBuffer)); + nSurroundSize = (gdwMixingFreq * m_nProLogicDelay) / 1000; + if (nSurroundSize > SURROUNDBUFFERSIZE) nSurroundSize = SURROUNDBUFFERSIZE; + nDolbyDepth = m_nProLogicDepth; + if (nDolbyDepth < 1) nDolbyDepth = 1; + if (nDolbyDepth > 16) nDolbyDepth = 16; + // Setup biquad filters + ShelfEQ(1024, &nDolbyHP_A1, &nDolbyHP_B0, &nDolbyHP_B1, 200, gdwMixingFreq, 0, 0.5f, 1); + ShelfEQ(1024, &nDolbyLP_A1, &nDolbyLP_B0, &nDolbyLP_B1, 7000, gdwMixingFreq, 1, 0.75f, 0); + nDolbyHP_X1 = nDolbyHP_Y1 = 0; + nDolbyLP_Y1 = 0; + // Surround Level + nDolbyHP_B0 = (nDolbyHP_B0 * nDolbyDepth) >> 5; + nDolbyHP_B1 = (nDolbyHP_B1 * nDolbyDepth) >> 5; + // +6dB + nDolbyLP_B0 *= 2; + nDolbyLP_B1 *= 2; + } + // Reverb Setup +#ifndef NO_REVERB + InitializeReverb(bReset); +#endif + // Bass Expansion Reset + if (gdwSoundSetup & SNDMIX_MEGABASS) + { + LONG a1 = 0, b0 = 1024, b1 = 0; + int nXBassCutOff = 50 + (m_nXBassRange+2) * 20; + int nXBassGain = m_nXBassDepth; + Limit(nXBassGain, 2, 8); + Limit(nXBassCutOff, 60, 600); + ShelfEQ(1024, &a1, &b0, &b1, nXBassCutOff, gdwMixingFreq, + 1.0f + (1.0f/16.0f) * (0x300 >> nXBassGain), + 1.0f, + 0.0000001f); + if (nXBassGain > 5) + { + b0 >>= (nXBassGain-5); + b1 >>= (nXBassGain-5); + } + nXBassFlt_A1 = a1; + nXBassFlt_B0 = b0; + nXBassFlt_B1 = b1; + //Log("b0=%d b1=%d a1=%d\n", b0, b1, a1); + } + if (bReset) + { + nXBassFlt_X1 = 0; + nXBassFlt_Y1 = 0; + nDCRFlt_X1l = 0; + nDCRFlt_X1r = 0; + nDCRFlt_Y1l = 0; + nDCRFlt_Y1r = 0; + } +} + + +// 2-channel surround +static void ProcessStereoSurround(int count) +//------------------------------------------ +{ + int *pr = MixSoundBuffer, hy1 = nDolbyHP_Y1; + for (int r=count; r; r--) + { + // Delay + int secho = SurroundBuffer[nSurroundPos]; + SurroundBuffer[nSurroundPos] = (pr[0]+pr[1]+256) >> 9; + // High-pass + int v0 = (nDolbyHP_B0 * secho + nDolbyHP_B1 * nDolbyHP_X1 + nDolbyHP_A1 * hy1) >> 10; + nDolbyHP_X1 = secho; + // Low-pass + int v = (nDolbyLP_B0 * v0 + nDolbyLP_B1 * hy1 + nDolbyLP_A1 * nDolbyLP_Y1) >> (10-8); + hy1 = v0; + nDolbyLP_Y1 = v >> 8; + // Add echo + pr[0] += v; + pr[1] -= v; + if (++nSurroundPos >= nSurroundSize) nSurroundPos = 0; + pr += 2; + } + nDolbyHP_Y1 = hy1; +} + + +// 4-channels surround +static void ProcessQuadSurround(int count) +//---------------------------------------- +{ + int *pr = MixSoundBuffer, hy1 = nDolbyHP_Y1; + for (int r=count; r; r--) + { + int vl = pr[0] >> 1; + int vr = pr[1] >> 1; + pr[(UINT)(MixRearBuffer-MixSoundBuffer)] += vl; + pr[((UINT)(MixRearBuffer-MixSoundBuffer))+1] += vr; + // Delay + int secho = SurroundBuffer[nSurroundPos]; + SurroundBuffer[nSurroundPos] = (vr+vl+256) >> 9; + // High-pass + int v0 = (nDolbyHP_B0 * secho + nDolbyHP_B1 * nDolbyHP_X1 + nDolbyHP_A1 * hy1) >> 10; + nDolbyHP_X1 = secho; + // Low-pass + int v = (nDolbyLP_B0 * v0 + nDolbyLP_B1 * hy1 + nDolbyLP_A1 * nDolbyLP_Y1) >> (10-8); + hy1 = v0; + nDolbyLP_Y1 = v >> 8; + // Add echo + pr[(UINT)(MixRearBuffer-MixSoundBuffer)] += v; + pr[((UINT)(MixRearBuffer-MixSoundBuffer))+1] += v; + if (++nSurroundPos >= nSurroundSize) nSurroundPos = 0; + pr += 2; + } + nDolbyHP_Y1 = hy1; +} + + +void CSoundFile::ProcessStereoDSP(int count) +//------------------------------------------ +{ + // Dolby Pro-Logic Surround + if (gdwSoundSetup & SNDMIX_SURROUND) + { + if (gnChannels > 2) ProcessQuadSurround(count); else + ProcessStereoSurround(count); + } + // DC Removal + if (gdwSoundSetup & SNDMIX_MEGABASS) + { + X86_StereoDCRemoval(MixSoundBuffer, count); + } + // Bass Expansion + if (gdwSoundSetup & SNDMIX_MEGABASS) + { + int *px = MixSoundBuffer; + int x1 = nXBassFlt_X1; + int y1 = nXBassFlt_Y1; + for (int x=count; x; x--) + { + int x_m = (px[0]+px[1]+0x100)>>9; + + y1 = (nXBassFlt_B0 * x_m + nXBassFlt_B1 * x1 + nXBassFlt_A1 * y1) >> (10-8); + x1 = x_m; + px[0] += y1; + px[1] += y1; + y1 = (y1+0x80) >> 8; + px += 2; + } + nXBassFlt_X1 = x1; + nXBassFlt_Y1 = y1; + } + // Noise Reduction + if (gdwSoundSetup & SNDMIX_NOISEREDUCTION) + { + int n1 = nLeftNR, n2 = nRightNR; + int *pnr = MixSoundBuffer; + for (int nr=count; nr; nr--) + { + int vnr = pnr[0] >> 1; + pnr[0] = vnr + n1; + n1 = vnr; + vnr = pnr[1] >> 1; + pnr[1] = vnr + n2; + n2 = vnr; + pnr += 2; + } + nLeftNR = n1; + nRightNR = n2; + } +} + + +void CSoundFile::ProcessMonoDSP(int count) +//---------------------------------------- +{ + // DC Removal + if (gdwSoundSetup & SNDMIX_MEGABASS) + { + X86_MonoDCRemoval(MixSoundBuffer, count); + } + // Bass Expansion + if (gdwSoundSetup & SNDMIX_MEGABASS) + { + int *px = MixSoundBuffer; + int x1 = nXBassFlt_X1; + int y1 = nXBassFlt_Y1; + for (int x=count; x; x--) + { + int x_m = (px[0]+0x80)>>8; + + y1 = (nXBassFlt_B0 * x_m + nXBassFlt_B1 * x1 + nXBassFlt_A1 * y1) >> (10-8); + x1 = x_m; + px[0] += y1; + y1 = (y1+0x40) >> 8; + px++; + } + nXBassFlt_X1 = x1; + nXBassFlt_Y1 = y1; + } + // Noise Reduction + if (gdwSoundSetup & SNDMIX_NOISEREDUCTION) + { + int n = nLeftNR; + int *pnr = MixSoundBuffer; + for (int nr=count; nr; pnr++, nr--) + { + int vnr = *pnr >> 1; + *pnr = vnr + n; + n = vnr; + } + nLeftNR = n; + } +} + + + +////////////////////////////////////////////////////////////////////////// +// +// DC Removal +// + +#define DCR_AMOUNT 9 + +VOID MPPASMCALL X86_StereoDCRemoval(int *pBuffer, UINT nSamples) +{ + int y1l=nDCRFlt_Y1l, x1l=nDCRFlt_X1l; + int y1r=nDCRFlt_Y1r, x1r=nDCRFlt_X1r; + + _asm { + mov esi, pBuffer + mov ecx, nSamples +stereodcr: + mov eax, [esi] + mov ebx, x1l + mov edx, [esi+4] + mov edi, x1r + add esi, 8 + sub ebx, eax + mov x1l, eax + mov eax, ebx + sar eax, DCR_AMOUNT+1 + sub edi, edx + sub eax, ebx + mov x1r, edx + add eax, y1l + mov edx, edi + sar edx, DCR_AMOUNT+1 + mov [esi-8], eax + sub edx, edi + mov ebx, eax + add edx, y1r + sar ebx, DCR_AMOUNT + mov [esi-4], edx + mov edi, edx + sub eax, ebx + sar edi, DCR_AMOUNT + mov y1l, eax + sub edx, edi + dec ecx + mov y1r, edx + jnz stereodcr + } + nDCRFlt_Y1l = y1l; + nDCRFlt_X1l = x1l; + nDCRFlt_Y1r = y1r; + nDCRFlt_X1r = x1r; +} + + +VOID MPPASMCALL X86_MonoDCRemoval(int *pBuffer, UINT nSamples) +{ + _asm { + mov esi, pBuffer + mov ecx, nSamples + mov edx, nDCRFlt_X1l + mov edi, nDCRFlt_Y1l +stereodcr: + mov eax, [esi] + mov ebx, edx + add esi, 4 + sub ebx, eax + mov edx, eax + mov eax, ebx + sar eax, DCR_AMOUNT+1 + sub eax, ebx + add eax, edi + mov [esi-4], eax + mov ebx, eax + sar ebx, DCR_AMOUNT + sub eax, ebx + dec ecx + mov edi, eax + jnz stereodcr + mov nDCRFlt_X1l, edx + mov nDCRFlt_Y1l, edi + } +} + + + + + +///////////////////////////////////////////////////////////////// +// Clean DSP Effects interface + +// [Reverb level 0(quiet)-100(loud)], [type = REVERBTYPE_XXXX] +BOOL CSoundFile::SetReverbParameters(UINT nDepth, UINT nType) +//----------------------------------------------------------- +{ + if (nDepth > 100) nDepth = 100; + UINT gain = (nDepth * 16) / 100; + if (gain > 16) gain = 16; + if (gain < 1) gain = 1; + m_nReverbDepth = gain; + if (nType < NUM_REVERBTYPES) gnReverbType = nType; + return TRUE; +} + + +// [XBass level 0(quiet)-100(loud)], [cutoff in Hz 20-100] +BOOL CSoundFile::SetXBassParameters(UINT nDepth, UINT nRange) +//----------------------------------------------------------- +{ + if (nDepth > 100) nDepth = 100; + UINT gain = nDepth / 20; + if (gain > 4) gain = 4; + m_nXBassDepth = 8 - gain; // filter attenuation 1/256 .. 1/16 + UINT range = nRange / 5; + if (range > 5) range -= 5; else range = 0; + if (nRange > 16) nRange = 16; + m_nXBassRange = 21 - range; // filter average on 0.5-1.6ms + return TRUE; +} + + +// [Surround level 0(quiet)-100(heavy)] [delay in ms, usually 5-50ms] +BOOL CSoundFile::SetSurroundParameters(UINT nDepth, UINT nDelay) +//-------------------------------------------------------------- +{ + UINT gain = (nDepth * 16) / 100; + if (gain > 16) gain = 16; + if (gain < 1) gain = 1; + m_nProLogicDepth = gain; + if (nDelay < 4) nDelay = 4; + if (nDelay > 50) nDelay = 50; + m_nProLogicDelay = nDelay; + return TRUE; +} + + + Copied: trunk/OpenMPT/sounddsp/EQ.cpp (from rev 1664, trunk/OpenMPT/soundlib/Snd_eq.cpp) =================================================================== --- trunk/OpenMPT/sounddsp/EQ.cpp (rev 0) +++ trunk/OpenMPT/sounddsp/EQ.cpp 2013-03-25 15:03:37 UTC (rev 1668) @@ -0,0 +1,532 @@ +/* + * EQ.cpp + * ---------- + * Purpose: Mixing code for equalizer. + * Notes : Ugh... This should really be removed at some point. + * Authors: Olivier Lapicque + * OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#include "stdafx.h" +#include "../soundlib/sndfile.h" +#include "../mptrack/TrackerSettings.h" + +#define EQ_BANDWIDTH 2.0 +#define EQ_ZERO 0.000001 +#define REAL float + +extern REAL MixFloatBuffer[]; + +extern void X86_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc); +extern void X86_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic); +extern void X86_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc); +extern void X86_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic); + +#ifdef ENABLE_SSE +extern void SSE_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc); +#endif +#ifdef ENABLE_3DNOW +extern void AMD_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc); +extern void AMD_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic); +#endif + + + + +#pragma pack(push, 4) +typedef struct _EQBANDSTRUCT +{ + REAL a0, a1, a2, b1, b2; + REAL x1, x2, y1, y2; + REAL Gain, CenterFrequency; + BOOL bEnable; +} EQBANDSTRUCT, *PEQBANDSTRUCT; +#pragma pack(pop) + +UINT gEqLinearToDB[33] = +{ + 16, 19, 22, 25, 28, 31, 34, 37, + 40, 43, 46, 49, 52, 55, 58, 61, + 64, 76, 88, 100, 112, 124, 136, 148, + 160, 172, 184, 196, 208, 220, 232, 244, 256 +}; + + +static REAL f2ic = (REAL)(1 << 28); +static REAL i2fc = (REAL)(1.0 / (1 << 28)); + +static EQBANDSTRUCT gEQ[MAX_EQ_BANDS*2] = +{ + // Default: Flat EQ + {0,0,0,0,0, 0,0,0,0, 1, 120, FALSE}, + {0,0,0,0,0, 0,0,0,0, 1, 600, FALSE}, + {0,0,0,0,0, 0,0,0,0, 1, 1200, FALSE}, + {0,0,0,0,0, 0,0,0,0, 1, 3000, FALSE}, + {0,0,0,0,0, 0,0,0,0, 1, 6000, FALSE}, + {0,0,0,0,0, 0,0,0,0, 1, 10000, FALSE}, + {0,0,0,0,0, 0,0,0,0, 1, 120, FALSE}, + {0,0,0,0,0, 0,0,0,0, 1, 600, FALSE}, + {0,0,0,0,0, 0,0,0,0, 1, 1200, FALSE}, + {0,0,0,0,0, 0,0,0,0, 1, 3000, FALSE}, + {0,0,0,0,0, 0,0,0,0, 1, 6000, FALSE}, + {0,0,0,0,0, 0,0,0,0, 1, 10000, FALSE}, +}; + +#define ASM_EQ +#ifdef ASM_EQ + +#pragma warning(disable:4100) + +#define PBS_A0 DWORD PTR [eax] +#define PBS_A1 DWORD PTR [eax+4] +#define PBS_A2 DWORD PTR [eax+8] +#define PBS_B1 DWORD PTR [eax+12] +#define PBS_B2 DWORD PTR [eax+16] +#define PBS_X1 DWORD PTR [eax+20] +#define PBS_X2 DWORD PTR [eax+24] +#define PBS_Y1 DWORD PTR [eax+28] +#define PBS_Y2 DWORD PTR [eax+32] + +void __cdecl EQFilter(EQBANDSTRUCT *pbs, REAL *pbuffer, UINT nCount) +//------------------------------------------------------------------ +{ + _asm { + mov eax, pbs // eax = pbs + mov edx, nCount // edx = nCount + mov ecx, pbuffer // ecx = pbuffer + fld PBS_Y2 // ST(3)=y2 + fld PBS_Y1 // ST(2)=y1 + fld PBS_X2 // ST(1)=x2 + fld PBS_X1 // ST(0)=x1 +EQ_Loop: + fld DWORD PTR [ecx] // ST(0):x ST(1):x1 ST(2):x2 ST(3):y1 ST(4):y2 + fld PBS_A0 // ST(0):a0 ST(1):x ST(2):x1 ST(3):x2 ST(4):y1 ST(5):y2 + fmul ST(0), ST(1) // ST(0):a0*x + fld PBS_A1 // ST(0):a1 ST(1):a0*x ST(2):x ST(3):x1 ST(4):x2 ST(5):y1 ST(6):y2 + fmul ST(0), ST(3) // ST(0):a1*x1 + add ecx, 4 + + faddp ST(1), ST(0) + fld PBS_A2 + fmul ST(0), ST(4) + faddp ST(1), ST(0) + fld PBS_B1 + fmul ST(0), ST(5) + faddp ST(1), ST(0) + fld PBS_B2 + fmul ST(0), ST(6) + sub edx, 1 + faddp ST(1), ST(0) + fst DWORD PTR [ecx-4] // *pbuffer = a0*x+a1*x1+a2*x2+b1*y1+b2*y2 + // Here, ST(0)=y ST(1)=x ST(2)=x1 ST(3)=x2 ST(4)=y1 ST(5)=y2 + fxch ST(4) // y1=y + fstp ST(5) // y2=y1 + // Here, ST(0)=x ST(1)=x1 ST(2)=x2 ST(3)=y1 ST(4)=y2 + fxch ST(1) // x1=x + fstp ST(2) // x2=x1 + jnz EQ_Loop + // Store x1,y1,x2,y2 and pop FPU stack + fstp PBS_X1 + fstp PBS_X2 + fstp PBS_Y1 + fstp PBS_Y2 + } +} + + +void AMD_StereoEQ(EQBANDSTRUCT *pbl, EQBANDSTRUCT *pbr, REAL *pbuffer, UINT nCount) +//--------------------------------------------------------------------------------- +{ +#ifdef ENABLE_3DNOW + float tmp[16]; + + _asm { + mov eax, pbl + mov edx, pbr + mov ebx, pbuffer + mov ecx, nCount + lea edi, [tmp+8] + and edi, 0xfffffff8 + movd mm7, [eax+EQBANDSTRUCT.a0] + movd mm0, [edx+EQBANDSTRUCT.a0] + movd mm6, [eax+EQBANDSTRUCT.a1] + movd mm1, [edx+EQBANDSTRUCT.a1] + punpckldq mm7, mm0 + punpckldq mm6, mm1 + movq [edi], mm7 // [edi] = a0 + movq [edi+8], mm6 // [edi+8] = a1 + movd mm5, [eax+EQBANDSTRUCT.a2] + movd mm0, [edx+EQBANDSTRUCT.a2] + movd mm4, [eax+EQBANDSTRUCT.b1] + movd mm1, [edx+EQBANDSTRUCT.b1] + movd mm3, [eax+EQBANDSTRUCT.b2] + movd mm2, [edx+EQBANDSTRUCT.b2] + punpckldq mm5, mm0 + punpckldq mm4, mm1 + punpckldq mm3, mm2 + movq [edi+16], mm5 // [edi+16] = a2 + movq [edi+24], mm4 // [edi+24] = b1 + movq [edi+32], mm3 // [edi+32] = b2 + movd mm4, [eax+EQBANDSTRUCT.x1] + movd mm0, [edx+EQBANDSTRUCT.x1] + movd mm5, [eax+EQBANDSTRUCT.x2] + movd mm1, [edx+EQBANDSTRUCT.x2] + punpckldq mm4, mm0 // mm4 = x1 + punpckldq mm5, mm1 // mm5 = x2 + movd mm6, [eax+EQBANDSTRUCT.y1] + movd mm2, [edx+EQBANDSTRUCT.y1] + movd mm7, [eax+EQBANDSTRUCT.y2] + movd mm3, [edx+EQBANDSTRUCT.y2] + punpckldq mm6, mm2 // mm6 = y1 + punpckldq mm7, mm3 // mm7 = y2 +mainloop: + movq mm0, [ebx] + movq mm3, [edi+8] + add ebx, 8 + movq mm1, [edi+16] + pfmul mm3, mm4 // x1 * a1 + movq mm2, [edi+32] + pfmul mm1, mm5 // x2 * a2 + movq mm5, mm4 // x2 = x1 + pfmul mm2, mm7 // y2 * b2 + movq mm7, mm6 // y2 = y1 + pfmul mm6, [edi+24] // y1 * b1 + movq mm4, mm0 // x1 = x + pfmul mm0, [edi] // x * a0 + pfadd mm6, mm1 // x2*a2 + y1*b1 + pfadd mm6, mm2 // x2*a2 + y1*b1 + y2*b2 + pfadd mm6, mm3 // x1*a1 + x2*a2 + y1*b1 + y2*b2 + pfadd mm6, mm0 // x*a0 + x1*a1 + x2*a2 + y1*b1 + y2*b2 + dec ecx + movq [ebx-8], mm6 + jnz mainloop + movd [eax+EQBANDSTRUCT.x1], mm4 + punpckhdq mm4, mm4 + movd [eax+EQBANDSTRUCT.x2], mm5 + punpckhdq mm5, mm5 + movd [eax+EQBANDSTRUCT.y1], mm6 + punpckhdq mm6, mm6 + movd [eax+EQBANDSTRUCT.y2], mm7 + punpckhdq mm7, mm7 + movd [edx+EQBANDSTRUCT.x1], mm4 + movd [edx+EQBANDSTRUCT.x2], mm5 + movd [edx+EQBANDSTRUCT.y1], mm6 + movd [edx+EQBANDSTRUCT.y2], mm7 + emms + } +#endif +} + + +void SSE_StereoEQ(EQBANDSTRUCT *pbl, EQBANDSTRUCT *pbr, REAL *pbuffer, UINT nCount) +//--------------------------------------------------------------------------------- +{ +#ifdef ENABLE_SSE + static const float gk1 = 1.0f; + _asm { + mov eax, pbl + mov edx, pbr + mov ebx, pbuffer + mov ecx, nCount + movss xmm0, [eax+EQBANDSTRUCT.Gain] + movss xmm1, gk1 + comiss xmm0, xmm1 + jne doeq + movss xmm0, [edx+EQBANDSTRUCT.Gain] + comiss xmm0, xmm1 + je done +doeq: + test ecx, ecx + jz done + movss xmm6, [eax+EQBANDSTRUCT.a1] + movss xmm7, [eax+EQBANDSTRUCT.a2] + movss xmm4, [eax+EQBANDSTRUCT.x1] + movss xmm5, [eax+EQBANDSTRUCT.x2] + movlhps xmm6, xmm7 // xmm6 = [ 0 | a2 | 0 | a1 ] + movlhps xmm4, xmm5 // xmm4 = [ 0 | x2 | 0 | x1 ] + movss xmm2, [edx+EQBANDSTRUCT.a1] + movss xmm3, [edx+EQBANDSTRUCT.a2] + movss xmm0, [edx+EQBANDSTRUCT.x1] + movss xmm1, [edx+EQBANDSTRUCT.x2] + movlhps xmm2, xmm3 // xmm2 = [ 0 | a'2 | 0 | a'1 ] + movlhps xmm0, xmm1 // xmm0 = [ 0 | x'2 | 0 | x'1 ] + shufps xmm6, xmm2, 0x88 // xmm6 = [ a'2 | a'1 | a2 | a1 ] + shufps xmm4, xmm0, 0x88 // xmm4 = [ x'2 | x'1 | x2 | x1 ] + shufps xmm6, xmm6, 0xD8 // xmm6 = [ a'2 | a2 | a'1 | a1 ] + shufps xmm4, xmm4, 0xD8 // xmm4 = [ x'2 | x2 | x'1 | x1 ] + movss xmm7, [eax+EQBANDSTRUCT.b1] + movss xmm0, [eax+EQBANDSTRUCT.b2] + movss xmm2, [edx+EQBANDSTRUCT.b1] + movss xmm1, [edx+EQBANDSTRUCT.b2] + movlhps xmm7, xmm0 // xmm7 = [ 0 | b2 | 0 | b1 ] + movlhps xmm2, xmm1 // xmm2 = [ 0 | b'2 | 0 | b'1 ] + shufps xmm7, xmm2, 0x88 // xmm7 = [ b'2 | b'1 | b2 | b1 ] + shufps xmm7, xmm7, 0xD8 // xmm7 = [ b'2 | b2 | b'1 | b1 ] + movss xmm5, [eax+EQBANDSTRUCT.y1] + movss xmm1, [eax+EQBANDSTRUCT.y2] + movss xmm3, [edx+EQBANDSTRUCT.y1] + movss xmm0, [edx+EQBANDSTRUCT.y2] + movlhps xmm5, xmm1 // xmm5 = [ 0 | y2 | 0 | y1 ] + movlhps xmm3, xmm0 // xmm3 = [ 0 | y'2 | 0 | y'1 ] + shufps xmm5, xmm3, 0x88 // xmm5 = [ y'2 | y'1 | y2 | y1 ] + shufps xmm5, xmm5, 0xD8 // xmm5 = [ y'2 | y2 | y'1 | y1 ] + movss xmm3, [eax+EQBANDSTRUCT.a0] + movss xmm2, [edx+EQBANDSTRUCT.a0] + shufps xmm3, xmm2, 0x88 + shufps xmm3, xmm3, 0xD8 // xmm3 = [ 0 | 0 | a'0 | a0 ] +mainloop: + movlps xmm0, qword ptr [ebx] + add ebx, 8 + movaps xmm1, xmm5 // xmm1 = [ y2r | y2l | y1r | y1l ] + mulps xmm1, xmm7 // xmm1 = [b2r*y2r|b2l*y2l|b1r*y1r|b1l*y1l] + movaps xmm2, xmm4 // xmm2 = [ x2r | x2l | x1r | x1l ] + mulps xmm2, xmm6 // xmm6 = [a2r*x2r|a2l*x2l|a1r*x1r|a1l*x1l] + shufps xmm4, xmm0, 0x44 // xmm4 = [ xr | xl | x1r | x1l ] + mulps xmm0, xmm3 // xmm0 = [ 0 | 0 |a0r*xr|a0l*xl] + shufps xmm4, xmm4, 0x4E // xmm4 = [ x1r | x1l | xr | xl ] + addps xmm1, xmm2 // xmm1 = [b2r*y2r+a2r*x2r|b2l*y2l+a2l*x2l|b1r*y1r+a1r*x1r|b1l*y1l+a1l*x1l] + addps xmm1, xmm0 // xmm1 = [b2r*y2r+a2r*x2r|b2l*y2l+a2l*x2l|b1r*y1r+a1r*x1r+a0r*xr|b1l*y1l+a1l*x1l+a0l*xl] + sub ecx, 1 + movhlps xmm0, xmm1 + addps xmm0, xmm1 // xmm0 = [ ? | ? | yr(n) | yl(n) ] + movlps [ebx-8], xmm0 + shufps xmm0, xmm5, 0x44 + movaps xmm5, xmm0 + jnz mainloop + movhlps xmm0, xmm4 + movhlps xmm1, xmm5 + movss [eax+EQBANDSTRUCT.x1], xmm4 + movss [eax+EQBANDSTRUCT.x2], xmm0 + movss [eax+EQBANDSTRUCT.y1], xmm5 + movss [eax+EQBANDSTRUCT.y2], xmm1 + shufps xmm4, xmm4, 0x01 + shufps xmm0, xmm0, 0x01 + shufps xmm5, xmm5, 0x01 + shufps xmm1, xmm1, 0x01 + movss [edx+EQBANDSTRUCT.x1], xmm4 + movss [edx+EQBANDSTRUCT.x2], xmm0 + movss [edx+EQBANDSTRUCT.y1], xmm5 + movss [edx+EQBANDSTRUCT.y2], xmm1 +done:; + } +#endif SSE_SPECIFIC +} + +#pragma warning(default:4100) + +#else + +void EQFilter(EQBANDSTRUCT *pbs, REAL *pbuffer, UINT nCount) +//---------------------------------------------------------- +{ + for (UINT i=0; i<nCount; i++) + { + REAL x = pbuffer[i]; + REAL y = pbs->a1 * pbs->x1 + pbs->a2 * pbs->x2 + pbs->a0 * x + pbs->b1 * pbs->y1 + pbs->b2 * pbs->y2; + pbs->x2 = pbs->x1; + pbs->y2 = pbs->y1; + pbs->x1 = x; + pbuffer[i] = y; + pbs->y1 = y; + } +} + +#endif + + +void CSoundFile::EQMono(int *pbuffer, UINT nCount) +//------------------------------------------------ +{ + MonoMixToFloat(pbuffer, MixFloatBuffer, nCount); + for (UINT b=0; b<MAX_EQ_BANDS; b++) + { + if ((gEQ[b].bEnable) && (gEQ[b].Gain != 1.0f)) EQFilter(&gEQ[b], MixFloatBuffer, nCount); + } + FloatToMonoMix(MixFloatBuffer, pbuffer, nCount); +} + + +void CSoundFile::EQStereo(int *pbuffer, UINT nCount) +//-------------------------------------------------- +{ + +#ifdef ENABLE_SSE +#ifdef ENABLE_MMX + + // Still allow the check, because the user can turn this on/off + + if ((gdwSysInfo & SYSMIX_SSE) && (gdwSoundSetup & SNDMIX_ENABLEMMX)) + { + int sse_state, sse_eqstate; + SSE_MonoMixToFloat(pbuffer, MixFloatBuffer, nCount*2, m_pConfig->getIntToFloat()); + + _asm stmxcsr sse_state; + sse_eqstate = sse_state | 0xFF80; + _asm ldmxcsr sse_eqstate; + for (UINT b=0; b<MAX_EQ_BANDS; b++) + { + if ((gEQ[b].bEnable) || (gEQ[b+MAX_EQ_BANDS].bEnable)) + SSE_StereoEQ(&gEQ[b], &gEQ[b+MAX_EQ_BANDS], MixFloatBuffer, nCount); + } + _asm ldmxcsr sse_state; + + X86_FloatToMonoMix(MixFloatBuffer, pbuffer, nCount*2, m_pConfig->getFloatToInt()); + + } else + +#endif // ENABLE_MMX +#endif // ENABLE_SSE + +#ifdef ENABLE_3DNOW + + // We still perform the MMX check because the user can enable/disable this + + if ((gdwSysInfo & SYSMIX_3DNOW) && (gdwSoundSetup & SNDMIX_ENABLEMMX)) + { + AMD_MonoMixToFloat(pbuffer, MixFloatBuffer, nCount*2, m_pConfig->getIntToFloat()); + + for (UINT b=0; b<MAX_EQ_BANDS; b++) + { + if (((gEQ[b].bEnable) && (gEQ[b].Gain != 1.0f)) + || ((gEQ[b+MAX_EQ_BANDS].bEnable) && (gEQ[b+MAX_EQ_BANDS].Gain != 1.0f))) + AMD_StereoEQ(&gEQ[b], &gEQ[b+MAX_EQ_BANDS], MixFloatBuffer, nCount); + } + + AMD_FloatToMonoMix(MixFloatBuffer, pbuffer, nCount*2, m_pConfig->getFloatToInt()); + + } else +#endif // ENABLE_3DNOW + + { + X86_StereoMixToFloat(pbuffer, MixFloatBuffer, MixFloatBuffer+MIXBUFFERSIZE, nCount, m_pConfig->getIntToFloat()); + + for (UINT bl=0; bl<MAX_EQ_BANDS; bl++) + { + if ((gEQ[bl].bEnable) && (gEQ[bl].Gain != 1.0f)) EQFilter(&gEQ[bl], MixFloatBuffer, nCount); + } + for (UINT br=MAX_EQ_BANDS; br<MAX_EQ_BANDS*2; br++) + { + if ((gEQ[br].bEnable) && (gEQ[br].Gain != 1.0f)) EQFilter(&gEQ[br], MixFloatBuffer+MIXBUFFERSIZE, nCount); + } + + X86_FloatToStereoMix(MixFloatBuffer, MixFloatBuffer+MIXBUFFERSIZE, pbuffer, nCount, m_pConfig->getFloatToInt()); + } +} + + +void CSoundFile::InitializeEQ(BOOL bReset) +//---------------------------------------- +{ + REAL fMixingFreq = (REAL)gdwMixingFreq; + // Gain = 0.5 (-6dB) .. 2 (+6dB) + for (UINT band=0; band<MAX_EQ_BANDS*2; band++) if (gEQ[band].bEnable) + { + REAL k, k2, r, f; + REAL v0, v1; + BOOL b = bReset; + + f = gEQ[band].CenterFrequency / fMixingFreq; + if (f > 0.45f) gEQ[band].Gain = 1; + // if (f > 0.25) f = 0.25; + // k = tan(PI*f); + k = f * 3.141592654f; + k = k + k*f; +// if (k > (REAL)0.707) k = (REAL)0.707; + k2 = k*k; + v0 = gEQ[band].Gain; + v1 = 1; + if (gEQ[band].Gain < 1.0) + { + v0 *= (0.5f/EQ_BANDWIDTH); + v1 *= (0.5f/EQ_BANDWIDTH); + } else + { + v0 *= (1.0f/EQ_BANDWIDTH); + v1 *= (1.0f/EQ_BANDWIDTH); + } + r = (1 + v0*k + k2) / (1 + v1*k + k2); + if (r != gEQ[band].a0) + { + gEQ[band].a0 = r; + b = TRUE; + } + r = 2 * (k2 - 1) / (1 + v1*k + k2); + if (r != gEQ[band].a1) + { + gEQ[band].a1 = r; + b = TRUE; + } + r = (1 - v0*k + k2) / (1 + v1*k + k2); + if (r != gEQ[band].a2) + { + gEQ[band].a2 = r; + b = TRUE; + } + r = - 2 * (k2 - 1) / (1 + v1*k + k2); + if (r != gEQ[band].b1) + { + gEQ[band].b1 = r; + b = TRUE; + } + r = - (1 - v1*k + k2) / (1 + v1*k + k2); + if (r != gEQ[band].b2) + { + gEQ[band].b2 = r; + b = TRUE; + } + if (b) + { + gEQ[band].x1 = 0; + gEQ[band].x2 = 0; + gEQ[band].y1 = 0; + gEQ[band].y2 = 0; + } + } else + { + gEQ[band].a0 = 0; + gEQ[band].a1 = 0; + gEQ[band].a2 = 0; + gEQ[band].b1 = 0; + gEQ[band].b2 = 0; + gEQ[band].x1 = 0; + gEQ[band].x2 = 0; + gEQ[band].y1 = 0; + gEQ[band].y2 = 0; + } +} + + +void CSoundFile::SetEQGains(const UINT *pGains, UINT nGains, const UINT *pFreqs, BOOL bReset) +//------------------------------------------------------------------------------------------- +{ + for (UINT i=0; i<MAX_EQ_BANDS; i++) + { + REAL g, f = 0; + if (i < nGains) + { + UINT n = pGains[i]; + if (n > 32) n = 32; + g = ((REAL)gEqLinearToDB[n]) / 64.0f; + if (pFreqs) f = (REAL)(int)pFreqs[i]; + } else + { + g = 1; + } + gEQ[i].Gain = g; + gEQ[i].CenterFrequency = f; + gEQ[i+MAX_EQ_BANDS].Gain = g; + gEQ[i+MAX_EQ_BANDS].CenterFrequency = f; + if (f > 20.0f) + { + gEQ[i].bEnable = TRUE; + gEQ[i+MAX_EQ_BANDS].bEnable = TRUE; + } else + { + gEQ[i].bEnable = FALSE; + gEQ[i+MAX_EQ_BANDS].bEnable = FALSE; + } + } + InitializeEQ(bReset); +} Deleted: trunk/OpenMPT/soundlib/Snd_dsp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_dsp.cpp 2013-03-25 14:43:07 UTC (rev 1667) +++ trunk/OpenMPT/soundlib/Snd_dsp.cpp 2013-03-25 15:03:37 UTC (rev 1668) @@ -1,521 +0,0 @@ -/* - * snd_dsp.cpp - * ----------- - * Purpose: Mixing code for various DSPs (EQ, Mega-Bass, ...) - * Notes : Ugh... This should really be removed at some point. - * Authors: Olivier Lapicque - * OpenMPT Devs - * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. - */ - - -#include "stdafx.h" -#include "sndfile.h" -#include <math.h> - - -// Bass Expansion -#define DEFAULT_XBASS_RANGE 14 // (x+2)*20 Hz (320Hz) -#define DEFAULT_XBASS_DEPTH 6 // 1+(3>>(x-4)) (+6dB) - -// Buffer Sizes -#define XBASSBUFFERSIZE 64 // 2 ms at 50KHz -#define SURROUNDBUFFERSIZE 2048 // 50ms @ 48kHz - - -// DSP Effects: PUBLIC members -UINT CSoundFile::m_nXBassDepth = DEFAULT_XBASS_DEPTH; -UINT CSoundFile::m_nXBassRange = DEFAULT_XBASS_RANGE; -UINT CSoundFile::gnReverbType = 0; -UINT CSoundFile::m_nReverbDepth = 8; // 50% -UINT CSoundFile::m_nProLogicDepth = 12; -UINT CSoundFile::m_nProLogicDelay = 20; - -//////////////////////////////////////////////////////////////////// -// DSP Effects internal state - -// Noise Reduction: simple low-pass filter -static LONG nLeftNR = 0; -static LONG nRightNR = 0; - -// Surround Encoding: 1 delay line + low-pass filter + high-pass filter -static LONG nSurroundSize = 0; -static LONG nSurroundPos = 0; -static LONG nDolbyDepth = 0; -// Surround Biquads -static LONG nDolbyHP_Y1 = 0; -static LONG nDolbyHP_X1 = 0; -static LONG nDolbyLP_Y1 = 0; -static LONG nDolbyHP_B0 = 0; -static LONG nDolbyHP_B1 = 0; -static LONG nDolbyHP_A1 = 0; -static LONG nDolbyLP_B0 = 0; -static LONG nDolbyLP_B1 = 0; -static LONG nDolbyLP_A1 = 0; - -// Bass Expansion: low-pass filter -static LONG nXBassFlt_Y1 = 0; -static LONG nXBassFlt_X1 = 0; -static LONG nXBassFlt_B0 = 0; -static LONG nXBassFlt_B1 = 0; -static LONG nXBassFlt_A1 = 0; - -// DC Removal Biquad -static LONG nDCRFlt_Y1l = 0; -static LONG nDCRFlt_X1l = 0; -static LONG nDCRFlt_Y1r = 0; -static LONG nDCRFlt_X1r = 0; - - -static LONG SurroundBuffer[SURROUNDBUFFERSIZE]; - - -// Access the main temporary mix buffer directly: avoids an extra pointer -extern int MixSoundBuffer[MIXBUFFERSIZE * 4]; -extern int MixRearBuffer[MIXBUFFERSIZE * 2]; - -extern VOID InitializeReverb(BOOL bReset); -extern VOID ProcessReverb(UINT nSamples); -extern VOID MPPASMCALL X86_InitMixBuffer(int *pBuffer, UINT nSamples); -extern VOID MPPASMCALL X86_StereoFill(int *pBuffer, UINT nSamples, LPLONG lpROfs, LPLONG lpLOfs); -extern VOID MPPASMCALL X86_StereoDCRemoval(int *, UINT count); -extern VOID MPPASMCALL X86_MonoDCRemoval(int *, UINT count); - -/////////////////////////////////////////////////////////////////////////////////// -// -// Biquad setup -// - - -#define PI 3.14159265358979323f -inline FLOAT Sgn(FLOAT x) { return (x >= 0) ? 1.0f : -1.0f; } -VOID ShelfEQ(LONG scale, - LONG *outA1, LONG *outB0, LONG *outB1, - LONG F_c, LONG F_s, FLOAT gainDC, FLOAT gainFT, FLOAT gainPI) -{ - FLOAT a1, b0, b1; - FLOAT gainFT2, gainDC2, gainPI2; - FLOAT alpha, beta0, beta1, rho; - FLOAT wT, quad; - - _asm { - // wT = PI*Fc/Fs - fild F_c - fldpi - fmulp ST(1), ST(0) - fild F_s - fdivp ST(1), ST(0) - fstp wT - // gain^2 - fld gainDC - fld gainFT - fld gainPI - fmul ST(0), ST(0) - fstp gainPI2 - fmul ST(0), ST(0) - fstp gainFT2 - fmul ST(0), ST(0) - fstp gainDC2 - } - - quad = gainPI2 + gainDC2 - (gainFT2*2); - - alpha = 0; - - if (quad != 0) - { - FLOAT lambda = (gainPI2 - gainDC2) / quad; - alpha = (FLOAT)(lambda - Sgn(lambda)*sqrt(lambda*lambda - 1.0f)); - } - - beta0 = 0.5f * ((gainDC + gainPI) + (gainDC - gainPI) * alpha); - beta1 = 0.5f * ((gainDC - gainPI) + (gainDC + gainPI) * alpha); - rho = (FLOAT)((sin((wT*0.5f) - (PI/4.0f))) / (sin((wT*0.5f) + (PI/4.0f)))); - - quad = 1.0f / (1.0f + rho*alpha); - - b0 = ((beta0 + rho*beta1) * quad); - b1 = ((beta1 + rho*beta0) * quad); - a1 = - ((rho + alpha) * quad); - - _asm { - fild scale - fld a1 - mov eax, outA1 - fmul ST(0), ST(1) - fistp dword ptr [eax] - fld b0 - mov eax, outB0 - fmul ST(0), ST(1) - fistp dword ptr [eax] - fld b1 - mov eax, outB1 - fmul ST(0), ST(1) - fistp dword ptr [eax] - fstp rho - } -} - - -void CSoundFile::InitializeDSP(BOOL bReset) -//----------------------------------------- -{ - if (gnReverbType >= NUM_REVERBTYPES) gnReverbType = 0; - if (!m_nProLogicDelay) m_nProLogicDelay = 20; - if (bReset) - { - // Noise Reduction - nLeftNR = nRightNR = 0; - } - // Pro-Logic Surround - nSurroundPos = nSurroundSize = 0; - if (gdwSoundSetup & SNDMIX_SURROUND) - { - memset(SurroundBuffer, 0, sizeof(SurroundBuffer)); - nSurroundSize = (gdwMixingFreq * m_nProLogicDelay) / 1000; - if (nSurroundSize > SURROUNDBUFFERSIZE) nSurroundSize = SURROUNDBUFFERSIZE; - nDolbyDepth = m_nProLogicDepth; - if (nDolbyDepth < 1) nDolbyDepth = 1; - if (nDolbyDepth > 16) nDolbyDepth = 16; - // Setup biquad filters - ShelfEQ(1024, &nDolbyHP_A1, &nDolbyHP_B0, &nDolbyHP_B1, 200, gdwMixingFreq, 0, 0.5f, 1); - ShelfEQ(1024, &nDolbyLP_A1, &nDolbyLP_B0, &nDolbyLP_B1, 7000, gdwMixingFreq, 1, 0.75f, 0); - nDolbyHP_X1 = nDolbyHP_Y1 = 0; - nDolbyLP_Y1 = 0; - // Surround Level - nDolbyHP_B0 = (nDolbyHP_B0 * nDolbyDepth) >> 5; - nDolbyHP_B1 = (nDolbyHP_B1 * nDolbyDepth) >> 5; - // +6dB - nDolbyLP_B0 *= 2; - nDolbyLP_B1 *= 2; - } - // Reverb Setup -#ifndef NO_REVERB - InitializeReverb(bReset); -#endif - // Bass Expansion Reset - if (gdwSoundSetup & SNDMIX_MEGABASS) - { - LONG a1 = 0, b0 = 1024, b1 = 0; - int nXBassCutOff = 50 + (m_nXBassRange+2) * 20; - int nXBassGain = m_nXBassDepth; - Limit(nXBassGain, 2, 8); - Limit(nXBassCutOff, 60, 600); - ShelfEQ(1024, &a1, &b0, &b1, nXBassCutOff, gdwMixingFreq, - 1.0f + (1.0f/16.0f) * (0x300 >> nXBassGain), - 1.0f, - 0.0000001f); - if (nXBassGain > 5) - { - b0 >>= (nXBassGain-5); - b1 >>= (nXBassGain-5); - } - nXBassFlt_A1 = a1; - nXBassFlt_B0 = b0; - nXBassFlt_B1 = b1; - //Log("b0=%d b1=%d a1=%d\n", b0, b1, a1); - } - if (bReset) - { - nXBassFlt_X1 = 0; - nXBassFlt_Y1 = 0; - nDCRFlt_X1l = 0; - nDCRFlt_X1r = 0; - nDCRFlt_Y1l = 0; - nDCRFlt_Y1r = 0; - } -} - - -// 2-channel surround -static void ProcessStereoSurround(int count) -//------------------------------------------ -{ - int *pr = MixSoundBuffer, hy1 = nDolbyHP_Y1; - for (int r=count; r; r--) - { - // Delay - int secho = SurroundBuffer[nSurroundPos]; - SurroundBuffer[nSurroundPos] = (pr[0]+pr[1]+256) >> 9; - // High-pass - int v0 = (nDolbyHP_B0 * secho + nDolbyHP_B1 * nDolbyHP_X1 + nDolbyHP_A1 * hy1) >> 10; - nDolbyHP_X1 = secho; - // Low-pass - int v = (nDolbyLP_B0 * v0 + nDolbyLP_B1 * hy1 + nDolbyLP_A1 * nDolbyLP_Y1) >> (10-8); - hy1 = v0; - nDolbyLP_Y1 = v >> 8; - // Add echo - pr[0] += v; - pr[1] -= v; - if (++nSurroundPos >= nSurroundSize) nSurroundPos = 0; - pr += 2; - } - nDolbyHP_Y1 = hy1; -} - - -// 4-channels surround -static void ProcessQuadSurround(int count) -//---------------------------------------- -{ - int *pr = MixSoundBuffer, hy1 = nDolbyHP_Y1; - for (int r=count; r; r--) - { - int vl = pr[0] >> 1; - int vr = pr[1] >> 1; - pr[(UINT)(MixRearBuffer-MixSoundBuffer)] += vl; - pr[((UINT)(MixRearBuffer-MixSoundBuffer))+1] += vr; - // Delay - int secho = SurroundBuffer[nSurroundPos]; - SurroundBuffer[nSurroundPos] = (vr+vl+256) >> 9; - // High-pass - int v0 = (nDolbyHP_B0 * secho + nDolbyHP_B1 * nDolbyHP_X1 + nDolbyHP_A1 * hy1) >> 10; - nDolbyHP_X1 = secho; - // Low-pass - int v = (nDolbyLP_B0 * v0 + nDolbyLP_B1 * hy1 + nDolbyLP_A1 * nDolbyLP_Y1) >> (10-8); - hy1 = v0; - nDolbyLP_Y1 = v >> 8; - // Add echo - pr[(UINT)(MixRearBuffer-MixSoundBuffer)] += v; - pr[((UINT)(MixRearBuffer-MixSoundBuffer))+1] += v; - if (++nSurroundPos >= nSurroundSize) nSurroundPos = 0; - pr += 2; - } - nDolbyHP_Y1 = hy1; -} - - -void CSoundFile::ProcessStereoDSP(int count) -//------------------------------------------ -{ - // Dolby Pro-Logic Surround - if (gdwSoundSetup & SNDMIX_SURROUND) - { - if (gnChannels > 2) ProcessQuadSurround(count); else - ProcessStereoSurround(count); - } - // DC Removal - if (gdwSoundSetup & SNDMIX_MEGABASS) - { - X86_StereoDCRemoval(MixSoundBuffer, count); - } - // Bass Expansion - if (gdwSoundSetup & SNDMIX_MEGABASS) - { - int *px = MixSoundBuffer; - int x1 = nXBassFlt_X1; - int y1 = nXBassFlt_Y1; - for (int x=count; x; x--) - { - int x_m = (px[0]+px[1]+0x100)>>9; - - y1 = (nXBassFlt_B0 * x_m + nXBassFlt_B1 * x1 + nXBassFlt_A1 * y1) >> (10-8); - x1 = x_m; - px[0] += y1; - px[1] += y1; - y1 = (y1+0x80) >> 8; - px += 2; - } - nXBassFlt_X1 = x1; - nXBassFlt_Y1 = y1; - } - // Noise Reduction - if (gdwSoundSetup & SNDMIX_NOISEREDUCTION) - { - int n1 = nLeftNR, n2 = nRightNR; - int *pnr = MixSoundBuffer; - for (int nr=count; nr; nr--) - { - int vnr = pnr[0] >> 1; - pnr[0] = vnr + n1; - n1 = vnr; - vnr = pnr[1] >> 1; - pnr[1] = vnr + n2; - n2 = vnr; - pnr += 2; - } - nLeftNR = n1; - nRightNR = n2; - } -} - - -void CSoundFile::ProcessMonoDSP(int count) -//---------------------------------------- -{ - // DC Removal - if (gdwSoundSetup & SNDMIX_MEGABASS) - { - X86_MonoDCRemoval(MixSoundBuffer, count); - } - // Bass Expansion - if (gdwSoundSetup & SNDMIX_MEGABASS) - { - int *px = MixSoundBuffer; - int x1 = nXBassFlt_X1; - int y1 = nXBassFlt_Y1; - for (int x=count; x; x--) - { - int x_m = (px[0]+0x80)>>8; - - y1 = (nXBassFlt_B0 * x_m + nXBassFlt_B1 * x1 + nXBassFlt_A1 * y1) >> (10-8); - x1 = x_m; - px[0] += y1; - y1 = (y1+0x40) >> 8; - px++; - } - nXBassFlt_X1 = x1; - nXBassFlt_Y1 = y1; - } - // Noise Reduction - if (gdwSoundSetup & SNDMIX_NOISEREDUCTION) - { - int n = nLeftNR; - int *pnr = MixSoundBuffer; - for (int nr=count; nr; pnr++, nr--) - { - int vnr = *pnr >> 1; - *pnr = vnr + n; - n = vnr; - } - nLeftNR = n; - } -} - - - -////////////////////////////////////////////////////////////////////////// -// -// DC Removal -// - -#define DCR_AMOUNT 9 - -VOID MPPASMCALL X86_StereoDCRemoval(int *pBuffer, UINT nSamples) -{ - int y1l=nDCRFlt_Y1l, x1l=nDCRFlt_X1l; - int y1r=nDCRFlt_Y1r, x1r=nDCRFlt_X1r; - - _asm { - mov esi, pBuffer - mov ecx, nSamples -stereodcr: - mov eax, [esi] - mov ebx, x1l - mov edx, [esi+4] - mov edi, x1r - add esi, 8 - sub ebx, eax - mov x1l, eax - mov eax, ebx - sar eax, DCR_AMOUNT+1 - sub edi, edx - sub eax, ebx - mov x1r, edx - add eax, y1l - mov edx, edi - sar edx, DCR_AMOUNT+1 - mov [esi-8], eax - sub edx, edi - mov ebx, eax - add edx, y1r - sar ebx, DCR_AMOUNT - mov [esi-4], edx - mov edi, edx - sub eax, ebx - sar edi, DCR_AMOUNT - mov y1l, eax - sub edx, edi - dec ecx - mov y1r, edx - jnz stereodcr - } - nDCRFlt_Y1l = y1l; - nDCRFlt_X1l = x1l; - nDCRFlt_Y1r = y1r; - nDCRFlt_X1r = x1r; -} - - -VOID MPPASMCALL X86_MonoDCRemoval(int *pBuffer, UINT nSamples) -{ - _asm { - mov esi, pBuffer - mov ecx, nSamples - mov edx, nDCRFlt_X1l - mov edi, nDCRFlt_Y1l -stereodcr: - mov eax, [esi] - mov ebx, edx - add esi, 4 - sub ebx, eax - mov edx, eax - mov eax, ebx - sar eax, DCR_AMOUNT+1 - sub eax, ebx - add eax, edi - mov [esi-4], eax - mov ebx, eax - sar ebx, DCR_AMOUNT - sub eax, ebx - dec ecx - mov edi, eax - jnz stereodcr - mov nDCRFlt_X1l, edx - mov nDCRFlt_Y1l, edi - } -} - - - - - -///////////////////////////////////////////////////////////////// -// Clean DSP Effects interface - -// [Reverb level 0(quiet)-100(loud)], [type = REVERBTYPE_XXXX] -BOOL CSoundFile::SetReverbParameters(UINT nDepth, UINT nType) -//----------------------------------------------------------- -{ - if (nDepth > 100) nDepth = 100; - UINT gain = (nDepth * 16) / 100; - if (gain > 16) gain = 16; - if (gain < 1) gain = 1; - m_nReverbDepth = gain; - if (nType < NUM_REVERBTYPES) gnReverbType = nType; - return TRUE; -} - - -// [XBass level 0(quiet)-100(loud)], [cutoff in Hz 20-100] -BOOL CSoundFile::SetXBassParameters(UINT nDepth, UINT nRange) -//----------------------------------------------------------- -{ - if (nDepth > 100) nDepth = 100; - UINT gain = nDepth / 20; - if (gain > 4) gain = 4; - m_nXBassDepth = 8 - gain; // filter attenuation 1/256 .. 1/16 - UINT range = nRange / 5; - if (range > 5) range -= 5; else range = 0; - if (nRange > 16) nRange = 16; - m_nXBassRange = 21 - range; // filter average on 0.5-1.6ms - return TRUE; -} - - -// [Surround level 0(quiet)-100(heavy)] [delay in ms, usually 5-50ms] -BOOL CSoundFile::SetSurroundParameters(UINT nDepth, UINT nDelay) -//-------------------------------------------------------------- -{ - UINT gain = (nDepth * 16) / 100; - if (gain > 16) gain = 16; - if (gain < 1) gain = 1; - m_nProLogicDepth = gain; - if (nDelay < 4) nDelay = 4; - if (nDelay > 50) nDelay = 50; - m_nProLogicDelay = nDelay; - return TRUE; -} - - - Deleted: trunk/OpenMPT/soundlib/Snd_eq.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_eq.cpp 2013-03-25 14:43:07 UTC (rev 1667) +++ trunk/OpenMPT/soundlib/Snd_eq.cpp 2013-03-25 15:03:37 UTC (rev 1668) @@ -1,532 +0,0 @@ -/* - * snd_eq.cpp - * ---------- - * Purpose: Mixing code for equalizer. - * Notes : Ugh... This should really be removed at some point. - * Authors: Olivier Lapicque - * OpenMPT Devs - * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. - */ - - -#include "stdafx.h" -#include "sndfile.h" -#include "../mptrack/TrackerSettings.h" - -#define EQ_BANDWIDTH 2.0 -#define EQ_ZERO 0.000001 -#define REAL float - -extern REAL MixFloatBuffer[]; - -extern void X86_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc); -extern void X86_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic); -extern void X86_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc); -extern void X86_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic); - -#ifdef ENABLE_SSE -extern void SSE_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc); -#endif -#ifdef ENABLE_3DNOW -extern void AMD_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc); -extern void AMD_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic); -#endif - - - - -#pragma pack(push, 4) -typedef struct _EQBANDSTRUCT -{ - REAL a0, a1, a2, b1, b2; - REAL x1, x2, y1, y2; - REAL Gain, CenterFrequency; - BOOL bEnable; -} EQBANDSTRUCT, *PEQBANDSTRUCT; -#pragma pack(pop) - -UINT gEqLinearToDB[33] = -{ - 16, 19, 22, 25, 28, 31, 34, 37, - 40, 43, 46, 49, 52, 55, 58, 61, - 64, 76, 88, 100, 112, 124, 136, 148, - 160, 172, 184, 196, 208, 220, 232, 244, 256 -}; - - -static REAL f2ic = (REAL)(1 << 28); -static REAL i2fc = (REAL)(1.0 / (1 << 28)); - -static EQBANDSTRUCT gEQ[MAX_EQ_BANDS*2] = -{ - // Default: Flat EQ - {0,0,0,0,0, 0,0,0,0, 1, 120, FALSE}, - {0,0,0,0,0, 0,0,0,0, 1, 600, FALSE}, - {0,0,0,0,0, 0,0,0,0, 1, 1200, FALSE}, - {0,0,0,0,0, 0,0,0,0, 1, 3000, FALSE}, - {0,0,0,0,0, 0,0,0,0, 1, 6000, FALSE}, - {0,0,0,0,0, 0,0,0,0, 1, 10000, FALSE}, - {0,0,0,0,0, 0,0,0,0, 1, 120, FALSE}, - {0,0,0,0,0, 0,0,0,0, 1, 600, FALSE}, - {0,0,0,0,0, 0,0,0,0, 1, 1200, FALSE}, - {0,0,0,0,0, 0,0,0,0, 1, 3000, FALSE}, - {0,0,0,0,0, 0,0,0,0, 1, 6000, FALSE}, - {0,0,0,0,0, 0,0,0,0, 1, 10000, FALSE}, -}; - -#define ASM_EQ -#ifdef ASM_EQ - -#pragma warning(disable:4100) - -#define PBS_A0 DWORD PTR [eax] -#define PBS_A1 DWORD PTR [eax+4] -#define PBS_A2 DWORD PTR [eax+8] -#define PBS_B1 DWORD PTR [eax+12] -#define PBS_B2 DWORD PTR [eax+16] -#define PBS_X1 DWORD PTR [eax+20] -#define PBS_X2 DWORD PTR [eax+24] -#define PBS_Y1 DWORD PTR [eax+28] -#define PBS_Y2 DWORD PTR [eax+32] - -void __cdecl EQFilter(EQBANDSTRUCT *pbs, REAL *pbuffer, UINT nCount) -//------------------------------------------------------------------ -{ - _asm { - mov eax, pbs // eax = pbs - mov edx, nCount // edx = nCount - mov ecx, pbuffer // ecx = pbuffer - fld PBS_Y2 // ST(3)=y2 - fld PBS_Y1 // ST(2)=y1 - fld PBS_X2 // ST(1)=x2 - fld PBS_X1 // ST(0)=x1 -EQ_Loop: - fld DWORD PTR [ecx] // ST(0):x ST(1):x1 ST(2):x2 ST(3):y1 ST(4):y2 - fld PBS_A0 // ST(0):a0 ST(1):x ST(2):x1 ST(3):x2 ST(4):y1 ST(5):y2 - fmul ST(0), ST(1) // ST(0):a0*x - fld PBS_A1 // ST(0):a1 ST(1):a0*x ST(2):x ST(3):x1 ST(4):x2 ST(5):y1 ST(6):y2 - fmul ST(0), ST(3) // ST(0):a1*x1 - add ecx, 4 - - faddp ST(1), ST(0) - fld PBS_A2 - fmul ST(0), ST(4) - faddp ST(1), ST(0) - fld PBS_B1 - fmul ST(0), ST(5) - faddp ST(1), ST(0) - fld PBS_B2 - fmul ST(0), ST(6) - sub edx, 1 - faddp ST(1), ST(0) - fst DWORD PTR [ecx-4] // *pbuffer = a0*x+a1*x1+a2*x2+b1*y1+b2*y2 - // Here, ST(0)=y ST(1)=x ST(2)=x1 ST(3)=x2 ST(4)=y1 ST(5)=y2 - fxch ST(4) // y1=y - fstp ST(5) // y2=y1 - // Here, ST(0)=x ST(1)=x1 ST(2)=x2 ST(3)=y1 ST(4)=y2 - fxch ST(1) // x1=x - fstp ST(2) // x2=x1 - jnz EQ_Loop - // Store x1,y1,x2,y2 and pop FPU stack - fstp PBS_X1 - fstp PBS_X2 - fstp PBS_Y1 - fstp PBS_Y2 - } -} - - -void AMD_StereoEQ(EQBANDSTRUCT *pbl, EQBANDSTRUCT *pbr, REAL *pbuffer, UINT nCount) -//--------------------------------------------------------------------------------- -{ -#ifdef ENABLE_3DNOW - float tmp[16]; - - _asm { - mov eax, pbl - mov edx, pbr - mov ebx, pbuffer - mov ecx, nCount - lea edi, [tmp+8] - and edi, 0xfffffff8 - movd mm7, [eax+EQBANDSTRUCT.a0] - movd mm0, [edx+EQBANDSTRUCT.a0] - movd mm6, [eax+EQBANDSTRUCT.a1] - movd mm1, [edx+EQBANDSTRUCT.a1] - punpckldq mm7, mm0 - punpckldq mm6, mm1 - movq [edi], mm7 // [edi] = a0 - movq [edi+8], mm6 // [edi+8] = a1 - movd mm5, [eax+EQBANDSTRUCT.a2] - movd mm0, [edx+EQBANDSTRUCT.a2] - movd mm4, [eax+EQBANDSTRUCT.b1] - movd mm1, [edx+EQBANDSTRUCT.b1] - movd mm3, [eax+EQBANDSTRUCT.b2] - movd mm2, [edx+EQBANDSTRUCT.b2] - punpckldq mm5, mm0 - punpckldq mm4, mm1 - punpckldq mm3, mm2 - movq [edi+16], mm5 // [edi+16] = a2 - movq [edi+24], mm4 // [edi+24] = b1 - movq [edi+32], mm3 // [edi+32] = b2 - movd mm4, [eax+EQBANDSTRUCT.x1] - movd mm0, [edx+EQBANDSTRUCT.x1] - movd mm5, [eax+EQBANDSTRUCT.x2] - movd mm1, [edx+EQBANDSTRUCT.x2] - punpckldq mm4, mm0 // mm4 = x1 - punpckldq mm5, mm1 // mm5 = x2 - movd mm6, [eax+EQBANDSTRUCT.y1] - movd mm2, [edx+EQBANDSTRUCT.y1] - movd mm7, [eax+EQBANDSTRUCT.y2] - movd mm3, [edx+EQBANDSTRUCT.y2] - punpckldq mm6, mm2 // mm6 = y1 - punpckldq mm7, mm3 // mm7 = y2 -mainloop: - movq mm0, [ebx] - movq mm3, [edi+8] - add ebx, 8 - movq mm1, [edi+16] - pfmul mm3, mm4 // x1 * a1 - movq mm2, [edi+32] - pfmul mm1, mm5 // x2 * a2 - movq mm5, mm4 // x2 = x1 - pfmul mm2, mm7 // y2 * b2 - movq mm7, mm6 // y2 = y1 - pfmul mm6, [edi+24] // y1 * b1 - movq mm4, mm0 // x1 = x - pfmul mm0, [edi] // x * a0 - pfadd mm6, mm1 // x2*a2 + y1*b1 - pfadd mm6, mm2 // x2*a2 + y1*b1 + y2*b2 - pfadd mm6, mm3 // x1*a1 + x2*a2 + y1*b1 + y2*b2 - pfadd mm6, mm0 // x*a0 + x1*a1 + x2*a2 + y1*b1 + y2*b2 - dec ecx - movq [ebx-8], mm6 - jnz mainloop - movd [eax+EQBANDSTRUCT.x1], mm4 - punpckhdq mm4, mm4 - movd [eax+EQBANDSTRUCT.x2], mm5 - punpckhdq mm5, mm5 - movd [eax+EQBANDSTRUCT.y1], mm6 - punpckhdq mm6, mm6 - movd [eax+EQBANDSTRUCT.y2], mm7 - punpckhdq mm7, mm7 - movd [edx+EQBANDSTRUCT.x1], mm4 - movd [edx+EQBANDSTRUCT.x2], mm5 - movd [edx+EQBANDSTRUCT.y1], mm6 - movd [edx+EQBANDSTRUCT.y2], mm7 - emms - } -#endif -} - - -void SSE_StereoEQ(EQBANDSTRUCT *pbl, EQBANDSTRUCT *pbr, REAL *pbuffer, UINT nCount) -//--------------------------------------------------------------------------------- -{ -#ifdef ENABLE_SSE - static const float gk1 = 1.0f; - _asm { - mov eax, pbl - mov edx, pbr - mov ebx, pbuffer - mov ecx, nCount - movss xmm0, [eax+EQBANDSTRUCT.Gain] - movss xmm1, gk1 - comiss xmm0, xmm1 - jne doeq - movss xmm0, [edx+EQBANDSTRUCT.Gain] - comiss xmm0, xmm1 - je done -doeq: - test ecx, ecx - jz done - movss xmm6, [eax+EQBANDSTRUCT.a1] - movss xmm7, [eax+EQBANDSTRUCT.a2] - movss xmm4, [eax+EQBANDSTRUCT.x1] - movss xmm5, [eax+EQBANDSTRUCT.x2] - movlhps xmm6, xmm7 // xmm6 = [ 0 | a2 | 0 | a1 ] - movlhps xmm4, xmm5 // xmm4 = [ 0 | x2 | 0 | x1 ] - movss xmm2, [edx+EQBANDSTRUCT.a1] - movss xmm3, [edx+EQBANDSTRUCT.a2] - movss xmm0, [edx+EQBANDSTRUCT.x1] - movss xmm1, [edx+EQBANDSTRUCT.x2] - movlhps xmm2, xmm3 // xmm2 = [ 0 | a'2 | 0 | a'1 ] - movlhps xmm0, xmm1 // xmm0 = [ 0 | x'2 | 0 | x'1 ] - shufps xmm6, xmm2, 0x88 // xmm6 = [ a'2 | a'1 | a2 | a1 ] - shufps xmm4, xmm0, 0x88 // xmm4 = [ x'2 | x'1 | x2 | x1 ] - shufps xmm6, xmm6, 0xD8 // xmm6 = [ a'2 | a2 | a'1 | a1 ] - shufps xmm4, xmm4, 0xD8 // xmm4 = [ x'2 | x2 | x'1 | x1 ] - movss xmm7, [eax+EQBANDSTRUCT.b1] - movss xmm0, [eax+EQBANDSTRUCT.b2] - movss xmm2, [edx+EQBANDSTRUCT.b1] - movss xmm1, [edx+EQBANDSTRUCT.b2] - movlhps xmm7, xmm0 // xmm7 = [ 0 | b2 | 0 | b1 ] - movlhps xmm2, xmm1 // xmm2 = [ 0 | b'2 | 0 | b'1 ] - shufps xmm7, xmm2, 0x88 // xmm7 = [ b'2 | b'1 | b2 | b1 ] - shufps xmm7, xmm7, 0xD8 // xmm7 = [ b'2 | b2 | b'1 | b1 ] - movss xmm5, [eax+EQBANDSTRUCT.y1] - movss xmm1, [eax+EQBANDSTRUCT.y2] - movss xmm3, [edx+EQBANDSTRUCT.y1] - movss xmm0, [edx+EQBANDSTRUCT.y2] - movlhps xmm5, xmm1 // xmm5 = [ 0 | y2 | 0 | y1 ] - movlhps xmm3, xmm0 // xmm3 = [ 0 | y'2 | 0 | y'1 ] - shufps xmm5, xmm3, 0x88 // xmm5 = [ y'2 | y'1 | y2 | y1 ] - shufps xmm5, xmm5, 0xD8 // xmm5 = [ y'2 | y2 | y'1 | y1 ] - movss xmm3, [eax+EQBANDSTRUCT.a0] - movss xmm2, [edx+EQBANDSTRUCT.a0] - shufps xmm3, xmm2, 0x88 - shufps xmm3, xmm3, 0xD8 // xmm3 = [ 0 | 0 | a'0 | a0 ] -mainloop: - movlps xmm0, qword ptr [ebx] - add ebx, 8 - movaps xmm1, xmm5 // xmm1 = [ y2r | y2l | y1r | y1l ] - mulps xmm1, xmm7 // xmm1 = [b2r*y2r|b2l*y2l|b1r*y1r|b1l*y1l] - movaps xmm2, xmm4 // xmm2 = [ x2r | x2l | x1r | x1l ] - mulps xmm2, xmm6 // xmm6 = [a2r*x2r|a2l*x2l|a1r*x1r|a1l*x1l] - shufps xmm4, xmm0, 0x44 // xmm4 = [ xr | xl | x1r | x1l ] - mulps xmm0, xmm3 // xmm0 = [ 0 | 0 |a0r*xr|a0l*xl] - shufps xmm4, xmm4, 0x4E // xmm4 = [ x1r | x1l | xr | xl ] - addps xmm1, xmm2 // xmm1 = [b2r*y2r+a2r*x2r|b2l*y2l+a2l*x2l|b1r*y1r+a1r*x1r|b1l*y1l+a1l*x1l] - addps xmm1, xmm0 // xmm1 = [b2r*y2r+a2r*x2r|b2l*y2l+a2l*x2l|b1r*y1r+a1r*x1r+a0r*xr|b1l*y1l+a1l*x1l+a0l*xl] - sub ecx, 1 - movhlps xmm0, xmm1 - addps xmm0, xmm1 // xmm0 = [ ? | ? | yr(n) | yl(n) ] - movlps [ebx-8], xmm0 - shufps xmm0, xmm5, 0x44 - movaps xmm5, xmm0 - jnz mainloop - movhlps xmm0, xmm4 - movhlps xmm1, xmm5 - movss [eax+EQBANDSTRUCT.x1], xmm4 - movss [eax+EQBANDSTRUCT.x2], xmm0 - movss [eax+EQBANDSTRUCT.y1], xmm5 - movss [eax+EQBANDSTRUCT.y2], xmm1 - shufps xmm4, xmm4, 0x01 - shufps xmm0, xmm0, 0x01 - shufps xmm5, xmm5, 0x01 - shufps xmm1, xmm1, 0x01 - movss [edx+EQBANDSTRUCT.x1], xmm4 - movss [edx+EQBANDSTRUCT.x2], xmm0 - movss [edx+EQBANDSTRUCT.y1], xmm5 - movss [edx+EQBANDSTRUCT.y2], xmm1 -done:; - } -#endif SSE_SPECIFIC -} - -#pragma warning(default:4100) - -#else - -void EQFilter(EQBANDSTRUCT *pbs, REAL *pbuffer, UINT nCount) -//---------------------------------------------------------- -{ - for (UINT i=0; i<nCount; i++) - { - REAL x = pbuffer[i]; - REAL y = pbs->a1 * pbs->x1 + pbs->a2 * pbs->x2 + pbs->a0 * x + pbs->b1 * pbs->y1 + pbs->b2 * pbs->y2; - pbs->x2 = pbs->x1; - pbs->y2 = pbs->y1; - pbs->x1 = x; - pbuffer[i] = y; - pbs->y1 = y; - } -} - -#endif - - -void CSoundFile::EQMono(int *pbuffer, UINT nCount) -//------------------------------------------------ -{ - MonoMixToFloat(pbuffer, MixFloatBuffer, nCount); - for (UINT b=0; b<MAX_EQ_BANDS; b++) - { - if ((gEQ[b].bEnable) && (gEQ[b].Gain != 1.0f)) EQFilter(&gEQ[b], MixFloatBuffer, nCount); - } - FloatToMonoMix(MixFloatBuffer, pbuffer, nCount); -} - - -void CSoundFile::EQStereo(int *pbuffer, UINT nCount) -//-------------------------------------------------- -{ - -#ifdef ENABLE_SSE -#ifdef ENABLE_MMX - - // Still allow the check, because the user can turn this on/off - - if ((gdwSysInfo & SYSMIX_SSE) && (gdwSoundSetup & SNDMIX_ENABLEMMX)) - { - int sse_state, sse_eqstate; - SSE_MonoMixToFloat(pbuffer, MixFloatBuffer, nCount*2, m_pConfig->getIntToFloat()); - - _asm stmxcsr sse_state; - sse_eqstate = sse_state | 0xFF80; - _asm ldmxcsr sse_eqstate; - for (UINT b=0; b<MAX_EQ_BANDS; b++) - { - if ((gEQ[b].bEnable) || (gEQ[b+MAX_EQ_BANDS].bEnable)) - SSE_StereoEQ(&gEQ[b], &gEQ[b+MAX_EQ_BANDS], MixFloatBuffer, nCount); - } - _asm ldmxcsr sse_state; - - X86_FloatToMonoMix(MixFloatBuffer, pbuffer, nCount*2, m_pConfig->getFloatToInt()); - - } else - -#endif // ENABLE_MMX -#endif // ENABLE_SSE - -#ifdef ENABLE_3DNOW - - // We still perform the MMX check because the user can enable/disable this - - if ((gdwSysInfo & SYSMIX_3DNOW) && (gdwSoundSetup & SNDMIX_ENABLEMMX)) - { - AMD_MonoMixToFloat(pbuffer, MixFloatBuffer, nCount*2, m_pConfig->getIntToFloat()); - - for (UINT b=0; b<MAX_EQ_BANDS; b++) - { - if (((gEQ[b].bEnable) && (gEQ[b].Gain != 1.0f)) - || ((gEQ[b+MAX_EQ_BANDS].bEnable) && (gEQ[b+MAX_EQ_BANDS].Gain != 1.0f))) - AMD_StereoEQ(&gEQ[b], &gEQ[b+MAX_EQ_BANDS], MixFloatBuffer, nCount); - } - - AMD_FloatToMonoMix(MixFloatBuffer, pbuffer, nCount*2, m_pConfig->getFloatToInt()); - - } else -#endif // ENABLE_3DNOW - - { - X86_StereoMixToFloat(pbuffer, MixFloatBuffer, MixFloatBuffer+MIXBUFFERSIZE, nCount, m_pConfig->getIntToFloat()); - - for (UINT bl=0; bl<MAX_EQ_BANDS; bl++) - { - if ((gEQ[bl].bEnable) && (gEQ[bl].Gain != 1.0f)) EQFilter(&gEQ[bl], MixFloatBuffer, nCount); - } - for (UINT br=MAX_EQ_BANDS; br<MAX_EQ_BANDS*2; br++) - { - if ((gEQ[br].bEnable) && (gEQ[br].Gain != 1.0f)) EQFilter(&gEQ[br], MixFloatBuffer+MIXBUFFERSIZE, nCount); - } - - X86_FloatToStereoMix(MixFloatBuffer, MixFloatBuffer+MIXBUFFERSIZE, pbuffer, nCount, m_pConfig->getFloatToInt()); - } -} - - -void CSoundFile::InitializeEQ(BOOL bReset) -//---------------------------------------- -{ - REAL fMixingFreq = (REAL)gdwMixingFreq; - // Gain = 0.5 (-6dB) .. 2 (+6dB) - for (UINT band=0; band<MAX_EQ_BANDS*2; band++) if (gEQ[band].bEnable) - { - REAL k, k2, r, f; - REAL v0, v1; - BOOL b = bReset; - - f = gEQ[band].CenterFrequency / fMixingFreq; - if (f > 0.45f) gEQ[band].Gain = 1; - // if (f > 0.25) f = 0.25; - // k = tan(PI*f); - k = f * 3.141592654f; - k = k + k*f; -// if (k > (REAL)0.707) k = (REAL)0.707; - k2 = k*k; - v0 = gEQ[band].Gain; - v1 = 1; - if (gEQ[band].Gain < 1.0) - { - v0 *= (0.5f/EQ_BANDWIDTH); - v1 *= (0.5f/EQ_BANDWIDTH); - } else - { - v0 *= (1.0f/EQ_BANDWIDTH); - v1 *= (1.0f/EQ_BANDWIDTH); - } - r = (1 + v0*k + k2) / (1 + v1*k + k2); - if (r != gEQ[band].a0) - { - gEQ[band].a0 = r; - b = TRUE; - } - r = 2 * (k2 - 1) / (1 + v1*k + k2); - if (r != gEQ[band].a1) - { - gEQ[band].a1 = r; - b = TRUE; - } - r = (1 - v0*k + k2) / (1 + v1*k + k2); - if (r != gEQ[band].a2) - { - gEQ[band].a2 = r; - b = TRUE; - } - r = - 2 * (k2 - 1) / (1 + v1*k + k2); - if (r != gEQ[band].b1) - { - gEQ[band].b1 = r; - b = TRUE; - } - r = - (1 - v1*k + k2) / (1 + v1*k + k2); - if (r != gEQ[band].b2) - { - gEQ[band].b2 = r; - b = TRUE; - } - if (b) - { - gEQ[band].x1 = 0; - gEQ[band].x2 = 0; - gEQ[band].y1 = 0; - gEQ[band].y2 = 0; - } - } else - { - gEQ[band].a0 = 0; - gEQ[band].a1 = 0; - gEQ[band].a2 = 0; - gEQ[band].b1 = 0; - gEQ[band].b2 = 0; - gEQ[band].x1 = 0; - gEQ[band].x2 = 0; - gEQ[band].y1 = 0; - gEQ[band].y2 = 0; - } -} - - -void CSoundFile::... [truncated message content] |
From: <man...@us...> - 2013-03-25 15:13:45
|
Revision: 1669 http://sourceforge.net/p/modplug/code/1669 Author: manxorist Date: 2013-03-25 15:13:37 +0000 (Mon, 25 Mar 2013) Log Message: ----------- [Ref] Move reverb-related state and setup code from sounddsp/DSP.cpp to soundlib/Snd_rvb.cpp and soundlib/Sndmix.cpp. Modified Paths: -------------- trunk/OpenMPT/sounddsp/DSP.cpp trunk/OpenMPT/soundlib/Snd_rvb.cpp trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/sounddsp/DSP.cpp =================================================================== --- trunk/OpenMPT/sounddsp/DSP.cpp 2013-03-25 15:03:37 UTC (rev 1668) +++ trunk/OpenMPT/sounddsp/DSP.cpp 2013-03-25 15:13:37 UTC (rev 1669) @@ -26,8 +26,6 @@ // DSP Effects: PUBLIC members UINT CSoundFile::m_nXBassDepth = DEFAULT_XBASS_DEPTH; UINT CSoundFile::m_nXBassRange = DEFAULT_XBASS_RANGE; -UINT CSoundFile::gnReverbType = 0; -UINT CSoundFile::m_nReverbDepth = 8; // 50% UINT CSoundFile::m_nProLogicDepth = 12; UINT CSoundFile::m_nProLogicDelay = 20; @@ -74,8 +72,6 @@ extern int MixSoundBuffer[MIXBUFFERSIZE * 4]; extern int MixRearBuffer[MIXBUFFERSIZE * 2]; -extern VOID InitializeReverb(BOOL bReset); -extern VOID ProcessReverb(UINT nSamples); extern VOID MPPASMCALL X86_InitMixBuffer(int *pBuffer, UINT nSamples); extern VOID MPPASMCALL X86_StereoFill(int *pBuffer, UINT nSamples, LPLONG lpROfs, LPLONG lpLOfs); extern VOID MPPASMCALL X86_StereoDCRemoval(int *, UINT count); @@ -160,7 +156,6 @@ void CSoundFile::InitializeDSP(BOOL bReset) //----------------------------------------- { - if (gnReverbType >= NUM_REVERBTYPES) gnReverbType = 0; if (!m_nProLogicDelay) m_nProLogicDelay = 20; if (bReset) { @@ -189,10 +184,6 @@ nDolbyLP_B0 *= 2; nDolbyLP_B1 *= 2; } - // Reverb Setup -#ifndef NO_REVERB - InitializeReverb(bReset); -#endif // Bass Expansion Reset if (gdwSoundSetup & SNDMIX_MEGABASS) { @@ -473,20 +464,6 @@ ///////////////////////////////////////////////////////////////// // Clean DSP Effects interface -// [Reverb level 0(quiet)-100(loud)], [type = REVERBTYPE_XXXX] -BOOL CSoundFile::SetReverbParameters(UINT nDepth, UINT nType) -//----------------------------------------------------------- -{ - if (nDepth > 100) nDepth = 100; - UINT gain = (nDepth * 16) / 100; - if (gain > 16) gain = 16; - if (gain < 1) gain = 1; - m_nReverbDepth = gain; - if (nType < NUM_REVERBTYPES) gnReverbType = nType; - return TRUE; -} - - // [XBass level 0(quiet)-100(loud)], [cutoff in Hz 20-100] BOOL CSoundFile::SetXBassParameters(UINT nDepth, UINT nRange) //----------------------------------------------------------- Modified: trunk/OpenMPT/soundlib/Snd_rvb.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_rvb.cpp 2013-03-25 15:03:37 UTC (rev 1668) +++ trunk/OpenMPT/soundlib/Snd_rvb.cpp 2013-03-25 15:13:37 UTC (rev 1669) @@ -34,6 +34,9 @@ LONG gnRvbROfsVol = 0; LONG gnRvbLOfsVol = 0; +UINT CSoundFile::gnReverbType = 0; +UINT CSoundFile::m_nReverbDepth = 8; // 50% + // Internal reverb state static BOOL g_bLastInPresent = 0; static BOOL g_bLastOutPresent = 0; @@ -243,6 +246,7 @@ VOID InitializeReverb(BOOL bReset) //-------------------------------- { + if (CSoundFile::gnReverbType >= NUM_REVERBTYPES) CSoundFile::gnReverbType = 0; static PSNDMIX_REVERB_PROPERTIES spCurrentPreset = NULL; PSNDMIX_REVERB_PROPERTIES pRvbPreset = &gRvbPresets[CSoundFile::gnReverbType].Preset; @@ -351,6 +355,20 @@ } +// [Reverb level 0(quiet)-100(loud)], [type = REVERBTYPE_XXXX] +BOOL CSoundFile::SetReverbParameters(UINT nDepth, UINT nType) +//----------------------------------------------------------- +{ + if (nDepth > 100) nDepth = 100; + UINT gain = (nDepth * 16) / 100; + if (gain > 16) gain = 16; + if (gain < 1) gain = 1; + m_nReverbDepth = gain; + if (nType < NUM_REVERBTYPES) gnReverbType = nType; + return TRUE; +} + + // Reverb VOID ProcessReverb(UINT nSamples) //------------------------------- Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-03-25 15:03:37 UTC (rev 1668) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-03-25 15:13:37 UTC (rev 1669) @@ -81,6 +81,7 @@ extern LONG gnRvbROfsVol; extern LONG gnRvbLOfsVol; +extern VOID InitializeReverb(BOOL bReset); extern void ProcessReverb(UINT nSamples); #endif @@ -164,6 +165,9 @@ gnRvbROfsVol = gnRvbLOfsVol = 0; #endif if (bReset) gnCPUUsage = 0; +#ifndef NO_REVERB + InitializeReverb(bReset); +#endif InitializeDSP(bReset); #ifdef ENABLE_EQ InitializeEQ(bReset); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-03-25 16:44:01
|
Revision: 1671 http://sourceforge.net/p/modplug/code/1671 Author: saga-games Date: 2013-03-25 16:43:54 +0000 (Mon, 25 Mar 2013) Log Message: ----------- [Fix] IT compatibility: Various compatibility fixes regarding portamento between different samples, and especially portamento in multisample instruments. [Mod] OpenMPT: Version is now 1.21.01.25 Modified Paths: -------------- trunk/OpenMPT/common/version.h trunk/OpenMPT/soundlib/Snd_fx.cpp Modified: trunk/OpenMPT/common/version.h =================================================================== --- trunk/OpenMPT/common/version.h 2013-03-25 16:20:32 UTC (rev 1670) +++ trunk/OpenMPT/common/version.h 2013-03-25 16:43:54 UTC (rev 1671) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 21 #define VER_MINOR 01 -#define VER_MINORMINOR 24 +#define VER_MINORMINOR 25 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-03-25 16:20:32 UTC (rev 1670) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-03-25 16:43:54 UTC (rev 1671) @@ -624,58 +624,47 @@ void CSoundFile::InstrumentChange(ModChannel *pChn, UINT instr, bool bPorta, bool bUpdVol, bool bResetEnv) //-------------------------------------------------------------------------------------------------------- { - if (instr >= MAX_INSTRUMENTS) return; + if(instr >= MAX_INSTRUMENTS) return; ModInstrument *pIns = (instr < MAX_INSTRUMENTS) ? Instruments[instr] : nullptr; ModSample *pSmp = &Samples[instr]; UINT note = pChn->nNewNote; if(note == NOTE_NONE && IsCompatibleMode(TRK_IMPULSETRACKER)) return; - if (pIns != nullptr && ModCommand::IsNote(note)) + if(pIns != nullptr && ModCommand::IsNote(note)) { - if(bPorta && pIns == pChn->pModInstrument && (pChn->pModSample != nullptr && pChn->pModSample->pSample != nullptr) && IsCompatibleMode(TRK_IMPULSETRACKER)) + // Impulse Tracker ignores empty slots. + // We won't ignore them if a plugin is assigned to this slot, so that VSTis still work as intended. + // Test case: emptyslot.it, PortaInsNum.it, gxsmp.it, gxsmp2.it + if(pIns->Keyboard[note - NOTE_MIN] == 0 && IsCompatibleMode(TRK_IMPULSETRACKER) && !pIns->HasValidMIDIChannel()) { -#ifdef DEBUG - { - // Check if original behaviour would have been used here - if (pIns->NoteMap[note-1] >= NOTE_MIN_SPECIAL) - { - ASSERT(false); + pChn->pModInstrument = pIns; return; } - UINT n = pIns->Keyboard[note-1]; + + if(pIns->NoteMap[note - NOTE_MIN] > NOTE_MAX) return; + UINT n = pIns->Keyboard[note - NOTE_MIN]; pSmp = ((n) && (n < MAX_SAMPLES)) ? &Samples[n] : nullptr; - if(pSmp != pChn->pModSample) - { - ASSERT(false); - } - } -#endif // DEBUG - // Impulse Tracker doesn't seem to look up the sample for new notes when in instrument mode and it encounters a situation like this: - // G-6 01 ... ... <-- G-6 is bound to sample 01 - // F-6 01 ... GFF <-- F-6 is bound to sample 02, but sample 01 will be played - // This behaviour is not used if sample 01 has no actual sample data (hence the "pChn->pModSample->pSample != nullptr") - // and it is also ignored when the instrument number changes. This fixes e.g. the guitars in "Ultima Ratio" by Nebularia - // and some slides in spx-shuttledeparture.it. - pSmp = pChn->pModSample; - } else - { - // Original behaviour - if(pIns->NoteMap[note - 1] > NOTE_MAX) return; - UINT n = pIns->Keyboard[note - 1]; - pSmp = ((n) && (n < MAX_SAMPLES)) ? &Samples[n] : nullptr; - } - } else if (GetNumInstruments()) + } else if(GetNumInstruments()) { // No valid instrument, or not a valid note. if (note >= NOTE_MIN_SPECIAL) return; + if(IsCompatibleMode(TRK_IMPULSETRACKER) && (pIns == nullptr || !pIns->HasValidMIDIChannel())) + { + // Impulse Tracker ignores empty slots. + // We won't ignore them if a plugin is assigned to this slot, so that VSTis still work as intended. + // Test case: emptyslot.it, PortaInsNum.it, gxsmp.it, gxsmp2.it + pChn->pModInstrument = nullptr; + pChn->nNewIns = 0; + return; + } pSmp = nullptr; } - const bool bNewTuning = (GetType() == MOD_TYPE_MPT && pIns && pIns->pTuning); + const bool newTuning = (GetType() == MOD_TYPE_MPT && pIns && pIns->pTuning); // Playback behavior change for MPT: With portamento don't change sample if it is in // the same instrument as previous sample. - if(bPorta && bNewTuning && pIns == pChn->pModInstrument) + if(bPorta && newTuning && pIns == pChn->pModInstrument) return; bool returnAfterVolumeAdjust = false; @@ -899,7 +888,7 @@ pChn->nAutoVibPos = 0; } - if(bNewTuning) + if(newTuning) { pChn->nC5Speed = pSmp->nC5Speed; pChn->m_CalculateFreq = true; @@ -962,7 +951,16 @@ if((pIns) && (note - NOTE_MIN < CountOf(pIns->Keyboard))) { UINT n = pIns->Keyboard[note - NOTE_MIN]; - if ((n) && (n < MAX_SAMPLES)) pSmp = &Samples[n]; + if((n) && (n < MAX_SAMPLES)) + { + pSmp = &Samples[n]; + } else if(IsCompatibleMode(TRK_IMPULSETRACKER) && !pIns->HasValidMIDIChannel()) + { + // Impulse Tracker ignores empty slots. + // We won't ignore them if a plugin is assigned to this slot, so that VSTis still work as intended. + // Test case: emptyslot.it, PortaInsNum.it, gxsmp.it, gxsmp2.it + return; + } note = pIns->NoteMap[note-1]; } // Key Off @@ -1353,7 +1351,16 @@ { n = pIns->Keyboard[note - 1]; note = pIns->NoteMap[note - 1]; - if(n > 0 && n < MAX_SAMPLES) pSample = Samples[n].pSample; + if ((n) && (n < MAX_SAMPLES)) + { + pSample = Samples[n].pSample; + } else if(IsCompatibleMode(TRK_IMPULSETRACKER) && !pIns->HasValidMIDIChannel()) + { + // Impulse Tracker ignores empty slots. + // We won't ignore them if a plugin is assigned to this slot, so that VSTis still work as intended. + // Test case: emptyslot.it, PortaInsNum.it, gxsmp.it, gxsmp2.it + return; + } } } else pSample = nullptr; } @@ -1927,16 +1934,30 @@ // Instrument Change ? if(instr) { - ModSample *psmp = pChn->pModSample; + const ModSample *oldSample = pChn->pModSample; + const ModInstrument *oldInstrument = pChn->pModInstrument; + InstrumentChange(pChn, instr, bPorta, true); pChn->nNewIns = 0; + + if(IsCompatibleMode(TRK_IMPULSETRACKER)) + { + // Test cases: PortaInsNum.it, PortaSample.it + if(ModCommand::IsNote(note) && oldSample != pChn->pModSample) + { + //const bool newInstrument = oldInstrument != pChn->pModInstrument && pChn->pModInstrument->Keyboard[pChn->nNewNote - NOTE_MIN] != 0; + pChn->nPos = pChn->nPosLo = 0; + } + } else + { // Special IT case: portamento+note causes sample change -> ignore portamento if ((GetType() & (MOD_TYPE_S3M | MOD_TYPE_IT | MOD_TYPE_MPT)) - && (psmp != pChn->pModSample) && (note) && (note < 0x80)) + && oldSample != pChn->pModSample && ModCommand::IsNote(note)) { bPorta = false; } } + } // New Note ? if (note) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-03-25 16:48:22
|
Revision: 1672 http://sourceforge.net/p/modplug/code/1672 Author: manxorist Date: 2013-03-25 16:48:14 +0000 (Mon, 25 Mar 2013) Log Message: ----------- [Ref] Properly encapsulate Surround, MegaBass and NoiseReduction into a seperate class CDSP and remove a lot of global variables while at it. CSoundFile::m_DSP is still global though at the moment. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/sounddsp/DSP.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Added Paths: ----------- trunk/OpenMPT/sounddsp/DSP.h Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-03-25 16:43:54 UTC (rev 1671) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-03-25 16:48:14 UTC (rev 1672) @@ -510,9 +510,9 @@ // Bass Expansion m_SbXBassDepth.SetRange(0,4); - m_SbXBassDepth.SetPos(8-CSoundFile::m_nXBassDepth); + m_SbXBassDepth.SetPos(8-CSoundFile::m_DSP.m_Settings.m_nXBassDepth); m_SbXBassRange.SetRange(0,4); - m_SbXBassRange.SetPos(4 - (CSoundFile::m_nXBassRange - 1) / 5); + m_SbXBassRange.SetPos(4 - (CSoundFile::m_DSP.m_Settings.m_nXBassRange - 1) / 5); // Reverb m_SbReverbDepth.SetRange(1, 16); m_SbReverbDepth.SetPos(CSoundFile::m_nReverbDepth); @@ -539,13 +539,13 @@ } // Surround { - UINT n = CSoundFile::m_nProLogicDepth; + UINT n = CSoundFile::m_DSP.m_Settings.m_nProLogicDepth; if (n < 1) n = 1; if (n > 16) n = 16; m_SbSurroundDepth.SetRange(1, 16); m_SbSurroundDepth.SetPos(n); m_SbSurroundDelay.SetRange(0, 8); - m_SbSurroundDelay.SetPos((CSoundFile::m_nProLogicDelay-5)/5); + m_SbSurroundDelay.SetPos((CSoundFile::m_DSP.m_Settings.m_nProLogicDelay-5)/5); } //rewbs.resamplerConf OnResamplerChanged(); @@ -670,8 +670,8 @@ UINT nXBassRange = (4-m_SbXBassRange.GetPos()) * 5 + 1; if (nXBassRange < 5) nXBassRange = 5; if (nXBassRange > 21) nXBassRange = 21; - CSoundFile::m_nXBassDepth = nXBassDepth; - CSoundFile::m_nXBassRange = nXBassRange; + CSoundFile::m_DSP.m_Settings.m_nXBassDepth = nXBassDepth; + CSoundFile::m_DSP.m_Settings.m_nXBassRange = nXBassRange; } // Reverb { @@ -683,8 +683,8 @@ { UINT nProLogicDepth = m_SbSurroundDepth.GetPos(); UINT nProLogicDelay = 5 + (m_SbSurroundDelay.GetPos() * 5); - CSoundFile::m_nProLogicDepth = nProLogicDepth; - CSoundFile::m_nProLogicDelay = nProLogicDelay; + CSoundFile::m_DSP.m_Settings.m_nProLogicDepth = nProLogicDepth; + CSoundFile::m_DSP.m_Settings.m_nProLogicDelay = nProLogicDelay; } // Notify CMainFrame CMainFrame *pParent = CMainFrame::GetMainFrame(); Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-03-25 16:43:54 UTC (rev 1671) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-03-25 16:48:14 UTC (rev 1672) @@ -416,12 +416,12 @@ // Effects Settings - CSoundFile::m_nXBassDepth = CMainFrame::GetPrivateProfileLong("Effects", "XBassDepth", CSoundFile::m_nXBassDepth, iniFile); - CSoundFile::m_nXBassRange = CMainFrame::GetPrivateProfileLong("Effects", "XBassRange", CSoundFile::m_nXBassRange, iniFile); + CSoundFile::m_DSP.m_Settings.m_nXBassDepth = CMainFrame::GetPrivateProfileLong("Effects", "XBassDepth", CSoundFile::m_DSP.m_Settings.m_nXBassDepth, iniFile); + CSoundFile::m_DSP.m_Settings.m_nXBassRange = CMainFrame::GetPrivateProfileLong("Effects", "XBassRange", CSoundFile::m_DSP.m_Settings.m_nXBassRange, iniFile); CSoundFile::m_nReverbDepth = CMainFrame::GetPrivateProfileLong("Effects", "ReverbDepth", CSoundFile::m_nReverbDepth, iniFile); CSoundFile::gnReverbType = CMainFrame::GetPrivateProfileLong("Effects", "ReverbType", CSoundFile::gnReverbType, iniFile); - CSoundFile::m_nProLogicDepth = CMainFrame::GetPrivateProfileLong("Effects", "ProLogicDepth", CSoundFile::m_nProLogicDepth, iniFile); - CSoundFile::m_nProLogicDelay = CMainFrame::GetPrivateProfileLong("Effects", "ProLogicDelay", CSoundFile::m_nProLogicDelay, iniFile); + CSoundFile::m_DSP.m_Settings.m_nProLogicDepth = CMainFrame::GetPrivateProfileLong("Effects", "ProLogicDepth", CSoundFile::m_DSP.m_Settings.m_nProLogicDepth, iniFile); + CSoundFile::m_DSP.m_Settings.m_nProLogicDelay = CMainFrame::GetPrivateProfileLong("Effects", "ProLogicDelay", CSoundFile::m_DSP.m_Settings.m_nProLogicDelay, iniFile); // EQ Settings @@ -561,12 +561,12 @@ dwSZSIZE = sizeof(m_szKbdFile); RegQueryValueEx(key, "Key_Config_File", NULL, &dwREG_SZ, (LPBYTE)m_szKbdFile, &dwSZSIZE); - RegQueryValueEx(key, "XBassDepth", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_nXBassDepth, &dwDWORDSize); - RegQueryValueEx(key, "XBassRange", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_nXBassRange, &dwDWORDSize); + RegQueryValueEx(key, "XBassDepth", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_DSP.m_Settings.m_nXBassDepth, &dwDWORDSize); + RegQueryValueEx(key, "XBassRange", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_DSP.m_Settings.m_nXBassRange, &dwDWORDSize); RegQueryValueEx(key, "ReverbDepth", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_nReverbDepth, &dwDWORDSize); RegQueryValueEx(key, "ReverbType", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::gnReverbType, &dwDWORDSize); - RegQueryValueEx(key, "ProLogicDepth", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_nProLogicDepth, &dwDWORDSize); - RegQueryValueEx(key, "ProLogicDelay", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_nProLogicDelay, &dwDWORDSize); + RegQueryValueEx(key, "ProLogicDepth", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_DSP.m_Settings.m_nProLogicDepth, &dwDWORDSize); + RegQueryValueEx(key, "ProLogicDelay", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_DSP.m_Settings.m_nProLogicDelay, &dwDWORDSize); RegQueryValueEx(key, "StereoSeparation", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_nStereoSeparation, &dwDWORDSize); RegQueryValueEx(key, "MixChannels", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_nMaxMixChannels, &dwDWORDSize); RegQueryValueEx(key, "WaveDevice", NULL, &dwREG_DWORD, (LPBYTE)&m_nWaveDevice, &dwDWORDSize); @@ -778,12 +778,12 @@ // Older versions of OpenMPT 1.18+ will look for this file if this entry is missing, so removing this entry after having read it is kind of backwards compatible. WritePrivateProfileString("Paths", "Key_Config_File", nullptr, iniFile); - CMainFrame::WritePrivateProfileLong("Effects", "XBassDepth", CSoundFile::m_nXBassDepth, iniFile); - CMainFrame::WritePrivateProfileLong("Effects", "XBassRange", CSoundFile::m_nXBassRange, iniFile); + CMainFrame::WritePrivateProfileLong("Effects", "XBassDepth", CSoundFile::m_DSP.m_Settings.m_nXBassDepth, iniFile); + CMainFrame::WritePrivateProfileLong("Effects", "XBassRange", CSoundFile::m_DSP.m_Settings.m_nXBassRange, iniFile); CMainFrame::WritePrivateProfileLong("Effects", "ReverbDepth", CSoundFile::m_nReverbDepth, iniFile); CMainFrame::WritePrivateProfileLong("Effects", "ReverbType", CSoundFile::gnReverbType, iniFile); - CMainFrame::WritePrivateProfileLong("Effects", "ProLogicDepth", CSoundFile::m_nProLogicDepth, iniFile); - CMainFrame::WritePrivateProfileLong("Effects", "ProLogicDelay", CSoundFile::m_nProLogicDelay, iniFile); + CMainFrame::WritePrivateProfileLong("Effects", "ProLogicDepth", CSoundFile::m_DSP.m_Settings.m_nProLogicDepth, iniFile); + CMainFrame::WritePrivateProfileLong("Effects", "ProLogicDelay", CSoundFile::m_DSP.m_Settings.m_nProLogicDelay, iniFile); WritePrivateProfileStruct("Effects", "EQ_Settings", &m_EqSettings, sizeof(EQPreset), iniFile); WritePrivateProfileStruct("Effects", "EQ_User1", &CEQSetupDlg::gUserPresets[0], sizeof(EQPreset), iniFile); Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-03-25 16:43:54 UTC (rev 1671) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-03-25 16:48:14 UTC (rev 1672) @@ -1055,6 +1055,10 @@ > </File> <File + RelativePath="..\sounddsp\DSP.h" + > + </File> + <File RelativePath="..\soundlib\SoundFilePlayConfig.h" > </File> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-03-25 16:43:54 UTC (rev 1671) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-03-25 16:48:14 UTC (rev 1672) @@ -404,6 +404,7 @@ <ClInclude Include="..\common\Reporting.h" /> <ClInclude Include="..\common\StringFixer.h" /> <ClInclude Include="..\common\typedefs.h" /> + <ClInclude Include="..\sounddsp\DSP.h" /> <ClInclude Include="..\soundlib\ChunkReader.h" /> <ClInclude Include="..\soundlib\FileReader.h" /> <ClInclude Include="..\soundlib\ITCompression.h" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-03-25 16:43:54 UTC (rev 1671) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-03-25 16:48:14 UTC (rev 1672) @@ -765,6 +765,9 @@ <ClInclude Include="..\common\mptString.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="..\sounddsp\DSP.h"> + <Filter>Header Files\sounddsp</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="res\bitmap1.bmp"> Modified: trunk/OpenMPT/sounddsp/DSP.cpp =================================================================== --- trunk/OpenMPT/sounddsp/DSP.cpp 2013-03-25 16:43:54 UTC (rev 1671) +++ trunk/OpenMPT/sounddsp/DSP.cpp 2013-03-25 16:48:14 UTC (rev 1672) @@ -18,65 +18,18 @@ #define DEFAULT_XBASS_RANGE 14 // (x+2)*20 Hz (320Hz) #define DEFAULT_XBASS_DEPTH 6 // 1+(3>>(x-4)) (+6dB) -// Buffer Sizes -#define XBASSBUFFERSIZE 64 // 2 ms at 50KHz -#define SURROUNDBUFFERSIZE 2048 // 50ms @ 48kHz -// DSP Effects: PUBLIC members -UINT CSoundFile::m_nXBassDepth = DEFAULT_XBASS_DEPTH; -UINT CSoundFile::m_nXBassRange = DEFAULT_XBASS_RANGE; -UINT CSoundFile::m_nProLogicDepth = 12; -UINT CSoundFile::m_nProLogicDelay = 20; - //////////////////////////////////////////////////////////////////// // DSP Effects internal state -// Noise Reduction: simple low-pass filter -static LONG nLeftNR = 0; -static LONG nRightNR = 0; -// Surround Encoding: 1 delay line + low-pass filter + high-pass filter -static LONG nSurroundSize = 0; -static LONG nSurroundPos = 0; -static LONG nDolbyDepth = 0; -// Surround Biquads -static LONG nDolbyHP_Y1 = 0; -static LONG nDolbyHP_X1 = 0; -static LONG nDolbyLP_Y1 = 0; -static LONG nDolbyHP_B0 = 0; -static LONG nDolbyHP_B1 = 0; -static LONG nDolbyHP_A1 = 0; -static LONG nDolbyLP_B0 = 0; -static LONG nDolbyLP_B1 = 0; -static LONG nDolbyLP_A1 = 0; -// Bass Expansion: low-pass filter -static LONG nXBassFlt_Y1 = 0; -static LONG nXBassFlt_X1 = 0; -static LONG nXBassFlt_B0 = 0; -static LONG nXBassFlt_B1 = 0; -static LONG nXBassFlt_A1 = 0; +extern VOID MPPASMCALL X86_InitMixBuffer(int *pBuffer, UINT nSamples); -// DC Removal Biquad -static LONG nDCRFlt_Y1l = 0; -static LONG nDCRFlt_X1l = 0; -static LONG nDCRFlt_Y1r = 0; -static LONG nDCRFlt_X1r = 0; +static VOID MPPASMCALL X86_StereoDCRemoval(int *, UINT count, LONG *nDCRFlt_Y1l, LONG *nDCRFlt_X1l, LONG *nDCRFlt_Y1r, LONG *nDCRFlt_X1r); +static VOID MPPASMCALL X86_MonoDCRemoval(int *, UINT count, LONG *nDCRFlt_Y1l, LONG *nDCRFlt_X1l); - -static LONG SurroundBuffer[SURROUNDBUFFERSIZE]; - - -// Access the main temporary mix buffer directly: avoids an extra pointer -extern int MixSoundBuffer[MIXBUFFERSIZE * 4]; -extern int MixRearBuffer[MIXBUFFERSIZE * 2]; - -extern VOID MPPASMCALL X86_InitMixBuffer(int *pBuffer, UINT nSamples); -extern VOID MPPASMCALL X86_StereoFill(int *pBuffer, UINT nSamples, LPLONG lpROfs, LPLONG lpLOfs); -extern VOID MPPASMCALL X86_StereoDCRemoval(int *, UINT count); -extern VOID MPPASMCALL X86_MonoDCRemoval(int *, UINT count); - /////////////////////////////////////////////////////////////////////////////////// // // Biquad setup @@ -84,8 +37,8 @@ #define PI 3.14159265358979323f -inline FLOAT Sgn(FLOAT x) { return (x >= 0) ? 1.0f : -1.0f; } -VOID ShelfEQ(LONG scale, +static inline FLOAT Sgn(FLOAT x) { return (x >= 0) ? 1.0f : -1.0f; } +static VOID ShelfEQ(LONG scale, LONG *outA1, LONG *outB0, LONG *outB1, LONG F_c, LONG F_s, FLOAT gainDC, FLOAT gainFT, FLOAT gainPI) { @@ -153,10 +106,56 @@ } -void CSoundFile::InitializeDSP(BOOL bReset) -//----------------------------------------- +CDSPSettings::CDSPSettings() : m_nXBassDepth(DEFAULT_XBASS_DEPTH), m_nXBassRange(DEFAULT_XBASS_RANGE), m_nProLogicDepth(12), m_nProLogicDelay(20) +//----------------------------------------------------------------------------------------------------------------------------------------------- { - if (!m_nProLogicDelay) m_nProLogicDelay = 20; + +} + + +CDSP::CDSP() +{ + // Noise Reduction: simple low-pass filter + nLeftNR = 0; + nRightNR = 0; + + // Surround Encoding: 1 delay line + low-pass filter + high-pass filter + nSurroundSize = 0; + nSurroundPos = 0; + nDolbyDepth = 0; + + // Surround Biquads + nDolbyHP_Y1 = 0; + nDolbyHP_X1 = 0; + nDolbyLP_Y1 = 0; + nDolbyHP_B0 = 0; + nDolbyHP_B1 = 0; + nDolbyHP_A1 = 0; + nDolbyLP_B0 = 0; + nDolbyLP_B1 = 0; + nDolbyLP_A1 = 0; + + // Bass Expansion: low-pass filter + nXBassFlt_Y1 = 0; + nXBassFlt_X1 = 0; + nXBassFlt_B0 = 0; + nXBassFlt_B1 = 0; + nXBassFlt_A1 = 0; + + // DC Removal Biquad + nDCRFlt_Y1l = 0; + nDCRFlt_X1l = 0; + nDCRFlt_Y1r = 0; + nDCRFlt_X1r = 0; + + MemsetZero(SurroundBuffer); + +} + +void CDSP::Initialize(BOOL bReset, DWORD MixingFreq, DWORD SoundSetupFlags) +//------------------------------------------------------------------------- +{ + if (!m_Settings.m_nProLogicDelay) m_Settings.m_nProLogicDelay = 20; if (bReset) { // Noise Reduction @@ -164,17 +163,17 @@ } // Pro-Logic Surround nSurroundPos = nSurroundSize = 0; - if (gdwSoundSetup & SNDMIX_SURROUND) + if (SoundSetupFlags & SNDMIX_SURROUND) { memset(SurroundBuffer, 0, sizeof(SurroundBuffer)); - nSurroundSize = (gdwMixingFreq * m_nProLogicDelay) / 1000; + nSurroundSize = (MixingFreq * m_Settings.m_nProLogicDelay) / 1000; if (nSurroundSize > SURROUNDBUFFERSIZE) nSurroundSize = SURROUNDBUFFERSIZE; - nDolbyDepth = m_nProLogicDepth; + nDolbyDepth = m_Settings.m_nProLogicDepth; if (nDolbyDepth < 1) nDolbyDepth = 1; if (nDolbyDepth > 16) nDolbyDepth = 16; // Setup biquad filters - ShelfEQ(1024, &nDolbyHP_A1, &nDolbyHP_B0, &nDolbyHP_B1, 200, gdwMixingFreq, 0, 0.5f, 1); - ShelfEQ(1024, &nDolbyLP_A1, &nDolbyLP_B0, &nDolbyLP_B1, 7000, gdwMixingFreq, 1, 0.75f, 0); + ShelfEQ(1024, &nDolbyHP_A1, &nDolbyHP_B0, &nDolbyHP_B1, 200, MixingFreq, 0, 0.5f, 1); + ShelfEQ(1024, &nDolbyLP_A1, &nDolbyLP_B0, &nDolbyLP_B1, 7000, MixingFreq, 1, 0.75f, 0); nDolbyHP_X1 = nDolbyHP_Y1 = 0; nDolbyLP_Y1 = 0; // Surround Level @@ -185,14 +184,14 @@ nDolbyLP_B1 *= 2; } // Bass Expansion Reset - if (gdwSoundSetup & SNDMIX_MEGABASS) + if (SoundSetupFlags & SNDMIX_MEGABASS) { LONG a1 = 0, b0 = 1024, b1 = 0; - int nXBassCutOff = 50 + (m_nXBassRange+2) * 20; - int nXBassGain = m_nXBassDepth; + int nXBassCutOff = 50 + (m_Settings.m_nXBassRange+2) * 20; + int nXBassGain = m_Settings.m_nXBassDepth; Limit(nXBassGain, 2, 8); Limit(nXBassCutOff, 60, 600); - ShelfEQ(1024, &a1, &b0, &b1, nXBassCutOff, gdwMixingFreq, + ShelfEQ(1024, &a1, &b0, &b1, nXBassCutOff, MixingFreq, 1.0f + (1.0f/16.0f) * (0x300 >> nXBassGain), 1.0f, 0.0000001f); @@ -219,8 +218,8 @@ // 2-channel surround -static void ProcessStereoSurround(int count) -//------------------------------------------ +void CDSP::ProcessStereoSurround(int * MixSoundBuffer, int count) +//--------------------------------------------------------------- { int *pr = MixSoundBuffer, hy1 = nDolbyHP_Y1; for (int r=count; r; r--) @@ -246,8 +245,8 @@ // 4-channels surround -static void ProcessQuadSurround(int count) -//---------------------------------------- +void CDSP::ProcessQuadSurround(int * MixSoundBuffer, int * MixRearBuffer, int count) +//---------------------------------------------------------------------------------- { int *pr = MixSoundBuffer, hy1 = nDolbyHP_Y1; for (int r=count; r; r--) @@ -276,22 +275,28 @@ } -void CSoundFile::ProcessStereoDSP(int count) -//------------------------------------------ +void CDSP::Process(int * MixSoundBuffer, int * MixRearBuffer, int count, DWORD SoundSetupFlags, UINT nChannels) +//------------------------------------------------------------------------------------------------------------- { + + + if(nChannels >= 2) + { + + // Dolby Pro-Logic Surround - if (gdwSoundSetup & SNDMIX_SURROUND) + if (SoundSetupFlags & SNDMIX_SURROUND) { - if (gnChannels > 2) ProcessQuadSurround(count); else - ProcessStereoSurround(count); + if (nChannels > 2) ProcessQuadSurround(MixSoundBuffer, MixRearBuffer, count); else + ProcessStereoSurround(MixSoundBuffer, count); } // DC Removal - if (gdwSoundSetup & SNDMIX_MEGABASS) + if (SoundSetupFlags & SNDMIX_MEGABASS) { - X86_StereoDCRemoval(MixSoundBuffer, count); + X86_StereoDCRemoval(MixSoundBuffer, count, &nDCRFlt_Y1l, &nDCRFlt_X1l, &nDCRFlt_Y1r, &nDCRFlt_X1r); } // Bass Expansion - if (gdwSoundSetup & SNDMIX_MEGABASS) + if (SoundSetupFlags & SNDMIX_MEGABASS) { int *px = MixSoundBuffer; int x1 = nXBassFlt_X1; @@ -311,7 +316,7 @@ nXBassFlt_Y1 = y1; } // Noise Reduction - if (gdwSoundSetup & SNDMIX_NOISEREDUCTION) + if (SoundSetupFlags & SNDMIX_NOISEREDUCTION) { int n1 = nLeftNR, n2 = nRightNR; int *pnr = MixSoundBuffer; @@ -328,19 +333,19 @@ nLeftNR = n1; nRightNR = n2; } -} + + } else + { -void CSoundFile::ProcessMonoDSP(int count) -//---------------------------------------- -{ + // DC Removal - if (gdwSoundSetup & SNDMIX_MEGABASS) + if (SoundSetupFlags & SNDMIX_MEGABASS) { - X86_MonoDCRemoval(MixSoundBuffer, count); + X86_MonoDCRemoval(MixSoundBuffer, count, &nDCRFlt_Y1l, &nDCRFlt_X1l); } // Bass Expansion - if (gdwSoundSetup & SNDMIX_MEGABASS) + if (SoundSetupFlags & SNDMIX_MEGABASS) { int *px = MixSoundBuffer; int x1 = nXBassFlt_X1; @@ -359,7 +364,7 @@ nXBassFlt_Y1 = y1; } // Noise Reduction - if (gdwSoundSetup & SNDMIX_NOISEREDUCTION) + if (SoundSetupFlags & SNDMIX_NOISEREDUCTION) { int n = nLeftNR; int *pnr = MixSoundBuffer; @@ -371,6 +376,11 @@ } nLeftNR = n; } + + + } + + } @@ -382,10 +392,10 @@ #define DCR_AMOUNT 9 -VOID MPPASMCALL X86_StereoDCRemoval(int *pBuffer, UINT nSamples) +static VOID MPPASMCALL X86_StereoDCRemoval(int *pBuffer, UINT nSamples, LONG *nDCRFlt_Y1l, LONG *nDCRFlt_X1l, LONG *nDCRFlt_Y1r, LONG *nDCRFlt_X1r) { - int y1l=nDCRFlt_Y1l, x1l=nDCRFlt_X1l; - int y1r=nDCRFlt_Y1r, x1r=nDCRFlt_X1r; + int y1l=*nDCRFlt_Y1l, x1l=*nDCRFlt_X1l; + int y1r=*nDCRFlt_Y1r, x1r=*nDCRFlt_X1r; _asm { mov esi, pBuffer @@ -421,20 +431,21 @@ mov y1r, edx jnz stereodcr } - nDCRFlt_Y1l = y1l; - nDCRFlt_X1l = x1l; - nDCRFlt_Y1r = y1r; - nDCRFlt_X1r = x1r; + *nDCRFlt_Y1l = y1l; + *nDCRFlt_X1l = x1l; + *nDCRFlt_Y1r = y1r; + *nDCRFlt_X1r = x1r; } -VOID MPPASMCALL X86_MonoDCRemoval(int *pBuffer, UINT nSamples) +static VOID MPPASMCALL X86_MonoDCRemoval(int *pBuffer, UINT nSamples, LONG *nDCRFlt_Y1l, LONG *nDCRFlt_X1l) { + int y1l=*nDCRFlt_Y1l, x1l=*nDCRFlt_X1l; _asm { mov esi, pBuffer mov ecx, nSamples - mov edx, nDCRFlt_X1l - mov edi, nDCRFlt_Y1l + mov edx, x1l + mov edi, y1l stereodcr: mov eax, [esi] mov ebx, edx @@ -452,9 +463,11 @@ dec ecx mov edi, eax jnz stereodcr - mov nDCRFlt_X1l, edx - mov nDCRFlt_Y1l, edi + mov x1l, edx + mov y1l, edi } + *nDCRFlt_Y1l = y1l; + *nDCRFlt_X1l = x1l; } @@ -465,34 +478,33 @@ // Clean DSP Effects interface // [XBass level 0(quiet)-100(loud)], [cutoff in Hz 20-100] -BOOL CSoundFile::SetXBassParameters(UINT nDepth, UINT nRange) -//----------------------------------------------------------- +BOOL CDSP::SetXBassParameters(UINT nDepth, UINT nRange) +//----------------------------------------------------- { if (nDepth > 100) nDepth = 100; UINT gain = nDepth / 20; if (gain > 4) gain = 4; - m_nXBassDepth = 8 - gain; // filter attenuation 1/256 .. 1/16 + m_Settings.m_nXBassDepth = 8 - gain; // filter attenuation 1/256 .. 1/16 UINT range = nRange / 5; if (range > 5) range -= 5; else range = 0; if (nRange > 16) nRange = 16; - m_nXBassRange = 21 - range; // filter average on 0.5-1.6ms + m_Settings.m_nXBassRange = 21 - range; // filter average on 0.5-1.6ms return TRUE; } // [Surround level 0(quiet)-100(heavy)] [delay in ms, usually 5-50ms] -BOOL CSoundFile::SetSurroundParameters(UINT nDepth, UINT nDelay) -//-------------------------------------------------------------- +BOOL CDSP::SetSurroundParameters(UINT nDepth, UINT nDelay) +//-------------------------------------------------------- { UINT gain = (nDepth * 16) / 100; if (gain > 16) gain = 16; if (gain < 1) gain = 1; - m_nProLogicDepth = gain; + m_Settings.m_nProLogicDepth = gain; if (nDelay < 4) nDelay = 4; if (nDelay > 50) nDelay = 50; - m_nProLogicDelay = nDelay; + m_Settings.m_nProLogicDelay = nDelay; return TRUE; } - Added: trunk/OpenMPT/sounddsp/DSP.h =================================================================== --- trunk/OpenMPT/sounddsp/DSP.h (rev 0) +++ trunk/OpenMPT/sounddsp/DSP.h 2013-03-25 16:48:14 UTC (rev 1672) @@ -0,0 +1,91 @@ +/* + * DSP.h + * ----- + * Purpose: Mixing code for various DSPs (EQ, Mega-Bass, ...) + * Notes : Ugh... This should really be removed at some point. + * Authors: Olivier Lapicque + * OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#pragma once + + +// Buffer Sizes +#define SURROUNDBUFFERSIZE 2048 // 50ms @ 48kHz + + +//================ +class CDSPSettings +//================ +{ +public: + UINT m_nXBassDepth; + UINT m_nXBassRange; + UINT m_nProLogicDepth; + UINT m_nProLogicDelay; +public: + CDSPSettings(); +}; + + +//======== +class CDSP +//======== +{ +public: + CDSPSettings m_Settings; +private: + + // Noise Reduction: simple low-pass filter + LONG nLeftNR; + LONG nRightNR; + + // Surround Encoding: 1 delay line + low-pass filter + high-pass filter + LONG nSurroundSize; + LONG nSurroundPos; + LONG nDolbyDepth; + + // Surround Biquads + LONG nDolbyHP_Y1; + LONG nDolbyHP_X1; + LONG nDolbyLP_Y1; + LONG nDolbyHP_B0; + LONG nDolbyHP_B1; + LONG nDolbyHP_A1; + LONG nDolbyLP_B0; + LONG nDolbyLP_B1; + LONG nDolbyLP_A1; + + // Bass Expansion: low-pass filter + LONG nXBassFlt_Y1; + LONG nXBassFlt_X1; + LONG nXBassFlt_B0; + LONG nXBassFlt_B1; + LONG nXBassFlt_A1; + + // DC Removal Biquad + LONG nDCRFlt_Y1l; + LONG nDCRFlt_X1l; + LONG nDCRFlt_Y1r; + LONG nDCRFlt_X1r; + + LONG SurroundBuffer[SURROUNDBUFFERSIZE]; + +public: + CDSP(); + ~CDSP() {} +public: + void SetSettings(const CDSPSettings &settings) { m_Settings = settings; } + // [XBass level 0(quiet)-100(loud)], [cutoff in Hz 10-100] + BOOL SetXBassParameters(UINT nDepth, UINT nRange); + // [Surround level 0(quiet)-100(heavy)] [delay in ms, usually 5-40ms] + BOOL SetSurroundParameters(UINT nDepth, UINT nDelay); + void Initialize(BOOL bReset, DWORD MixingFreq, DWORD SoundSetupFlags); + void Process(int * MixSoundBuffer, int * MixRearBuffer, int count, DWORD SoundSetupFlags, UINT nChannels); +private: + void ProcessStereoSurround(int * MixSoundBuffer, int count); + void ProcessQuadSurround(int * MixSoundBuffer, int * MixRearBuffer, int count); +}; + Property changes on: trunk/OpenMPT/sounddsp/DSP.h ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-chdr \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-03-25 16:43:54 UTC (rev 1671) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-03-25 16:48:14 UTC (rev 1672) @@ -32,6 +32,8 @@ #include "plugins/PlugInterface.h" #include "RowVisitor.h" +#include "../sounddsp/DSP.h" + // ----------------------------------------------------------------------------------------- // MODULAR ModInstrument FIELD ACCESS : body content at the (near) top of Sndfile.cpp !!! // ----------------------------------------------------------------------------------------- @@ -227,9 +229,8 @@ bool m_bITBidiMode; // Process bidi loops like Impulse Tracker (see Fastmix.cpp for an explanation) public: // Static Members - static UINT m_nXBassDepth, m_nXBassRange; + static CDSP m_DSP; static UINT m_nReverbDepth, gnReverbType; - static UINT m_nProLogicDepth, m_nProLogicDelay; static UINT m_nStereoSeparation; static UINT m_nMaxMixChannels; static DWORD gdwSysInfo, gdwSoundSetup, gdwMixingFreq, gnBitsPerSample, gnChannels; @@ -486,16 +487,8 @@ static void SetAGC(BOOL b); static void ResetAGC(); static void ProcessAGC(int count); - // DSP Effects - static void InitializeDSP(BOOL bReset); - static void ProcessStereoDSP(int count); - static void ProcessMonoDSP(int count); // [Reverb level 0(quiet)-100(loud)], [REVERBTYPE_XXXX] static BOOL SetReverbParameters(UINT nDepth, UINT nType); - // [XBass level 0(quiet)-100(loud)], [cutoff in Hz 10-100] - static BOOL SetXBassParameters(UINT nDepth, UINT nRange); - // [Surround level 0(quiet)-100(heavy)] [delay in ms, usually 5-40ms] - static BOOL SetSurroundParameters(UINT nDepth, UINT nDelay); #ifdef ENABLE_EQ // EQ static void InitializeEQ(BOOL bReset=TRUE); Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-03-25 16:43:54 UTC (rev 1671) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-03-25 16:48:14 UTC (rev 1672) @@ -35,6 +35,7 @@ DWORD CSoundFile::gdwMixingFreq = 44100; DWORD CSoundFile::gnBitsPerSample = 16; // Mixing data initialized in +CDSP CSoundFile::m_DSP; UINT CSoundFile::gnAGC = AGC_UNITY; double CSoundFile::gdWFIRCutoff = 0.97; //default value BYTE CSoundFile::gbWFIRType = 7; //WFIR_KAISER4T; //default value @@ -168,7 +169,7 @@ #ifndef NO_REVERB InitializeReverb(bReset); #endif - InitializeDSP(bReset); + m_DSP.Initialize(bReset, gdwMixingFreq, gdwSoundSetup); #ifdef ENABLE_EQ InitializeEQ(bReset); #endif @@ -313,8 +314,6 @@ { ApplyGlobalVolume(MixSoundBuffer, MixRearBuffer, lSampleCount); } - - ProcessStereoDSP(lCount); } else { m_nMixStat += CreateStereoMix(lCount); @@ -331,10 +330,10 @@ { ApplyGlobalVolume(MixSoundBuffer, nullptr, lSampleCount); } - - ProcessMonoDSP(lCount); } + m_DSP.Process(MixSoundBuffer, MixRearBuffer, lCount, gdwSoundSetup, gnChannels); + #ifdef ENABLE_EQ // Graphic Equalizer if (gdwSoundSetup & SNDMIX_EQ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-03-25 17:26:23
|
Revision: 1673 http://sourceforge.net/p/modplug/code/1673 Author: saga-games Date: 2013-03-25 17:26:16 +0000 (Mon, 25 Mar 2013) Log Message: ----------- [Imp] Instrument envelopes are now also evaluated if no sample, but a MIDI channel is assigned to the instrument - great for automating plugins using envelopes. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-03-25 16:48:14 UTC (rev 1672) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-03-25 17:26:16 UTC (rev 1673) @@ -1060,9 +1060,10 @@ { ModChannel *pChn = &m_pSndFile->Chn[k]; p->dwPos[k] = 0; - if ((nIns) && (nIns <= m_pSndFile->m_nInstruments) && (pChn->nLength) - && (pChn->pModInstrument) && (pChn->pModInstrument == m_pSndFile->Instruments[nIns]) - && ((!(pChn->dwFlags & CHN_NOTEFADE)) || (pChn->nFadeOutVol))) + if(nIns != 0 && nIns <= m_pSndFile->GetNumInstruments() // There is an instrument + && pChn->pModInstrument && pChn->pModInstrument == m_pSndFile->Instruments[nIns] // And it's the correct instrument + && (pChn->nLength || pChn->pModInstrument->HasValidMIDIChannel()) // And it's playing something (sample or instrument) + && (!pChn->dwFlags[CHN_NOTEFADE] || pChn->nFadeOutVol)) // And it hasn't completely faded out yet, so it's still playing { enmEnvelopeTypes notifyEnv = ENV_VOLUME; if (m_dwNotifyType & MPTNOTIFY_PITCHENV) @@ -1549,11 +1550,14 @@ // Avoid global volume ramping when trying samples in the treeview. m_WaveFile.m_pConfig->setGlobalVolumeAppliesToMaster(false); m_WaveFile.m_nDefaultGlobalVolume = m_WaveFile.m_nGlobalVolume = MAX_GLOBAL_VOLUME; + m_WaveFile.m_nSamplePreAmp = 48; m_WaveFile.m_nDefaultTempo = 125; m_WaveFile.m_nDefaultSpeed = 6; m_WaveFile.m_nType = MOD_TYPE_IT; m_WaveFile.m_nChannels = 4; m_WaveFile.m_nInstruments = 1; + m_WaveFile.m_nTempoMode = tempo_mode_classic; + m_WaveFile.m_nMixLevels = mixLevels_compatible; m_WaveFile.Order.resize(2); m_WaveFile.Order[0] = 0; m_WaveFile.Order[1] = 1; Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-03-25 16:48:14 UTC (rev 1672) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-03-25 17:26:16 UTC (rev 1673) @@ -759,6 +759,9 @@ pChn->dwFlags.reset(CHN_SURROUND); } } + } else if(pIns && pIns->HasValidMIDIChannel()) + { + pChn->nInsVol = pIns->nGlobalVol; } @@ -829,7 +832,7 @@ } } // Invalid sample ? - if(!pSmp) + if(pSmp == nullptr && (pIns == nullptr || !pIns->HasValidMIDIChannel())) { pChn->pModSample = nullptr; pChn->nInsVol = 0; @@ -837,24 +840,23 @@ } // Tone-Portamento doesn't reset the pingpong direction flag - if(bPorta && pSmp == pChn->pModSample) + if(bPorta && pSmp == pChn->pModSample && pSmp != nullptr) { // If channel length is 0, we cut a previous sample using SCx. In that case, we have to update sample length, loop points, etc... if(GetType() & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT) && pChn->nLength != 0) return; pChn->dwFlags.reset(CHN_KEYOFF | CHN_NOTEFADE); - pChn->dwFlags = (pChn->dwFlags & (CHN_CHANNELFLAGS | CHN_PINGPONGFLAG)) | (pSmp->uFlags & CHN_SAMPLEFLAGS); - } else + pChn->dwFlags = (pChn->dwFlags & (CHN_CHANNELFLAGS | CHN_PINGPONGFLAG)); + } else //if(!instrumentChanged || pChn->rowCommand.instr != 0 || !IsCompatibleMode(TRK_FASTTRACKER2)) // SampleChange.xm? { pChn->dwFlags.reset(CHN_KEYOFF | CHN_NOTEFADE); // IT compatibility tentative fix: Don't change bidi loop direction when // no sample nor instrument is changed. if(IsCompatibleMode(TRK_ALLTRACKERS) && pSmp == pChn->pModSample && !instrumentChanged) - pChn->dwFlags = (pChn->dwFlags & (CHN_CHANNELFLAGS | CHN_PINGPONGFLAG)) | (pSmp->uFlags & CHN_SAMPLEFLAGS); + pChn->dwFlags = (pChn->dwFlags & (CHN_CHANNELFLAGS | CHN_PINGPONGFLAG)); else - pChn->dwFlags = (pChn->dwFlags & CHN_CHANNELFLAGS) | (pSmp->uFlags & CHN_SAMPLEFLAGS); + pChn->dwFlags = (pChn->dwFlags & CHN_CHANNELFLAGS); - if(pIns) { // Copy envelope flags (we actually only need the "enabled" and "pitch" flag) @@ -876,10 +878,16 @@ pChn->nResSwing = pChn->nCutSwing = 0; } + if(pSmp == nullptr) + { + return; + } + pChn->pModSample = pSmp; pChn->nLength = pSmp->nLength; pChn->nLoopStart = pSmp->nLoopStart; pChn->nLoopEnd = pSmp->nLoopEnd; + pChn->dwFlags |= (pSmp->uFlags & CHN_SAMPLEFLAGS); // IT Compatibility: Autovibrato reset if(IsCompatibleMode(TRK_IMPULSETRACKER)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-03-25 17:58:00
|
Revision: 1682 http://sourceforge.net/p/modplug/code/1682 Author: manxorist Date: 2013-03-25 17:57:53 +0000 (Mon, 25 Mar 2013) Log Message: ----------- [Ref] Move AGC code from soundlib to sounddsp. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/sounddsp/DSP.cpp trunk/OpenMPT/soundlib/Fastmix.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Added Paths: ----------- trunk/OpenMPT/sounddsp/AGC.cpp trunk/OpenMPT/sounddsp/AGC.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-03-25 17:37:21 UTC (rev 1681) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-03-25 17:57:53 UTC (rev 1682) @@ -1310,7 +1310,7 @@ pSndFile->SetupITBidiMode(); if(m_pSndFile != nullptr || (m_dwStatus & MODSTATUS_PLAYING)) PauseMod(); - if(m_pSndFile != nullptr && (pSndFile != m_pSndFile || !m_pSndFile->GetTotalSampleCount())) CSoundFile::ResetAGC(); + if(m_pSndFile != nullptr && (pSndFile != m_pSndFile || !m_pSndFile->GetTotalSampleCount())) CSoundFile::m_AGC.Reset(); m_pSndFile = pSndFile; m_pModPlaying = pModDoc; m_hFollowSong = hPat; @@ -2007,7 +2007,7 @@ { gdwIdleTime = 0; // After 15 seconds of inactivity, we reset the AGC - CSoundFile::ResetAGC(); + CSoundFile::m_AGC.Reset(); gdwPlayLatency = 0; } } Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-03-25 17:37:21 UTC (rev 1681) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-03-25 17:57:53 UTC (rev 1682) @@ -493,6 +493,10 @@ > </File> <File + RelativePath="..\sounddsp\AGC.cpp" + > + </File> + <File RelativePath="..\sounddsp\DSP.cpp" > </File> @@ -1055,6 +1059,10 @@ > </File> <File + RelativePath="..\sounddsp\AGC.h" + > + </File> + <File RelativePath="..\sounddsp\DSP.h" > </File> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-03-25 17:37:21 UTC (rev 1681) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-03-25 17:57:53 UTC (rev 1682) @@ -247,6 +247,7 @@ <ClCompile Include="..\common\AudioCriticalSection.cpp" /> <ClCompile Include="..\common\misc_util.cpp" /> <ClCompile Include="..\common\Reporting.cpp" /> + <ClCompile Include="..\sounddsp\AGC.cpp" /> <ClCompile Include="..\sounddsp\DSP.cpp" /> <ClCompile Include="..\sounddsp\EQ.cpp" /> <ClCompile Include="..\soundlib\ITCompression.cpp" /> @@ -404,6 +405,7 @@ <ClInclude Include="..\common\Reporting.h" /> <ClInclude Include="..\common\StringFixer.h" /> <ClInclude Include="..\common\typedefs.h" /> + <ClInclude Include="..\sounddsp\AGC.h" /> <ClInclude Include="..\sounddsp\DSP.h" /> <ClInclude Include="..\soundlib\ChunkReader.h" /> <ClInclude Include="..\soundlib\FileReader.h" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-03-25 17:37:21 UTC (rev 1681) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-03-25 17:57:53 UTC (rev 1682) @@ -427,6 +427,9 @@ <ClCompile Include="..\sounddsp\EQ.cpp"> <Filter>Source Files\sounddsp</Filter> </ClCompile> + <ClCompile Include="..\sounddsp\AGC.cpp"> + <Filter>Source Files\sounddsp</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="AbstractVstEditor.h"> @@ -768,6 +771,9 @@ <ClInclude Include="..\sounddsp\DSP.h"> <Filter>Header Files\sounddsp</Filter> </ClInclude> + <ClInclude Include="..\sounddsp\AGC.h"> + <Filter>Header Files\sounddsp</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="res\bitmap1.bmp"> Added: trunk/OpenMPT/sounddsp/AGC.cpp =================================================================== --- trunk/OpenMPT/sounddsp/AGC.cpp (rev 0) +++ trunk/OpenMPT/sounddsp/AGC.cpp 2013-03-25 17:57:53 UTC (rev 1682) @@ -0,0 +1,111 @@ +/* + * AGC.cpp + * ------- + * Purpose: Automatic Gain Control + * Notes : Ugh... This should really be removed at some point. + * Authors: Olivier Lapicque + * OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#include "stdafx.h" +#include "../soundlib/Sndfile.h" +#include "../sounddsp/DSP.h" + + +////////////////////////////////////////////////////////////////////////////////// +// Automatic Gain Control + +#ifndef NO_AGC + +#define AGC_PRECISION 10 +#define AGC_UNITY (1 << AGC_PRECISION) + +// Limiter +#define MIXING_LIMITMAX (0x08100000) +#define MIXING_LIMITMIN (-MIXING_LIMITMAX) + +UINT MPPASMCALL X86_AGC(int *pBuffer, UINT nSamples, UINT nAGC) +//------------------------------------------------------------- +{ + UINT result; + _asm { + mov esi, pBuffer // esi = pBuffer+i + mov ecx, nSamples // ecx = i + mov edi, nAGC // edi = AGC (0..256) +agcloop: + mov eax, dword ptr [esi] + imul edi + shrd eax, edx, AGC_PRECISION + add esi, 4 + cmp eax, MIXING_LIMITMIN + jl agcupdate + cmp eax, MIXING_LIMITMAX + jg agcupdate +agcrecover: + dec ecx + mov dword ptr [esi-4], eax + jnz agcloop + jmp done +agcupdate: + dec edi + jmp agcrecover +done: + mov result, edi + } + return result; +} + +#pragma warning (default:4100) + + +CAGC::CAGC() +//---------- +{ + m_nAGC = AGC_UNITY; +} + + +void CAGC::Process(int * MixSoundBuffer, int count, DWORD MixingFreq, UINT nChannels) +//----------------------------------------------------------------------------------- +{ + static DWORD gAGCRecoverCount = 0; + UINT agc = X86_AGC(MixSoundBuffer, count, m_nAGC); + // Some kind custom law, so that the AGC stays quite stable, but slowly + // goes back up if the sound level stays below a level inversely proportional + // to the AGC level. (J'me comprends) + if ((agc >= m_nAGC) && (m_nAGC < AGC_UNITY)) + { + gAGCRecoverCount += count; + UINT agctimeout = MixingFreq >> (AGC_PRECISION-8); + if (nChannels < 2) agctimeout >>= 1; + if (gAGCRecoverCount >= agctimeout) + { + gAGCRecoverCount = 0; + m_nAGC++; + } + } else + { + m_nAGC = agc; + gAGCRecoverCount = 0; + } +} + + +void CAGC::Adjust(UINT oldVol, UINT newVol) +//----------------------------------------- +{ + m_nAGC = m_nAGC * oldVol / newVol; + if (m_nAGC > AGC_UNITY) m_nAGC = AGC_UNITY; +} + + +void CAGC::Reset() +//---------------- +{ + m_nAGC = AGC_UNITY; +} + + +#endif // NO_AGC Property changes on: trunk/OpenMPT/sounddsp/AGC.cpp ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-c++src \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/OpenMPT/sounddsp/AGC.h =================================================================== --- trunk/OpenMPT/sounddsp/AGC.h (rev 0) +++ trunk/OpenMPT/sounddsp/AGC.h 2013-03-25 17:57:53 UTC (rev 1682) @@ -0,0 +1,46 @@ +/* + * AGC.h + * ----- + * Purpose: Mixing code for various DSPs (EQ, Mega-Bass, ...) + * Notes : Ugh... This should really be removed at some point. + * Authors: Olivier Lapicque + * OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#pragma once + +/* + * AGC.h + * ----- + * Purpose: Automatic Gain Control + * Notes : Ugh... This should really be removed at some point. + * Authors: Olivier Lapicque + * OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + +#pragma once + + +#ifndef NO_AGC + +//======== +class CAGC +//======== +{ +private: + UINT m_nAGC; +public: + CAGC(); + ~CAGC() {} +public: + void Initialize(BOOL bReset, DWORD MixingFreq, DWORD SoundSetupFlags); + void Process(int * MixSoundBuffer, int count, DWORD MixingFreq, UINT nChannels); + void Adjust(UINT oldVol, UINT newVol); + void Reset(); +private: +}; + +#endif // NO_AGC Property changes on: trunk/OpenMPT/sounddsp/AGC.h ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-chdr \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/OpenMPT/sounddsp/DSP.cpp =================================================================== --- trunk/OpenMPT/sounddsp/DSP.cpp 2013-03-25 17:37:21 UTC (rev 1681) +++ trunk/OpenMPT/sounddsp/DSP.cpp 2013-03-25 17:57:53 UTC (rev 1682) @@ -10,7 +10,8 @@ #include "stdafx.h" -#include "../soundlib/sndfile.h" +#include "../soundlib/Sndfile.h" +#include "../sounddsp/DSP.h" #include <math.h> Modified: trunk/OpenMPT/soundlib/Fastmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Fastmix.cpp 2013-03-25 17:37:21 UTC (rev 1681) +++ trunk/OpenMPT/soundlib/Fastmix.cpp 2013-03-25 17:57:53 UTC (rev 1682) @@ -2331,79 +2331,3 @@ #endif } - -////////////////////////////////////////////////////////////////////////////////// -// Automatic Gain Control - -#ifndef NO_AGC - -// Limiter -#define MIXING_LIMITMAX (0x08100000) -#define MIXING_LIMITMIN (-MIXING_LIMITMAX) - -UINT MPPASMCALL X86_AGC(int *pBuffer, UINT nSamples, UINT nAGC) -//------------------------------------------------------------- -{ - UINT result; - _asm { - mov esi, pBuffer // esi = pBuffer+i - mov ecx, nSamples // ecx = i - mov edi, nAGC // edi = AGC (0..256) -agcloop: - mov eax, dword ptr [esi] - imul edi - shrd eax, edx, AGC_PRECISION - add esi, 4 - cmp eax, MIXING_LIMITMIN - jl agcupdate - cmp eax, MIXING_LIMITMAX - jg agcupdate -agcrecover: - dec ecx - mov dword ptr [esi-4], eax - jnz agcloop - jmp done -agcupdate: - dec edi - jmp agcrecover -done: - mov result, edi - } - return result; -} - -#pragma warning (default:4100) - -void CSoundFile::ProcessAGC(int count) -//------------------------------------ -{ - static DWORD gAGCRecoverCount = 0; - UINT agc = X86_AGC(MixSoundBuffer, count, gnAGC); - // Some kind custom law, so that the AGC stays quite stable, but slowly - // goes back up if the sound level stays below a level inversely proportional - // to the AGC level. (J'me comprends) - if ((agc >= gnAGC) && (gnAGC < AGC_UNITY)) - { - gAGCRecoverCount += count; - UINT agctimeout = gdwMixingFreq >> (AGC_PRECISION-8); - if (gnChannels < 2) agctimeout >>= 1; - if (gAGCRecoverCount >= agctimeout) - { - gAGCRecoverCount = 0; - gnAGC++; - } - } else - { - gnAGC = agc; - gAGCRecoverCount = 0; - } -} - - -void CSoundFile::ResetAGC() -//------------------------- -{ - gnAGC = AGC_UNITY; -} - -#endif // NO_AGC Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-03-25 17:37:21 UTC (rev 1681) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-03-25 17:57:53 UTC (rev 1682) @@ -958,8 +958,7 @@ if (nVol > 0x200) nVol = 0x200; // x4 maximum if ((nVol < m_nMasterVolume) && (nVol) && (gdwSoundSetup & SNDMIX_AGC) && (adjustAGC)) { - gnAGC = gnAGC * m_nMasterVolume / nVol; - if (gnAGC > AGC_UNITY) gnAGC = AGC_UNITY; + m_AGC.Adjust(m_nMasterVolume, nVol); } m_nMasterVolume = nVol; } @@ -973,7 +972,7 @@ if (!(gdwSoundSetup & SNDMIX_AGC)) { gdwSoundSetup |= SNDMIX_AGC; - gnAGC = AGC_UNITY; + m_AGC.Reset(); } } else gdwSoundSetup &= ~SNDMIX_AGC; } Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-03-25 17:37:21 UTC (rev 1681) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-03-25 17:57:53 UTC (rev 1682) @@ -32,6 +32,7 @@ #include "plugins/PlugInterface.h" #include "RowVisitor.h" +#include "../sounddsp/AGC.h" #include "../sounddsp/DSP.h" // ----------------------------------------------------------------------------------------- @@ -230,11 +231,11 @@ public: // Static Members static CDSP m_DSP; + static CAGC m_AGC; static UINT m_nReverbDepth, gnReverbType; static UINT m_nStereoSeparation; static UINT m_nMaxMixChannels; static DWORD gdwSysInfo, gdwSoundSetup, gdwMixingFreq, gnBitsPerSample, gnChannels; - static UINT gnAGC; static double gdWFIRCutoff; static BYTE gbWFIRType; static UINT gnVolumeRampUpSamples, gnVolumeRampUpSamplesTarget, gnVolumeRampDownSamples; @@ -485,8 +486,6 @@ // AGC static BOOL GetAGC() { return (gdwSoundSetup & SNDMIX_AGC) ? TRUE : FALSE; } static void SetAGC(BOOL b); - static void ResetAGC(); - static void ProcessAGC(int count); // [Reverb level 0(quiet)-100(loud)], [REVERBTYPE_XXXX] static BOOL SetReverbParameters(UINT nDepth, UINT nType); #ifdef ENABLE_EQ @@ -753,8 +752,6 @@ #define VOLUMERAMPPRECISION 12 #define FADESONGDELAY 100 #define EQ_BUFFERSIZE (MIXBUFFERSIZE) -#define AGC_PRECISION 10 -#define AGC_UNITY (1 << AGC_PRECISION) // Calling conventions #ifdef WIN32 Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-03-25 17:37:21 UTC (rev 1681) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-03-25 17:57:53 UTC (rev 1682) @@ -36,7 +36,7 @@ DWORD CSoundFile::gnBitsPerSample = 16; // Mixing data initialized in CDSP CSoundFile::m_DSP; -UINT CSoundFile::gnAGC = AGC_UNITY; +CAGC CSoundFile::m_AGC; double CSoundFile::gdWFIRCutoff = 0.97; //default value BYTE CSoundFile::gbWFIRType = 7; //WFIR_KAISER4T; //default value UINT CSoundFile::gnVolumeRampUpSamples = 42; //default value @@ -349,7 +349,7 @@ #ifndef NO_AGC // Automatic Gain Control - if (gdwSoundSetup & SNDMIX_AGC) ProcessAGC(lSampleCount); + if (gdwSoundSetup & SNDMIX_AGC) m_AGC.Process(MixSoundBuffer, lSampleCount, gdwMixingFreq, gnChannels); #endif // NO_AGC UINT lTotalSampleCount = lSampleCount; // Including rear channels This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-03-25 18:43:34
|
Revision: 1684 http://sourceforge.net/p/modplug/code/1684 Author: manxorist Date: 2013-03-25 18:43:27 +0000 (Mon, 25 Mar 2013) Log Message: ----------- [Ref] Properly encapsulate EQ into its own class. Modified Paths: -------------- trunk/OpenMPT/mptrack/TrackerSettings.h trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/sounddsp/AGC.h trunk/OpenMPT/sounddsp/EQ.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Added Paths: ----------- trunk/OpenMPT/sounddsp/EQ.h Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2013-03-25 18:02:36 UTC (rev 1683) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2013-03-25 18:43:27 UTC (rev 1684) @@ -12,6 +12,7 @@ #pragma once #include "../soundlib/MixerSettings.h" +#include "../sounddsp/EQ.h" ///////////////////////////////////////////////////////////////////////// // Default directories @@ -114,7 +115,6 @@ // EQ -#define MAX_EQ_BANDS 6 struct EQPreset { char szName[12]; Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-03-25 18:02:36 UTC (rev 1683) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-03-25 18:43:27 UTC (rev 1684) @@ -1067,6 +1067,10 @@ > </File> <File + RelativePath="..\sounddsp\EQ.h" + > + </File> + <File RelativePath="..\soundlib\SoundFilePlayConfig.h" > </File> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-03-25 18:02:36 UTC (rev 1683) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-03-25 18:43:27 UTC (rev 1684) @@ -407,6 +407,7 @@ <ClInclude Include="..\common\typedefs.h" /> <ClInclude Include="..\sounddsp\AGC.h" /> <ClInclude Include="..\sounddsp\DSP.h" /> + <ClInclude Include="..\sounddsp\EQ.h" /> <ClInclude Include="..\soundlib\ChunkReader.h" /> <ClInclude Include="..\soundlib\FileReader.h" /> <ClInclude Include="..\soundlib\ITCompression.h" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-03-25 18:02:36 UTC (rev 1683) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-03-25 18:43:27 UTC (rev 1684) @@ -774,6 +774,9 @@ <ClInclude Include="..\sounddsp\AGC.h"> <Filter>Header Files\sounddsp</Filter> </ClInclude> + <ClInclude Include="..\sounddsp\EQ.h"> + <Filter>Header Files\sounddsp</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="res\bitmap1.bmp"> Modified: trunk/OpenMPT/sounddsp/AGC.h =================================================================== --- trunk/OpenMPT/sounddsp/AGC.h 2013-03-25 18:02:36 UTC (rev 1683) +++ trunk/OpenMPT/sounddsp/AGC.h 2013-03-25 18:43:27 UTC (rev 1684) @@ -1,19 +1,6 @@ /* * AGC.h * ----- - * Purpose: Mixing code for various DSPs (EQ, Mega-Bass, ...) - * Notes : Ugh... This should really be removed at some point. - * Authors: Olivier Lapicque - * OpenMPT Devs - * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. - */ - - -#pragma once - -/* - * AGC.h - * ----- * Purpose: Automatic Gain Control * Notes : Ugh... This should really be removed at some point. * Authors: Olivier Lapicque Modified: trunk/OpenMPT/sounddsp/EQ.cpp =================================================================== --- trunk/OpenMPT/sounddsp/EQ.cpp 2013-03-25 18:02:36 UTC (rev 1683) +++ trunk/OpenMPT/sounddsp/EQ.cpp 2013-03-25 18:43:27 UTC (rev 1684) @@ -1,6 +1,6 @@ /* * EQ.cpp - * ---------- + * ------ * Purpose: Mixing code for equalizer. * Notes : Ugh... This should really be removed at some point. * Authors: Olivier Lapicque @@ -11,11 +11,11 @@ #include "stdafx.h" #include "../soundlib/sndfile.h" -#include "../mptrack/TrackerSettings.h" +#include "../sounddsp/EQ.h" + #define EQ_BANDWIDTH 2.0 #define EQ_ZERO 0.000001 -#define REAL float extern REAL MixFloatBuffer[]; @@ -35,17 +35,8 @@ -#pragma pack(push, 4) -typedef struct _EQBANDSTRUCT -{ - REAL a0, a1, a2, b1, b2; - REAL x1, x2, y1, y2; - REAL Gain, CenterFrequency; - BOOL bEnable; -} EQBANDSTRUCT, *PEQBANDSTRUCT; -#pragma pack(pop) -UINT gEqLinearToDB[33] = +static const UINT gEqLinearToDB[33] = { 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58, 61, @@ -54,10 +45,10 @@ }; -static REAL f2ic = (REAL)(1 << 28); -static REAL i2fc = (REAL)(1.0 / (1 << 28)); +static const REAL f2ic = (REAL)(1 << 28); +static const REAL i2fc = (REAL)(1.0 / (1 << 28)); -static EQBANDSTRUCT gEQ[MAX_EQ_BANDS*2] = +static const EQBANDSTRUCT gEQDefaults[MAX_EQ_BANDS*2] = { // Default: Flat EQ {0,0,0,0,0, 0,0,0,0, 1, 120, FALSE}, @@ -89,8 +80,8 @@ #define PBS_Y1 DWORD PTR [eax+28] #define PBS_Y2 DWORD PTR [eax+32] -void __cdecl EQFilter(EQBANDSTRUCT *pbs, REAL *pbuffer, UINT nCount) -//------------------------------------------------------------------ +static void __cdecl EQFilter(EQBANDSTRUCT *pbs, REAL *pbuffer, UINT nCount) +//------------------------------------------------------------------------- { _asm { mov eax, pbs // eax = pbs @@ -136,8 +127,8 @@ } -void AMD_StereoEQ(EQBANDSTRUCT *pbl, EQBANDSTRUCT *pbr, REAL *pbuffer, UINT nCount) -//--------------------------------------------------------------------------------- +static void AMD_StereoEQ(EQBANDSTRUCT *pbl, EQBANDSTRUCT *pbr, REAL *pbuffer, UINT nCount) +//---------------------------------------------------------------------------------------- { #ifdef ENABLE_3DNOW float tmp[16]; @@ -220,8 +211,8 @@ } -void SSE_StereoEQ(EQBANDSTRUCT *pbl, EQBANDSTRUCT *pbr, REAL *pbuffer, UINT nCount) -//--------------------------------------------------------------------------------- +static void SSE_StereoEQ(EQBANDSTRUCT *pbl, EQBANDSTRUCT *pbr, REAL *pbuffer, UINT nCount) +//---------------------------------------------------------------------------------------- { #ifdef ENABLE_SSE static const float gk1 = 1.0f; @@ -311,15 +302,15 @@ movss [edx+EQBANDSTRUCT.y2], xmm1 done:; } -#endif SSE_SPECIFIC +#endif // ENABLE_SSE } #pragma warning(default:4100) #else -void EQFilter(EQBANDSTRUCT *pbs, REAL *pbuffer, UINT nCount) -//---------------------------------------------------------- +static void EQFilter(EQBANDSTRUCT *pbs, REAL *pbuffer, UINT nCount) +//----------------------------------------------------------------- { for (UINT i=0; i<nCount; i++) { @@ -336,20 +327,20 @@ #endif -void CSoundFile::EQMono(int *pbuffer, UINT nCount) -//------------------------------------------------ +void CEQ::ProcessMono(int *pbuffer, UINT nCount, CSoundFilePlayConfig *pConfig) +//------------------------------------------------------------------------ { - MonoMixToFloat(pbuffer, MixFloatBuffer, nCount); + X86_MonoMixToFloat(pbuffer, MixFloatBuffer, nCount, pConfig->getIntToFloat()); for (UINT b=0; b<MAX_EQ_BANDS; b++) { if ((gEQ[b].bEnable) && (gEQ[b].Gain != 1.0f)) EQFilter(&gEQ[b], MixFloatBuffer, nCount); } - FloatToMonoMix(MixFloatBuffer, pbuffer, nCount); + X86_FloatToMonoMix(MixFloatBuffer, pbuffer, nCount, pConfig->getFloatToInt()); } -void CSoundFile::EQStereo(int *pbuffer, UINT nCount) -//-------------------------------------------------- +void CEQ::ProcessStereo(int *pbuffer, UINT nCount, CSoundFilePlayConfig *pConfig, DWORD SoundSetupFlags, DWORD SysInfoFlags) +//--------------------------------------------------------------------------------------------------------------------------- { #ifdef ENABLE_SSE @@ -357,10 +348,10 @@ // Still allow the check, because the user can turn this on/off - if ((gdwSysInfo & SYSMIX_SSE) && (gdwSoundSetup & SNDMIX_ENABLEMMX)) + if ((SysInfoFlags & SYSMIX_SSE) && (SoundSetupFlags & SNDMIX_ENABLEMMX)) { int sse_state, sse_eqstate; - SSE_MonoMixToFloat(pbuffer, MixFloatBuffer, nCount*2, m_pConfig->getIntToFloat()); + SSE_MonoMixToFloat(pbuffer, MixFloatBuffer, nCount*2, pConfig->getIntToFloat()); _asm stmxcsr sse_state; sse_eqstate = sse_state | 0xFF80; @@ -372,7 +363,7 @@ } _asm ldmxcsr sse_state; - X86_FloatToMonoMix(MixFloatBuffer, pbuffer, nCount*2, m_pConfig->getFloatToInt()); + X86_FloatToMonoMix(MixFloatBuffer, pbuffer, nCount*2, pConfig->getFloatToInt()); } else @@ -383,9 +374,9 @@ // We still perform the MMX check because the user can enable/disable this - if ((gdwSysInfo & SYSMIX_3DNOW) && (gdwSoundSetup & SNDMIX_ENABLEMMX)) + if ((SysInfoFlags & SYSMIX_3DNOW) && (SoundSetupFlags & SNDMIX_ENABLEMMX)) { - AMD_MonoMixToFloat(pbuffer, MixFloatBuffer, nCount*2, m_pConfig->getIntToFloat()); + AMD_MonoMixToFloat(pbuffer, MixFloatBuffer, nCount*2, pConfig->getIntToFloat()); for (UINT b=0; b<MAX_EQ_BANDS; b++) { @@ -394,13 +385,13 @@ AMD_StereoEQ(&gEQ[b], &gEQ[b+MAX_EQ_BANDS], MixFloatBuffer, nCount); } - AMD_FloatToMonoMix(MixFloatBuffer, pbuffer, nCount*2, m_pConfig->getFloatToInt()); + AMD_FloatToMonoMix(MixFloatBuffer, pbuffer, nCount*2, pConfig->getFloatToInt()); } else #endif // ENABLE_3DNOW { - X86_StereoMixToFloat(pbuffer, MixFloatBuffer, MixFloatBuffer+MIXBUFFERSIZE, nCount, m_pConfig->getIntToFloat()); + X86_StereoMixToFloat(pbuffer, MixFloatBuffer, MixFloatBuffer+MIXBUFFERSIZE, nCount, pConfig->getIntToFloat()); for (UINT bl=0; bl<MAX_EQ_BANDS; bl++) { @@ -411,15 +402,22 @@ if ((gEQ[br].bEnable) && (gEQ[br].Gain != 1.0f)) EQFilter(&gEQ[br], MixFloatBuffer+MIXBUFFERSIZE, nCount); } - X86_FloatToStereoMix(MixFloatBuffer, MixFloatBuffer+MIXBUFFERSIZE, pbuffer, nCount, m_pConfig->getFloatToInt()); + X86_FloatToStereoMix(MixFloatBuffer, MixFloatBuffer+MIXBUFFERSIZE, pbuffer, nCount, pConfig->getFloatToInt()); } } -void CSoundFile::InitializeEQ(BOOL bReset) -//---------------------------------------- +CEQ::CEQ() +//-------- { - REAL fMixingFreq = (REAL)gdwMixingFreq; + memcpy(gEQ, gEQDefaults, sizeof(gEQ)); +} + + +void CEQ::Initialize(BOOL bReset, DWORD MixingFreq) +//------------------------------------------------- +{ + REAL fMixingFreq = (REAL)MixingFreq; // Gain = 0.5 (-6dB) .. 2 (+6dB) for (UINT band=0; band<MAX_EQ_BANDS*2; band++) if (gEQ[band].bEnable) { @@ -498,8 +496,8 @@ } -void CSoundFile::SetEQGains(const UINT *pGains, UINT nGains, const UINT *pFreqs, BOOL bReset) -//------------------------------------------------------------------------------------------- +void CEQ::SetEQGains(const UINT *pGains, UINT nGains, const UINT *pFreqs, BOOL bReset, DWORD MixingFreq) +//------------------------------------------------------------------------------------------------------ { for (UINT i=0; i<MAX_EQ_BANDS; i++) { @@ -528,5 +526,6 @@ gEQ[i+MAX_EQ_BANDS].bEnable = FALSE; } } - InitializeEQ(bReset); + Initialize(bReset, MixingFreq); } + Added: trunk/OpenMPT/sounddsp/EQ.h =================================================================== --- trunk/OpenMPT/sounddsp/EQ.h (rev 0) +++ trunk/OpenMPT/sounddsp/EQ.h 2013-03-25 18:43:27 UTC (rev 1684) @@ -0,0 +1,47 @@ +/* + * EQ.h + * ---- + * Purpose: Mixing code for equalizer. + * Notes : Ugh... This should really be removed at some point. + * Authors: Olivier Lapicque + * OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#pragma once + + +#include "../soundlib/SoundFilePlayConfig.h" + + +#define REAL float +#define MAX_EQ_BANDS 6 + +#pragma pack(push, 4) +typedef struct _EQBANDSTRUCT +{ + REAL a0, a1, a2, b1, b2; + REAL x1, x2, y1, y2; + REAL Gain, CenterFrequency; + BOOL bEnable; +} EQBANDSTRUCT, *PEQBANDSTRUCT; +#pragma pack(pop) + + +//======= +class CEQ +//======= +{ +private: + EQBANDSTRUCT gEQ[MAX_EQ_BANDS*2]; +public: + CEQ(); + ~CEQ() {} +public: + void Initialize(BOOL bReset, DWORD MixingFreq); + void ProcessStereo(int *pbuffer, UINT nCount, CSoundFilePlayConfig *pConfig, DWORD SoundSetupFlags, DWORD SysInfoFlags); + void ProcessMono(int *pbuffer, UINT nCount, CSoundFilePlayConfig *pConfig); + void SetEQGains(const UINT *pGains, UINT nGains, const UINT *pFreqs, BOOL bReset, DWORD MixingFreq); +}; + Property changes on: trunk/OpenMPT/sounddsp/EQ.h ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-chdr \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-03-25 18:02:36 UTC (rev 1683) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-03-25 18:43:27 UTC (rev 1684) @@ -34,6 +34,7 @@ #include "../sounddsp/AGC.h" #include "../sounddsp/DSP.h" +#include "../sounddsp/EQ.h" // ----------------------------------------------------------------------------------------- // MODULAR ModInstrument FIELD ACCESS : body content at the (near) top of Sndfile.cpp !!! @@ -231,6 +232,7 @@ public: // Static Members static CDSP m_DSP; + static CEQ m_EQ; static CAGC m_AGC; static UINT m_nReverbDepth, gnReverbType; static UINT m_nStereoSeparation; @@ -490,10 +492,7 @@ static BOOL SetReverbParameters(UINT nDepth, UINT nType); #ifdef ENABLE_EQ // EQ - static void InitializeEQ(BOOL bReset=TRUE); - static void SetEQGains(const UINT *pGains, UINT nBands, const UINT *pFreqs=NULL, BOOL bReset=FALSE); // 0=-12dB, 32=+12dB - /*static*/ void EQStereo(int *pbuffer, UINT nCount); - /*static*/ void EQMono(int *pbuffer, UINT nCount); + static void SetEQGains(const UINT *pGains, UINT nBands, const UINT *pFreqs=NULL, BOOL bReset=FALSE) { m_EQ.SetEQGains(pGains, nBands, pFreqs, bReset, gdwMixingFreq); } // 0=-12dB, 32=+12dB #endif // Float <-> Int conversion routines /*static */VOID StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount); Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-03-25 18:02:36 UTC (rev 1683) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-03-25 18:43:27 UTC (rev 1684) @@ -36,6 +36,7 @@ DWORD CSoundFile::gnBitsPerSample = 16; // Mixing data initialized in CDSP CSoundFile::m_DSP; +CEQ CSoundFile::m_EQ; CAGC CSoundFile::m_AGC; double CSoundFile::gdWFIRCutoff = 0.97; //default value BYTE CSoundFile::gbWFIRType = 7; //WFIR_KAISER4T; //default value @@ -171,7 +172,7 @@ #endif m_DSP.Initialize(bReset, gdwMixingFreq, gdwSoundSetup); #ifdef ENABLE_EQ - InitializeEQ(bReset); + m_EQ.Initialize(bReset, gdwMixingFreq); #endif return TRUE; } @@ -339,9 +340,9 @@ if (gdwSoundSetup & SNDMIX_EQ) { if (gnChannels >= 2) - EQStereo(MixSoundBuffer, lCount); + m_EQ.ProcessStereo(MixSoundBuffer, lCount, m_pConfig, gdwSoundSetup, gdwSysInfo); else - EQMono(MixSoundBuffer, lCount); + m_EQ.ProcessMono(MixSoundBuffer, lCount, m_pConfig); } #endif // ENABLE_EQ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-03-25 20:21:06
|
Revision: 1688 http://sourceforge.net/p/modplug/code/1688 Author: manxorist Date: 2013-03-25 20:20:56 +0000 (Mon, 25 Mar 2013) Log Message: ----------- [Ref] Add NO_DSP compile time setting, make NO_AGC actually compile and replace ENABLE_EQ with the negated NO_EQ instead. Disable corresponding GUI widgest in options dialog when these features are disabled. Modified Paths: -------------- trunk/OpenMPT/common/stdafx.h trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h trunk/OpenMPT/sounddsp/DSP.cpp trunk/OpenMPT/sounddsp/DSP.h trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/common/stdafx.h =================================================================== --- trunk/OpenMPT/common/stdafx.h 2013-03-25 18:58:54 UTC (rev 1687) +++ trunk/OpenMPT/common/stdafx.h 2013-03-25 20:20:56 UTC (rev 1688) @@ -95,9 +95,15 @@ #endif // ENABLE_ASM -// Enable the built-in equalizer. -#define ENABLE_EQ +// Disable built-in miscellaneous DSP effects (surround, mega bass, noise reduction) +//#define NO_DSP +// Disable the built-in equalizer. +//#define NO_EQ + +// Disable the built-in automatic gain control +//#define NO_AGC + // Define to build without ASIO support; makes build possible without ASIO SDK. //#define NO_ASIO Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-03-25 18:58:54 UTC (rev 1687) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-03-25 20:20:56 UTC (rev 1688) @@ -914,8 +914,10 @@ gpSoundDevice->Configure(m_hWnd, NUM_AUDIO_BUFFERS, TrackerSettings::Instance().m_nBufferLength, fulOptions); gbStopSent = FALSE; m_pSndFile->SetResamplingMode(TrackerSettings::Instance().m_nSrcMode); - m_pSndFile->UPDATEDSPEFFECTS(); + UpdateDspEffects(); +#ifndef NO_AGC m_pSndFile->SetAGC(TrackerSettings::Instance().m_dwQuality & QUALITY_AGC); +#endif if (!gpSoundDevice->Open(nDevNo, &WaveFormat.Format)) return -1; return 0; } @@ -1117,6 +1119,32 @@ } +void CMainFrame::UpdateDspEffects() +//--------------------------------- +{ + CSoundFile::SetDspEffects( +#ifndef NO_DSP + TrackerSettings::Instance().m_dwQuality & QUALITY_SURROUND, +#else + FALSE, +#endif + TrackerSettings::Instance().m_dwQuality & QUALITY_REVERB, +#ifndef NO_DSP + TrackerSettings::Instance().m_dwQuality & QUALITY_MEGABASS, + TrackerSettings::Instance().m_dwQuality & QUALITY_NOISEREDUCTION, +#else + FALSE, + FALSE, +#endif +#ifndef NO_EQ + TrackerSettings::Instance().m_dwQuality & QUALITY_EQ +#else + FALSE +#endif + ); +} + + void CMainFrame::UpdateAudioParameters(BOOL bReset) //------------------------------------------------- { @@ -1140,9 +1168,13 @@ else CSoundFile::gdwSoundSetup &= ~SNDMIX_MUTECHNMODE; CSoundFile::SetResamplingMode(TrackerSettings::Instance().m_nSrcMode); - CSoundFile::UPDATEDSPEFFECTS(); + UpdateDspEffects(); +#ifndef NO_AGC CSoundFile::SetAGC(TrackerSettings::Instance().m_dwQuality & QUALITY_AGC); +#endif +#ifndef NO_EQ CSoundFile::SetEQGains( TrackerSettings::Instance().m_EqSettings.Gains, MAX_EQ_BANDS, TrackerSettings::Instance().m_EqSettings.Freqs, bReset ); +#endif if (bReset) { CSoundFile::SetMixerSettings(TrackerSettings::Instance().m_MixerSettings); @@ -1310,7 +1342,12 @@ pSndFile->SetupITBidiMode(); if(m_pSndFile != nullptr || (m_dwStatus & MODSTATUS_PLAYING)) PauseMod(); - if(m_pSndFile != nullptr && (pSndFile != m_pSndFile || !m_pSndFile->GetTotalSampleCount())) CSoundFile::m_AGC.Reset(); + if(m_pSndFile != nullptr && (pSndFile != m_pSndFile || !m_pSndFile->GetTotalSampleCount())) + { +#ifndef NO_AGC + CSoundFile::m_AGC.Reset(); +#endif + } m_pSndFile = pSndFile; m_pModPlaying = pModDoc; m_hFollowSong = hPat; @@ -1684,8 +1721,10 @@ CriticalSection cs; CSoundFile::SetMixerSettings(TrackerSettings::Instance().m_MixerSettings); CSoundFile::SetResamplingMode(TrackerSettings::Instance().m_nSrcMode); - CSoundFile::UPDATEDSPEFFECTS(); + UpdateDspEffects(); +#ifndef NO_AGC CSoundFile::SetAGC(TrackerSettings::Instance().m_dwQuality & QUALITY_AGC); +#endif } PostMessage(WM_MOD_INVALIDATEPATTERNS, HINT_MPTSETUP); } @@ -1829,13 +1868,17 @@ COptionsColors colors; COptionsPlayer playerdlg; CMidiSetupDlg mididlg(TrackerSettings::Instance().m_dwMidiSetup, TrackerSettings::Instance().m_nMidiDevice); +#ifndef NO_EQ CEQSetupDlg eqdlg(&TrackerSettings::Instance().m_EqSettings); +#endif CAutoSaverGUI autosavedlg(m_pAutoSaver); //rewbs.AutoSaver CUpdateSetupDlg updatedlg; dlg.AddPage(&general); dlg.AddPage(&sounddlg); dlg.AddPage(&playerdlg); +#ifndef NO_EQ dlg.AddPage(&eqdlg); +#endif dlg.AddPage(&keyboard); dlg.AddPage(&colors); dlg.AddPage(&mididlg); @@ -2007,7 +2050,9 @@ { gdwIdleTime = 0; // After 15 seconds of inactivity, we reset the AGC +#ifndef NO_AGC CSoundFile::m_AGC.Reset(); +#endif gdwPlayLatency = 0; } } Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-03-25 18:58:54 UTC (rev 1687) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-03-25 20:20:56 UTC (rev 1688) @@ -121,12 +121,18 @@ #define SOUNDSETUP_SECONDARY 0x40 #define SOUNDSETUP_RESTARTMASK SOUNDSETUP_SECONDARY +#ifndef NO_DSP #define QUALITY_NOISEREDUCTION 0x01 #define QUALITY_MEGABASS 0x02 #define QUALITY_SURROUND 0x08 +#endif #define QUALITY_REVERB 0x20 +#ifndef NO_AGC #define QUALITY_AGC 0x40 +#endif +#ifndef NO_EQ #define QUALITY_EQ 0x80 +#endif #define NUM_VUMETER_PENS 32 @@ -290,12 +296,6 @@ #define DeleteGDIObject(h) if (h) { ::DeleteObject(h); h = NULL; } -#define UPDATEDSPEFFECTS() SetDspEffects(\ - TrackerSettings::Instance().m_dwQuality & QUALITY_SURROUND,\ - TrackerSettings::Instance().m_dwQuality & QUALITY_REVERB,\ - TrackerSettings::Instance().m_dwQuality & QUALITY_MEGABASS,\ - TrackerSettings::Instance().m_dwQuality & QUALITY_NOISEREDUCTION,\ - TrackerSettings::Instance().m_dwQuality & QUALITY_EQ) #include "mainbar.h" #include "TrackerSettings.h" @@ -367,6 +367,7 @@ // Low-Level Audio public: + static void UpdateDspEffects(); static void UpdateAudioParameters(BOOL bReset=FALSE); static void EnableLowLatencyMode(BOOL bOn=TRUE); static void CalcStereoVuMeters(int *, unsigned long, unsigned long); Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-03-25 18:58:54 UTC (rev 1687) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-03-25 20:20:56 UTC (rev 1688) @@ -706,7 +706,9 @@ // -! NEW_FEATURE#0024 { m_pSndFile->gnBitsPerSample = 24; +#ifndef NO_AGC m_pSndFile->SetAGC(FALSE); +#endif if (oldVol > 128) m_pSndFile->SetMasterVolume(128); } else { Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-03-25 18:58:54 UTC (rev 1687) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-03-25 20:20:56 UTC (rev 1688) @@ -500,19 +500,42 @@ m_CbnResampling.SetCurSel(TrackerSettings::Instance().m_nSrcMode); } // Effects +#ifndef NO_DSP if (dwQuality & QUALITY_MEGABASS) CheckDlgButton(IDC_CHECK1, MF_CHECKED); +#else + GetDlgItem(IDC_CHECK1)->ShowWindow(SW_HIDE); +#endif +#ifndef NO_AGC if (dwQuality & QUALITY_AGC) CheckDlgButton(IDC_CHECK2, MF_CHECKED); +#else + GetDlgItem(IDC_CHECK2)->ShowWindow(SW_HIDE); +#endif +#ifndef NO_DSP if (dwQuality & QUALITY_SURROUND) CheckDlgButton(IDC_CHECK4, MF_CHECKED); if (dwQuality & QUALITY_NOISEREDUCTION) CheckDlgButton(IDC_CHECK5, MF_CHECKED); +#else + GetDlgItem(IDC_CHECK4)->ShowWindow(SW_HIDE); + GetDlgItem(IDC_CHECK5)->ShowWindow(SW_HIDE); +#endif +#ifndef NO_EQ if (CSoundFile::GetSysInfo() & SYSMIX_SLOWCPU) ::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHECK3), FALSE); else if (dwQuality & QUALITY_EQ) CheckDlgButton(IDC_CHECK3, MF_CHECKED); +#else + GetDlgItem(IDC_CHECK3)->ShowWindow(SW_HIDE); + ::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHECK3), FALSE); +#endif +#ifndef NO_DSP // Bass Expansion m_SbXBassDepth.SetRange(0,4); m_SbXBassDepth.SetPos(8-CSoundFile::m_DSP.m_Settings.m_nXBassDepth); m_SbXBassRange.SetRange(0,4); m_SbXBassRange.SetPos(4 - (CSoundFile::m_DSP.m_Settings.m_nXBassRange - 1) / 5); +#else + m_SbXBassDepth.ShowWindow(SW_HIDE); + m_SbXBassRange.ShowWindow(SW_HIDE); +#endif // Reverb m_SbReverbDepth.SetRange(1, 16); m_SbReverbDepth.SetPos(CSoundFile::m_nReverbDepth); @@ -537,6 +560,7 @@ { if (dwQuality & QUALITY_REVERB) CheckDlgButton(IDC_CHECK6, MF_CHECKED); } +#ifndef NO_DSP // Surround { UINT n = CSoundFile::m_DSP.m_Settings.m_nProLogicDepth; @@ -547,6 +571,10 @@ m_SbSurroundDelay.SetRange(0, 8); m_SbSurroundDelay.SetPos((CSoundFile::m_DSP.m_Settings.m_nProLogicDelay-5)/5); } +#else + m_SbSurroundDepth.ShowWindow(SW_HIDE); + m_SbSurroundDelay.ShowWindow(SW_HIDE); +#endif //rewbs.resamplerConf OnResamplerChanged(); @@ -654,14 +682,23 @@ DWORD dwQuality = 0; DWORD dwSrcMode = 0; +#ifndef NO_DSP if (IsDlgButtonChecked(IDC_CHECK1)) dwQuality |= QUALITY_MEGABASS; +#endif +#ifndef NO_AGC if (IsDlgButtonChecked(IDC_CHECK2)) dwQuality |= QUALITY_AGC; +#endif +#ifndef NO_EQ if (IsDlgButtonChecked(IDC_CHECK3)) dwQuality |= QUALITY_EQ; +#endif +#ifndef NO_DSP if (IsDlgButtonChecked(IDC_CHECK4)) dwQuality |= QUALITY_SURROUND; if (IsDlgButtonChecked(IDC_CHECK5)) dwQuality |= QUALITY_NOISEREDUCTION; +#endif if (IsDlgButtonChecked(IDC_CHECK6)) dwQuality |= QUALITY_REVERB; dwSrcMode = m_CbnResampling.GetCurSel(); +#ifndef NO_DSP // Bass Expansion { UINT nXBassDepth = 8-m_SbXBassDepth.GetPos(); @@ -673,12 +710,14 @@ CSoundFile::m_DSP.m_Settings.m_nXBassDepth = nXBassDepth; CSoundFile::m_DSP.m_Settings.m_nXBassRange = nXBassRange; } +#endif // Reverb { // Reverb depth is dynamically changed UINT nReverbType = m_CbnReverbPreset.GetItemData(m_CbnReverbPreset.GetCurSel()); if (nReverbType < NUM_REVERBTYPES) CSoundFile::gnReverbType = nReverbType; } +#ifndef NO_DSP // Surround { UINT nProLogicDepth = m_SbSurroundDepth.GetPos(); @@ -686,6 +725,7 @@ CSoundFile::m_DSP.m_Settings.m_nProLogicDepth = nProLogicDepth; CSoundFile::m_DSP.m_Settings.m_nProLogicDelay = nProLogicDelay; } +#endif // Notify CMainFrame CMainFrame *pParent = CMainFrame::GetMainFrame(); //rewbs.resamplerConf @@ -912,8 +952,10 @@ void CEQSetupDlg::UpdateEQ(BOOL bReset) //------------------------------------- { +#ifndef NO_EQ CriticalSection cs; CSoundFile::SetEQGains( m_pEqPreset->Gains, MAX_EQ_BANDS, m_pEqPreset->Freqs, bReset); +#endif } Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-03-25 18:58:54 UTC (rev 1687) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-03-25 20:20:56 UTC (rev 1688) @@ -68,8 +68,10 @@ m_nWaveDevice = SNDDEV_BUILD_ID(0, SNDDEV_WAVEOUT); // Default value will be overridden m_nBufferLength = 50; +#ifndef NO_EQ // Default EQ settings MemCopy(m_EqSettings, CEQSetupDlg::gEQPresets[0]); +#endif // MIDI Setup m_nMidiDevice = 0; @@ -416,14 +418,19 @@ // Effects Settings +#ifndef NO_DSP CSoundFile::m_DSP.m_Settings.m_nXBassDepth = CMainFrame::GetPrivateProfileLong("Effects", "XBassDepth", CSoundFile::m_DSP.m_Settings.m_nXBassDepth, iniFile); CSoundFile::m_DSP.m_Settings.m_nXBassRange = CMainFrame::GetPrivateProfileLong("Effects", "XBassRange", CSoundFile::m_DSP.m_Settings.m_nXBassRange, iniFile); +#endif CSoundFile::m_nReverbDepth = CMainFrame::GetPrivateProfileLong("Effects", "ReverbDepth", CSoundFile::m_nReverbDepth, iniFile); CSoundFile::gnReverbType = CMainFrame::GetPrivateProfileLong("Effects", "ReverbType", CSoundFile::gnReverbType, iniFile); +#ifndef NO_DSP CSoundFile::m_DSP.m_Settings.m_nProLogicDepth = CMainFrame::GetPrivateProfileLong("Effects", "ProLogicDepth", CSoundFile::m_DSP.m_Settings.m_nProLogicDepth, iniFile); CSoundFile::m_DSP.m_Settings.m_nProLogicDelay = CMainFrame::GetPrivateProfileLong("Effects", "ProLogicDelay", CSoundFile::m_DSP.m_Settings.m_nProLogicDelay, iniFile); +#endif +#ifndef NO_EQ // EQ Settings GetPrivateProfileStruct("Effects", "EQ_Settings", &m_EqSettings, sizeof(EQPreset), iniFile); GetPrivateProfileStruct("Effects", "EQ_User1", &CEQSetupDlg::gUserPresets[0], sizeof(EQPreset), iniFile); @@ -435,6 +442,7 @@ StringFixer::SetNullTerminator(CEQSetupDlg::gUserPresets[1].szName); StringFixer::SetNullTerminator(CEQSetupDlg::gUserPresets[2].szName); StringFixer::SetNullTerminator(CEQSetupDlg::gUserPresets[3].szName); +#endif // Auto saver settings @@ -561,12 +569,16 @@ dwSZSIZE = sizeof(m_szKbdFile); RegQueryValueEx(key, "Key_Config_File", NULL, &dwREG_SZ, (LPBYTE)m_szKbdFile, &dwSZSIZE); +#ifndef NO_DSP RegQueryValueEx(key, "XBassDepth", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_DSP.m_Settings.m_nXBassDepth, &dwDWORDSize); RegQueryValueEx(key, "XBassRange", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_DSP.m_Settings.m_nXBassRange, &dwDWORDSize); +#endif RegQueryValueEx(key, "ReverbDepth", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_nReverbDepth, &dwDWORDSize); RegQueryValueEx(key, "ReverbType", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::gnReverbType, &dwDWORDSize); +#ifndef NO_DSP RegQueryValueEx(key, "ProLogicDepth", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_DSP.m_Settings.m_nProLogicDepth, &dwDWORDSize); RegQueryValueEx(key, "ProLogicDelay", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_DSP.m_Settings.m_nProLogicDelay, &dwDWORDSize); +#endif RegQueryValueEx(key, "StereoSeparation", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_nStereoSeparation, &dwDWORDSize); RegQueryValueEx(key, "MixChannels", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_nMaxMixChannels, &dwDWORDSize); RegQueryValueEx(key, "WaveDevice", NULL, &dwREG_DWORD, (LPBYTE)&m_nWaveDevice, &dwDWORDSize); @@ -589,12 +601,14 @@ RegQueryValueEx(key, "ChannelMode", NULL, &dwREG_DWORD, (LPBYTE)&m_nChannels, &dwDWORDSize); RegQueryValueEx(key, "MidiImportSpeed", NULL, &dwREG_DWORD, (LPBYTE)&midiImportSpeed, &dwDWORDSize); RegQueryValueEx(key, "MidiImportPatLen", NULL, &dwREG_DWORD, (LPBYTE)&midiImportPatternLen, &dwDWORDSize); +#ifndef NO_EQ // EQ LoadRegistryEQ(key, "EQ_Settings", &m_EqSettings); LoadRegistryEQ(key, "EQ_User1", &CEQSetupDlg::gUserPresets[0]); LoadRegistryEQ(key, "EQ_User2", &CEQSetupDlg::gUserPresets[1]); LoadRegistryEQ(key, "EQ_User3", &CEQSetupDlg::gUserPresets[2]); LoadRegistryEQ(key, "EQ_User4", &CEQSetupDlg::gUserPresets[3]); +#endif //rewbs.resamplerConf dwDWORDSize = sizeof(m_MixerSettings.gbWFIRType); @@ -778,18 +792,24 @@ // Older versions of OpenMPT 1.18+ will look for this file if this entry is missing, so removing this entry after having read it is kind of backwards compatible. WritePrivateProfileString("Paths", "Key_Config_File", nullptr, iniFile); +#ifndef NO_DSP CMainFrame::WritePrivateProfileLong("Effects", "XBassDepth", CSoundFile::m_DSP.m_Settings.m_nXBassDepth, iniFile); CMainFrame::WritePrivateProfileLong("Effects", "XBassRange", CSoundFile::m_DSP.m_Settings.m_nXBassRange, iniFile); +#endif CMainFrame::WritePrivateProfileLong("Effects", "ReverbDepth", CSoundFile::m_nReverbDepth, iniFile); CMainFrame::WritePrivateProfileLong("Effects", "ReverbType", CSoundFile::gnReverbType, iniFile); +#ifndef NO_DSP CMainFrame::WritePrivateProfileLong("Effects", "ProLogicDepth", CSoundFile::m_DSP.m_Settings.m_nProLogicDepth, iniFile); CMainFrame::WritePrivateProfileLong("Effects", "ProLogicDelay", CSoundFile::m_DSP.m_Settings.m_nProLogicDelay, iniFile); +#endif +#ifndef NO_EQ WritePrivateProfileStruct("Effects", "EQ_Settings", &m_EqSettings, sizeof(EQPreset), iniFile); WritePrivateProfileStruct("Effects", "EQ_User1", &CEQSetupDlg::gUserPresets[0], sizeof(EQPreset), iniFile); WritePrivateProfileStruct("Effects", "EQ_User2", &CEQSetupDlg::gUserPresets[1], sizeof(EQPreset), iniFile); WritePrivateProfileStruct("Effects", "EQ_User3", &CEQSetupDlg::gUserPresets[2], sizeof(EQPreset), iniFile); WritePrivateProfileStruct("Effects", "EQ_User4", &CEQSetupDlg::gUserPresets[3], sizeof(EQPreset), iniFile); +#endif if(CMainFrame::m_pAutoSaver != nullptr) { Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2013-03-25 18:58:54 UTC (rev 1687) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2013-03-25 20:20:56 UTC (rev 1688) @@ -168,7 +168,9 @@ DWORD m_dwSoundSetup, m_dwRate, m_dwQuality, m_nSrcMode, m_nBitsPerSample, m_nPreAmp, gbLoopSong, m_nChannels; LONG m_nWaveDevice; // use the SNDDEV_GET_NUMBER and SNDDEV_GET_TYPE macros to decode DWORD m_nBufferLength; +#ifndef NO_EQ EQPreset m_EqSettings; +#endif // MIDI Setup LONG m_nMidiDevice; Modified: trunk/OpenMPT/sounddsp/DSP.cpp =================================================================== --- trunk/OpenMPT/sounddsp/DSP.cpp 2013-03-25 18:58:54 UTC (rev 1687) +++ trunk/OpenMPT/sounddsp/DSP.cpp 2013-03-25 20:20:56 UTC (rev 1688) @@ -15,17 +15,18 @@ #include <math.h> +#ifndef NO_DSP + + // Bass Expansion #define DEFAULT_XBASS_RANGE 14 // (x+2)*20 Hz (320Hz) #define DEFAULT_XBASS_DEPTH 6 // 1+(3>>(x-4)) (+6dB) - //////////////////////////////////////////////////////////////////// // DSP Effects internal state - extern VOID MPPASMCALL X86_InitMixBuffer(int *pBuffer, UINT nSamples); static VOID MPPASMCALL X86_StereoDCRemoval(int *, UINT count, LONG *nDCRFlt_Y1l, LONG *nDCRFlt_X1l, LONG *nDCRFlt_Y1r, LONG *nDCRFlt_X1r); @@ -509,3 +510,5 @@ } +#endif // NO_DSP + Modified: trunk/OpenMPT/sounddsp/DSP.h =================================================================== --- trunk/OpenMPT/sounddsp/DSP.h 2013-03-25 18:58:54 UTC (rev 1687) +++ trunk/OpenMPT/sounddsp/DSP.h 2013-03-25 20:20:56 UTC (rev 1688) @@ -12,6 +12,8 @@ #pragma once +#ifndef NO_DSP + // Buffer Sizes #define SURROUNDBUFFERSIZE 2048 // 50ms @ 48kHz @@ -89,3 +91,4 @@ void ProcessQuadSurround(int * MixSoundBuffer, int * MixRearBuffer, int count); }; +#endif // NO_DSP Modified: trunk/OpenMPT/soundlib/Snd_defs.h =================================================================== --- trunk/OpenMPT/soundlib/Snd_defs.h 2013-03-25 18:58:54 UTC (rev 1687) +++ trunk/OpenMPT/soundlib/Snd_defs.h 2013-03-25 20:20:56 UTC (rev 1688) @@ -275,16 +275,24 @@ // Global Options (Renderer) #define SNDMIX_REVERSESTEREO 0x0001 // swap L/R audio channels +#ifndef NO_DSP #define SNDMIX_NOISEREDUCTION 0x0002 // reduce hiss (do not use, it's just a simple low-pass filter) +#endif // NO_DSP +#ifndef NO_AGC #define SNDMIX_AGC 0x0004 // automatic gain control +#endif // ~NO_AGC #define SNDMIX_NORESAMPLING 0x0008 // force no resampling // SNDMIX_NOLINEARSRCMODE is the default //#define SNDMIX_HQRESAMPLER 0x0010 //rewbs.resamplerConf: renamed SNDMIX_HQRESAMPLER to SNDMIX_SPLINESRCMODE #define SNDMIX_SPLINESRCMODE 0x0010 // cubic resampling (?) +#ifndef NO_DSP #define SNDMIX_MEGABASS 0x0020 // bass expansion #define SNDMIX_SURROUND 0x0040 // surround mix +#endif // NO_DSP #define SNDMIX_REVERB 0x0080 // apply reverb +#ifndef NO_EQ #define SNDMIX_EQ 0x0100 // apply EQ +#endif // NO_EQ #define SNDMIX_SOFTPANNING 0x0200 // soft panning mode (this is forced with mixmode RC3 and later) //#define SNDMIX_ULTRAHQSRCMODE 0x0400 //rewbs.resamplerConf: renamed SNDMIX_ULTRAHQSRCMODE to SNDMIX_POLYPHASESRCMODE #define SNDMIX_POLYPHASESRCMODE 0x0400 // polyphase resampling Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-03-25 18:58:54 UTC (rev 1687) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-03-25 20:20:56 UTC (rev 1688) @@ -916,13 +916,16 @@ //------------------------------------------------------------------------------------------ { CriticalSection cs; - - DWORD d = gdwSoundSetup & ~(SNDMIX_SURROUND | SNDMIX_REVERB | SNDMIX_MEGABASS | SNDMIX_NOISEREDUCTION | SNDMIX_EQ); - if (bSurround) d |= SNDMIX_SURROUND; - if ((bReverb) && (gdwSysInfo & SYSMIX_ENABLEMMX)) d |= SNDMIX_REVERB; - if (bMegaBass) d |= SNDMIX_MEGABASS; - if (bNR) d |= SNDMIX_NOISEREDUCTION; - if (bEQ) d |= SNDMIX_EQ; + DWORD d = gdwSoundSetup; + if ((bReverb) && (gdwSysInfo & SYSMIX_ENABLEMMX)) d |= SNDMIX_REVERB; else d &= ~SNDMIX_REVERB; +#ifndef NO_DSP + if (bSurround) d |= SNDMIX_SURROUND; else d &= ~SNDMIX_SURROUND; + if (bMegaBass) d |= SNDMIX_MEGABASS; else d &= ~SNDMIX_MEGABASS; + if (bNR) d |= SNDMIX_NOISEREDUCTION; else d &= ~SNDMIX_NOISEREDUCTION; +#endif +#ifndef NO_EQ + if (bEQ) d |= SNDMIX_EQ; else d &= ~SNDMIX_EQ; +#endif gdwSoundSetup = d; InitPlayer(FALSE); return TRUE; @@ -956,14 +959,17 @@ { if (nVol < 1) nVol = 1; if (nVol > 0x200) nVol = 0x200; // x4 maximum +#ifndef NO_AGC if ((nVol < m_nMasterVolume) && (nVol) && (gdwSoundSetup & SNDMIX_AGC) && (adjustAGC)) { m_AGC.Adjust(m_nMasterVolume, nVol); } +#endif m_nMasterVolume = nVol; } +#ifndef NO_AGC void CSoundFile::SetAGC(BOOL b) //----------------------------- { @@ -976,6 +982,7 @@ } } else gdwSoundSetup &= ~SNDMIX_AGC; } +#endif UINT CSoundFile::GetCurrentPos() const Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-03-25 18:58:54 UTC (rev 1687) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-03-25 20:20:56 UTC (rev 1688) @@ -231,9 +231,15 @@ bool m_bITBidiMode; // Process bidi loops like Impulse Tracker (see Fastmix.cpp for an explanation) public: // Static Members +#ifndef NO_DSP static CDSP m_DSP; +#endif +#ifndef NO_EQ static CEQ m_EQ; +#endif +#ifndef NO_AGC static CAGC m_AGC; +#endif static UINT m_nReverbDepth, gnReverbType; static UINT m_nStereoSeparation; static UINT m_nMaxMixChannels; @@ -478,22 +484,21 @@ static MixerSettings GetMixerSettings(); static BOOL InitPlayer(BOOL bReset=FALSE); static BOOL SetWaveConfig(UINT nRate,UINT nBits,UINT nChannels,BOOL bMMX=FALSE); - static BOOL SetDspEffects(BOOL bSurround,BOOL bReverb,BOOL xbass,BOOL dolbynr=FALSE,BOOL bEQ=FALSE); + static BOOL SetDspEffects(BOOL bSurround,BOOL bReverb,BOOL xbass,BOOL dolbynr,BOOL bEQ); static BOOL SetResamplingMode(UINT nMode); // SRCMODE_XXXX static DWORD GetSampleRate() { return gdwMixingFreq; } static DWORD GetBitsPerSample() { return gnBitsPerSample; } static DWORD InitSysInfo(); static DWORD GetSysInfo() { return gdwSysInfo; } static void EnableMMX(bool b) { if (b) gdwSoundSetup |= SNDMIX_ENABLEMMX; else gdwSoundSetup &= ~SNDMIX_ENABLEMMX; } - // AGC - static BOOL GetAGC() { return (gdwSoundSetup & SNDMIX_AGC) ? TRUE : FALSE; } +#ifndef NO_AGC static void SetAGC(BOOL b); +#endif // [Reverb level 0(quiet)-100(loud)], [REVERBTYPE_XXXX] static BOOL SetReverbParameters(UINT nDepth, UINT nType); -#ifdef ENABLE_EQ - // EQ - static void SetEQGains(const UINT *pGains, UINT nBands, const UINT *pFreqs=NULL, BOOL bReset=FALSE) { m_EQ.SetEQGains(pGains, nBands, pFreqs, bReset, gdwMixingFreq); } // 0=-12dB, 32=+12dB -#endif +#ifndef NO_EQ + static void SetEQGains(const UINT *pGains, UINT nBands, const UINT *pFreqs=NULL, BOOL bReset=FALSE) { m_EQ.SetEQGains(pGains, nBands, pFreqs, bReset, gdwMixingFreq); } // 0=-12dB, 32=+12dB +#endif // NO_EQ // Float <-> Int conversion routines /*static */VOID StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount); /*static */VOID FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount); Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-03-25 18:58:54 UTC (rev 1687) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-03-25 20:20:56 UTC (rev 1688) @@ -35,9 +35,15 @@ DWORD CSoundFile::gdwMixingFreq = 44100; DWORD CSoundFile::gnBitsPerSample = 16; // Mixing data initialized in +#ifndef NO_DSP CDSP CSoundFile::m_DSP; +#endif +#ifndef NO_EQ CEQ CSoundFile::m_EQ; +#endif +#ifndef NO_AGC CAGC CSoundFile::m_AGC; +#endif double CSoundFile::gdWFIRCutoff = 0.97; //default value BYTE CSoundFile::gbWFIRType = 7; //WFIR_KAISER4T; //default value UINT CSoundFile::gnVolumeRampUpSamples = 42; //default value @@ -90,7 +96,7 @@ // Log tables for pre-amp // Pre-amp (or more precisely: Pre-attenuation) depends on the number of channels, // Which this table takes care of. -const UINT PreAmpTable[16] = +static const UINT PreAmpTable[16] = { 0x60, 0x60, 0x60, 0x70, // 0-7 0x80, 0x88, 0x90, 0x98, // 8-15 @@ -98,13 +104,15 @@ 0xB0, 0xB4, 0xB8, 0xBC, // 24-31 }; -const UINT PreAmpAGCTable[16] = +#ifndef NO_AGC +static const UINT PreAmpAGCTable[16] = { 0x60, 0x60, 0x60, 0x64, 0x68, 0x70, 0x78, 0x80, 0x84, 0x88, 0x8C, 0x90, 0x92, 0x94, 0x96, 0x98, }; +#endif typedef CTuning::RATIOTYPE RATIOTYPE; @@ -170,8 +178,10 @@ #ifndef NO_REVERB InitializeReverb(bReset); #endif +#ifndef NO_DSP m_DSP.Initialize(bReset, gdwMixingFreq, gdwSoundSetup); -#ifdef ENABLE_EQ +#endif +#ifndef NO_EQ m_EQ.Initialize(bReset, gdwMixingFreq); #endif return TRUE; @@ -333,9 +343,11 @@ } } +#ifndef NO_DSP m_DSP.Process(MixSoundBuffer, MixRearBuffer, lCount, gdwSoundSetup, gnChannels); +#endif -#ifdef ENABLE_EQ +#ifndef NO_EQ // Graphic Equalizer if (gdwSoundSetup & SNDMIX_EQ) { @@ -344,7 +356,7 @@ else m_EQ.ProcessMono(MixSoundBuffer, lCount, m_pConfig); } -#endif // ENABLE_EQ +#endif // NO_EQ nStat++; @@ -1691,7 +1703,11 @@ if (m_pConfig->getUseGlobalPreAmp()) { - UINT attenuation = (gdwSoundSetup & SNDMIX_AGC) ? PreAmpAGCTable[nchn32 >> 1] : PreAmpTable[nchn32 >> 1]; + UINT attenuation = +#ifndef NO_AGC + (gdwSoundSetup & SNDMIX_AGC) ? PreAmpAGCTable[nchn32 >> 1] : +#endif + PreAmpTable[nchn32 >> 1]; if(attenuation < 1) attenuation = 1; nMasterVol = (mastervol << 7) / attenuation; } else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-03-25 21:11:56
|
Revision: 1691 http://sourceforge.net/p/modplug/code/1691 Author: manxorist Date: 2013-03-25 21:11:50 +0000 (Mon, 25 Mar 2013) Log Message: ----------- [Mod] Remove SYSMIX_SLOWCPU and associated lower quality resampling in some cases. In 2013, the user can just disable interpolation for CPUs that old. Also remove SYSMIX_FASTCPU which meant exactly the same as SYSMIX_ENABLEMMX. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/soundlib/Mmx_mix.cpp trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-03-25 20:55:55 UTC (rev 1690) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-03-25 21:11:50 UTC (rev 1691) @@ -518,9 +518,7 @@ GetDlgItem(IDC_CHECK5)->ShowWindow(SW_HIDE); #endif #ifndef NO_EQ - if (CSoundFile::GetSysInfo() & SYSMIX_SLOWCPU) - ::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHECK3), FALSE); - else if (dwQuality & QUALITY_EQ) CheckDlgButton(IDC_CHECK3, MF_CHECKED); + if (dwQuality & QUALITY_EQ) CheckDlgButton(IDC_CHECK3, MF_CHECKED); #else GetDlgItem(IDC_CHECK3)->ShowWindow(SW_HIDE); ::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHECK3), FALSE); Modified: trunk/OpenMPT/soundlib/Mmx_mix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Mmx_mix.cpp 2013-03-25 20:55:55 UTC (rev 1690) +++ trunk/OpenMPT/soundlib/Mmx_mix.cpp 2013-03-25 21:11:50 UTC (rev 1691) @@ -137,11 +137,9 @@ dwProcSupport &= PROCSUPPORT_CPUID|PROCSUPPORT_MMX|PROCSUPPORT_3DNOW|PROCSUPPORT_MMXEX; } } - if (dwProcSupport & PROCSUPPORT_MMX) d |= (SYSMIX_ENABLEMMX|SYSMIX_FASTCPU); if (dwProcSupport & PROCSUPPORT_MMXEX) d |= SYSMIX_MMXEX; if (dwProcSupport & PROCSUPPORT_3DNOW) d |= SYSMIX_3DNOW; if (dwProcSupport & PROCSUPPORT_SSE) d |= SYSMIX_SSE; - if (!(dwProcSupport & PROCSUPPORT_CPUID)) d |= SYSMIX_SLOWCPU; gdwSysInfo = d; return d; } Modified: trunk/OpenMPT/soundlib/Snd_defs.h =================================================================== --- trunk/OpenMPT/soundlib/Snd_defs.h 2013-03-25 20:55:55 UTC (rev 1690) +++ trunk/OpenMPT/soundlib/Snd_defs.h 2013-03-25 21:11:50 UTC (rev 1691) @@ -234,8 +234,6 @@ // Mixer Hardware-Dependent features #define SYSMIX_ENABLEMMX 0x01 // Hardware acceleration features (MMX/3DNow!/SSE) are supported by this processor -#define SYSMIX_SLOWCPU 0x02 // *Really* old processor (in this context, it doesn't know CPUID instructions => Must be older than Pentium) -#define SYSMIX_FASTCPU 0x04 // "Fast" processor (in this context, anything that is at least a Pentium MMX) #define SYSMIX_MMXEX 0x08 // Processor supports AMD MMX extensions #define SYSMIX_3DNOW 0x10 // Processor supports AMD 3DNow! instructions #define SYSMIX_SSE 0x20 // Processor supports SSE instructions Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-03-25 20:55:55 UTC (rev 1690) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-03-25 21:11:50 UTC (rev 1691) @@ -1603,10 +1603,10 @@ LONG nRightDelta = ((pChn->nNewRightVol - pChn->nRightVol) << VOLUMERAMPPRECISION); LONG nLeftDelta = ((pChn->nNewLeftVol - pChn->nLeftVol) << VOLUMERAMPPRECISION); // if ((gdwSoundSetup & SNDMIX_DIRECTTODISK) -// || ((gdwSysInfo & (SYSMIX_ENABLEMMX|SYSMIX_FASTCPU)) +// || ((gdwSysInfo & (SYSMIX_ENABLEMMX)) // && (gdwSoundSetup & SNDMIX_HQRESAMPLER))) if((gdwSoundSetup & SNDMIX_DIRECTTODISK) - || ((gdwSysInfo & (SYSMIX_ENABLEMMX | SYSMIX_FASTCPU)) && (gdwSoundSetup & SNDMIX_HQRESAMPLER) && !enableCustomRamp)) + || ((gdwSysInfo & SYSMIX_ENABLEMMX) && (gdwSoundSetup & SNDMIX_HQRESAMPLER) && !enableCustomRamp)) { if((pChn->nRightVol | pChn->nLeftVol) && (pChn->nNewRightVol | pChn->nNewLeftVol) && !pChn->dwFlags[CHN_FASTVOLRAMP]) { @@ -2044,12 +2044,8 @@ if ((!(gdwSoundSetup & SNDMIX_DIRECTTODISK)) && (!(gdwSoundSetup & SNDMIX_ULTRAHQSRCMODE))) { int fmax = 0x20000; - if (gdwSysInfo & SYSMIX_SLOWCPU) + if (!(gdwSysInfo & SYSMIX_ENABLEMMX)) { - fmax = 0xFE00; - } else - if (!(gdwSysInfo & (SYSMIX_ENABLEMMX|SYSMIX_FASTCPU))) - { fmax = 0x18000; } if ((pChn->nNewLeftVol < 0x80) && (pChn->nNewRightVol < 0x80) @@ -2067,8 +2063,7 @@ } else { - if ((pChn->nInc >= 0x14000) - || ((pChn->nInc >= 0xFF00) && ((pChn->nInc < 0x10100) || (gdwSysInfo & SYSMIX_SLOWCPU)))) + if ((pChn->nInc >= 0x14000) || ((pChn->nInc >= 0xFF00) && (pChn->nInc < 0x10100))) pChn->dwFlags.set(CHN_NOIDO); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-03-25 23:15:09
|
Revision: 1696 http://sourceforge.net/p/modplug/code/1696 Author: saga-games Date: 2013-03-25 23:14:59 +0000 (Mon, 25 Mar 2013) Log Message: ----------- [Ref] Guarantee ModInstrument::name to be null-terminated. Basically, it should have been like that already. [Ref] Added StringFixer::Copy and StringFixer::CopyN, which are idiot-proof strncpy wrappers which always add the trailing null character. [Ref] Got rid of a few more mpt::String members which are already part of std::string (e.g. Empty <-> clear, IsEmpty <-> empty) Modified Paths: -------------- trunk/OpenMPT/common/StringFixer.h trunk/OpenMPT/common/mptString.h trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/CleanupSong.cpp trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Ctrl_pat.cpp trunk/OpenMPT/mptrack/Ctrl_seq.cpp trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/Draw_pat.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp trunk/OpenMPT/mptrack/SelectPluginDialog.cpp trunk/OpenMPT/mptrack/View_gen.cpp trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/Vstplug.h trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/mptrack/mod2midi.cpp trunk/OpenMPT/mptrack/view_com.cpp trunk/OpenMPT/soundlib/Dlsbank.cpp trunk/OpenMPT/soundlib/Load_itp.cpp trunk/OpenMPT/soundlib/Load_umx.cpp trunk/OpenMPT/soundlib/Message.cpp trunk/OpenMPT/soundlib/ModInstrument.h trunk/OpenMPT/soundlib/SampleFormats.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/WAVTools.cpp trunk/OpenMPT/soundlib/pattern.cpp trunk/OpenMPT/soundlib/patternContainer.cpp Modified: trunk/OpenMPT/common/StringFixer.h =================================================================== --- trunk/OpenMPT/common/StringFixer.h 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/common/StringFixer.h 2013-03-25 23:14:59 UTC (rev 1696) @@ -215,4 +215,22 @@ } } + + // Copy from one fixed size char array to another one. + template <size_t destSize, size_t srcSize> + void Copy(char (&destBuffer)[destSize], const char (&srcBuffer)[srcSize]) + //----------------------------------------------------------------------- + { + CopyN(destBuffer, srcBuffer, srcSize); + } + + // Copy from a char array to a fixed size char array. + template <size_t destSize> + void CopyN(char (&destBuffer)[destSize], const char *srcBuffer, const size_t srcSize = SIZE_T_MAX) + //------------------------------------------------------------------------------------------------ + { + const size_t copySize = min(destSize - 1, srcSize); + strncpy(destBuffer, srcBuffer, copySize); + destBuffer[copySize] = '\0'; + } }; Modified: trunk/OpenMPT/common/mptString.h =================================================================== --- trunk/OpenMPT/common/mptString.h 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/common/mptString.h 2013-03-25 23:14:59 UTC (rev 1696) @@ -44,32 +44,17 @@ // To allow easy assignment to CString in GUI side. operator const CharT*() const {return c_str();} - // Clears string. - void Empty() {clear();} - - // Tests whether string is empty. - bool IsEmpty() const {return empty();} - - // See std::string::compare. - int Compare(const CharT* psz) const {return compare(psz);} - - // Equivalent to Empty(); Append(psz, nCount); + // Set the string to psz, copy at most nCount characters void SetString(const CharT* psz, const size_t nCount) { - Empty(); + clear(); Append(psz, nCount); } - // Append string to this. - void Append(const CharT* psz) {append(psz);} - // Appends given string to this. Stops after 'nCount' chars if null terminator // hasn't been encountered before that. void Append(const CharT* psz, const size_t nCount) {append(psz, nCount);} - // Appends single character to string. - void AppendChar(const CharT c) {append(1, c);} - // Difference between Append and AppendChars is that latter can be used to add // potentially non-null terminated char array. template <size_t N> @@ -78,9 +63,6 @@ append(arr, arr + N); } - // Reserves store for the string without resizing. - void Reserve(size_t nSize) {reserve(nSize);} - // Formats this string, like CString::Format. void Format(const CharT* pszFormat, ...) { Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2013-03-25 23:14:59 UTC (rev 1696) @@ -873,7 +873,7 @@ m_nInstrument = nIns; _snprintf(pIns->name, CountOf(pIns->name) - 1, _T("%d: %s"), m_pVstPlugin->GetSlot() + 1, pSndFile->m_MixPlugins[m_pVstPlugin->GetSlot()].GetName()); - strncpy(pIns->filename, pSndFile->m_MixPlugins[m_pVstPlugin->GetSlot()].GetLibraryName(), CountOf(pIns->filename) - 1); + StringFixer::CopyN(pIns->filename, pSndFile->m_MixPlugins[m_pVstPlugin->GetSlot()].GetLibraryName()); pIns->nMixPlug = (PLUGINDEX)m_pVstPlugin->GetSlot() + 1; pIns->nMidiChannel = 1; // People will forget to change this anyway, so the following lines can lead to some bad surprises after re-opening the module. Modified: trunk/OpenMPT/mptrack/CleanupSong.cpp =================================================================== --- trunk/OpenMPT/mptrack/CleanupSong.cpp 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/mptrack/CleanupSong.cpp 2013-03-25 23:14:59 UTC (rev 1696) @@ -328,7 +328,7 @@ { //strncpy_s(pTTTA->szText, sizeof(pTTTA->szText), strTipText, // strTipText.GetLength() + 1); - strncpy(pTTTA->szText, strTipText, min(strTipText.GetLength() + 1, CountOf(pTTTA->szText) - 1)); + StringFixer::CopyN(pTTTA->szText, strTipText); } else { Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2013-03-25 23:14:59 UTC (rev 1696) @@ -1269,15 +1269,10 @@ m_SliderResSwing.EnableWindow((pIns != nullptr && (m_pSndFile->GetType() == MOD_TYPE_MPT || pIns->nResSwing != 0)) ? TRUE : FALSE); m_CbnFilterMode.EnableWindow((pIns != nullptr && (m_pSndFile->GetType() == MOD_TYPE_MPT || pIns->nFilterMode != FLTMODE_UNCHANGED)) ? TRUE : FALSE); - CHAR s[128]; if (pIns) { - memcpy(s, pIns->name, 32); - s[32] = 0; - m_EditName.SetWindowText(s); - memcpy(s, pIns->filename, 12); - s[12] = 0; - m_EditFileName.SetWindowText(s); + m_EditName.SetWindowText(pIns->name); + m_EditFileName.SetWindowText(pIns->filename); // Fade Out Volume SetDlgItemInt(IDC_EDIT7, pIns->nFadeOut); // Global Volume @@ -1491,16 +1486,12 @@ if (!pIns->name[0] && m_pSndFile->GetModSpecifications().instrNameLengthMax > 0) { - strncpy(pIns->name, szName, CountOf(pIns->name) - 1); - ASSERT(m_pSndFile->GetModSpecifications().instrNameLengthMax < CountOf(pIns->name)); - pIns->name[m_pSndFile->GetModSpecifications().instrNameLengthMax] = '\0'; + StringFixer::CopyN(pIns->name, szName, m_pSndFile->GetModSpecifications().instrNameLengthMax); } if (!pIns->filename[0] && m_pSndFile->GetModSpecifications().instrFilenameLengthMax > 0) { strcat(szName, szExt); - strncpy(pIns->filename, szName, CountOf(pIns->filename) - 1); - ASSERT(m_pSndFile->GetModSpecifications().instrFilenameLengthMax < CountOf(pIns->filename)); - pIns->filename[m_pSndFile->GetModSpecifications().instrFilenameLengthMax] = '\0'; + StringFixer::CopyN(pIns->filename, szName, m_pSndFile->GetModSpecifications().instrFilenameLengthMax); } SetCurrentInstrument(m_nInstrument); @@ -1803,12 +1794,11 @@ if (!pIns) return; if (pIns->filename[0]) { - strncpy(szFileName, pIns->filename, min(CountOf(pIns->filename), CountOf(szFileName) - 1)); + StringFixer::Copy(szFileName, pIns->filename); } else { - strncpy(szFileName, pIns->name, min(CountOf(pIns->name), CountOf(szFileName) - 1)); + StringFixer::Copy(szFileName, pIns->name); } - StringFixer::SetNullTerminator(szFileName); SanitizeFilename(szFileName); int index = 0; @@ -1881,11 +1871,10 @@ CHAR s[64]; s[0] = 0; m_EditName.GetWindowText(s, sizeof(s)); - for (UINT i=strlen(s); i<=32; i++) s[i] = 0; ModInstrument *pIns = m_pSndFile->Instruments[m_nInstrument]; - if ((pIns) && (strncmp(s, pIns->name, 32))) + if ((pIns) && (strncmp(s, pIns->name, MAX_INSTRUMENTNAME))) { - memcpy(pIns->name, s, 32); + StringFixer::Copy(pIns->name, s); SetInstrumentModified(true); } } Modified: trunk/OpenMPT/mptrack/Ctrl_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2013-03-25 23:14:59 UTC (rev 1696) @@ -1117,13 +1117,13 @@ m_EditPatName.GetWindowText(s, CountOf(s)); StringFixer::SetNullTerminator(s); - if (m_pSndFile->Patterns[nPat].GetName().Compare(s)) + if(m_pSndFile->Patterns[nPat].GetName() != s) { - if(m_pSndFile->Patterns[nPat].SetName(s)) - { - if (m_pSndFile->m_nType & (MOD_TYPE_XM|MOD_TYPE_IT|MOD_TYPE_MPT)) m_pModDoc->SetModified(); - m_pModDoc->UpdateAllViews(NULL, (nPat << HINT_SHIFT_PAT) | HINT_PATNAMES, this); - } + if(m_pSndFile->Patterns[nPat].SetName(s)) + { + if(m_pSndFile->GetType() & (MOD_TYPE_XM|MOD_TYPE_IT|MOD_TYPE_MPT)) m_pModDoc->SetModified(); + m_pModDoc->UpdateAllViews(NULL, (nPat << HINT_SHIFT_PAT) | HINT_PATNAMES, this); + } } } } Modified: trunk/OpenMPT/mptrack/Ctrl_seq.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2013-03-25 23:14:59 UTC (rev 1696) @@ -1014,7 +1014,7 @@ for(SEQUENCEINDEX i = 0; i < numSequences; i++) { CString str; - if(sndFile.Order.GetSequence(i).m_sName.IsEmpty()) + if(sndFile.Order.GetSequence(i).m_sName.empty()) str.Format(TEXT("Sequence %u"), i); else str.Format(TEXT("%u: %s"), i, (LPCTSTR)sndFile.Order.GetSequence(i).m_sName); Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-03-25 23:14:59 UTC (rev 1696) @@ -668,12 +668,10 @@ wsprintf(s, "%d-bit %s, len: %d", sample.GetElementarySampleSize() * 8, (sample.uFlags & CHN_STEREO) ? "stereo" : "mono", sample.nLength); SetDlgItemText(IDC_TEXT5, s); // Name - memcpy(s, m_pSndFile->m_szNames[m_nSample], MAX_SAMPLENAME); - s[31] = 0; + StringFixer::Copy(s, m_pSndFile->m_szNames[m_nSample]); SetDlgItemText(IDC_SAMPLE_NAME, s); // File Name - memcpy(s, sample.filename, MAX_SAMPLEFILENAME); - s[21] = 0; + StringFixer::Copy(s, sample.filename); if (m_pSndFile->GetType() & (MOD_TYPE_MOD | MOD_TYPE_XM)) s[0] = 0; SetDlgItemText(IDC_SAMPLE_FILENAME, s); // Volume @@ -848,11 +846,10 @@ { // S3M/IT szFullFilename[31] = 0; - if (!m_pSndFile->m_szNames[m_nSample][0]) memcpy(m_pSndFile->m_szNames[m_nSample], szFullFilename, MAX_SAMPLENAME); + if (!m_pSndFile->m_szNames[m_nSample][0]) StringFixer::Copy(m_pSndFile->m_szNames[m_nSample], szFullFilename); if (strlen(szFullFilename) < 9) strcat(szFullFilename, szExt); } - szFullFilename[21] = 0; - memcpy(sample.filename, szFullFilename, MAX_SAMPLEFILENAME); + StringFixer::Copy(sample.filename, szFullFilename); } if ((m_pSndFile->GetType() & MOD_TYPE_XM) && (!(sample.uFlags & CHN_PANNING))) { @@ -1029,11 +1026,11 @@ } if(m_pSndFile->GetType() & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT)) { - strncpy(szFileName, m_pSndFile->GetSample(m_nSample).filename, Util::Min(CountOf(m_pSndFile->GetSample(m_nSample).filename), CountOf(szFileName) - 1)); + StringFixer::Copy(szFileName, m_pSndFile->GetSample(m_nSample).filename); } if(!szFileName[0]) { - strncpy(szFileName, m_pSndFile->m_szNames[m_nSample], Util::Min(CountOf(m_pSndFile->m_szNames[m_nSample]), CountOf(szFileName) - 1)); + StringFixer::Copy(szFileName, m_pSndFile->m_szNames[m_nSample]); } if(!szFileName[0]) strcpy(szFileName, "untitled"); if(strlen(szFileName) >= 5 && !_strcmpi(szFileName + strlen(szFileName) - 5, ".flac")) @@ -2364,7 +2361,7 @@ s[31] = 0; if (strncmp(s, m_pSndFile->m_szNames[m_nSample], MAX_SAMPLENAME)) { - memcpy(m_pSndFile->m_szNames[m_nSample], s, MAX_SAMPLENAME); + StringFixer::Copy(m_pSndFile->m_szNames[m_nSample], s); m_pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | (HINT_SMPNAMES|HINT_SAMPLEINFO), this); m_pModDoc->UpdateAllViews(NULL, HINT_INSNAMES, this); m_pModDoc->SetModified(); @@ -2384,7 +2381,7 @@ if (strncmp(s, m_pSndFile->GetSample(m_nSample).filename, MAX_SAMPLEFILENAME)) { - memcpy(m_pSndFile->GetSample(m_nSample).filename, s, MAX_SAMPLEFILENAME); + StringFixer::Copy(m_pSndFile->GetSample(m_nSample).filename, s); m_pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEINFO, this); if (m_pSndFile->m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT)) m_pModDoc->SetModified(); } Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Draw_pat.cpp 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/mptrack/Draw_pat.cpp 2013-03-25 23:14:59 UTC (rev 1696) @@ -1599,7 +1599,7 @@ // display plugin name. if(m->instr <= MAX_MIXPLUGINS) { - strncpy(sztmp, pSndFile->m_MixPlugins[m->instr - 1].GetName(), CountOf(sztmp)); + StringFixer::CopyN(sztmp, pSndFile->m_MixPlugins[m->instr - 1].GetName()); } } else { @@ -1609,8 +1609,7 @@ if ((m->instr <= pSndFile->GetNumInstruments()) && (pSndFile->Instruments[m->instr])) { ModInstrument *pIns = pSndFile->Instruments[m->instr]; - memcpy(sztmp, pIns->name, 32); - sztmp[32] = 0; + StringFixer::Copy(sztmp, pIns->name); if ((m->note) && (m->note <= NOTE_MAX)) { const SAMPLEINDEX nsmp = pIns->Keyboard[m->note - 1]; @@ -1627,8 +1626,7 @@ { if (m->instr <= pSndFile->GetNumSamples()) { - memcpy(sztmp, pSndFile->m_szNames[m->instr], MAX_SAMPLENAME); - sztmp[32] = 0; + StringFixer::Copy(sztmp, pSndFile->m_szNames[m->instr]); } } @@ -1646,8 +1644,7 @@ if(m->instr > 0 && m->instr <= MAX_MIXPLUGINS) { CHAR sztmp[128] = ""; - strncpy(sztmp, pSndFile->m_MixPlugins[m->instr - 1].GetParamName(m->GetValueVolCol()), sizeof(sztmp)); - StringFixer::SetNullTerminator(sztmp); + StringFixer::CopyN(sztmp, pSndFile->m_MixPlugins[m->instr - 1].GetParamName(m->GetValueVolCol())); if (sztmp[0]) wsprintf(s, "%d: %s", m->GetValueVolCol(), sztmp); } } else Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-03-25 23:14:59 UTC (rev 1696) @@ -276,7 +276,7 @@ pIns = m_SndFile.Instruments[nIns]; // Reset pIns because ExtractInstrument may delete the previous value. if ((dwKey >= 24) && (dwKey < 100)) { - lstrcpyn(pIns->name, szMidiPercussionNames[dwKey-24], sizeof(pIns->name)); + StringFixer::CopyN(pIns->name, szMidiPercussionNames[dwKey - 24]); } bEmbedded = TRUE; } @@ -318,7 +318,7 @@ pIns = m_SndFile.Instruments[nIns]; // Reset pIns because ExtractInstrument may delete the previous value. if ((dwKey >= 24) && (dwKey < 24+61)) { - lstrcpyn(pIns->name, szMidiPercussionNames[dwKey-24], sizeof(pIns->name)); + StringFixer::CopyN(pIns->name, szMidiPercussionNames[dwKey-24]); } } } @@ -339,17 +339,17 @@ _splitpath(pszMidiMapName, NULL, NULL, szName, szExt); strncat(szName, szExt, sizeof(szName)); pIns = m_SndFile.Instruments[nIns]; - if (!pIns->filename[0]) lstrcpyn(pIns->filename, szName, sizeof(pIns->filename)); + if (!pIns->filename[0]) StringFixer::Copy(pIns->filename, szName); if (!pIns->name[0]) { if (nMidiCode < 128) { - lstrcpyn(pIns->name, szMidiProgramNames[nMidiCode], sizeof(pIns->name)); + StringFixer::CopyN(pIns->name, szMidiProgramNames[nMidiCode]); } else { UINT nKey = nMidiCode & 0x7F; if (nKey >= 24) - lstrcpyn(pIns->name, szMidiPercussionNames[nKey-24], sizeof(pIns->name)); + StringFixer::CopyN(pIns->name, szMidiPercussionNames[nKey - 24]); } } } @@ -521,7 +521,7 @@ if(instr > 0 && instr <= GetNumInstruments()) { instr--; - if(!m_SndFile.m_szInstrumentPath[instr].IsEmpty()) + if(!m_SndFile.m_szInstrumentPath[instr].empty()) { const size_t len = m_SndFile.m_szInstrumentPath[instr].length(); const bool iti = _stricmp(&m_SndFile.m_szInstrumentPath[instr][len - 3], "iti") == 0; Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2013-03-25 23:14:59 UTC (rev 1696) @@ -528,7 +528,7 @@ } InitializeInstrument(instrument); - lstrcpyn(instrument->name, m_SndFile.m_szNames[smp], MAX_INSTRUMENTNAME); + StringFixer::Copy(instrument->name, m_SndFile.m_szNames[smp]); MuteInstrument(smp, muted); } Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-03-25 23:14:59 UTC (rev 1696) @@ -157,7 +157,7 @@ CHAR s[_MAX_PATH], *pszCmd, *pszData; int len; - lstrcpyn(s, lpszCommand, CountOf(s)); + StringFixer::CopyN(s, lpszCommand); len = strlen(s) - 1; while ((len > 0) && (strchr("(){}[]\'\" ", s[len]))) s[len--] = 0; pszCmd = s; Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2013-03-25 23:14:59 UTC (rev 1696) @@ -920,7 +920,7 @@ if (pSndFile->GetNumInstruments()) { if (pSndFile->Instruments[i]) - memcpy(s+k, pSndFile->Instruments[i]->name, 32); + memcpy(s + k, pSndFile->Instruments[i]->name, CountOf(pSndFile->Instruments[i]->name)); } else memcpy(s+k, pSndFile->m_szNames[i], MAX_SAMPLENAME); s[k+32] = 0; Modified: trunk/OpenMPT/mptrack/SelectPluginDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2013-03-25 23:14:59 UTC (rev 1696) @@ -152,10 +152,8 @@ break; } - lstrcpyn(m_pPlugin->Info.szName, pFactory->szLibraryName, 32); - lstrcpyn(m_pPlugin->Info.szLibraryName, pFactory->szLibraryName, 64); - StringFixer::SetNullTerminator(m_pPlugin->Info.szName); - StringFixer::SetNullTerminator(m_pPlugin->Info.szLibraryName); + StringFixer::Copy(m_pPlugin->Info.szName, pFactory->szLibraryName); + StringFixer::Copy(m_pPlugin->Info.szLibraryName, pFactory->szLibraryName); cs.Leave(); @@ -171,7 +169,7 @@ if ((p->GetDefaultEffectName(s)) && (s[0])) { s[31] = 0; - lstrcpyn(m_pPlugin->Info.szName, s, 32); + StringFixer::Copy(m_pPlugin->Info.szName, s); } } } Modified: trunk/OpenMPT/mptrack/View_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_gen.cpp 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/mptrack/View_gen.cpp 2013-03-25 23:14:59 UTC (rev 1696) @@ -877,7 +877,7 @@ StringFixer::SetNullTerminator(s); if (strcmp(s, pSndFile->m_MixPlugins[m_nCurrentPlugin].GetName())) { - lstrcpyn(pSndFile->m_MixPlugins[m_nCurrentPlugin].Info.szName, s, 32); + StringFixer::Copy(pSndFile->m_MixPlugins[m_nCurrentPlugin].Info.szName, s); if(pSndFile->GetModSpecifications().supportsPlugins) pModDoc->SetModified(); pModDoc->UpdateAllViews(NULL, HINT_MODCHANNELS | (m_nActiveTab << HINT_SHIFT_CHNTAB)); Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2013-03-25 23:14:59 UTC (rev 1696) @@ -801,7 +801,7 @@ { // more than one sequence -> add folder CString sSeqName; - if(sndFile.Order.GetSequence(nSeq).m_sName.IsEmpty()) + if(sndFile.Order.GetSequence(nSeq).m_sName.empty()) sSeqName.Format("Sequence %d", nSeq); else sSeqName.Format("%d: %s", nSeq, (LPCTSTR)sndFile.Order.GetSequence(nSeq).m_sName); @@ -1008,7 +1008,7 @@ if(sndFile.m_SongFlags[SONG_ITPROJECT]) { // path info for ITP instruments - const bool pathOk = !sndFile.m_szInstrumentPath[nIns - 1].IsEmpty(); + const bool pathOk = !sndFile.m_szInstrumentPath[nIns - 1].empty(); const bool instMod = pDoc->m_bsInstrumentModified.test(nIns - 1); wsprintf(s, pathOk ? (instMod ? "%3d: * %s" : "%3d: %s") : "%3d: ? %s", nIns, (LPCTSTR)sndFile.GetInstrumentName(nIns)); } else @@ -1322,7 +1322,7 @@ { // Preview sample / instrument in module char szName[16]; - lstrcpyn(szName, GetItemText(hItem), sizeof(szName)); + StringFixer::CopyN(szName, GetItemText(hItem)); const size_t n = ConvertStrTo<size_t>(szName); CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); if (pMainFrm && m_SongFile) @@ -1619,7 +1619,7 @@ ModInstrument *pIns = m_SongFile->Instruments[iIns]; if(pIns) { - lstrcpyn(szPath, pIns->name, 32); + StringFixer::Copy(szPath, pIns->name); wsprintf(s, "%3d: %s", iIns, szPath); ModTreeBuildTVIParam(tvis, s, IMAGE_INSTRUMENTS); InsertItem(&tvis); @@ -1628,7 +1628,7 @@ for(SAMPLEINDEX iSmp = 1; iSmp <= m_SongFile->GetNumSamples(); iSmp++) { const ModSample &sample = m_SongFile->GetSample(iSmp); - lstrcpyn(szPath, m_SongFile->m_szNames[iSmp], 32); + strcpy(szPath, m_SongFile->m_szNames[iSmp]); if (sample.pSample) { wsprintf(s, "%3d: %s", iSmp, szPath); @@ -1996,7 +1996,7 @@ if (m_szSongName[0]) { CHAR s[32]; - lstrcpyn(s, GetItemText(m_hItemDrag), CountOf(s)); + StringFixer::CopyN(s, GetItemText(m_hItemDrag)); UINT n = 0; if (s[0] >= '0') n += (s[0] - '0'); if ((s[1] >= '0') && (s[1] <= '9')) n = n*10 + (s[1] - '0'); @@ -3192,7 +3192,7 @@ if(pSndFile && modItemID) { - if(pSndFile->m_szInstrumentPath[modItemID - 1].IsEmpty()) + if(pSndFile->m_szInstrumentPath[modItemID - 1].empty()) { FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(false, (pSndFile->GetType() == MOD_TYPE_XM) ? "xi" : "iti", "", (pSndFile->GetType() == MOD_TYPE_XM) ? @@ -3612,7 +3612,7 @@ case MODITEM_SAMPLE: if(modItemID <= sndFile.GetNumSamples() && strcmp(sndFile.m_szNames[modItemID], info->item.pszText)) { - strncpy(sndFile.m_szNames[modItemID], info->item.pszText, modSpecs.sampleNameLengthMax); + StringFixer::CopyN(sndFile.m_szNames[modItemID], info->item.pszText, modSpecs.sampleNameLengthMax); modDoc->SetModified(); modDoc->UpdateAllViews(NULL, (UINT(modItemID) << HINT_SHIFT_SMP) | HINT_SMPNAMES | HINT_SAMPLEDATA | HINT_SAMPLEINFO); } @@ -3621,7 +3621,7 @@ case MODITEM_INSTRUMENT: if(modItemID <= sndFile.GetNumInstruments() && sndFile.Instruments[modItemID] != nullptr && strcmp(sndFile.Instruments[modItemID]->name, info->item.pszText)) { - strncpy(sndFile.Instruments[modItemID]->name, info->item.pszText, modSpecs.instrNameLengthMax); + StringFixer::CopyN(sndFile.Instruments[modItemID]->name, info->item.pszText, modSpecs.instrNameLengthMax); modDoc->SetModified(); modDoc->UpdateAllViews(NULL, (UINT(modItemID) << HINT_SHIFT_INS) | HINT_ENVELOPE | HINT_INSTRUMENT); } Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2013-03-25 23:14:59 UTC (rev 1696) @@ -49,8 +49,7 @@ //---------------------------------------------- { char fn[_MAX_PATH]; - strncpy(fn, s, sizeof(fn)); - fn[sizeof(fn)-1] = 0; + StringFixer::Copy(fn, s); int f; for(f = 0; fn[f] != 0; f++) fn[f] = toupper(fn[f]); return LittleEndian(crc32(0, (BYTE *)fn, f)); @@ -161,8 +160,7 @@ p->dwPluginId1 = kDmoMagic; p->dwPluginId2 = clsid.Data1; p->category = VSTPluginLib::catDMO; - lstrcpyn(p->szLibraryName, s, sizeof(p->szLibraryName)); - StringFixer::SetNullTerminator(p->szLibraryName); + StringFixer::Copy(p->szLibraryName, s); StringFromGUID2(clsid, w, 100); WideCharToMultiByte(CP_ACP, 0, w, -1, p->szDllPath, sizeof(p->szDllPath), nullptr, nullptr); @@ -556,10 +554,10 @@ { // Try finding the plugin DLL in the plugin directory instead. CHAR s[_MAX_PATH]; - strncpy(s, TrackerSettings::Instance().GetDefaultDirectory(DIR_PLUGINS), CountOf(s)); - if(!strcmp(s, "")) + StringFixer::CopyN(s, TrackerSettings::Instance().GetDefaultDirectory(DIR_PLUGINS)); + if(!s[0]) { - strncpy(s, theApp.GetAppDirPath(), CountOf(s)); + StringFixer::CopyN(s, theApp.GetAppDirPath()); } size_t len = strlen(s); if((len > 0) && (s[len - 1] != '\\') && (s[len - 1] != '/')) @@ -1197,7 +1195,7 @@ MemsetZero(szInitPath); if(fileSel->initialPath) { - strncpy(szInitPath, fileSel->initialPath, _MAX_PATH - 1); + StringFixer::CopyN(szInitPath, fileSel->initialPath); } char szBuffer[_MAX_PATH]; Modified: trunk/OpenMPT/mptrack/Vstplug.h =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.h 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/mptrack/Vstplug.h 2013-03-25 23:14:59 UTC (rev 1696) @@ -76,8 +76,7 @@ category = catUnknown; if(dllPath != nullptr) { - lstrcpyn(szDllPath, dllPath, CountOf(szDllPath)); - StringFixer::SetNullTerminator(szDllPath); + StringFixer::CopyN(szDllPath, dllPath); } } Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp 2013-03-25 23:14:59 UTC (rev 1696) @@ -449,7 +449,7 @@ //strncpy_s(pTTTA->szText, sizeof(pTTTA->szText), strTipText, // strTipText.GetLength() + 1); // 80 chars max?! - strncpy(pTTTA->szText, strTipText, min(strTipText.GetLength() + 1, CountOf(pTTTA->szText) - 1)); + StringFixer::CopyN(pTTTA->szText, strTipText); } else { ::MultiByteToWideChar(CP_ACP , 0, strTipText, strTipText.GetLength() + 1, Modified: trunk/OpenMPT/mptrack/mod2midi.cpp =================================================================== --- trunk/OpenMPT/mptrack/mod2midi.cpp 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/mptrack/mod2midi.cpp 2013-03-25 23:14:59 UTC (rev 1696) @@ -404,7 +404,7 @@ for (CHANNELINDEX iInit = 0; iInit < m_pSndFile->GetNumChannels(); iInit++) { DYNMIDITRACK &track = Tracks[iInit]; - lstrcpyn(s, m_pSndFile->ChnSettings[iInit].szName, MAX_CHANNELNAME); + StringFixer::Copy(s, m_pSndFile->ChnSettings[iInit].szName); track.nMidiChannel = iInit & 7; if (s[0]) { Modified: trunk/OpenMPT/mptrack/view_com.cpp =================================================================== --- trunk/OpenMPT/mptrack/view_com.cpp 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/mptrack/view_com.cpp 2013-03-25 23:14:59 UTC (rev 1696) @@ -263,7 +263,7 @@ switch(iCol) { case SMPLIST_SAMPLENAME: - lstrcpyn(s, pSndFile->m_szNames[iSmp + 1], MAX_SAMPLENAME); + StringFixer::Copy(s, pSndFile->m_szNames[iSmp + 1]); break; case SMPLIST_SAMPLENO: wsprintf(s, "%02d", iSmp + 1); @@ -278,7 +278,7 @@ } break; case SMPLIST_TYPE: - if (sample.nLength) + if(sample.nLength) { wsprintf(s, "%d Bit", sample.GetElementarySampleSize() * 8); } @@ -363,7 +363,7 @@ switch(iCol) { case INSLIST_INSTRUMENTNAME: - if (pIns) lstrcpyn(s, pIns->name, sizeof(pIns->name)); + if (pIns) StringFixer::Copy(s, pIns->name); break; case INSLIST_INSTRUMENTNO: wsprintf(s, "%02d", iIns+1); @@ -515,8 +515,7 @@ { if(iItem < pSndFile->GetNumSamples()) { - strncpy(pSndFile->m_szNames[iItem + 1], lvItem.pszText, MAX_SAMPLENAME); - StringFixer::SetNullTerminator(pSndFile->m_szNames[iItem + 1]); + StringFixer::CopyN(pSndFile->m_szNames[iItem + 1], lvItem.pszText); pModDoc->UpdateAllViews(this, ((iItem + 1) << HINT_SHIFT_SMP) | (HINT_SMPNAMES | HINT_SAMPLEINFO), this); pModDoc->SetModified(); } @@ -525,8 +524,7 @@ if((iItem < pSndFile->GetNumInstruments()) && (pSndFile->Instruments[iItem + 1])) { ModInstrument *pIns = pSndFile->Instruments[iItem + 1]; - strncpy(pIns->name, lvItem.pszText, MAX_INSTRUMENTNAME); - StringFixer::SetNullTerminator(pIns->name); + StringFixer::CopyN(pIns->name, lvItem.pszText); pModDoc->UpdateAllViews(this, ((iItem + 1) << HINT_SHIFT_INS) | (HINT_INSNAMES | HINT_INSTRUMENT), this); pModDoc->SetModified(); } Modified: trunk/OpenMPT/soundlib/Dlsbank.cpp =================================================================== --- trunk/OpenMPT/soundlib/Dlsbank.cpp 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/soundlib/Dlsbank.cpp 2013-03-25 23:14:59 UTC (rev 1696) @@ -872,8 +872,7 @@ SFSAMPLE *p = (SFSAMPLE *)(pchunk+1); for (UINT i=0; i<m_nSamplesEx; i++, pDlsSmp++, p++) { - memcpy(pDlsSmp->szName, p->achSampleName, 20); - StringFixer::SetNullTerminator(pDlsSmp->szName); + StringFixer::Copy(pDlsSmp->szName, p->achSampleName); pDlsSmp->dwLen = 0; pDlsSmp->dwSampleRate = p->dwSampleRate; pDlsSmp->byOriginalPitch = p->byOriginalPitch; @@ -1684,12 +1683,10 @@ } lstrcat(s, ")"); } - s[31] = 0; - strcpy(pIns->name, s); + StringFixer::Copy(pIns->name, s); } else { - memcpy(pIns->name, pDlsIns->szName, 32); - StringFixer::SetNullTerminator(pIns->name); + StringFixer::Copy(pIns->name, pDlsIns->szName); } int nTranspose = 0; if (pDlsIns->ulBank & F_INSTRUMENT_DRUMS) Modified: trunk/OpenMPT/soundlib/Load_itp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_itp.cpp 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/soundlib/Load_itp.cpp 2013-03-25 23:14:59 UTC (rev 1696) @@ -201,7 +201,7 @@ for(INSTRUMENTINDEX ins = 0; ins < GetNumInstruments(); ins++) { - if(m_szInstrumentPath[ins].IsEmpty() || !f.Open(m_szInstrumentPath[ins])) continue; + if(m_szInstrumentPath[ins].empty() || !f.Open(m_szInstrumentPath[ins])) continue; size = f.GetLength(); LPBYTE lpFile = f.Lock(size); @@ -265,7 +265,7 @@ if(!m_SongFlags[SONG_ITPROJECT]) return false; UINT i,j = 0; - for(i = 0 ; i < m_nInstruments ; i++) { if(!m_szInstrumentPath[i].IsEmpty() || !Instruments[i+1]) j++; } + for(i = 0 ; i < m_nInstruments ; i++) { if(!m_szInstrumentPath[i].empty() || !Instruments[i+1]) j++; } if(m_nInstruments && j != m_nInstruments) return false; // Open file Modified: trunk/OpenMPT/soundlib/Load_umx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_umx.cpp 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/soundlib/Load_umx.cpp 2013-03-25 23:14:59 UTC (rev 1696) @@ -289,7 +289,7 @@ m_nSamples++; if(static_cast<size_t>(objName) < names.size()) { - strncpy(m_szNames[GetNumSamples()], names[objName].c_str(), MAX_SAMPLENAME - 1); + StringFixer::CopyN(m_szNames[GetNumSamples()], names[objName].c_str()); } } } Modified: trunk/OpenMPT/soundlib/Message.cpp =================================================================== --- trunk/OpenMPT/soundlib/Message.cpp 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/soundlib/Message.cpp 2013-03-25 23:14:59 UTC (rev 1696) @@ -205,7 +205,7 @@ } const size_t len = strlen(m_lpszSongComments); - comments.Reserve(len); + comments.reserve(len); for(size_t i = 0; i < len; i++) { @@ -215,21 +215,21 @@ { case leCR: default: - comments.Append("\r"); + comments.append(1, '\r'); break; + case leCRLF: + comments.append(1, 'r'); + // Intentional fall-through case leLF: - comments.Append("\n"); + comments.append(1, '\n'); break; - case leCRLF: - comments.Append("\r\n"); - break; } } else { char c = m_lpszSongComments[i]; // Pre-process text if(pTextConverter != nullptr) pTextConverter(c); - comments.AppendChar(c); + comments.append(1, c); } } return comments; Modified: trunk/OpenMPT/soundlib/ModInstrument.h =================================================================== --- trunk/OpenMPT/soundlib/ModInstrument.h 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/soundlib/ModInstrument.h 2013-03-25 23:14:59 UTC (rev 1696) @@ -89,7 +89,7 @@ uint8 NoteMap[128]; // Note mapping, e.g. C-5 => D-5. SAMPLEINDEX Keyboard[128]; // Sample mapping, e.g. C-5 => Sample 1 - char name[MAX_INSTRUMENTNAME]; // Note: not guaranteed to be null-terminated. + char name[MAX_INSTRUMENTNAME]; char filename[MAX_INSTRUMENTFILENAME]; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-03-25 23:14:59 UTC (rev 1696) @@ -150,7 +150,7 @@ // -> CODE#0023 // -> DESC="IT project files (.itp)" - m_szInstrumentPath[nInstr - 1].Empty(); + m_szInstrumentPath[nInstr - 1].clear(); #ifdef MODPLUG_TRACKER if(GetpModDoc()) { @@ -776,8 +776,7 @@ Instruments[nInstr] = pIns; nSamples = plh->samples; if (nSamples > 16) nSamples = 16; - memcpy(pIns->name, pih->name, 16); - pIns->name[16] = 0; + StringFixer::Copy(pIns->name, pih->name); pIns->nFadeOut = 2048; if (GetType() & (MOD_TYPE_IT|MOD_TYPE_MPT)) { @@ -1673,6 +1672,10 @@ if(fadr && code != 'K[..') // copy field data in instrument's header memcpy(fadr, file.GetRawData(), size); // (except for keyboard mapping) + if(fadr && code == 'n[..') + StringFixer::SetNullTerminator(pIns->name); + if(fadr && code == 'fn[.') + StringFixer::SetNullTerminator(pIns->filename); file.Skip(size); if(code == 'dF..' && fadr != nullptr) // 'dF..' field requires additional processing. Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-03-25 23:14:59 UTC (rev 1696) @@ -1292,9 +1292,7 @@ return TEXT(""); ASSERT(nInstr <= GetNumInstruments()); - mpt::String str; - str.AppendChars(Instruments[nInstr]->name); - return str; + return mpt::String(Instruments[nInstr]->name); } @@ -1721,8 +1719,7 @@ { if(strcmp(m_szNames[0], titleCandidate)) { - strncpy(m_szNames[0], titleCandidate, Util::Min(CountOf(m_szNames[0]), strSize)); - StringFixer::SetNullTerminator(m_szNames[0]); + StringFixer::CopyN(m_szNames[0], titleCandidate, strSize); return true; } return false; Modified: trunk/OpenMPT/soundlib/WAVTools.cpp =================================================================== --- trunk/OpenMPT/soundlib/WAVTools.cpp 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/soundlib/WAVTools.cpp 2013-03-25 23:14:59 UTC (rev 1696) @@ -129,8 +129,7 @@ if(isDLS) { // DLS sample -> sample filename - strncpy(sample.filename, sampleName, CountOf(sample.filename) - 1); - StringFixer::SetNullTerminator(sample.filename); + StringFixer::Copy(sample.filename, sampleName); } // Read software name Modified: trunk/OpenMPT/soundlib/pattern.cpp =================================================================== --- trunk/OpenMPT/soundlib/pattern.cpp 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/soundlib/pattern.cpp 2013-03-25 23:14:59 UTC (rev 1696) @@ -133,7 +133,7 @@ m_Rows = m_RowsPerBeat = m_RowsPerMeasure = 0; FreePattern(m_ModCommands); m_ModCommands = nullptr; - m_PatternName.Empty(); + m_PatternName.clear(); } Modified: trunk/OpenMPT/soundlib/patternContainer.cpp =================================================================== --- trunk/OpenMPT/soundlib/patternContainer.cpp 2013-03-25 21:52:32 UTC (rev 1695) +++ trunk/OpenMPT/soundlib/patternContainer.cpp 2013-03-25 23:14:59 UTC (rev 1696) @@ -190,7 +190,7 @@ } for(PATTERNINDEX nPat = Size(); nPat > 0; nPat--) { - if(!m_Patterns[nPat - 1].GetName().IsEmpty()) + if(!m_Patterns[nPat - 1].GetName().empty()) { return nPat; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-03-26 19:15:33
|
Revision: 1698 http://sourceforge.net/p/modplug/code/1698 Author: saga-games Date: 2013-03-26 19:15:25 +0000 (Tue, 26 Mar 2013) Log Message: ----------- [Fix] Fixed instrument name display (broke with string refactoring) [Fix] Fixed instrument plugin preview (broke with sample map fixes) [Mod] VST: Send offline rendering state to plugins Modified Paths: -------------- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2013-03-25 23:18:25 UTC (rev 1697) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2013-03-26 19:15:25 UTC (rev 1698) @@ -192,7 +192,7 @@ { if (pSndFile->m_nInstruments) { - wsprintf(s, "%03d:%s", n, (pSndFile->Instruments[n]) ? (LPCTSTR)pSndFile->GetInstrumentName(n) : ""); + wsprintf(s, "%03d:%s", n, pSndFile->GetInstrumentName(n)); } else { wsprintf(s, "%03d:%s", n, pSndFile->m_szNames[n]); Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2013-03-25 23:18:25 UTC (rev 1697) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2013-03-26 19:15:25 UTC (rev 1698) @@ -1010,10 +1010,10 @@ // path info for ITP instruments const bool pathOk = !sndFile.m_szInstrumentPath[nIns - 1].empty(); const bool instMod = pDoc->m_bsInstrumentModified.test(nIns - 1); - wsprintf(s, pathOk ? (instMod ? "%3d: * %s" : "%3d: %s") : "%3d: ? %s", nIns, (LPCTSTR)sndFile.GetInstrumentName(nIns)); + wsprintf(s, pathOk ? (instMod ? "%3d: * %s" : "%3d: %s") : "%3d: ? %s", nIns, sndFile.GetInstrumentName(nIns)); } else { - wsprintf(s, "%3d: %s", nIns, (LPCTSTR)sndFile.GetInstrumentName(nIns)); + wsprintf(s, "%3d: %s", nIns, sndFile.GetInstrumentName(nIns)); } int nImage = IMAGE_INSTRUMENTS; Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2013-03-25 23:18:25 UTC (rev 1697) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2013-03-26 19:15:25 UTC (rev 1698) @@ -905,14 +905,10 @@ return 1; //we replace. case audioMasterGetCurrentProcessLevel: - //Log("VST plugin to host: Get Current Process Level\n"); - //TODO: Support offline processing -/* if (CMainFrame::GetMainFrame()->IsRendering()) { - return 4; //Offline - } else { - return 2; //Unknown. - } -*/ + if(CMainFrame::GetMainFrame()->IsRendering()) + return kVstProcessLevelOffline; + else + return kVstProcessLevelRealtime; break; // returns 0: not supported, 1: off, 2:read, 3:write, 4:read/write @@ -1028,7 +1024,7 @@ case audioMasterUpdateDisplay: if (pVstPlugin != nullptr) { - // Note to self for testing: Electri-Q sends opcode. Korg M1 sends this when switchin between Combi and Multi mode to update the preset names. + // Note to self for testing: Electri-Q sends opcode. Korg M1 sends this when switching between Combi and Multi mode to update the preset names. CAbstractVstEditor *pVstEditor = pVstPlugin->GetEditor(); if (pVstEditor && ::IsWindow(pVstEditor->m_hWnd)) { @@ -1904,10 +1900,10 @@ CString CVstPlugin::GetFormattedParamName(PlugParamIndex param) //------------------------------------------------------------- { - static VstParameterProperties properties; - CString paramName; + VstParameterProperties properties; + MemsetZero(properties.label); if(Dispatch(effGetParameterProperties, param, 0, &properties, 0.0f) == 1) { StringFixer::SetNullTerminator(properties.label); @@ -2145,7 +2141,7 @@ { for(size_t i = 0; i < nSamples; i++) { - outputBuffers[iOut % 2][i] += outputBuffers[iOut][i]; // assumed stereo. + outputBuffers[iOut % 2u][i] += outputBuffers[iOut][i]; // assumed stereo. } } @@ -2343,8 +2339,8 @@ { VSTInstrChannel &channel = m_MidiCh[mc]; - MidiPitchBend(mc, EncodePitchBendParam(MIDIEvents::pitchBendCentre)); // centre pitch bend - MidiSend(MIDIEvents::CC(MIDIEvents::MIDICC_AllControllersOff, mc, 0)); // reset all controllers + MidiPitchBend(mc, EncodePitchBendParam(MIDIEvents::pitchBendCentre)); // centre pitch bend + MidiSend(MIDIEvents::CC(MIDIEvents::MIDICC_AllControllersOff, mc, 0)); // reset all controllers MidiSend(MIDIEvents::CC(MIDIEvents::MIDICC_AllNotesOff, mc, 0)); // all notes off MidiSend(MIDIEvents::CC(MIDIEvents::MIDICC_AllSoundOff, mc, 0)); // all sounds off Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-03-25 23:18:25 UTC (rev 1697) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-03-26 19:15:25 UTC (rev 1698) @@ -880,6 +880,8 @@ if(pSmp == nullptr) { + pChn->pModSample = nullptr; + pChn->nLength = 0; return; } Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-03-25 23:18:25 UTC (rev 1697) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-03-26 19:15:25 UTC (rev 1698) @@ -1285,14 +1285,14 @@ } -mpt::String CSoundFile::GetInstrumentName(UINT nInstr) const -//------------------------------------------------------ +const char *CSoundFile::GetInstrumentName(INSTRUMENTINDEX nInstr) const +//--------------------------------------------------------------------- { - if ((nInstr >= MAX_INSTRUMENTS) || (!Instruments[nInstr])) + if((nInstr >= MAX_INSTRUMENTS) || (!Instruments[nInstr])) return TEXT(""); ASSERT(nInstr <= GetNumInstruments()); - return mpt::String(Instruments[nInstr]->name); + return Instruments[nInstr]->name; } Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-03-25 23:18:25 UTC (rev 1697) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-03-26 19:15:25 UTC (rev 1698) @@ -92,15 +92,19 @@ #define INTERNAL_LINEENDING '\r' // The character that represents line endings internally +#ifdef MODPLUG_TRACKER + // For WAV export (writing pattern positions to file) struct PatternCuePoint { - ULONGLONG offset; // offset in the file (in samples) - ORDERINDEX order; // which order is this? - bool processed; // has this point been processed by the main WAV render function yet? + uint64 offset; // offset in the file (in samples) + ORDERINDEX order; // which order is this? + bool processed; // has this point been processed by the main WAV render function yet? }; +#endif // MODPLUG_TRACKER + // Return values for GetLength() struct GetLengthType { @@ -315,7 +319,9 @@ DWORD m_dwCreatedWithVersion; DWORD m_dwLastSavedWithVersion; +#ifdef MODPLUG_TRACKER vector<PatternCuePoint> m_PatternCuePoints; // For WAV export (writing pattern positions to file) +#endif // MODPLUG_TRACKER // For handling backwards jumps and stuff to prevent infinite loops when counting the mod length or rendering to wav. RowVisitor visitedSongRows; @@ -365,7 +371,7 @@ void SetCurrentOrder(ORDERINDEX nOrder); LPCSTR GetTitle() const { return m_szNames[0]; } LPCTSTR GetSampleName(UINT nSample) const; - mpt::String GetInstrumentName(UINT nInstr) const; + const char *GetInstrumentName(INSTRUMENTINDEX nInstr) const; UINT GetMusicSpeed() const { return m_nMusicSpeed; } UINT GetMusicTempo() const { return m_nMusicTempo; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-04-02 17:37:24
|
Revision: 1702 http://sourceforge.net/p/modplug/code/1702 Author: manxorist Date: 2013-04-02 17:37:11 +0000 (Tue, 02 Apr 2013) Log Message: ----------- [Ref] Make the magic value tables in Tables.cpp const and add a proper Tables.h header. [Ref] Remove the rather pointless custom sections .modplug and .tables . Modified Paths: -------------- trunk/OpenMPT/mptrack/EffectInfo.cpp trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/soundlib/Fastmix.cpp trunk/OpenMPT/soundlib/Load_mod.cpp trunk/OpenMPT/soundlib/Snd_flt.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Snd_rvb.cpp trunk/OpenMPT/soundlib/Sndmix.cpp trunk/OpenMPT/soundlib/Tables.cpp trunk/OpenMPT/soundlib/modcommand.cpp Added Paths: ----------- trunk/OpenMPT/soundlib/Tables.h Modified: trunk/OpenMPT/mptrack/EffectInfo.cpp =================================================================== --- trunk/OpenMPT/mptrack/EffectInfo.cpp 2013-03-28 10:56:48 UTC (rev 1701) +++ trunk/OpenMPT/mptrack/EffectInfo.cpp 2013-04-02 17:37:11 UTC (rev 1702) @@ -12,9 +12,8 @@ #include "EffectInfo.h" #include "mptrack.h" #include "..\soundlib\modcommand.h" +#include "../soundlib/Tables.h" -extern WORD S3MFineTuneTable[16]; - /////////////////////////////////////////////////////////////////////////// // Effects description Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-03-28 10:56:48 UTC (rev 1701) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-04-02 17:37:11 UTC (rev 1702) @@ -1083,6 +1083,10 @@ > </File> <File + RelativePath=".\Tables.h" + > + </File> + <File RelativePath=".\tagging.h" > </File> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-03-28 10:56:48 UTC (rev 1701) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-04-02 17:37:11 UTC (rev 1702) @@ -426,6 +426,7 @@ <ClInclude Include="..\soundlib\SampleFormatConverters.h" /> <ClInclude Include="..\soundlib\SampleIO.h" /> <ClInclude Include="..\soundlib\snd_rvb.h" /> + <ClInclude Include="..\soundlib\Tables.h" /> <ClInclude Include="..\soundlib\WAVTools.h" /> <ClInclude Include="..\soundlib\XMTools.h" /> <ClInclude Include="ACMConvert.h" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-03-28 10:56:48 UTC (rev 1701) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-04-02 17:37:11 UTC (rev 1702) @@ -777,6 +777,9 @@ <ClInclude Include="..\sounddsp\EQ.h"> <Filter>Header Files\sounddsp</Filter> </ClInclude> + <ClInclude Include="..\soundlib\Tables.h"> + <Filter>Header Files</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="res\bitmap1.bmp"> Modified: trunk/OpenMPT/soundlib/Fastmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Fastmix.cpp 2013-03-28 10:56:48 UTC (rev 1701) +++ trunk/OpenMPT/soundlib/Fastmix.cpp 2013-04-02 17:37:11 UTC (rev 1702) @@ -17,8 +17,6 @@ #include "WindowedFIR.h" -#pragma bss_seg(".modplug") - // Front Mix Buffer (Also room for interleaved rear mix) int MixSoundBuffer[MIXBUFFERSIZE * 4]; @@ -30,9 +28,7 @@ int MixRearBuffer[MIXBUFFERSIZE * 2]; float MixFloatBuffer[MIXBUFFERSIZE * 2]; -#pragma bss_seg() - #ifndef NO_REVERB extern UINT gnReverbSend; #endif Modified: trunk/OpenMPT/soundlib/Load_mod.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mod.cpp 2013-03-28 10:56:48 UTC (rev 1701) +++ trunk/OpenMPT/soundlib/Load_mod.cpp 2013-04-02 17:37:11 UTC (rev 1702) @@ -11,6 +11,7 @@ #include "stdafx.h" #include "Loaders.h" +#include "Tables.h" void CSoundFile::ConvertModCommand(ModCommand &m) const //----------------------------------------------------- @@ -1025,8 +1026,6 @@ #include "../mptrack/moddoc.h" #endif // MODPLUG_TRACKER -extern WORD ProTrackerPeriodTable[6*12]; - bool CSoundFile::SaveMod(LPCSTR lpszFileName) const //------------------------------------------------- { Modified: trunk/OpenMPT/soundlib/Snd_flt.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_flt.cpp 2013-03-28 10:56:48 UTC (rev 1701) +++ trunk/OpenMPT/soundlib/Snd_flt.cpp 2013-04-02 17:37:11 UTC (rev 1702) @@ -11,6 +11,7 @@ #include "stdafx.h" #include "sndfile.h" +#include "Tables.h" // AWE32: cutoff = reg[0-255] * 31.25 + 100 -> [100Hz-8060Hz] // EMU10K1 docs: cutoff = reg[0-127]*62+100 @@ -18,9 +19,7 @@ #define _USE_MATH_DEFINES #include <math.h> -extern float ITResonanceTable[128]; - DWORD CSoundFile::CutOffToFrequency(UINT nCutOff, int flt_modifier) const //----------------------------------------------------------------------- { Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-03-28 10:56:48 UTC (rev 1701) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-04-02 17:37:11 UTC (rev 1702) @@ -20,27 +20,11 @@ #include "../mptrack/moddoc.h" #endif // MODPLUG_TRACKER #include "tuning.h" +#include "Tables.h" #pragma warning(disable:4244) -// Tables defined in tables.cpp -extern BYTE ImpulseTrackerPortaVolCmd[16]; -extern WORD S3MFineTuneTable[16]; -extern WORD ProTrackerPeriodTable[6*12]; -extern WORD ProTrackerTunedPeriods[15*12]; -extern WORD FreqS3MTable[]; -extern WORD XMPeriodTable[96+8]; -extern UINT XMLinearTable[768]; -extern DWORD FineLinearSlideUpTable[16]; -extern DWORD FineLinearSlideDownTable[16]; -extern DWORD LinearSlideUpTable[256]; -extern DWORD LinearSlideDownTable[256]; -extern signed char retrigTable1[16]; -extern signed char retrigTable2[16]; -extern short int ModRandomTable[64]; -extern BYTE ModEFxTable[16]; - //////////////////////////////////////////////////////////// // Length Modified: trunk/OpenMPT/soundlib/Snd_rvb.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_rvb.cpp 2013-03-28 10:56:48 UTC (rev 1701) +++ trunk/OpenMPT/soundlib/Snd_rvb.cpp 2013-04-02 17:37:11 UTC (rev 1702) @@ -22,10 +22,8 @@ extern VOID MPPASMCALL X86_StereoFill(int *pBuffer, UINT nSamples, LPLONG lpROfs, LPLONG lpLOfs); // Reverb mix buffers -#pragma bss_seg(".modplug") static SWRVBREFDELAY g_RefDelay; static SWLATEREVERB g_LateReverb; -#pragma bss_seg() // Shared reverb state UINT gnReverbSamples = 0; Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-03-28 10:56:48 UTC (rev 1701) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-04-02 17:37:11 UTC (rev 1702) @@ -14,6 +14,7 @@ #include "sndfile.h" #include "MIDIEvents.h" #include "tuning.h" +#include "Tables.h" #ifdef MODPLUG_TRACKER #include "../mptrack/TrackerSettings.h" #endif @@ -68,18 +69,6 @@ extern VOID MPPASMCALL X86_MonoFromStereo(int *pMixBuf, UINT nSamples); extern void SndMixInitializeTables(const MixerSettings &mixersettings); -extern short int ModSinusTable[64]; -extern short int ModRampDownTable[64]; -extern short int ModSquareTable[64]; -extern short int ModRandomTable[64]; -extern short int ITSinusTable[256]; -extern short int ITRampDownTable[256]; -extern short int ITSquareTable[256]; -extern DWORD LinearSlideUpTable[256]; -extern DWORD LinearSlideDownTable[256]; -extern DWORD FineLinearSlideUpTable[16]; -extern DWORD FineLinearSlideDownTable[16]; -extern signed char ft2VibratoTable[256]; // -64 .. +64 extern int MixSoundBuffer[MIXBUFFERSIZE * 4]; extern int MixRearBuffer[MIXBUFFERSIZE * 2]; Modified: trunk/OpenMPT/soundlib/Tables.cpp =================================================================== --- trunk/OpenMPT/soundlib/Tables.cpp 2013-03-28 10:56:48 UTC (rev 1701) +++ trunk/OpenMPT/soundlib/Tables.cpp 2013-04-02 17:37:11 UTC (rev 1702) @@ -10,6 +10,7 @@ #include "stdafx.h" +#include "Tables.h" #include <math.h> #include "sndfile.h" @@ -28,7 +29,7 @@ char *extension; // "mod" }; -const ModFormatInfo modFormatInfo[] = +static const ModFormatInfo modFormatInfo[] = { { MOD_TYPE_MOD, "ProTracker", "mod" }, { MOD_TYPE_S3M, "ScreamTracker III", "s3m" }, @@ -78,7 +79,7 @@ { MOD_TYPE_MPT, "OpenMPT", "mptmz" }, }; -const ModFormatInfo otherFormatInfo[] = +static const ModFormatInfo otherFormatInfo[] = { // Other stuff { MOD_TYPE_WAV, "Wave", "wav" }, @@ -113,19 +114,15 @@ /////////////////////////////////////////////////////////////////////// -#pragma data_seg(".tables") -#pragma bss_seg(".modplug") -/////////////////////////////////////////////////////////////////////// - -BYTE ImpulseTrackerPortaVolCmd[16] = +const BYTE ImpulseTrackerPortaVolCmd[16] = { 0x00, 0x01, 0x04, 0x08, 0x10, 0x20, 0x40, 0x60, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; // Period table for Protracker octaves 0-5: -WORD ProTrackerPeriodTable[6*12] = +const WORD ProTrackerPeriodTable[6*12] = { 1712,1616,1524,1440,1356,1280,1208,1140,1076,1016,960,907, 856,808,762,720,678,640,604,570,538,508,480,453, @@ -136,7 +133,7 @@ }; -WORD ProTrackerTunedPeriods[16*12] = +const WORD ProTrackerTunedPeriods[16*12] = { 1712,1616,1524,1440,1356,1280,1208,1140,1076,1016,960,907, 1700,1604,1514,1430,1348,1274,1202,1134,1070,1010,954,900, @@ -157,14 +154,14 @@ }; // Table for Invert Loop and Funk Repeat effects (EFx, .MOD only) -BYTE ModEFxTable[16] = +const BYTE ModEFxTable[16] = { 0, 5, 6, 7, 8, 10, 11, 13, 16, 19, 22, 26, 32, 43, 64, 128 }; // S3M C-4 periods -WORD FreqS3MTable[16] = +const WORD FreqS3MTable[16] = { 1712,1616,1524,1440,1356,1280, 1208,1140,1076,1016,960,907, @@ -172,7 +169,7 @@ }; // S3M FineTune frequencies -WORD S3MFineTuneTable[16] = +const WORD S3MFineTuneTable[16] = { 7895,7941,7985,8046,8107,8169,8232,8280, 8363,8413,8463,8529,8581,8651,8723,8757, // 8363*2^((i-8)/(12*8)) @@ -180,7 +177,7 @@ // Sinus table -short int ModSinusTable[64] = +const short int ModSinusTable[64] = { 0,12,25,37,49,60,71,81,90,98,106,112,117,122,125,126, 127,126,125,122,117,112,106,98,90,81,71,60,49,37,25,12, @@ -189,7 +186,7 @@ }; // Triangle wave table (ramp down) -short int ModRampDownTable[64] = +const short int ModRampDownTable[64] = { 0,-4,-8,-12,-16,-20,-24,-28,-32,-36,-40,-44,-48,-52,-56,-60, -64,-68,-72,-76,-80,-84,-88,-92,-96,-100,-104,-108,-112,-116,-120,-124, @@ -198,7 +195,7 @@ }; // Square wave table -short int ModSquareTable[64] = +const short int ModSquareTable[64] = { 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127, 127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127, @@ -218,7 +215,7 @@ // Impulse Tracker tables (ITTECH.TXT) // Sinus table -short int ITSinusTable[256] = +const short int ITSinusTable[256] = { 0, 2, 3, 5, 6, 8, 9, 11, 12, 14, 16, 17, 19, 20, 22, 23, 24, 26, 27, 29, 30, 32, 33, 34, 36, 37, 38, 39, 41, 42, 43, 44, @@ -239,7 +236,7 @@ }; // Triangle wave table (ramp down) -short int ITRampDownTable[256] = +const short int ITRampDownTable[256] = { 64, 63, 63, 62, 62, 61, 61, 60, 60, 59, 59, 58, 58, 57, 57, 56, 56, 55, 55, 54, 54, 53, 53, 52, 52, 51, 51, 50, 50, 49, 49, 48, @@ -260,7 +257,7 @@ }; // Square wave table -short int ITSquareTable[256] = +const short int ITSquareTable[256] = { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, @@ -281,16 +278,16 @@ }; // volume fade tables for Retrig Note: -signed char retrigTable1[16] = +const signed char retrigTable1[16] = { 0, 0, 0, 0, 0, 0, 10, 8, 0, 0, 0, 0, 0, 0, 24, 32 }; -signed char retrigTable2[16] = +const signed char retrigTable2[16] = { 0, -1, -2, -4, -8, -16, 0, 0, 0, 1, 2, 4, 8, 16, 0, 0 }; -WORD XMPeriodTable[104] = +const WORD XMPeriodTable[104] = { 907,900,894,887,881,875,868,862,856,850,844,838,832,826,820,814, 808,802,796,791,785,779,774,768,762,757,752,746,741,736,730,725, @@ -302,7 +299,7 @@ }; -UINT XMLinearTable[768] = +const UINT XMLinearTable[768] = { 535232,534749,534266,533784,533303,532822,532341,531861, 531381,530902,530423,529944,529466,528988,528511,528034, @@ -403,7 +400,7 @@ }; -signed char ft2VibratoTable[256] = +const signed char ft2VibratoTable[256] = { 0,-2,-3,-5,-6,-8,-9,-11,-12,-14,-16,-17,-19,-20,-22,-23, -24,-26,-27,-29,-30,-32,-33,-34,-36,-37,-38,-39,-41,-42, @@ -425,21 +422,21 @@ -DWORD FineLinearSlideUpTable[16] = +const DWORD FineLinearSlideUpTable[16] = { 65536, 65595, 65654, 65714, 65773, 65832, 65892, 65951, 66011, 66071, 66130, 66190, 66250, 66309, 66369, 66429 }; -DWORD FineLinearSlideDownTable[16] = +const DWORD FineLinearSlideDownTable[16] = { 65535, 65477, 65418, 65359, 65300, 65241, 65182, 65123, 65065, 65006, 64947, 64888, 64830, 64772, 64713, 64645 }; -DWORD LinearSlideUpTable[256] = +const DWORD LinearSlideUpTable[256] = { 65536, 65773, 66010, 66249, 66489, 66729, 66971, 67213, 67456, 67700, 67945, 68190, 68437, 68685, 68933, 69182, @@ -477,7 +474,7 @@ -DWORD LinearSlideDownTable[256] = +const DWORD LinearSlideDownTable[256] = { 65536, 65299, 65064, 64830, 64596, 64363, 64131, 63900, 63670, 63440, 63212, 62984, 62757, 62531, 62305, 62081, @@ -515,7 +512,7 @@ // LUT for 2 * damping factor -float ITResonanceTable[128] = +const float ITResonanceTable[128] = { 1.0000000000000000f, 0.9786446094512940f, 0.9577452540397644f, 0.9372922182083130f, 0.9172759056091309f, 0.8976871371269226f, 0.8785166740417481f, 0.8597555756568909f, @@ -636,10 +633,6 @@ ///////////////////////////////////////////////////////////////////////////////////////////// -#pragma bss_seg() -#pragma data_seg() - - // Compute Bessel function Izero(y) using a series approximation static double izero(double y) { Added: trunk/OpenMPT/soundlib/Tables.h =================================================================== --- trunk/OpenMPT/soundlib/Tables.h (rev 0) +++ trunk/OpenMPT/soundlib/Tables.h 2013-04-02 17:37:11 UTC (rev 1702) @@ -0,0 +1,37 @@ +/* + * Tables.h + * -------- + * Purpose: Effect, interpolation, data and other pre-calculated tables. + * Notes : (currently none) + * Authors: Olivier Lapicque + * OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#pragma once + + +extern const BYTE ImpulseTrackerPortaVolCmd[16]; +extern const WORD ProTrackerPeriodTable[6*12]; +extern const WORD ProTrackerTunedPeriods[16*12]; +extern const BYTE ModEFxTable[16]; +extern const WORD FreqS3MTable[16]; +extern const WORD S3MFineTuneTable[16]; +extern const short int ModSinusTable[64]; +extern const short int ModRampDownTable[64]; +extern const short int ModSquareTable[64]; +extern short int ModRandomTable[64]; +extern const short int ITSinusTable[256]; +extern const short int ITRampDownTable[256]; +extern const short int ITSquareTable[256]; +extern const signed char retrigTable1[16]; +extern const signed char retrigTable2[16]; +extern const WORD XMPeriodTable[104]; +extern const UINT XMLinearTable[768]; +extern const signed char ft2VibratoTable[256]; +extern const DWORD FineLinearSlideUpTable[16]; +extern const DWORD FineLinearSlideDownTable[16]; +extern const DWORD LinearSlideUpTable[256]; +extern const DWORD LinearSlideDownTable[256]; +extern const float ITResonanceTable[128]; Property changes on: trunk/OpenMPT/soundlib/Tables.h ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-chdr \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/OpenMPT/soundlib/modcommand.cpp =================================================================== --- trunk/OpenMPT/soundlib/modcommand.cpp 2013-03-28 10:56:48 UTC (rev 1701) +++ trunk/OpenMPT/soundlib/modcommand.cpp 2013-04-02 17:37:11 UTC (rev 1702) @@ -10,10 +10,9 @@ #include "stdafx.h" #include "Sndfile.h" +#include "Tables.h" -extern BYTE ImpulseTrackerPortaVolCmd[16]; - // Convert an Exx command (MOD) to Sxx command (S3M) void ModCommand::ExtendedMODtoS3MEffect() //--------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-04-02 18:00:33
|
Revision: 1704 http://sourceforge.net/p/modplug/code/1704 Author: saga-games Date: 2013-04-02 18:00:27 +0000 (Tue, 02 Apr 2013) Log Message: ----------- [Imp] ITP: If an instrument cannot be saved, a warning is shown. [Fix] When inputting MIDI notes > B-9, they are now properly clamped to B-9 and stopped properly (live fixing at Revision, tx Knoeki) [Ref] Removed more unused stuff. Modified Paths: -------------- trunk/OpenMPT/common/stdafx.h trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/View_ins.cpp trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/soundlib/Snd_rvb.cpp Modified: trunk/OpenMPT/common/stdafx.h =================================================================== --- trunk/OpenMPT/common/stdafx.h 2013-04-02 17:39:47 UTC (rev 1703) +++ trunk/OpenMPT/common/stdafx.h 2013-04-02 18:00:27 UTC (rev 1704) @@ -50,31 +50,6 @@ #include <fstream> #include <strstream> -#ifndef OFN_FORCESHOWHIDDEN -#define OFN_FORCESHOWHIDDEN 0x10000000 -#endif - -#ifndef _WAVEFORMATEXTENSIBLE_ -#define _WAVEFORMATEXTENSIBLE_ - -typedef struct { - WAVEFORMATEX Format; - union { - WORD wValidBitsPerSample; /* bits of precision */ - WORD wSamplesPerBlock; /* valid if wBitsPerSample==0 */ - WORD wReserved; /* If neither applies, set to zero. */ - } Samples; - DWORD dwChannelMask; /* which channels are */ - /* present in stream */ - GUID SubFormat; -} WAVEFORMATEXTENSIBLE, *PWAVEFORMATEXTENSIBLE; - -#endif // !_WAVEFORMATEXTENSIBLE_ - -#if !defined(WAVE_FORMAT_EXTENSIBLE) -#define WAVE_FORMAT_EXTENSIBLE 0xFFFE -#endif // !defined(WAVE_FORMAT_EXTENSIBLE) - // Use inline assembly at all #define ENABLE_ASM @@ -112,7 +87,7 @@ // Define to build without MO3 support. //#define NO_MO3_SUPPORT - + // Define to build without DirectSound support. //#define NO_DSOUND Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-04-02 17:39:47 UTC (rev 1703) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-04-02 18:00:27 UTC (rev 1704) @@ -1595,11 +1595,9 @@ m_WaveFile.m_nInstruments = 1; m_WaveFile.m_nTempoMode = tempo_mode_classic; m_WaveFile.m_nMixLevels = mixLevels_compatible; - m_WaveFile.Order.resize(2); + m_WaveFile.Order.resize(1); m_WaveFile.Order[0] = 0; - m_WaveFile.Order[1] = 1; m_WaveFile.Patterns.Insert(0, 64); - m_WaveFile.Patterns.Insert(1, 1); } @@ -1625,14 +1623,10 @@ m[63 * 4].note = NOTE_NOTECUT; m[63 * 4 + 1].note = NOTE_NOTECUT; } + m[63 * 4 + 2].command = CMD_POSITIONJUMP; + m[63 * 4 + 3].command = CMD_PATTERNBREAK; + m[63 * 4 + 3].param = 63; } - - m = m_WaveFile.Patterns[1]; - if(m) - { - m->command = CMD_POSITIONJUMP; - m->param = 1; - } } Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-04-02 17:39:47 UTC (rev 1703) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-04-02 18:00:27 UTC (rev 1704) @@ -518,24 +518,28 @@ bool CModDoc::SaveInstrument(INSTRUMENTINDEX instr) //------------------------------------------------- { + bool success = false; if(instr > 0 && instr <= GetNumInstruments()) { instr--; if(!m_SndFile.m_szInstrumentPath[instr].empty()) { const size_t len = m_SndFile.m_szInstrumentPath[instr].length(); - const bool iti = _stricmp(&m_SndFile.m_szInstrumentPath[instr][len - 3], "iti") == 0; - const bool xi = _stricmp(&m_SndFile.m_szInstrumentPath[instr][len - 2], "xi") == 0; + const bool iti = !_stricmp(&m_SndFile.m_szInstrumentPath[instr][len - 3], "iti"); + const bool xi = !_stricmp(&m_SndFile.m_szInstrumentPath[instr][len - 2], "xi"); - if(iti || (!iti && !xi && m_SndFile.GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT))) - m_SndFile.SaveITIInstrument(instr + 1, m_SndFile.m_szInstrumentPath[instr], false); - if(xi || (!xi && !iti && m_SndFile.GetType() == MOD_TYPE_XM)) - m_SndFile.SaveXIInstrument(instr + 1, m_SndFile.m_szInstrumentPath[instr]); - m_bsInstrumentModified.reset(instr); - return true; + if(iti || (!xi && m_SndFile.GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT))) + success = m_SndFile.SaveITIInstrument(instr + 1, m_SndFile.m_szInstrumentPath[instr], false); + else + success = m_SndFile.SaveXIInstrument(instr + 1, m_SndFile.m_szInstrumentPath[instr]); + + if(success) + m_bsInstrumentModified.reset(instr); + else + Reporting::Error(("Error while saving\n" + m_SndFile.m_szInstrumentPath[instr] + "!").c_str()); } } - return false; + return success; } // -! NEW_FEATURE#0023 Modified: trunk/OpenMPT/mptrack/View_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_ins.cpp 2013-04-02 17:39:47 UTC (rev 1703) +++ trunk/OpenMPT/mptrack/View_ins.cpp 2013-04-02 18:00:27 UTC (rev 1704) @@ -2158,8 +2158,8 @@ CSoundFile* pSndFile = (pModDoc) ? pModDoc->GetSoundFile() : nullptr; if(!pSndFile) return 0; - const BYTE nNote = midiByte1 + NOTE_MIN; - int nVol = midiByte2; + uint8 nNote = midiByte1 + NOTE_MIN; + int nVol = midiByte2; MIDIEvents::EventType event = MIDIEvents::GetTypeFromEvent(dwMidiData); if((event == MIDIEvents::evNoteOn) && !nVol) event = MIDIEvents::evNoteOff; //Convert event to note-off if req'd @@ -2188,8 +2188,9 @@ midiByte2 = 0; case MIDIEvents::evNoteOn: // Note On + LimitMax(nNote, NOTE_MAX); pModDoc->NoteOff(nNote, false, m_nInstrument); - if (midiByte2 & 0x7F) + if(midiByte2 & 0x7F) { nVol = CMainFrame::ApplyVolumeRelatedSettings(dwMidiData, midivolume); pModDoc->PlayNote(nNote, m_nInstrument, 0, false, nVol); Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2013-04-02 17:39:47 UTC (rev 1703) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2013-04-02 18:00:27 UTC (rev 1704) @@ -4702,6 +4702,11 @@ } CSoundFile &sndFile = pModDoc->GetrSoundFile(); + if(note < NOTE_MIN_SPECIAL) + { + Limit(note, sndFile.GetModSpecifications().noteMin, sndFile.GetModSpecifications().noteMax); + } + const bool liveRecord = IsLiveRecord(); const bool isSplit = IsNoteSplit(note); UINT ins = 0; Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2013-04-02 17:39:47 UTC (rev 1703) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2013-04-02 18:00:27 UTC (rev 1704) @@ -2621,7 +2621,7 @@ CSoundFile* pSndFile = (pModDoc) ? pModDoc->GetSoundFile() : NULL; if (!pSndFile) return 0; - const BYTE nNote = midibyte1 + NOTE_MIN; + uint8 nNote = midibyte1 + NOTE_MIN; int nVol = midibyte2; MIDIEvents::EventType event = MIDIEvents::GetTypeFromEvent(dwMidiData); if(event == MIDIEvents::evNoteOn && !nVol) @@ -2644,6 +2644,7 @@ midibyte2 = 0; case MIDIEvents::evNoteOn: // Note On + LimitMax(nNote, NOTE_MAX); pModDoc->NoteOff(nNote, true); if(midibyte2 & 0x7F) { Modified: trunk/OpenMPT/soundlib/Snd_rvb.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_rvb.cpp 2013-04-02 17:39:47 UTC (rev 1703) +++ trunk/OpenMPT/soundlib/Snd_rvb.cpp 2013-04-02 18:00:27 UTC (rev 1704) @@ -1054,33 +1054,3 @@ } return fresult; } - - -//#define _ASM_MATH -#ifdef _ASM_MATH - -// pow(a,b) returns a^^b -> 2^^(b.log2(a)) -static float pow(float a, float b) -{ - long tmpint; - float result; - _asm { - fld b // Load b - fld a // Load a - fyl2x // ST(0) = b.log2(a) - fist tmpint // Store integer exponent - fisub tmpint // ST(0) = -1 <= (b*log2(a)) <= 1 - f2xm1 // ST(0) = 2^(x)-1 - fild tmpint // load integer exponent - fld1 // Load 1 - fscale // ST(0) = 2^ST(1) - fstp ST(1) // Remove the integer from the stack - fmul ST(1), ST(0) // multiply with fractional part - faddp ST(1), ST(0) // add integer_part - fstp result // Store the result - } - return result; -} -#else -#include <math.h> -#endif // _ASM_MATH This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-04-02 19:04:53
|
Revision: 1708 http://sourceforge.net/p/modplug/code/1708 Author: manxorist Date: 2013-04-02 19:04:41 +0000 (Tue, 02 Apr 2013) Log Message: ----------- [Ref] Make NO_REVERB actually remove all reverb related code. Modified Paths: -------------- trunk/OpenMPT/common/stdafx.h trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/soundlib/Snd_rvb.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/snd_rvb.h Modified: trunk/OpenMPT/common/stdafx.h =================================================================== --- trunk/OpenMPT/common/stdafx.h 2013-04-02 18:45:11 UTC (rev 1707) +++ trunk/OpenMPT/common/stdafx.h 2013-04-02 19:04:41 UTC (rev 1708) @@ -70,6 +70,9 @@ #endif // ENABLE_ASM +// Disable the built-in reverb effect +//#define NO_REVERB + // Disable built-in miscellaneous DSP effects (surround, mega bass, noise reduction) //#define NO_DSP Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-04-02 18:45:11 UTC (rev 1707) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-04-02 19:04:41 UTC (rev 1708) @@ -534,6 +534,8 @@ m_SbXBassDepth.ShowWindow(SW_HIDE); m_SbXBassRange.ShowWindow(SW_HIDE); #endif + +#ifndef NO_REVERB // Reverb m_SbReverbDepth.SetRange(1, 16); m_SbReverbDepth.SetPos(CSoundFile::m_nReverbDepth); @@ -558,6 +560,12 @@ { if (dwQuality & QUALITY_REVERB) CheckDlgButton(IDC_CHECK6, MF_CHECKED); } +#else + GetDlgItem(IDC_CHECK6)->ShowWindow(SW_HIDE); + m_SbReverbDepth.ShowWindow(SW_HIDE); + m_CbnReverbPreset.ShowWindow(SW_HIDE); +#endif + #ifndef NO_DSP // Surround { @@ -600,13 +608,15 @@ //----------------------------------------------------------------- { if (nSBCode == SB_ENDSCROLL) return; - UINT n = m_SbReverbDepth.GetPos(); if ((psb) && (psb->m_hWnd == m_SbReverbDepth.m_hWnd)) { +#ifndef NO_REVERB + UINT n = m_SbReverbDepth.GetPos(); if (n != CSoundFile::m_nReverbDepth) { if ((n) && (n <= 16)) CSoundFile::m_nReverbDepth = n; } +#endif } else { OnSettingsChanged(); @@ -709,12 +719,14 @@ CSoundFile::m_DSP.m_Settings.m_nXBassRange = nXBassRange; } #endif +#ifndef NO_REVERB // Reverb { // Reverb depth is dynamically changed UINT nReverbType = m_CbnReverbPreset.GetItemData(m_CbnReverbPreset.GetCurSel()); if (nReverbType < NUM_REVERBTYPES) CSoundFile::gnReverbType = nReverbType; } +#endif #ifndef NO_DSP // Surround { Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-04-02 18:45:11 UTC (rev 1707) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-04-02 19:04:41 UTC (rev 1708) @@ -422,8 +422,10 @@ CSoundFile::m_DSP.m_Settings.m_nXBassDepth = CMainFrame::GetPrivateProfileLong("Effects", "XBassDepth", CSoundFile::m_DSP.m_Settings.m_nXBassDepth, iniFile); CSoundFile::m_DSP.m_Settings.m_nXBassRange = CMainFrame::GetPrivateProfileLong("Effects", "XBassRange", CSoundFile::m_DSP.m_Settings.m_nXBassRange, iniFile); #endif +#ifndef NO_REVERB CSoundFile::m_nReverbDepth = CMainFrame::GetPrivateProfileLong("Effects", "ReverbDepth", CSoundFile::m_nReverbDepth, iniFile); CSoundFile::gnReverbType = CMainFrame::GetPrivateProfileLong("Effects", "ReverbType", CSoundFile::gnReverbType, iniFile); +#endif #ifndef NO_DSP CSoundFile::m_DSP.m_Settings.m_nProLogicDepth = CMainFrame::GetPrivateProfileLong("Effects", "ProLogicDepth", CSoundFile::m_DSP.m_Settings.m_nProLogicDepth, iniFile); CSoundFile::m_DSP.m_Settings.m_nProLogicDelay = CMainFrame::GetPrivateProfileLong("Effects", "ProLogicDelay", CSoundFile::m_DSP.m_Settings.m_nProLogicDelay, iniFile); @@ -573,8 +575,10 @@ RegQueryValueEx(key, "XBassDepth", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_DSP.m_Settings.m_nXBassDepth, &dwDWORDSize); RegQueryValueEx(key, "XBassRange", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_DSP.m_Settings.m_nXBassRange, &dwDWORDSize); #endif +#ifndef NO_REVERB RegQueryValueEx(key, "ReverbDepth", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_nReverbDepth, &dwDWORDSize); RegQueryValueEx(key, "ReverbType", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::gnReverbType, &dwDWORDSize); +#endif NO_REVERB #ifndef NO_DSP RegQueryValueEx(key, "ProLogicDepth", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_DSP.m_Settings.m_nProLogicDepth, &dwDWORDSize); RegQueryValueEx(key, "ProLogicDelay", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_DSP.m_Settings.m_nProLogicDelay, &dwDWORDSize); @@ -796,8 +800,10 @@ CMainFrame::WritePrivateProfileLong("Effects", "XBassDepth", CSoundFile::m_DSP.m_Settings.m_nXBassDepth, iniFile); CMainFrame::WritePrivateProfileLong("Effects", "XBassRange", CSoundFile::m_DSP.m_Settings.m_nXBassRange, iniFile); #endif +#ifndef NO_REVERB CMainFrame::WritePrivateProfileLong("Effects", "ReverbDepth", CSoundFile::m_nReverbDepth, iniFile); CMainFrame::WritePrivateProfileLong("Effects", "ReverbType", CSoundFile::gnReverbType, iniFile); +#endif #ifndef NO_DSP CMainFrame::WritePrivateProfileLong("Effects", "ProLogicDepth", CSoundFile::m_DSP.m_Settings.m_nProLogicDepth, iniFile); CMainFrame::WritePrivateProfileLong("Effects", "ProLogicDelay", CSoundFile::m_DSP.m_Settings.m_nProLogicDelay, iniFile); Modified: trunk/OpenMPT/soundlib/Snd_rvb.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_rvb.cpp 2013-04-02 18:45:11 UTC (rev 1707) +++ trunk/OpenMPT/soundlib/Snd_rvb.cpp 2013-04-02 19:04:41 UTC (rev 1708) @@ -13,6 +13,8 @@ #include "sndfile.h" #include "snd_rvb.h" +#ifndef NO_REVERB + #pragma warning(disable:4725) // Pentium fdiv bug #pragma warning(disable:4731) // ebp modified @@ -1054,3 +1056,5 @@ } return fresult; } + +#endif // NO_REVERB Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-04-02 18:45:11 UTC (rev 1707) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-04-02 19:04:41 UTC (rev 1708) @@ -244,7 +244,9 @@ #ifndef NO_AGC static CAGC m_AGC; #endif +#ifndef NO_REVERB static UINT m_nReverbDepth, gnReverbType; +#endif static UINT m_nStereoSeparation; static UINT m_nMaxMixChannels; static DWORD gdwSysInfo, gdwSoundSetup, gdwMixingFreq, gnBitsPerSample, gnChannels; Modified: trunk/OpenMPT/soundlib/snd_rvb.h =================================================================== --- trunk/OpenMPT/soundlib/snd_rvb.h 2013-04-02 18:45:11 UTC (rev 1707) +++ trunk/OpenMPT/soundlib/snd_rvb.h 2013-04-02 19:04:41 UTC (rev 1708) @@ -10,6 +10,8 @@ #pragma once +#ifndef NO_REVERB + ///////////////////////////////////////////////////////////////////////////// // // SW Reverb structures @@ -197,3 +199,4 @@ #define SNDMIX_REVERB_PRESET_PLATE \ -1000, -200, 1.30f,0.90f, 0,0.002f, 0,0.010f,100.0f, 75.0f +#endif // NO_REVERB This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-04-02 20:17:42
|
Revision: 1712 http://sourceforge.net/p/modplug/code/1712 Author: manxorist Date: 2013-04-02 20:17:31 +0000 (Tue, 02 Apr 2013) Log Message: ----------- [Ref] Move all reverb related data into class CReverb. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/soundlib/Fastmix.cpp trunk/OpenMPT/soundlib/Snd_rvb.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp trunk/OpenMPT/soundlib/snd_rvb.h Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-04-02 19:30:32 UTC (rev 1711) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-04-02 20:17:31 UTC (rev 1712) @@ -538,7 +538,7 @@ #ifndef NO_REVERB // Reverb m_SbReverbDepth.SetRange(1, 16); - m_SbReverbDepth.SetPos(CSoundFile::m_nReverbDepth); + m_SbReverbDepth.SetPos(CSoundFile::m_Reverb.m_Settings.m_nReverbDepth); UINT nSel = 0; for (UINT iRvb=0; iRvb<NUM_REVERBTYPES; iRvb++) { @@ -547,7 +547,7 @@ { UINT n = m_CbnReverbPreset.AddString(pszName); m_CbnReverbPreset.SetItemData(n, iRvb); - if (iRvb == CSoundFile::gnReverbType) nSel = n; + if (iRvb == CSoundFile::m_Reverb.m_Settings.m_nReverbType) nSel = n; } } m_CbnReverbPreset.SetCurSel(nSel); @@ -612,9 +612,9 @@ { #ifndef NO_REVERB UINT n = m_SbReverbDepth.GetPos(); - if (n != CSoundFile::m_nReverbDepth) + if (n != CSoundFile::m_Reverb.m_Settings.m_nReverbDepth) { - if ((n) && (n <= 16)) CSoundFile::m_nReverbDepth = n; + if ((n) && (n <= 16)) CSoundFile::m_Reverb.m_Settings.m_nReverbDepth = n; } #endif } else @@ -724,7 +724,7 @@ { // Reverb depth is dynamically changed UINT nReverbType = m_CbnReverbPreset.GetItemData(m_CbnReverbPreset.GetCurSel()); - if (nReverbType < NUM_REVERBTYPES) CSoundFile::gnReverbType = nReverbType; + if (nReverbType < NUM_REVERBTYPES) CSoundFile::m_Reverb.m_Settings.m_nReverbType = nReverbType; } #endif #ifndef NO_DSP Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-04-02 19:30:32 UTC (rev 1711) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-04-02 20:17:31 UTC (rev 1712) @@ -423,8 +423,8 @@ CSoundFile::m_DSP.m_Settings.m_nXBassRange = CMainFrame::GetPrivateProfileLong("Effects", "XBassRange", CSoundFile::m_DSP.m_Settings.m_nXBassRange, iniFile); #endif #ifndef NO_REVERB - CSoundFile::m_nReverbDepth = CMainFrame::GetPrivateProfileLong("Effects", "ReverbDepth", CSoundFile::m_nReverbDepth, iniFile); - CSoundFile::gnReverbType = CMainFrame::GetPrivateProfileLong("Effects", "ReverbType", CSoundFile::gnReverbType, iniFile); + CSoundFile::m_Reverb.m_Settings.m_nReverbDepth = CMainFrame::GetPrivateProfileLong("Effects", "ReverbDepth", CSoundFile::m_Reverb.m_Settings.m_nReverbDepth, iniFile); + CSoundFile::m_Reverb.m_Settings.m_nReverbType = CMainFrame::GetPrivateProfileLong("Effects", "ReverbType", CSoundFile::m_Reverb.m_Settings.m_nReverbType, iniFile); #endif #ifndef NO_DSP CSoundFile::m_DSP.m_Settings.m_nProLogicDepth = CMainFrame::GetPrivateProfileLong("Effects", "ProLogicDepth", CSoundFile::m_DSP.m_Settings.m_nProLogicDepth, iniFile); @@ -576,8 +576,8 @@ RegQueryValueEx(key, "XBassRange", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_DSP.m_Settings.m_nXBassRange, &dwDWORDSize); #endif #ifndef NO_REVERB - RegQueryValueEx(key, "ReverbDepth", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_nReverbDepth, &dwDWORDSize); - RegQueryValueEx(key, "ReverbType", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::gnReverbType, &dwDWORDSize); + RegQueryValueEx(key, "ReverbDepth", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_Reverb.m_Settings.m_nReverbDepth, &dwDWORDSize); + RegQueryValueEx(key, "ReverbType", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_Reverb.m_Settings.m_nReverbType, &dwDWORDSize); #endif NO_REVERB #ifndef NO_DSP RegQueryValueEx(key, "ProLogicDepth", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_DSP.m_Settings.m_nProLogicDepth, &dwDWORDSize); @@ -801,8 +801,8 @@ CMainFrame::WritePrivateProfileLong("Effects", "XBassRange", CSoundFile::m_DSP.m_Settings.m_nXBassRange, iniFile); #endif #ifndef NO_REVERB - CMainFrame::WritePrivateProfileLong("Effects", "ReverbDepth", CSoundFile::m_nReverbDepth, iniFile); - CMainFrame::WritePrivateProfileLong("Effects", "ReverbType", CSoundFile::gnReverbType, iniFile); + CMainFrame::WritePrivateProfileLong("Effects", "ReverbDepth", CSoundFile::m_Reverb.m_Settings.m_nReverbDepth, iniFile); + CMainFrame::WritePrivateProfileLong("Effects", "ReverbType", CSoundFile::m_Reverb.m_Settings.m_nReverbType, iniFile); #endif #ifndef NO_DSP CMainFrame::WritePrivateProfileLong("Effects", "ProLogicDepth", CSoundFile::m_DSP.m_Settings.m_nProLogicDepth, iniFile); Modified: trunk/OpenMPT/soundlib/Fastmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Fastmix.cpp 2013-04-02 19:30:32 UTC (rev 1711) +++ trunk/OpenMPT/soundlib/Fastmix.cpp 2013-04-02 20:17:31 UTC (rev 1712) @@ -29,15 +29,10 @@ float MixFloatBuffer[MIXBUFFERSIZE * 2]; -#ifndef NO_REVERB -extern UINT gnReverbSend; -#endif - extern LONG gnDryROfsVol; extern LONG gnDryLOfsVol; -extern LONG gnRvbROfsVol; -extern LONG gnRvbLOfsVol; + // 4x256 taps polyphase FIR resampling filter extern short int gFastSinc[]; extern short int gKaiserSinc[]; // 8-taps polyphase @@ -1546,13 +1541,13 @@ #ifndef NO_REVERB if (pbuffer == MixReverbBuffer) { - if (!gnReverbSend) + if (!m_Reverb.gnReverbSend) { - X86_StereoFill(MixReverbBuffer, count, &gnRvbROfsVol, &gnRvbLOfsVol); + X86_StereoFill(MixReverbBuffer, count, &m_Reverb.gnRvbROfsVol, &m_Reverb.gnRvbLOfsVol); } - gnReverbSend += count; - pOfsR = &gnRvbROfsVol; - pOfsL = &gnRvbLOfsVol; + m_Reverb.gnReverbSend += count; + pOfsR = &m_Reverb.gnRvbROfsVol; + pOfsL = &m_Reverb.gnRvbLOfsVol; } #endif bSurround = (pbuffer == MixRearBuffer); Modified: trunk/OpenMPT/soundlib/Snd_rvb.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_rvb.cpp 2013-04-02 19:30:32 UTC (rev 1711) +++ trunk/OpenMPT/soundlib/Snd_rvb.cpp 2013-04-02 20:17:31 UTC (rev 1712) @@ -18,43 +18,52 @@ #pragma warning(disable:4725) // Pentium fdiv bug #pragma warning(disable:4731) // ebp modified -extern int MixReverbBuffer[MIXBUFFERSIZE * 2]; -extern int MixSoundBuffer[MIXBUFFERSIZE * 4]; - extern VOID MPPASMCALL X86_StereoFill(int *pBuffer, UINT nSamples, LPLONG lpROfs, LPLONG lpLOfs); -// Reverb mix buffers -static SWRVBREFDELAY g_RefDelay; -static SWLATEREVERB g_LateReverb; -// Shared reverb state -UINT gnReverbSamples = 0; -UINT gnReverbDecaySamples = 0; -UINT gnReverbSend = 0; -LONG gnRvbROfsVol = 0; -LONG gnRvbLOfsVol = 0; -UINT CSoundFile::gnReverbType = 0; -UINT CSoundFile::m_nReverbDepth = 8; // 50% +CReverbSettings::CReverbSettings() +//-------------------------------- +{ + m_nReverbType = 0; + m_nReverbDepth = 8; // 50% +} -// Internal reverb state -static BOOL g_bLastInPresent = 0; -static BOOL g_bLastOutPresent = 0; -static int g_nLastRvbIn_xl = 0; -static int g_nLastRvbIn_xr = 0; -static int g_nLastRvbIn_yl = 0; -static int g_nLastRvbIn_yr = 0; -static int g_nLastRvbOut_xl = 0; -static int g_nLastRvbOut_xr = 0; -static __int64 gnDCRRvb_Y1 = 0; -static __int64 gnDCRRvb_X1 = 0; +CReverb::CReverb() +//---------------- +{ + // Shared reverb state + gnReverbSamples = 0; + gnReverbDecaySamples = 0; + gnReverbSend = 0; + gnRvbROfsVol = 0; + gnRvbLOfsVol = 0; + + // Internal reverb state + g_bLastInPresent = 0; + g_bLastOutPresent = 0; + g_nLastRvbIn_xl = 0; + g_nLastRvbIn_xr = 0; + g_nLastRvbIn_yl = 0; + g_nLastRvbIn_yr = 0; + g_nLastRvbOut_xl = 0; + g_nLastRvbOut_xr = 0; + gnDCRRvb_Y1 = 0; + gnDCRRvb_X1 = 0; + + // Reverb mix buffers + MemsetZero(g_RefDelay); + MemsetZero(g_LateReverb); + +} + + // Misc functions -LONG OnePoleLowPassCoef(LONG scale, FLOAT g, FLOAT F_c, FLOAT F_s); -LONG mBToLinear(LONG scale, LONG value_mB); -FLOAT mBToLinear(LONG value_mB); -FLOAT pow(FLOAT a, FLOAT b); +static LONG OnePoleLowPassCoef(LONG scale, FLOAT g, FLOAT F_c, FLOAT F_s); +static LONG mBToLinear(LONG scale, LONG value_mB); +static FLOAT mBToLinear(LONG value_mB); typedef struct _SNDMIX_RVBPRESET { @@ -220,8 +229,8 @@ } -void ReverbShutdown() -//------------------- +void CReverb::Shutdown() +//---------------------- { // Clear out all reverb state g_bLastInPresent = FALSE; @@ -243,17 +252,17 @@ } -VOID InitializeReverb(BOOL bReset) -//-------------------------------- +void CReverb::Initialize(BOOL bReset, DWORD MixingFreq) +//----------------------------------------------------- { - if (CSoundFile::gnReverbType >= NUM_REVERBTYPES) CSoundFile::gnReverbType = 0; + if (m_Settings.m_nReverbType >= NUM_REVERBTYPES) m_Settings.m_nReverbType = 0; static PSNDMIX_REVERB_PROPERTIES spCurrentPreset = NULL; - PSNDMIX_REVERB_PROPERTIES pRvbPreset = &gRvbPresets[CSoundFile::gnReverbType].Preset; + PSNDMIX_REVERB_PROPERTIES pRvbPreset = &gRvbPresets[m_Settings.m_nReverbType].Preset; if ((pRvbPreset != spCurrentPreset) || (bReset)) { // Reverb output frequency is half of the dry output rate - FLOAT flOutputFrequency = (FLOAT)CSoundFile::gdwMixingFreq; + FLOAT flOutputFrequency = (FLOAT)MixingFreq; ENVIRONMENTREVERB rvb; // Reset reverb parameters @@ -345,33 +354,33 @@ if (bReset) { gnReverbSamples = 0; - ReverbShutdown(); + Shutdown(); } // Wait at least 5 seconds before shutting down the reverb - if (gnReverbDecaySamples < CSoundFile::gdwMixingFreq*5) + if (gnReverbDecaySamples < MixingFreq*5) { - gnReverbDecaySamples = CSoundFile::gdwMixingFreq*5; + gnReverbDecaySamples = MixingFreq*5; } } // [Reverb level 0(quiet)-100(loud)], [type = REVERBTYPE_XXXX] -BOOL CSoundFile::SetReverbParameters(UINT nDepth, UINT nType) -//----------------------------------------------------------- +bool CReverb::SetReverbParameters(UINT nDepth, UINT nType) +//-------------------------------------------------------- { if (nDepth > 100) nDepth = 100; UINT gain = (nDepth * 16) / 100; if (gain > 16) gain = 16; if (gain < 1) gain = 1; - m_nReverbDepth = gain; - if (nType < NUM_REVERBTYPES) gnReverbType = nType; - return TRUE; + m_Settings.m_nReverbDepth = gain; + if (nType < NUM_REVERBTYPES) m_Settings.m_nReverbType = nType; + return true; } // Reverb -VOID ProcessReverb(UINT nSamples) -//------------------------------- +void CReverb::Process(int *MixSoundBuffer, int *MixReverbBuffer, UINT nSamples) +//----------------------------------------------------------------------------- { UINT nIn, nOut; @@ -380,11 +389,11 @@ if (!(CSoundFile::gdwSysInfo & SYSMIX_ENABLEMMX)) return; // Dynamically adjust reverb master gains LONG lMasterGain; - lMasterGain = ((g_RefDelay.lMasterGain * CSoundFile::m_nReverbDepth) >> 4); + lMasterGain = ((g_RefDelay.lMasterGain * m_Settings.m_nReverbDepth) >> 4); if (lMasterGain > 0x7fff) lMasterGain = 0x7fff; g_RefDelay.ReflectionsGain[0] = (SHORT)lMasterGain; g_RefDelay.ReflectionsGain[1] = (SHORT)lMasterGain; - lMasterGain = ((g_LateReverb.lMasterGain * CSoundFile::m_nReverbDepth) >> 4); + lMasterGain = ((g_LateReverb.lMasterGain * m_Settings.m_nReverbDepth) >> 4); if (lMasterGain > 0x10000) lMasterGain = 0x10000; g_LateReverb.RvbOutGains[0] = (SHORT)((lMasterGain+0x7f) >> 3); // l->l g_LateReverb.RvbOutGains[1] = (SHORT)((lMasterGain+0xff) >> 4); // r->l @@ -393,7 +402,7 @@ // Process Dry/Wet Mix LONG lMaxRvbGain = (g_RefDelay.lMasterGain > g_LateReverb.lMasterGain) ? g_RefDelay.lMasterGain : g_LateReverb.lMasterGain; if (lMaxRvbGain > 32768) lMaxRvbGain = 32768; - LONG lDryVol = (36 - CSoundFile::m_nReverbDepth)>>1; + LONG lDryVol = (36 - m_Settings.m_nReverbDepth)>>1; if (lDryVol < 8) lDryVol = 8; if (lDryVol > 16) lDryVol = 16; lDryVol = 16 - (((16-lDryVol) * lMaxRvbGain) >> 15); @@ -437,14 +446,14 @@ else if (gnReverbSamples > nSamples) gnReverbSamples -= nSamples; else { - if (gnReverbSamples) ReverbShutdown(); + if (gnReverbSamples) Shutdown(); gnReverbSamples = 0; } } -VOID X86_ReverbDryMix(int *pDry, int *pWet, int lDryVol, UINT nSamples) -//--------------------------------------------------------------------- +VOID CReverb::X86_ReverbDryMix(int *pDry, int *pWet, int lDryVol, UINT nSamples) +//------------------------------------------------------------------------------ { for (UINT i=0; i<nSamples; i++) { @@ -454,8 +463,8 @@ } -UINT X86_ReverbProcessPreFiltering2x(int *pWet, UINT nSamples) -//------------------------------------------------------------ +UINT CReverb::X86_ReverbProcessPreFiltering2x(int *pWet, UINT nSamples) +//--------------------------------------------------------------------- { UINT nOutSamples = 0; int lowpass = g_RefDelay.nCoeffs[0]; @@ -504,8 +513,8 @@ } -UINT X86_ReverbProcessPreFiltering1x(int *pWet, UINT nSamples) -//------------------------------------------------------------ +UINT CReverb::X86_ReverbProcessPreFiltering1x(int *pWet, UINT nSamples) +//--------------------------------------------------------------------- { int lowpass = g_RefDelay.nCoeffs[0]; int y1_l = g_nLastRvbIn_yl, y1_r = g_nLastRvbIn_yr; @@ -525,8 +534,8 @@ } -VOID X86_ReverbProcessPostFiltering2x(const int *pRvb, int *pDry, UINT nSamples) -//------------------------------------------------------------------------------ +VOID CReverb::X86_ReverbProcessPostFiltering2x(const int *pRvb, int *pDry, UINT nSamples) +//--------------------------------------------------------------------------------------- { UINT n0 = nSamples, n; int x1_l = g_nLastRvbOut_xl, x1_r = g_nLastRvbOut_xr; @@ -567,12 +576,14 @@ #define DCR_AMOUNT 9 // Stereo Add + DC removal -VOID MMX_ReverbProcessPostFiltering1x(const int *pRvb, int *pDry, UINT nSamples) -//------------------------------------------------------------------------------ +VOID CReverb::MMX_ReverbProcessPostFiltering1x(const int *pRvb, int *pDry, UINT nSamples) +//--------------------------------------------------------------------------------------- { + __int64 nDCRRvb_X1 = gnDCRRvb_X1; + __int64 nDCRRvb_Y1 = gnDCRRvb_Y1; _asm { - movq mm4, gnDCRRvb_Y1 // mm4 = [ y1r | y1l ] - movq mm1, gnDCRRvb_X1 // mm5 = [ x1r | x1l ] + movq mm4, nDCRRvb_Y1 // mm4 = [ y1r | y1l ] + movq mm1, nDCRRvb_X1 // mm5 = [ x1r | x1l ] mov ebx, pDry mov ecx, pRvb mov edx, nSamples @@ -594,19 +605,23 @@ psubd mm4, mm0 movq qword ptr [ebx-8], mm3 jnz stereodcr - movq gnDCRRvb_Y1, mm4 - movq gnDCRRvb_X1, mm5 + movq nDCRRvb_Y1, mm4 + movq nDCRRvb_X1, mm5 emms } + gnDCRRvb_X1 = nDCRRvb_X1; + gnDCRRvb_Y1 = nDCRRvb_Y1; } -VOID MMX_ReverbDCRemoval(int *pBuffer, UINT nSamples) -//--------------------------------------------------- +VOID CReverb::MMX_ReverbDCRemoval(int *pBuffer, UINT nSamples) +//------------------------------------------------------------ { + __int64 nDCRRvb_X1 = gnDCRRvb_X1; + __int64 nDCRRvb_Y1 = gnDCRRvb_Y1; _asm { - movq mm4, gnDCRRvb_Y1 // mm4 = [ y1r | y1l ] - movq mm1, gnDCRRvb_X1 // mm5 = [ x1r | x1l ] + movq mm4, nDCRRvb_Y1 // mm4 = [ y1r | y1l ] + movq mm1, nDCRRvb_X1 // mm5 = [ x1r | x1l ] mov ecx, pBuffer mov edx, nSamples stereodcr: @@ -624,10 +639,12 @@ movq mm1, mm5 psubd mm4, mm0 jnz stereodcr - movq gnDCRRvb_Y1, mm4 - movq gnDCRRvb_X1, mm5 + movq nDCRRvb_Y1, mm4 + movq nDCRRvb_X1, mm5 emms } + gnDCRRvb_X1 = nDCRRvb_X1; + gnDCRRvb_Y1 = nDCRRvb_Y1; } @@ -640,8 +657,8 @@ // 3. Insert the result in the reflections delay buffer // -VOID MMX_ProcessPreDelay(PSWRVBREFDELAY pPreDelay, const int *pIn, UINT nSamples) -//------------------------------------------------------------------------------- +VOID CReverb::MMX_ProcessPreDelay(PSWRVBREFDELAY pPreDelay, const int *pIn, UINT nSamples) +//---------------------------------------------------------------------------------------- { _asm { mov eax, pPreDelay @@ -714,8 +731,8 @@ } DUMMYREFARRAY, *PDUMMYREFARRAY; -VOID MMX_ProcessReflections(PSWRVBREFDELAY pPreDelay, short int *pRefOut, int *pOut, UINT nSamples) -//------------------------------------------------------------------------------------------------- +VOID CReverb::MMX_ProcessReflections(PSWRVBREFDELAY pPreDelay, short int *pRefOut, int *pOut, UINT nSamples) +//---------------------------------------------------------------------------------------------------------- { _asm { // First stage @@ -840,7 +857,8 @@ // Late reverberation (with SW reflections) // -VOID MMX_ProcessLateReverb(PSWLATEREVERB pReverb, short int *pRefOut, int *pMixOut, UINT nSamples) +VOID CReverb::MMX_ProcessLateReverb(PSWLATEREVERB pReverb, short int *pRefOut, int *pMixOut, UINT nSamples) +//--------------------------------------------------------------------------------------------------------- { _asm { push ebp @@ -949,7 +967,7 @@ // (1-gcos(w)-sqrt(2g(1-cos w) - g2(1-(cos w)^2))) / (1-g) -LONG OnePoleLowPassCoef(LONG scale, FLOAT g, FLOAT F_c, FLOAT F_s) +static LONG OnePoleLowPassCoef(LONG scale, FLOAT g, FLOAT F_c, FLOAT F_s) //---------------------------------------------------------------- { FLOAT cosw; // cos(2*PI*Fc/Fs) @@ -1003,7 +1021,7 @@ } -LONG mBToLinear(LONG scale, LONG value_mB) +static LONG mBToLinear(LONG scale, LONG value_mB) { // factor = log2(10)/(100*20) const float _factor = 3.321928094887362304f / (100.0f * 20.0f); @@ -1030,7 +1048,7 @@ } -FLOAT mBToLinear(LONG value_mB) +static FLOAT mBToLinear(LONG value_mB) { // factor = log2(10)/(100*20) const float _factor = 3.321928094887362304f / (100.0f * 20.0f); Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-04-02 19:30:32 UTC (rev 1711) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-04-02 20:17:31 UTC (rev 1712) @@ -32,6 +32,7 @@ #include "plugins/PlugInterface.h" #include "RowVisitor.h" +#include "snd_rvb.h" #include "../sounddsp/AGC.h" #include "../sounddsp/DSP.h" #include "../sounddsp/EQ.h" @@ -235,6 +236,9 @@ bool m_bITBidiMode; // Process bidi loops like Impulse Tracker (see Fastmix.cpp for an explanation) public: // Static Members +#ifndef NO_REVERB + static CReverb m_Reverb; +#endif #ifndef NO_DSP static CDSP m_DSP; #endif @@ -244,9 +248,6 @@ #ifndef NO_AGC static CAGC m_AGC; #endif -#ifndef NO_REVERB - static UINT m_nReverbDepth, gnReverbType; -#endif static UINT m_nStereoSeparation; static UINT m_nMaxMixChannels; static DWORD gdwSysInfo, gdwSoundSetup, gdwMixingFreq, gnBitsPerSample, gnChannels; @@ -501,8 +502,6 @@ #ifndef NO_AGC static void SetAGC(BOOL b); #endif - // [Reverb level 0(quiet)-100(loud)], [REVERBTYPE_XXXX] - static BOOL SetReverbParameters(UINT nDepth, UINT nType); #ifndef NO_EQ static void SetEQGains(const UINT *pGains, UINT nBands, const UINT *pFreqs=NULL, BOOL bReset=FALSE) { m_EQ.SetEQGains(pGains, nBands, pFreqs, bReset, gdwMixingFreq); } // 0=-12dB, 32=+12dB #endif // NO_EQ Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-04-02 19:30:32 UTC (rev 1711) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-04-02 20:17:31 UTC (rev 1712) @@ -36,6 +36,9 @@ DWORD CSoundFile::gdwMixingFreq = 44100; DWORD CSoundFile::gnBitsPerSample = 16; // Mixing data initialized in +#ifndef NO_REVERB +CReverb CSoundFile::m_Reverb; +#endif #ifndef NO_DSP CDSP CSoundFile::m_DSP; #endif @@ -73,12 +76,7 @@ extern int MixRearBuffer[MIXBUFFERSIZE * 2]; #ifndef NO_REVERB -extern UINT gnReverbSend; -extern LONG gnRvbROfsVol; -extern LONG gnRvbLOfsVol; - -extern VOID InitializeReverb(BOOL bReset); -extern void ProcessReverb(UINT nSamples); +extern int MixReverbBuffer[MIXBUFFERSIZE * 2]; #endif // Log tables for pre-amp @@ -160,10 +158,10 @@ if (gdwMixingFreq > MAX_SAMPLE_RATE) gdwMixingFreq = MAX_SAMPLE_RATE; gnDryROfsVol = gnDryLOfsVol = 0; #ifndef NO_REVERB - gnRvbROfsVol = gnRvbLOfsVol = 0; + m_Reverb.gnRvbROfsVol = m_Reverb.gnRvbLOfsVol = 0; #endif #ifndef NO_REVERB - InitializeReverb(bReset); + m_Reverb.Initialize(bReset, gdwMixingFreq); #endif #ifndef NO_DSP m_DSP.Initialize(bReset, gdwMixingFreq, gdwSoundSetup); @@ -289,7 +287,7 @@ lSampleCount = lCount; #ifndef NO_REVERB - gnReverbSend = 0; + m_Reverb.gnReverbSend = 0; #endif // NO_REVERB // Resetting sound buffer @@ -302,7 +300,7 @@ m_nMixStat += CreateStereoMix(lCount); #ifndef NO_REVERB - ProcessReverb(lCount); + m_Reverb.Process(MixSoundBuffer, MixReverbBuffer, lCount); #endif // NO_REVERB if (nMaxPlugins) ProcessPlugins(lCount); @@ -317,7 +315,7 @@ m_nMixStat += CreateStereoMix(lCount); #ifndef NO_REVERB - ProcessReverb(lCount); + m_Reverb.Process(MixSoundBuffer, MixReverbBuffer, lCount); #endif // NO_REVERB if (nMaxPlugins) ProcessPlugins(lCount); Modified: trunk/OpenMPT/soundlib/snd_rvb.h =================================================================== --- trunk/OpenMPT/soundlib/snd_rvb.h 2013-04-02 19:30:32 UTC (rev 1711) +++ trunk/OpenMPT/soundlib/snd_rvb.h 2013-04-02 20:17:31 UTC (rev 1712) @@ -106,20 +106,77 @@ } ENVIRONMENTREVERB, *PENVIRONMENTREVERB; -// Pre/Post resampling and filtering -UINT X86_ReverbProcessPreFiltering1x(int *pWet, UINT nSamples); -UINT X86_ReverbProcessPreFiltering2x(int *pWet, UINT nSamples); -VOID MMX_ReverbProcessPostFiltering1x(const int *pRvb, int *pDry, UINT nSamples); -VOID X86_ReverbProcessPostFiltering2x(const int *pRvb, int *pDry, UINT nSamples); -VOID MMX_ReverbDCRemoval(int *pBuffer, UINT nSamples); -VOID X86_ReverbDryMix(int *pDry, int *pWet, int lDryVol, UINT nSamples); -// Process pre-diffusion and pre-delay -VOID MMX_ProcessPreDelay(PSWRVBREFDELAY pPreDelay, const int *pIn, UINT nSamples); -// Process reflections -VOID MMX_ProcessReflections(PSWRVBREFDELAY pPreDelay, short int *pRefOut, int *pMixOut, UINT nSamples); -// Process Late Reverb (SW Reflections): stereo reflections output, 32-bit reverb output, SW reverb gain -VOID MMX_ProcessLateReverb(PSWLATEREVERB pReverb, short int *pRefOut, int *pMixOut, UINT nSamples); +//=================== +class CReverbSettings +//=================== +{ +public: + UINT m_nReverbDepth; + UINT m_nReverbType; +public: + CReverbSettings(); +}; + +//=========== +class CReverb +//=========== +{ +public: + CReverbSettings m_Settings; + + // Shared reverb state + UINT gnReverbSend; + LONG gnRvbROfsVol; + LONG gnRvbLOfsVol; + +private: + + UINT gnReverbSamples; + UINT gnReverbDecaySamples; + + // Internal reverb state + BOOL g_bLastInPresent; + BOOL g_bLastOutPresent; + int g_nLastRvbIn_xl; + int g_nLastRvbIn_xr; + int g_nLastRvbIn_yl; + int g_nLastRvbIn_yr; + int g_nLastRvbOut_xl; + int g_nLastRvbOut_xr; + __int64 gnDCRRvb_Y1; + __int64 gnDCRRvb_X1; + + // Reverb mix buffers + SWRVBREFDELAY g_RefDelay; + SWLATEREVERB g_LateReverb; + +public: + CReverb(); + ~CReverb() {} +public: + void Initialize(BOOL bReset, DWORD MixingFreq); + void Process(int *MixSoundBuffer, int *MixReverbBuffer, UINT nSamples); + // [Reverb level 0(quiet)-100(loud)], [REVERBTYPE_XXXX] + bool SetReverbParameters(UINT nDepth, UINT nType); +private: + void Shutdown(); + // Pre/Post resampling and filtering + UINT X86_ReverbProcessPreFiltering1x(int *pWet, UINT nSamples); + UINT X86_ReverbProcessPreFiltering2x(int *pWet, UINT nSamples); + VOID MMX_ReverbProcessPostFiltering1x(const int *pRvb, int *pDry, UINT nSamples); + VOID X86_ReverbProcessPostFiltering2x(const int *pRvb, int *pDry, UINT nSamples); + VOID MMX_ReverbDCRemoval(int *pBuffer, UINT nSamples); + VOID X86_ReverbDryMix(int *pDry, int *pWet, int lDryVol, UINT nSamples); + // Process pre-diffusion and pre-delay + VOID MMX_ProcessPreDelay(PSWRVBREFDELAY pPreDelay, const int *pIn, UINT nSamples); + // Process reflections + VOID MMX_ProcessReflections(PSWRVBREFDELAY pPreDelay, short int *pRefOut, int *pMixOut, UINT nSamples); + // Process Late Reverb (SW Reflections): stereo reflections output, 32-bit reverb output, SW reverb gain + VOID MMX_ProcessLateReverb(PSWLATEREVERB pReverb, short int *pRefOut, int *pMixOut, UINT nSamples); +}; + + ///////////////////////////////////////////////////////////////////////////////// // // I3DL2 reverb presets @@ -199,4 +256,5 @@ #define SNDMIX_REVERB_PRESET_PLATE \ -1000, -200, 1.30f,0.90f, 0,0.002f, 0,0.010f,100.0f, 75.0f + #endif // NO_REVERB This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-04-03 10:06:46
|
Revision: 1714 http://sourceforge.net/p/modplug/code/1714 Author: manxorist Date: 2013-04-03 10:06:28 +0000 (Wed, 03 Apr 2013) Log Message: ----------- Merge branch snddev-fixes. Merged revision(s) 1606, 1609-1619, 1621, 1627-1628, 1633, 1635-1639, 1643-1648, 1651-1659, 1662-1664, 1670 from branches/manx/snddev-fixes: [Mod] Options Dialog: Changed "buffer length" value into "Latency" (real audio latency) and "Update Interval" (for GUI updates). [Fix] Pattern display no longer lags with high Wave Out latency values. [Ref] Remove SetLastMixActiveTime() which calculated stuff that was used nowhere. [Ref] Remove EnableLowLatencyMode() which did nothing for asio and was most of the time broken for dsound. [Ref] Remove the related nMaxLatency parameter in ISoundDevice::FillAudioBuffer. [Ref] Modify WaveOut code to refill the buffer more often than exactly 3 times. [Ref] Free WaveOut buffers as soon as they are not needed anymore. [Ref] Replace the old configuration variable BufferLength with 2 new ones: Latency=3*BufferLength (Latency=BufferLength for ASIO) and UpdaterInterval=BufferLength/8 which matches the old behaviour as close as possible. [Ref] Sanitize the wakeup intervals of the AudioThread. [Ref] Properly shut down the audio thread. [Ref] Add common/mutex.h with a general mutex implementation in the spirit of c++11. [Ref] Rewrite the NotificationBuffer to use proper syncronization primitives and a fixed size ring buffer to avoid a bunch of possible race conditions and other strange effects. [Ref] Count up the total rendered samples monotonically without ever resetting the counter. [Ref] Properly shut down the notification thread. [Ref] Remove a bunch of now-unused global variables. [Ref] Replace a bunch of m_dwStatus&MODSTATUS_PLAYING tests with IsPlaying(). [Mod] Show actual values used for the sound device in the options dialog. ........ [Ref] Add m_AudioThreadActive flag to signal when the audio thread should do rendering. [Ref] Remove redundant CMainFrame::m_dwStatus and associated MODSTATUS_PLAYING and MODSTATUS_RENDERING. Change the meaning of IsPlaying() while opening the sound device and adapt code to it. [Ref] Also remove redundant CMainFrame::m_pModPlaying. [Ref] Make a bunch of audio and notify thread related variables non-global. ........ [Fix] Fix crash in CMainFrame::PauseMod and CMainFrame::SetAudioThreadActive which was introduced by the CMainFrame::m_dwStatus removal commit. ........ [Ref] Remove CMainFrame::slSampleSize and pass around the amount of audio data in the unit of samples instead of bytes in the ISoundSource interface. [Ref] Change CSoundFile::Read to also take the buffer size in number of samples. The return value had already been in the unit of number of samples anyway. ........ [Ref] Remove pointless fallbacks in CMainFrame::audioOpenDevice when opening the audio device with the chosen settings did not work. ........ [Ref] Remove dwUser parameter in ISoundDevice::FillAudioBuffer. ........ [Ref] Move applying of TrackerSettings to m_pSndFile from function audioTryOpeningDevice, PlayMod and PlaySoundfile to a new function ApplyTrackerSettings. ........ [Fix] Oops, when introducing ApplyTrackerSettings in r1614, an unrelated change slipped in, revert it. ........ [Ref] Rewrite AudioThread to consume no CPU time at all when idle. Only increase the MMTIMER resolution when the thread is nott idling. Terminate it by using an event instead of WM_QUIT so this thread does not need a message queue at all. ........ [Ref] Remove unused m_RefCount in ISoundDevice. [Ref] Let CreateSoundDevice() return the interface pointer directly. ........ [Ref] Properly wait in SetAudioThreadActive(false) until the audio thread has really entered idle state and is not running any more. Stop the audio device right after that. This makes stopping audio output synchronous. [Ref] Fix a deadlock caused by this change in CModDoc::OnPlayerPlayFromStart() by moving AudioCriticalSection after the call to PauseMod() (every other PauseMod() call site does it this way anyway). ........ [Fix] Latency estimation for ASIO was wrong in the call to AudioDone. It used the wrong unit (in the old code it used Samples and the AudioDone() code expected bytes and now it used a meaningless Samples devided by samplesize. Pass on the correct value as samples now. Has been broken probably forever. Did probably not matter that much because ASIO latencies tend to be very small anyway. ........ [Ref] The audio thread should not, in any way, directly interact with the gui thread. When a audio stream reached its end, the audio thread did a PostMessage to the gui thread, simulating a click on the Stop button. Generate a notification instead and let the gui thread itself simulate the click. Refactor FillAudioBuffer and AudioDone to prapagate when end of stream is reached. [Ref] Wake up the audio thread only for non-ASIO devices. [Ref] Start() and Stop() non/ASIO devices directly from the audio thread. It knows best when it is ready to fill the buffer. ........ [Ref] Add ISoundDevice::HasGetStreamPosition() and ISoundDevice::GetStreamPositionSamples() to query the precise actual sample position that is currently being sent to the audio output. [Ref] Rework notification timestamp handling to optionally use this information for ISoundDevices that support it. This changes the meaning of MPTNOTIFICATION::TimestampSamples depending of whether the ISoundDevice implementation supports GetStreamPositionSamples() from latency compensated to not latency compensated timestamps. Also, clear the notification buffer and reset m_TotalSamplesRendered after the sound device has been closed. Notifications still pending at that point are completely meaningless anyway. [Ref] Implement GetStreamPositionSamples() for CWaveDevice. [Fix] Call AudioDone() more regularly when using Waveout and more than one buffer has to be filled. Prevents stuttering gui redraw in some situations (especially directly after stream start with high latencies). ........ [Fix] Actually starting waveout device in CWaveDevice::Start() makes sense now. ........ [Ref] Move old minimum and maximum values for buffer length into TrackerSettings.cpp. They are now only used for loading and sanitizing old configuration settings. ........ [Var] Add portaudio v19-20111121 source code. ........ [Var] Integrate portaudio into the VS2010 build process and document the related changes to portaudio in include/portaudio/OpenMPT.txt. ........ [Var] Use multiprocessor compilation for portaudio release builds with VS2010. ........ [Var] Add portaudio to VS2008 build process. ........ [New] Implement a new sound device class CPortaudioDevice. Use it to additionally provide WASAPI and WDM-KS audio output support. Add a NO_PORTAUDIO macro to optionally disable any portaudio code. Portaudio is linked as a delay loaded DLL and the availability of the DLL is checked before trying any portaudio functionality at all. This gives the user the ability to disable portaudio by just deleting or renaming the DLL in case something behaves strangely, e.g. during device enumeration. ........ [Fix] Initialize m_bMixRunning in CAsioDevice. [Var] Add debugging assertions to check for unbalanced Start() / Stop() in CAsioDevice. [Ref] Add CriticalSection::AssertUnlock() to assert that the current thread does not hold the audio ctricial section at a certain point. [Ref] Make audioOpenDevice() idempotent. Add audioReopenDevice(). [Ref] Rewrite and try to clean up the playing/not-playing state transitions in PlayMod(),PauseMod(),StopMod() and PlaySoundFile(). The basic idea is to pause the playback then fiddle around with m_pSndFile and then unpause the playback again. [Mod] In certain cases, when OpenMPT stops the sound device for presumably a short period of time, do not actually stop the asio device but switch it to render silence instead. Avoids anoying state changes with some asio drivers. [Ref] Document the MPTNOTIFY constants. ........ [Fix] Fix enumeration of portaudio device to actually really include only device supporting sound output. ........ [Mod] Got rid of pointless AGC reset after 15 seconds of silence. ........ [Reg] Do not pause playback while loading and/or generating previews. ........ [Ref] Remove redundant PausePlayback(). ........ [Ref] Add a SetSource() member do ISoundDevice to avoid needing a global function SoundDeviceCallback. [Ref] Add ISoundSource::FillAudioBufferLocked which should take all needed locks and then call back into CSoundDevice::FillAudioBuffer which in turn will call ISoundSource::AudioRead and ISoundSource::AudioDone. [Ref] Remove CMPTSoundSource and its global instance gMPTSoundSource and let CMainFrame directly implement ISoundSource ........ [Ref] Move audio thread implementation into its own class CAudioThread. ........ [Ref] Move CAudioThread to snddev.cpp ........ [Ref] Move CAudioThread handling completely out of CMainFrame and directly into the ISoundDevice implementations that need their own thread (Waveout and Directsound). This is implemented via CWaveDevice and CDSoundDevice deriving from a new CSoundDeviceWithThread. ........ [Ref] Remove unused ISoundDevice::DirectCallback() ........ [Ref] Remove unused DSoundDone() ........ [Ref] Pass a IFillAudioBuffer reference to CMainFrame::FillAudioBufferLocked so that it directly knows were to call back instead of relying on the state of a member variable. ........ [Ref] Remove unused BOOL audioFillBuffers(); ........ [Ref] Always generate mastervu, it's not that heavy anyway. Remove the coresponding MPTNOTIFY_MASTERVU and remove ApplyMixerHooks which did just enable and disable this one single hook. Now, a permanently visible VU meter could be added somewhere in the GUI. ........ [Mod] Disable WDM-KS support in portaudio again. The implementation in portaudio seems broken. ........ [Mod] Link portaudio statically and thereby disable the possibility to deactivate it by deleting the DLL. ........ [Var] Fix debug build of portaudio with VS2010. ........ [Fix] Improve handling of DSERR_BUFFERLOST when calling ->Lock() or ->Play(). ........ [Ref] More consistent usage of MemsetZero in Snddev.cpp ........ Revision Links: -------------- http://sourceforge.net/p/modplug/code/1614 Modified Paths: -------------- trunk/OpenMPT/common/AudioCriticalSection.cpp trunk/OpenMPT/common/AudioCriticalSection.h trunk/OpenMPT/common/misc_util.h trunk/OpenMPT/common/stdafx.h trunk/OpenMPT/mptrack/Ctrl_com.cpp trunk/OpenMPT/mptrack/Ctrl_gen.cpp trunk/OpenMPT/mptrack/InputHandler.h trunk/OpenMPT/mptrack/MPTRACK_08.sln trunk/OpenMPT/mptrack/MPTRACK_10.sln trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/Mpdlgs.h trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/mptrack/resource.h trunk/OpenMPT/soundlib/SNDDEV.H trunk/OpenMPT/soundlib/SNDDEVX.H trunk/OpenMPT/soundlib/Snddev.cpp trunk/OpenMPT/soundlib/Sndmix.cpp Added Paths: ----------- trunk/OpenMPT/common/mutex.h trunk/OpenMPT/include/portaudio/ Removed Paths: ------------- trunk/OpenMPT/common/mutex.h Property Changed: ---------------- trunk/OpenMPT/ trunk/OpenMPT/include/portaudio/bindings/ trunk/OpenMPT/include/portaudio/bindings/cpp/ trunk/OpenMPT/include/portaudio/bindings/cpp/bin/ trunk/OpenMPT/include/portaudio/bindings/cpp/build/ trunk/OpenMPT/include/portaudio/bindings/cpp/build/gnu/ trunk/OpenMPT/include/portaudio/bindings/cpp/build/vc6/ trunk/OpenMPT/include/portaudio/bindings/cpp/build/vc7/ trunk/OpenMPT/include/portaudio/bindings/cpp/build/vc7_1/ trunk/OpenMPT/include/portaudio/bindings/cpp/doc/ trunk/OpenMPT/include/portaudio/bindings/cpp/example/ trunk/OpenMPT/include/portaudio/bindings/cpp/include/ trunk/OpenMPT/include/portaudio/bindings/cpp/include/portaudiocpp/ trunk/OpenMPT/include/portaudio/bindings/cpp/lib/ trunk/OpenMPT/include/portaudio/bindings/cpp/source/ trunk/OpenMPT/include/portaudio/bindings/cpp/source/portaudiocpp/ trunk/OpenMPT/include/portaudio/build/ trunk/OpenMPT/include/portaudio/build/msvc/ trunk/OpenMPT/include/portaudio/build/scons/ trunk/OpenMPT/include/portaudio/cmake_support/ trunk/OpenMPT/include/portaudio/doc/ trunk/OpenMPT/include/portaudio/doc/html/ trunk/OpenMPT/include/portaudio/doc/src/ trunk/OpenMPT/include/portaudio/doc/src/images/ trunk/OpenMPT/include/portaudio/doc/utils/ trunk/OpenMPT/include/portaudio/examples/ trunk/OpenMPT/include/portaudio/include/ trunk/OpenMPT/include/portaudio/pablio/ trunk/OpenMPT/include/portaudio/qa/ trunk/OpenMPT/include/portaudio/qa/loopback/ trunk/OpenMPT/include/portaudio/qa/loopback/macosx/ trunk/OpenMPT/include/portaudio/qa/loopback/src/ trunk/OpenMPT/include/portaudio/src/ trunk/OpenMPT/include/portaudio/src/common/ trunk/OpenMPT/include/portaudio/src/hostapi/ trunk/OpenMPT/include/portaudio/src/hostapi/alsa/ trunk/OpenMPT/include/portaudio/src/hostapi/asihpi/ trunk/OpenMPT/include/portaudio/src/hostapi/asio/ trunk/OpenMPT/include/portaudio/src/hostapi/coreaudio/ trunk/OpenMPT/include/portaudio/src/hostapi/dsound/ trunk/OpenMPT/include/portaudio/src/hostapi/jack/ trunk/OpenMPT/include/portaudio/src/hostapi/oss/ trunk/OpenMPT/include/portaudio/src/hostapi/skeleton/ trunk/OpenMPT/include/portaudio/src/hostapi/wasapi/ trunk/OpenMPT/include/portaudio/src/hostapi/wasapi/mingw-include/ trunk/OpenMPT/include/portaudio/src/hostapi/wdmks/ trunk/OpenMPT/include/portaudio/src/hostapi/wmme/ trunk/OpenMPT/include/portaudio/src/os/ trunk/OpenMPT/include/portaudio/src/os/mac_osx/ trunk/OpenMPT/include/portaudio/src/os/unix/ trunk/OpenMPT/include/portaudio/src/os/win/ trunk/OpenMPT/include/portaudio/test/ trunk/OpenMPT/include/portaudio/testcvs/ Index: trunk/OpenMPT =================================================================== --- trunk/OpenMPT 2013-04-02 20:18:42 UTC (rev 1713) +++ trunk/OpenMPT 2013-04-03 10:06:28 UTC (rev 1714) Property changes on: trunk/OpenMPT ___________________________________________________________________ Modified: svn:mergeinfo ## -1,3 +1,4 ## /branches/manx/build-speedup:1586-1589 /branches/manx/header-dependencies-cleanups:1394-1397,1401-1402,1405-1406 /branches/manx/project-files-cleanups:1378-1382 +/branches/manx/snddev-fixes:1605-1713 \ No newline at end of property Modified: trunk/OpenMPT/common/AudioCriticalSection.cpp =================================================================== --- trunk/OpenMPT/common/AudioCriticalSection.cpp 2013-04-02 20:18:42 UTC (rev 1713) +++ trunk/OpenMPT/common/AudioCriticalSection.cpp 2013-04-03 10:06:28 UTC (rev 1714) @@ -12,3 +12,7 @@ #include "../common/AudioCriticalSection.h" CRITICAL_SECTION g_csAudio; +#ifdef _DEBUG +int g_csAudioLockCount = 0; +#endif + Modified: trunk/OpenMPT/common/AudioCriticalSection.h =================================================================== --- trunk/OpenMPT/common/AudioCriticalSection.h 2013-04-02 20:18:42 UTC (rev 1713) +++ trunk/OpenMPT/common/AudioCriticalSection.h 2013-04-03 10:06:28 UTC (rev 1714) @@ -12,6 +12,9 @@ #include <windows.h> extern CRITICAL_SECTION g_csAudio; +#ifdef _DEBUG +extern int g_csAudioLockCount; +#endif // Critical section handling done in (safe) RAII style. // Create a CriticalSection object whenever you need exclusive access to CSoundFile. @@ -23,8 +26,46 @@ protected: bool inSection; public: - CriticalSection() { inSection = false; Enter(); }; - ~CriticalSection() { Leave(); }; - void Enter() { if(!inSection) { inSection = true; EnterCriticalSection(&g_csAudio); } }; - void Leave() { if(inSection) { inSection = false; LeaveCriticalSection(&g_csAudio); } }; + CriticalSection() + { + inSection = false; + Enter(); + }; + void Enter() + { + if(!inSection) + { + inSection = true; + EnterCriticalSection(&g_csAudio); +#ifdef _DEBUG + g_csAudioLockCount++; +#endif + } + }; + void Leave() + { + if(inSection) + { + inSection = false; +#ifdef _DEBUG + g_csAudioLockCount--; +#endif + LeaveCriticalSection(&g_csAudio); + } + }; + ~CriticalSection() + { + Leave(); + }; + static void AssertUnlocked() + { + // asserts that the critical section is currently not hold by THIS thread +#ifdef _DEBUG + if(TryEnterCriticalSection(&g_csAudio)) + { + ASSERT(g_csAudioLockCount==0); + LeaveCriticalSection(&g_csAudio); + } +#endif + } }; Modified: trunk/OpenMPT/common/misc_util.h =================================================================== --- trunk/OpenMPT/common/misc_util.h 2013-04-02 20:18:42 UTC (rev 1713) +++ trunk/OpenMPT/common/misc_util.h 2013-04-03 10:06:28 UTC (rev 1714) @@ -383,4 +383,71 @@ return static_cast<int32>( ( static_cast<int64>(a) * b + ( c / 2 ) ) / c ); } + template<typename T, std::size_t n> + class fixed_size_queue { + private: + T buffer[n+1]; + std::size_t read_position; + std::size_t write_position; + public: + fixed_size_queue() : read_position(0), write_position(0) { + return; + } + void clear() { + read_position = 0; + write_position = 0; + } + std::size_t read_size() const { + if ( write_position > read_position ) { + return write_position - read_position; + } else if ( write_position < read_position ) { + return write_position - read_position + n + 1; + } else { + return 0; + } + } + std::size_t write_size() const { + if ( write_position > read_position ) { + return read_position - write_position + n; + } else if ( write_position < read_position ) { + return read_position - write_position - 1; + } else { + return n; + } + } + bool push( const T & v ) { + if ( !write_size() ) { + return false; + } + buffer[write_position] = v; + write_position = ( write_position + 1 ) % ( n + 1 ); + return true; + } + bool pop() { + if ( !read_size() ) { + return false; + } + read_position = ( read_position + 1 ) % ( n + 1 ); + return true; + } + T peek() { + if ( !read_size() ) { + return T(); + } + return buffer[read_position]; + } + const T * peek_p() { + if ( !read_size() ) { + return nullptr; + } + return &(buffer[read_position]); + } + const T * peek_next_p() { + if ( read_size() < 2 ) { + return nullptr; + } + return &(buffer[(read_position+1)%(n+1)]); + } + }; + } // namespace Util Deleted: trunk/OpenMPT/common/mutex.h =================================================================== --- trunk/OpenMPT/common/mutex.h 2013-04-02 20:18:42 UTC (rev 1713) +++ trunk/OpenMPT/common/mutex.h 2013-04-03 10:06:28 UTC (rev 1714) @@ -1,51 +0,0 @@ -/* - * mutex.h - * ------- - * Purpose: Partially implement c++ mutexes as far as openmpt needs them. Can eventually go away when we only support c++11 compilers some time. - * Notes : (currently none) - * Authors: OpenMPT Devs - * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. - */ - -#pragma once - -#define WIN32_LEAN_AND_MEAN -#define VC_EXTRALEAN -#define NOMINMAX -#include <windows.h> - -namespace Util { - -// compatible with c++11 std::mutex, can eventually be replaced without touching any usage site -class mutex { -private: - CRITICAL_SECTION impl; -public: - mutex() { InitializeCriticalSection(&impl); } - ~mutex() { DeleteCriticalSection(&impl); } - void lock() { EnterCriticalSection(&impl); } - void unlock() { LeaveCriticalSection(&impl); } -}; - -// compatible with c++11 std::recursive_mutex, can eventually be replaced without touching any usage site -class recursive_mutex { -private: - CRITICAL_SECTION impl; -public: - recursive_mutex() { InitializeCriticalSection(&impl); } - ~recursive_mutex() { DeleteCriticalSection(&impl); } - void lock() { EnterCriticalSection(&impl); } - void unlock() { LeaveCriticalSection(&impl); } -}; - -// compatible with c++11 std::lock_guard, can eventually be replaced without touching any usage site -template< typename mutex_type > -class lock_guard { -private: - mutex_type & mutex; -public: - lock_guard( mutex_type & m ) : mutex(m) { mutex.lock(); } - ~lock_guard() { mutex.unlock(); } -}; - -} // namespace Util Copied: trunk/OpenMPT/common/mutex.h (from rev 1713, branches/manx/snddev-fixes/common/mutex.h) =================================================================== --- trunk/OpenMPT/common/mutex.h (rev 0) +++ trunk/OpenMPT/common/mutex.h 2013-04-03 10:06:28 UTC (rev 1714) @@ -0,0 +1,51 @@ +/* + * mutex.h + * ------- + * Purpose: Partially implement c++ mutexes as far as openmpt needs them. Can eventually go away when we only support c++11 compilers some time. + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + +#pragma once + +#define WIN32_LEAN_AND_MEAN +#define VC_EXTRALEAN +#define NOMINMAX +#include <windows.h> + +namespace Util { + +// compatible with c++11 std::mutex, can eventually be replaced without touching any usage site +class mutex { +private: + CRITICAL_SECTION impl; +public: + mutex() { InitializeCriticalSection(&impl); } + ~mutex() { DeleteCriticalSection(&impl); } + void lock() { EnterCriticalSection(&impl); } + void unlock() { LeaveCriticalSection(&impl); } +}; + +// compatible with c++11 std::recursive_mutex, can eventually be replaced without touching any usage site +class recursive_mutex { +private: + CRITICAL_SECTION impl; +public: + recursive_mutex() { InitializeCriticalSection(&impl); } + ~recursive_mutex() { DeleteCriticalSection(&impl); } + void lock() { EnterCriticalSection(&impl); } + void unlock() { LeaveCriticalSection(&impl); } +}; + +// compatible with c++11 std::lock_guard, can eventually be replaced without touching any usage site +template< typename mutex_type > +class lock_guard { +private: + mutex_type & mutex; +public: + lock_guard( mutex_type & m ) : mutex(m) { mutex.lock(); } + ~lock_guard() { mutex.unlock(); } +}; + +} // namespace Util Modified: trunk/OpenMPT/common/stdafx.h =================================================================== --- trunk/OpenMPT/common/stdafx.h 2013-04-02 20:18:42 UTC (rev 1713) +++ trunk/OpenMPT/common/stdafx.h 2013-04-03 10:06:28 UTC (rev 1714) @@ -88,6 +88,9 @@ // (HACK) Define to build without VST support; makes build possible without VST SDK. //#define NO_VST +// Define to build without portaudio. +//#define NO_PORTAUDIO + // Define to build without MO3 support. //#define NO_MO3_SUPPORT Index: trunk/OpenMPT/include/portaudio =================================================================== --- branches/manx/snddev-fixes/include/portaudio 2013-04-02 20:18:42 UTC (rev 1713) +++ trunk/OpenMPT/include/portaudio 2013-04-03 10:06:28 UTC (rev 1714) Property changes on: trunk/OpenMPT/include/portaudio ___________________________________________________________________ Added: tsvn:logminsize ## -0,0 +1 ## +10 \ No newline at end of property Modified: trunk/OpenMPT/mptrack/Ctrl_com.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_com.cpp 2013-04-02 20:18:42 UTC (rev 1713) +++ trunk/OpenMPT/mptrack/Ctrl_com.cpp 2013-04-03 10:06:28 UTC (rev 1714) @@ -52,7 +52,7 @@ void CCtrlComments::OnActivatePage(LPARAM) //---------------------------------------- { - CMainFrame::EnableLowLatencyMode(FALSE); + // nothing } Modified: trunk/OpenMPT/mptrack/Ctrl_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2013-04-02 20:18:42 UTC (rev 1713) +++ trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2013-04-03 10:06:28 UTC (rev 1714) @@ -145,9 +145,8 @@ //--------------------------------------- { CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); - if (m_pModDoc) m_pModDoc->SetFollowWnd(m_hWnd, MPTNOTIFY_MASTERVU); - if (pMainFrm) pMainFrm->SetFollowSong(m_pModDoc, m_hWnd, TRUE, MPTNOTIFY_MASTERVU); - CMainFrame::EnableLowLatencyMode(FALSE); + if (m_pModDoc) m_pModDoc->SetFollowWnd(m_hWnd, MPTNOTIFY_DEFAULT); + if (pMainFrm) pMainFrm->SetFollowSong(m_pModDoc, m_hWnd, TRUE, MPTNOTIFY_DEFAULT); PostViewMessage(VIEWMSG_SETACTIVE, NULL); SetFocus(); @@ -528,15 +527,8 @@ MPTNOTIFICATION *pnotify = (MPTNOTIFICATION *)lParam; if (pnotify) { - if (pnotify->dwType & MPTNOTIFY_MASTERVU) - { - m_VuMeterLeft.SetVuMeter(pnotify->dwPos[0]); - m_VuMeterRight.SetVuMeter(pnotify->dwPos[1]); - } else - { - m_VuMeterLeft.SetVuMeter(0); - m_VuMeterRight.SetVuMeter(0); - } + m_VuMeterLeft.SetVuMeter(pnotify->MasterVuLeft); + m_VuMeterRight.SetVuMeter(pnotify->MasterVuRight); } return 0; } Modified: trunk/OpenMPT/mptrack/InputHandler.h =================================================================== --- trunk/OpenMPT/mptrack/InputHandler.h 2013-04-02 20:18:42 UTC (rev 1713) +++ trunk/OpenMPT/mptrack/InputHandler.h 2013-04-03 10:06:28 UTC (rev 1714) @@ -14,6 +14,7 @@ enum { WM_MOD_UPDATEPOSITION = (WM_USER+1973), + WM_MOD_UPDATEPOSITIONTHREADED, WM_MOD_INVALIDATEPATTERNS, WM_MOD_ACTIVATEVIEW, WM_MOD_CHANGEVIEWCLASS, Modified: trunk/OpenMPT/mptrack/MPTRACK_08.sln =================================================================== --- trunk/OpenMPT/mptrack/MPTRACK_08.sln 2013-04-02 20:18:42 UTC (rev 1713) +++ trunk/OpenMPT/mptrack/MPTRACK_08.sln 2013-04-03 10:06:28 UTC (rev 1714) @@ -7,6 +7,7 @@ {DCC2BB2F-6778-4FD3-9C00-D6CD8DC917B8} = {DCC2BB2F-6778-4FD3-9C00-D6CD8DC917B8} {FAE39936-1DC7-40BB-AD3F-3B5B9E9AB0E8} = {FAE39936-1DC7-40BB-AD3F-3B5B9E9AB0E8} {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8} = {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8} + {0A18A071-125E-442F-AFF7-A3F68ABECF99} = {0A18A071-125E-442F-AFF7-A3F68ABECF99} {4CEFBC84-C215-11DB-8314-0800200C9A66} = {4CEFBC84-C215-11DB-8314-0800200C9A66} {CF3C2CA5-5D45-4635-BBA4-C1F435E10896} = {CF3C2CA5-5D45-4635-BBA4-C1F435E10896} {FF541CE2-DAA1-4F84-9883-0A0F111BAA0B} = {FF541CE2-DAA1-4F84-9883-0A0F111BAA0B} @@ -34,6 +35,8 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libFLAC_static", "..\include\flac\src\libFLAC\libFLAC_static_08.vcproj", "{4CEFBC84-C215-11DB-8314-0800200C9A66}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "portaudio", "..\include\portaudio\build\msvc\portaudio_openmpt_vs2008.vcproj", "{0A18A071-125E-442F-AFF7-A3F68ABECF99}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -76,6 +79,10 @@ {4CEFBC84-C215-11DB-8314-0800200C9A66}.Debug|Win32.Build.0 = Debug|Win32 {4CEFBC84-C215-11DB-8314-0800200C9A66}.Release|Win32.ActiveCfg = Release|Win32 {4CEFBC84-C215-11DB-8314-0800200C9A66}.Release|Win32.Build.0 = Release|Win32 + {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|Win32.ActiveCfg = Debug|Win32 + {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|Win32.Build.0 = Debug|Win32 + {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|Win32.ActiveCfg = Release|Win32 + {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Modified: trunk/OpenMPT/mptrack/MPTRACK_10.sln =================================================================== --- trunk/OpenMPT/mptrack/MPTRACK_10.sln 2013-04-02 20:18:42 UTC (rev 1713) +++ trunk/OpenMPT/mptrack/MPTRACK_10.sln 2013-04-03 10:06:28 UTC (rev 1714) @@ -21,6 +21,8 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unzip", "..\unzip\unzip_10.vcxproj", "{F23CC68D-1D58-4EB1-9425-A28F5058EB31}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "portaudio", "..\include\portaudio\build\msvc\portaudio_openmpt_vs2010.vcxproj", "{0A18A071-125E-442F-AFF7-A3F68ABECF99}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -82,6 +84,12 @@ {F23CC68D-1D58-4EB1-9425-A28F5058EB31}.Release|Win32.Build.0 = Release|Win32 {F23CC68D-1D58-4EB1-9425-A28F5058EB31}.ReleaseNoLTCG|Win32.ActiveCfg = Release|Win32 {F23CC68D-1D58-4EB1-9425-A28F5058EB31}.ReleaseNoLTCG|Win32.Build.0 = Release|Win32 + {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|Win32.ActiveCfg = Debug|Win32 + {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|Win32.Build.0 = Debug|Win32 + {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|Win32.ActiveCfg = Release|Win32 + {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|Win32.Build.0 = Release|Win32 + {0A18A071-125E-442F-AFF7-A3F68ABECF99}.ReleaseNoLTCG|Win32.ActiveCfg = Release|Win32 + {0A18A071-125E-442F-AFF7-A3F68ABECF99}.ReleaseNoLTCG|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-04-02 20:18:42 UTC (rev 1713) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-04-03 10:06:28 UTC (rev 1714) @@ -45,19 +45,6 @@ #define MPTTIMER_PERIOD 200 -//======================================== -class CMPTSoundSource: public ISoundSource -//======================================== -{ -public: - CMPTSoundSource() {} - ULONG AudioRead(PVOID pData, ULONG cbSize); - VOID AudioDone(ULONG dwSize, ULONG dwLatency); -}; - - -CMPTSoundSource gMPTSoundSource; - ///////////////////////////////////////////////////////////////////////////// // CMainFrame @@ -99,6 +86,7 @@ ON_UPDATE_COMMAND_UI(ID_INDICATOR_CPU, OnUpdateCPU) ON_UPDATE_COMMAND_UI(IDD_TREEVIEW, OnUpdateControlBarMenu) ON_MESSAGE(WM_MOD_UPDATEPOSITION, OnUpdatePosition) + ON_MESSAGE(WM_MOD_UPDATEPOSITIONTHREADED, OnUpdatePositionThreaded) ON_MESSAGE(WM_MOD_INVALIDATEPATTERNS, OnInvalidatePatterns) ON_MESSAGE(WM_MOD_SPECIALKEY, OnSpecialKey) ON_MESSAGE(WM_MOD_KEYCOMMAND, OnCustomKeyMsg) //rewbs.customKeys @@ -112,31 +100,13 @@ ON_WM_SHOWWINDOW() END_MESSAGE_MAP() -// Static -static int gdwLastLowLatencyTime = 0; -static int gdwLastMixActiveTime = 0; -static DWORD gsdwTotalSamples = 0; -static DWORD gdwPlayLatency = 0; - // Globals -DWORD CMainFrame::gdwNotificationType = MPTNOTIFY_DEFAULT; UINT CMainFrame::m_nLastOptionsPage = 0; HHOOK CMainFrame::ghKbdHook = NULL; std::vector<CString> CMainFrame::s_ExampleModulePaths; std::vector<CString> CMainFrame::s_TemplateModulePaths; -HANDLE CMainFrame::m_hPlayThread = NULL; -DWORD CMainFrame::m_dwPlayThreadId = 0; -HANDLE CMainFrame::m_hAudioWakeUp = NULL; -HANDLE CMainFrame::m_hNotifyThread = NULL; -DWORD CMainFrame::m_dwNotifyThreadId = 0; -HANDLE CMainFrame::m_hNotifyWakeUp = NULL; -ISoundDevice *CMainFrame::gpSoundDevice = NULL; -LONG CMainFrame::slSampleSize = 2; -LONG CMainFrame::sdwSamplesPerSec = 44100; -LONG CMainFrame::sdwAudioBufferSize = MAX_AUDIO_BUFFERSIZE; -UINT CMainFrame::gdwIdleTime = 0; LONG CMainFrame::gnLVuMeter = 0; LONG CMainFrame::gnRVuMeter = 0; @@ -200,23 +170,31 @@ ID_INDICATOR_CPU }; + ///////////////////////////////////////////////////////////////////////////// // CMainFrame construction/destruction //#include <direct.h> CMainFrame::CMainFrame() //---------------------- { + + m_hNotifyThread = NULL; + m_dwNotifyThreadId = 0; + m_hNotifyWakeUp = NULL; + gpSoundDevice = NULL; + m_IsPlaybackRunning = false; + m_bModTreeHasFocus = false; //rewbs.customKeys m_pNoteMapHasFocus = nullptr; //rewbs.customKeys m_pOrderlistHasFocus = nullptr; m_bOptionsLocked = false; //rewbs.customKeys + m_SoundCardOptionsDialog = nullptr; + m_pJustModifiedDoc = nullptr; - m_pModPlaying = nullptr; m_hFollowSong = NULL; m_hWndMidi = NULL; m_pSndFile = nullptr; - m_dwStatus = 0; m_dwTimeSec = 0; m_dwNotifyType = 0; m_nTimer = 0; @@ -225,6 +203,9 @@ m_szInfoText[0] = 0; m_szXInfoText[0]= 0; //rewbs.xinfo + m_TotalSamplesRendered = 0; + m_PendingNotificationSempahore = NULL; + MemsetZero(gpenVuMeter); // Create Audio Critical Section @@ -262,6 +243,8 @@ SetTitle(title); OnUpdateFrameTitle(false); + CSoundFile::gpSndMixHook = CalcStereoVuMeters; + // Check for valid sound device if (!EnumerateSoundDevices(SNDDEV_GET_TYPE(TrackerSettings::Instance().m_nWaveDevice), SNDDEV_GET_NUMBER(TrackerSettings::Instance().m_nWaveDevice), nullptr, 0)) { @@ -272,11 +255,10 @@ } } - // Create Audio Thread - m_hAudioWakeUp = CreateEvent(NULL, FALSE, FALSE, NULL); + // Create Notify Thread + m_PendingNotificationSempahore = CreateSemaphore(NULL, 0, 1, NULL); m_hNotifyWakeUp = CreateEvent(NULL, FALSE, FALSE, NULL); - m_hPlayThread = CreateThread(NULL, 0, AudioThread, NULL, 0, &m_dwPlayThreadId); - m_hNotifyThread = CreateThread(NULL, 0, NotifyThread, NULL, 0, &m_dwNotifyThreadId); + m_hNotifyThread = CreateThread(NULL, 0, NotifyThreadWrapper, NULL, 0, &m_dwNotifyThreadId); // Setup timer OnUpdateUser(NULL); m_nTimer = SetTimer(1, MPTTIMER_PERIOD, NULL); @@ -395,6 +377,8 @@ BOOL CMainFrame::DestroyWindow() //------------------------------ { + CSoundFile::gpSndMixHook = nullptr; + SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS); // Uninstall Keyboard Hook if (ghKbdHook) @@ -409,14 +393,23 @@ m_nTimer = 0; } if (shMidiIn) midiCloseDevice(); - if (m_hPlayThread != NULL) + if(m_hNotifyThread != NULL) { - if(TerminateThread(m_hPlayThread, 0)) m_hPlayThread = NULL; + PostThreadMessage(m_dwNotifyThreadId, WM_QUIT, 0, 0); + WaitForSingleObject(m_hNotifyThread, INFINITE); + m_dwNotifyThreadId = 0; + m_hNotifyThread = NULL; } - if (m_hNotifyThread != NULL) + if(m_hNotifyWakeUp != NULL) { - if(TerminateThread(m_hNotifyThread, 0)) m_hNotifyThread = NULL; + CloseHandle(m_hNotifyWakeUp); + m_hNotifyWakeUp = NULL; } + if(m_PendingNotificationSempahore != NULL) + { + CloseHandle(m_PendingNotificationSempahore); + m_PendingNotificationSempahore = NULL; + } // Delete bitmaps if (bmpPatterns) { @@ -492,14 +485,14 @@ CChildFrame *pMDIActive = (CChildFrame *)MDIGetActive(); BeginWaitCursor(); - if (m_dwStatus & MODSTATUS_PLAYING) PauseMod(); + if (IsPlaying()) PauseMod(); if (pMDIActive) pMDIActive->SavePosition(TRUE); if (gpSoundDevice) { CriticalSection cs; //gpSoundDevice->Reset(); //audioCloseDevice(); - gpSoundDevice->Release(); + delete gpSoundDevice; gpSoundDevice = NULL; } // Save Settings @@ -667,214 +660,147 @@ ///////////////////////////////////////////////////////////////////////////// // CMainFrame Sound Library -static BOOL gbStopSent = FALSE; - -// Sound Device Callback -BOOL SoundDeviceCallback(DWORD dwUser) -//------------------------------------ +// Notify thread +DWORD WINAPI CMainFrame::NotifyThreadWrapper(LPVOID) { - BOOL bOk = FALSE; - CMainFrame *pMainFrm = (CMainFrame *)theApp.m_pMainWnd; - if (gbStopSent) return FALSE; - CriticalSection cs; - if ((pMainFrm) && (pMainFrm->IsPlaying()) && (CMainFrame::gpSoundDevice)) - { - bOk = CMainFrame::gpSoundDevice->FillAudioBuffer(&gMPTSoundSource, gdwPlayLatency, dwUser); - } - if (!bOk) - { - gbStopSent = TRUE; - pMainFrm->PostMessage(WM_COMMAND, ID_PLAYER_STOP); - } - return bOk; + return ((CMainFrame*)theApp.m_pMainWnd)->NotifyThread(); } - - -// Audio thread -DWORD WINAPI CMainFrame::AudioThread(LPVOID) -//------------------------------------------ +DWORD CMainFrame::NotifyThread() +//------------------------------------------- { - CMainFrame *pMainFrm; - BOOL bWait; - UINT nSleep; - -// -> CODE#0021 -// -> DESC="use multimedia timer instead of Sleep() in audio thread" - HANDLE sleepEvent = CreateEvent(NULL,TRUE,FALSE,NULL); -// -! BEHAVIOUR_CHANGE#0021 - - bWait = TRUE; - nSleep = 50; -// -> CODE#0021 -// -> DESC="use multimedia timer instead of Sleep() in audio thread" -//rewbs: reduce to normal priority during debug for easier hang debugging + // initialize thread message queue + MSG msg; + PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE); #ifdef NDEBUG - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL ); + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL ); // we shall not stall the audio thread while holding m_NotificationBufferMutex #endif -#ifdef _DEBUG - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL); -#endif -// SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL); -// -! BEHAVIOUR_CHANGE#0021 - for (;;) + bool terminate = false; + bool cansend = true; + while(!terminate) { - if (bWait) + switch(MsgWaitForMultipleObjects(1, &m_hNotifyWakeUp, FALSE, 1000, QS_ALLEVENTS)) { - WaitForSingleObject(CMainFrame::m_hAudioWakeUp, 250); - } else - { -// -> CODE#0021 -// -> DESC="use multimedia timer instead of Sleep() in audio thread" -// Sleep(nSleep); - timeSetEvent(nSleep,1,(LPTIMECALLBACK)sleepEvent,NULL,TIME_ONESHOT | TIME_CALLBACK_EVENT_SET); - WaitForSingleObject(sleepEvent,nSleep); - ResetEvent(sleepEvent); -// -! BEHAVIOUR_CHANGE#0021 - } - bWait = TRUE; - pMainFrm = (CMainFrame *)theApp.m_pMainWnd; - CriticalSection cs; - if ((!gbStopSent) && (pMainFrm) && (pMainFrm->IsPlaying()) && (CMainFrame::gpSoundDevice)) - { - if (!CMainFrame::gpSoundDevice->Directcallback()) + case WAIT_OBJECT_0 + 1: { - if (CMainFrame::gpSoundDevice->FillAudioBuffer(&gMPTSoundSource, gdwPlayLatency)) + while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { - ULONG nMaxSleep = CMainFrame::gpSoundDevice->GetMaxFillInterval(); - bWait = FALSE; - nSleep = TrackerSettings::Instance().m_nBufferLength / 8; - if (nSleep > nMaxSleep) nSleep = nMaxSleep; - if (nSleep < 10) nSleep = 10; - if (nSleep > 40) nSleep = 40; - } else - { - gbStopSent = TRUE; - pMainFrm->PostMessage(WM_COMMAND, ID_PLAYER_STOP); + if(msg.message == WM_QUIT) terminate = true; } - } else - { - nSleep = 50; } - } - } - -// -> CODE#0021 -// -> DESC="use multimedia timer instead of Sleep() in audio thread" - // Commented as this caused "warning C4702: unreachable code" - //CloseHandle(sleepEvent); -// -! BEHAVIOUR_CHANGE#0021 - - // Commented the two lines below as those caused "warning C4702: unreachable code" - //ExitThread(0); - //return 0; -} - - -// Notify thread -DWORD WINAPI CMainFrame::NotifyThread(LPVOID) -//------------------------------------------- -{ - CMainFrame *pMainFrm; - - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL); - for (;;) - { - WaitForSingleObject(CMainFrame::m_hNotifyWakeUp, 1000); - pMainFrm = (CMainFrame *)theApp.m_pMainWnd; - if ((pMainFrm) && (pMainFrm->IsPlaying())) - { - MPTNOTIFICATION *pnotify = NULL; - DWORD dwLatency = 0; - - for (UINT i=0; i<MAX_UPDATE_HISTORY; i++) - { - MPTNOTIFICATION *p = &pMainFrm->NotifyBuffer[i]; - if ((p->dwType & MPTNOTIFY_PENDING) - && (!(pMainFrm->m_dwStatus & MODSTATUS_BUSY))) + break; + case WAIT_OBJECT_0: { - if (p->dwLatency >= dwLatency) + const MPTNOTIFICATION * pnotify = nullptr; { - if (pnotify) pnotify->dwType = 0; - pnotify = p; - } else + int64 currenttotalsamples = 0; + Util::lock_guard<Util::mutex> lock(m_NotificationBufferMutex); + if(gpSoundDevice && gpSoundDevice->HasGetStreamPosition()) + { + currenttotalsamples = gpSoundDevice->GetStreamPositionSamples(); + } else + { + currenttotalsamples = m_TotalSamplesRendered; + } + // advance to the newest notification, drop the obsolete ones + const MPTNOTIFICATION * p = m_NotifyBuffer.peek_p(); + if(p && currenttotalsamples >= p->TimestampSamples) + { + pnotify = p; + while(m_NotifyBuffer.peek_next_p() && currenttotalsamples >= m_NotifyBuffer.peek_next_p()->TimestampSamples) + { + m_NotifyBuffer.pop(); + p = m_NotifyBuffer.peek_p(); + pnotify = p; + } + } + } + if(pnotify) { - p->dwType = 0; + if(!cansend) + { + // poll the semaphore instead of waiting directly after sending the message to avoid deadlocks on termination of openmpt or when stopping audio rendering + if(WaitForSingleObject(m_PendingNotificationSempahore, 0) == WAIT_OBJECT_0) + { + // last notification has been handled by gui thread, so we can pop the notify buffer + cansend = true; + } + } + if(cansend) + { + m_PendingNotification = *pnotify; // copy notification so that we can free the buffer + { + Util::lock_guard<Util::mutex> lock(m_NotificationBufferMutex); + m_NotifyBuffer.pop(); + } + if(PostMessage(WM_MOD_UPDATEPOSITIONTHREADED, 0, 0)) + { + cansend = false; + } + } } } - } - if (pnotify) - { - pMainFrm->m_dwStatus |= MODSTATUS_BUSY; - pMainFrm->PostMessage(WM_MOD_UPDATEPOSITION, 0, (LPARAM)pnotify); - } + break; } } - // Commented the two lines below as those caused "warning C4702: unreachable code" - //ExitThread(0); - //return 0; + return 0; } - - -ULONG CMPTSoundSource::AudioRead(PVOID pData, ULONG cbSize) -//--------------------------------------------------------- +void CMainFrame::SetAudioThreadActive(bool active) +//------------------------------------------------ { - CMainFrame *pMainFrm = (CMainFrame *)theApp.m_pMainWnd; - if (pMainFrm) return pMainFrm->AudioRead(pData, cbSize); - return 0; + if(active) + { + if(m_IsPlaybackRunning) return; + m_IsPlaybackRunning = true; + gpSoundDevice->Start(); + } else + { + if(!m_IsPlaybackRunning) return; + gpSoundDevice->Stop(); + m_IsPlaybackRunning = false; + } } -VOID CMPTSoundSource::AudioDone(ULONG nBytesWritten, ULONG nLatency) -//------------------------------------------------------------------ +void CMainFrame::FillAudioBufferLocked(IFillAudioBuffer &callback) +//---------------------------------------------------------------- { - CMainFrame *pMainFrm = (CMainFrame *)theApp.m_pMainWnd; - if (pMainFrm) pMainFrm->AudioDone(nBytesWritten, nLatency); + CriticalSection cs; + callback.FillAudioBuffer(); } - -ULONG CMainFrame::AudioRead(PVOID pvData, ULONG ulSize) -//----------------------------------------------------- +ULONG CMainFrame::AudioRead(PVOID pvData, ULONG MaxSamples) +//--------------------------------------------------------- { - if ((IsPlaying()) && (m_pSndFile)) - { - DWORD dwSamplesRead = m_pSndFile->Read(pvData, ulSize); + DWORD dwSamplesRead = m_pSndFile->Read(pvData, MaxSamples); //m_dTotalCPU = m_pPerfCounter->StartStop()/(static_cast<double>(dwSamplesRead)/m_dwRate); - return dwSamplesRead * slSampleSize; - } - return 0; + return dwSamplesRead; } -VOID CMainFrame::AudioDone(ULONG nBytesWritten, ULONG nLatency) -//------------------------------------------------------------- +void CMainFrame::AudioDone(ULONG SamplesWritten, ULONG SamplesLatency, bool end_of_stream) +//---------------------------------------------------------------------------------------- { - if (nBytesWritten > (DWORD)slSampleSize) + if (SamplesWritten > 0) { - DoNotification(nBytesWritten/CMainFrame::slSampleSize, nLatency); + DoNotification(SamplesWritten, SamplesLatency, end_of_stream); } } -LONG CMainFrame::audioTryOpeningDevice(UINT channels, UINT bits, UINT samplespersec) +bool CMainFrame::audioTryOpeningDevice(UINT channels, UINT bits, UINT samplespersec) //---------------------------------------------------------------------------------- { WAVEFORMATEXTENSIBLE WaveFormat; - UINT buflen = TrackerSettings::Instance().m_nBufferLength; - if (!m_pSndFile) return -1; - slSampleSize = (bits/8) * channels; - sdwAudioBufferSize = ((samplespersec * buflen) / 1000) * slSampleSize; - sdwAudioBufferSize = (sdwAudioBufferSize + 0x0F) & ~0x0F; - if (sdwAudioBufferSize < MIN_AUDIO_BUFFERSIZE) sdwAudioBufferSize = MIN_AUDIO_BUFFERSIZE; - if (sdwAudioBufferSize > MAX_AUDIO_BUFFERSIZE) sdwAudioBufferSize = MAX_AUDIO_BUFFERSIZE; + UINT bytespersample = (bits/8) * channels; WaveFormat.Format.wFormatTag = WAVE_FORMAT_PCM; WaveFormat.Format.nChannels = (unsigned short) channels; WaveFormat.Format.nSamplesPerSec = samplespersec; - WaveFormat.Format.nAvgBytesPerSec = samplespersec * slSampleSize; - WaveFormat.Format.nBlockAlign = (unsigned short) slSampleSize; + WaveFormat.Format.nAvgBytesPerSec = samplespersec * bytespersample; + WaveFormat.Format.nBlockAlign = (unsigned short)bytespersample; WaveFormat.Format.wBitsPerSample = (unsigned short)bits; WaveFormat.Format.cbSize = 0; // MultiChannel configuration @@ -890,79 +816,74 @@ case 2: WaveFormat.dwChannelMask = 0x0003; break; // FRONT_LEFT | FRONT_RIGHT case 3: WaveFormat.dwChannelMask = 0x0103; break; // FRONT_LEFT|FRONT_RIGHT|BACK_CENTER case 4: WaveFormat.dwChannelMask = 0x0033; break; // FRONT_LEFT|FRONT_RIGHT|BACK_LEFT|BACK_RIGHT - default: WaveFormat.dwChannelMask = 0; break; + default: WaveFormat.dwChannelMask = 0; return false; break; } WaveFormat.SubFormat = guid_MEDIASUBTYPE_PCM; } - if (TrackerSettings::Instance().m_dwSoundSetup & SOUNDSETUP_STREVERSE) CSoundFile::gdwSoundSetup |= SNDMIX_REVERSESTEREO; - else CSoundFile::gdwSoundSetup &= ~SNDMIX_REVERSESTEREO; - m_pSndFile->SetWaveConfig(samplespersec, bits, channels, (TrackerSettings::Instance().m_dwSoundSetup & SOUNDSETUP_ENABLEMMX) ? TRUE : FALSE); - // Maybe we failed because someone is playing sound already. - // Shut any sound off, and try once more before giving up. UINT nDevType = SNDDEV_GET_TYPE(TrackerSettings::Instance().m_nWaveDevice); - UINT nDevNo = SNDDEV_GET_NUMBER(TrackerSettings::Instance().m_nWaveDevice); - UINT fulOptions = (TrackerSettings::Instance().m_dwSoundSetup & SOUNDSETUP_SECONDARY) ? SNDDEV_OPTIONS_SECONDARY : 0; if ((gpSoundDevice) && (gpSoundDevice->GetDeviceType() != nDevType)) { - gpSoundDevice->Release(); + delete gpSoundDevice; gpSoundDevice = NULL; } - if (!gpSoundDevice) - { - if (!CreateSoundDevice(nDevType, &gpSoundDevice)) return -1; - } - gpSoundDevice->Configure(m_hWnd, NUM_AUDIO_BUFFERS, TrackerSettings::Instance().m_nBufferLength, fulOptions); - gbStopSent = FALSE; - m_pSndFile->SetResamplingMode(TrackerSettings::Instance().m_nSrcMode); - UpdateDspEffects(); -#ifndef NO_AGC - m_pSndFile->SetAGC(TrackerSettings::Instance().m_dwQuality & QUALITY_AGC); -#endif - if (!gpSoundDevice->Open(nDevNo, &WaveFormat.Format)) return -1; - return 0; + if(!gpSoundDevice) gpSoundDevice = CreateSoundDevice(nDevType); + if(!gpSoundDevice) return false; + gpSoundDevice->SetSource(this); + gpSoundDevice->Configure(m_hWnd, TrackerSettings::Instance().m_LatencyMS, TrackerSettings::Instance().m_UpdateIntervalMS, (TrackerSettings::Instance().m_dwSoundSetup & SOUNDSETUP_SECONDARY) ? SNDDEV_OPTIONS_SECONDARY : 0); + if (!gpSoundDevice->Open(SNDDEV_GET_NUMBER(TrackerSettings::Instance().m_nWaveDevice), &WaveFormat.Format)) return false; + return true; } -BOOL CMainFrame::audioOpenDevice() +bool CMainFrame::IsAudioDeviceOpen() const +//---------------------------------------- +{ + return gpSoundDevice && gpSoundDevice->IsOpen(); +} + + +bool CMainFrame::audioOpenDevice() //-------------------------------- { + if(IsAudioDeviceOpen()) return true; UINT nFixedBitsPerSample; - LONG err; + bool err = false; - if ((!m_pSndFile) || (!m_pSndFile->GetType())) return FALSE; - if (m_dwStatus & MODSTATUS_PLAYING) return TRUE; - if (!TrackerSettings::Instance().m_dwRate) TrackerSettings::Instance().m_dwRate = 22050; - if ((TrackerSettings::Instance().m_nChannels != 1) && (TrackerSettings::Instance().m_nChannels != 2) && (TrackerSettings::Instance().m_nChannels != 4)) TrackerSettings::Instance().m_nChannels = 2; - err = audioTryOpeningDevice(TrackerSettings::Instance().m_nChannels, + if (!TrackerSettings::Instance().m_dwRate) err = true; + if ((TrackerSettings::Instance().m_nChannels != 1) && (TrackerSettings::Instance().m_nChannels != 2) && (TrackerSettings::Instance().m_nChannels != 4)) err = true; + if(!err) + { + err = !audioTryOpeningDevice(TrackerSettings::Instance().m_nChannels, TrackerSettings::Instance().m_nBitsPerSample, TrackerSettings::Instance().m_dwRate); - nFixedBitsPerSample = (gpSoundDevice) ? gpSoundDevice->HasFixedBitsPerSample() : 0; - if ((err) && ((TrackerSettings::Instance().m_dwRate > 44100) || (TrackerSettings::Instance().m_nChannels > 2) || (TrackerSettings::Instance().m_nBitsPerSample > 16) - || ((nFixedBitsPerSample) && (nFixedBitsPerSample != TrackerSettings::Instance().m_nBitsPerSample)))) - { - DWORD oldrate = TrackerSettings::Instance().m_dwRate; - - TrackerSettings::Instance().m_dwRate = 44100; - if (TrackerSettings::Instance().m_nChannels > 2) TrackerSettings::Instance().m_nChannels = 2; - if (nFixedBitsPerSample) TrackerSettings::Instance().m_nBitsPerSample = nFixedBitsPerSample; - else if (TrackerSettings::Instance().m_nBitsPerSample > 16) TrackerSettings::Instance().m_nBitsPerSample = 16; - err = audioTryOpeningDevice(TrackerSettings::Instance().m_nChannels, + nFixedBitsPerSample = (gpSoundDevice) ? gpSoundDevice->HasFixedBitsPerSample() : 0; + if(err && (nFixedBitsPerSample && (nFixedBitsPerSample != TrackerSettings::Instance().m_nBitsPerSample))) + { + if(nFixedBitsPerSample) TrackerSettings::Instance().m_nBitsPerSample = nFixedBitsPerSample; + err = !audioTryOpeningDevice(TrackerSettings::Instance().m_nChannels, TrackerSettings::Instance().m_nBitsPerSample, TrackerSettings::Instance().m_dwRate); - if (err) TrackerSettings::Instance().m_dwRate = oldrate; + } } // Display error message box - if (err != 0) + if(err) { Reporting::Error("Unable to open sound device!"); - return FALSE; + return false; } // Device is ready - gdwLastMixActiveTime = timeGetTime(); - return TRUE; + return true; } +bool CMainFrame::audioReopenDevice() +//---------------------------------- +{ + audioCloseDevice(); + return audioOpenDevice(); +} + + void CMainFrame::audioCloseDevice() //--------------------------------- { @@ -972,6 +893,13 @@ gpSoundDevice->Reset(); gpSoundDevice->Close(); + + // reset notify buffer as timestamps revert here + { + Util::lock_guard<Util::mutex> lock(m_NotificationBufferMutex); + m_NotifyBuffer.clear(); + m_TotalSamplesRendered = 0; + } } } @@ -1007,36 +935,38 @@ } -BOOL CMainFrame::DoNotification(DWORD dwSamplesRead, DWORD dwLatency) +BOOL CMainFrame::DoNotification(DWORD dwSamplesRead, DWORD SamplesLatency, bool end_of_stream) //------------------------------------------------------------------- { - gsdwTotalSamples += dwSamplesRead; + int64 notificationtimestamp = 0; + { + Util::lock_guard<Util::mutex> lock(m_NotificationBufferMutex); // protect m_TotalSamplesRendered + m_TotalSamplesRendered += dwSamplesRead; + if(gpSoundDevice->HasGetStreamPosition()) + { + notificationtimestamp = m_TotalSamplesRendered; + } else + { + notificationtimestamp = m_TotalSamplesRendered + SamplesLatency; + } + } if (!m_pSndFile) return FALSE; if (m_nMixChn < m_pSndFile->m_nMixStat) m_nMixChn++; if (m_nMixChn > m_pSndFile->m_nMixStat) m_nMixChn--; if (!(m_dwNotifyType & MPTNOTIFY_TYPEMASK)) return FALSE; // Notify Client - for (UINT i=0; i<MAX_UPDATE_HISTORY; i++) + //if(m_NotifyBuffer.read_size() > 0) { - MPTNOTIFICATION *p = &NotifyBuffer[i]; - if ((p->dwType & MPTNOTIFY_TYPEMASK) - && (!(p->dwType & MPTNOTIFY_PENDING)) - && (gsdwTotalSamples >= p->dwLatency)) - { - p->dwType |= MPTNOTIFY_PENDING; - SetEvent(m_hNotifyWakeUp); - } + SetEvent(m_hNotifyWakeUp); } - if (!m_pSndFile) return FALSE; // Add an entry to the notification history - for (UINT j=0; j<MAX_UPDATE_HISTORY; j++) - { - MPTNOTIFICATION *p = &NotifyBuffer[j]; - if (!(p->dwType & MPTNOTIFY_TYPEMASK)) - { - p->dwType = m_dwNotifyType; - DWORD d = dwLatency / slSampleSize; - p->dwLatency = gsdwTotalSamples + d; + + MPTNOTIFICATION notification; + MemsetZero(notification); + MPTNOTIFICATION *p = ¬ification; + + p->dwType = m_dwNotifyType | (end_of_stream ? MPTNOTIFY_EOS : 0); + p->TimestampSamples = notificationtimestamp; p->nOrder = m_pSndFile->m_nCurrentOrder; p->nRow = m_pSndFile->m_nRow; p->nPattern = m_pSndFile->m_nPattern; @@ -1099,23 +1029,29 @@ UINT vur = pChn->nRightVU; p->dwPos[k] = (vul << 8) | (vur); } - } else if (m_dwNotifyType & MPTNOTIFY_MASTERVU) + } { DWORD lVu = (gnLVuMeter >> 11); DWORD rVu = (gnRVuMeter >> 11); if (lVu > 0x10000) lVu = 0x10000; if (rVu > 0x10000) rVu = 0x10000; - p->dwPos[0] = lVu; - p->dwPos[1] = rVu; + p->MasterVuLeft = lVu; + p->MasterVuRight = rVu; DWORD dwVuDecay = Util::muldiv(dwSamplesRead, 120000, TrackerSettings::Instance().m_dwRate) + 1; if (lVu >= dwVuDecay) gnLVuMeter = (lVu - dwVuDecay) << 11; else gnLVuMeter = 0; if (rVu >= dwVuDecay) gnRVuMeter = (rVu - dwVuDecay) << 11; else gnRVuMeter = 0; } - return TRUE; - } + + { + Util::lock_guard<Util::mutex> lock(m_NotificationBufferMutex); + if(m_NotifyBuffer.write_size() == 0) return FALSE; // drop notification + m_NotifyBuffer.push(notification); } - return FALSE; + SetEvent(m_hNotifyWakeUp); + + return TRUE; + } @@ -1183,14 +1119,6 @@ } -void CMainFrame::EnableLowLatencyMode(BOOL bOn) -//--------------------------------------------- -{ - gdwPlayLatency = (bOn) ? sdwAudioBufferSize : 0; - gdwLastLowLatencyTime = timeGetTime(); -} - - ///////////////////////////////////////////////////////////////////////////// // CMainFrame diagnostics @@ -1316,115 +1244,95 @@ } -BOOL CMainFrame::ResetNotificationBuffer(HWND hwnd) -//------------------------------------------------- +void CMainFrame::ResetNotificationBuffer() +//---------------------------------------- { - if ((!hwnd) || (m_hFollowSong == hwnd)) - { - MemsetZero(NotifyBuffer); - gsdwTotalSamples = 0; - return TRUE; - } - return FALSE; + Util::lock_guard<Util::mutex> lock(m_NotificationBufferMutex); + m_NotifyBuffer.clear(); } -BOOL CMainFrame::PlayMod(CModDoc *pModDoc, HWND hPat, DWORD dwNotifyType) -//----------------------------------------------------------------------- +void CMainFrame::ApplyTrackerSettings(CSoundFile *pSndFile) +//---------------------------------------------------------- { - if (!pModDoc) return FALSE; - CSoundFile *pSndFile = pModDoc->GetSoundFile(); - if ((!pSndFile) || (!pSndFile->GetType())) return FALSE; - const bool bPaused = pSndFile->IsPaused(); - const bool bPatLoop = pSndFile->m_SongFlags[SONG_PATTERNLOOP]; - pSndFile->ResetChannels(); - // Select correct bidi loop mode when playing a module. - pSndFile->SetupITBidiMode(); - - if(m_pSndFile != nullptr || (m_dwStatus & MODSTATUS_PLAYING)) PauseMod(); - if(m_pSndFile != nullptr && (pSndFile != m_pSndFile || !m_pSndFile->GetTotalSampleCount())) - { + if(!pSndFile) return; + if (TrackerSettings::Instance().m_dwSoundSetup & SOUNDSETUP_STREVERSE) CSoundFile::gdwSoundSetup |= SNDMIX_REVERSESTEREO; + else CSoundFile::gdwSoundSetup &= ~SNDMIX_REVERSESTEREO; + pSndFile->SetWaveConfig(TrackerSettings::Instance().m_dwRate, TrackerSettings::Instance().m_nBitsPerSample, TrackerSettings::Instance().m_nChannels, (TrackerSettings::Instance().m_dwSoundSetup & SOUNDSETUP_ENABLEMMX) ? TRUE : FALSE); + pSndFile->SetResamplingMode(TrackerSettings::Instance().m_nSrcMode); + UpdateDspEffects(); #ifndef NO_AGC - CSoundFile::m_AGC.Reset(); + pSndFile->SetAGC(TrackerSettings::Instance().m_dwQuality & QUALITY_AGC); #endif - } - m_pSndFile = pSndFile; - m_pModPlaying = pModDoc; - m_hFollowSong = hPat; - m_dwNotifyType = dwNotifyType; - if (m_dwNotifyType & MPTNOTIFY_MASTERVU) - { - gnLVuMeter = gnRVuMeter = 0; - CSoundFile::gpSndMixHook = CalcStereoVuMeters; - } else - { - CSoundFile::gpSndMixHook = NULL; - } + pSndFile->SetMasterVolume(TrackerSettings::Instance().m_nPreAmp, true); + pSndFile->SetMixerSettings(TrackerSettings::Instance().m_MixerSettings); +#ifndef NO_AGC + CSoundFile::m_AGC.Reset(); +#endif +} - if (!audioOpenDevice()) - { - m_pSndFile = NULL; - m_pModPlaying = NULL; - m_hFollowSong = NULL; - return FALSE; - } - m_nMixChn = m_nAvgMixChn = 0; - gsdwTotalSamples = 0; - if (!bPatLoop) - { - if (bPaused) - { - pSndFile->m_SongFlags.set(SONG_PAUSED); - } - } - pSndFile->SetRepeatCount((TrackerSettings::Instance().gbLoopSong) ? -1 : 0); - m_pSndFile->SetMasterVolume(TrackerSettings::Instance().m_nPreAmp, true); - m_pSndFile->SetMixerSettings(TrackerSettings::Instance().m_MixerSettings); - m_pSndFile->InitPlayer(TRUE); - MemsetZero(NotifyBuffer); - m_dwStatus |= MODSTATUS_PLAYING; - m_wndToolBar.SetCurrentSong(m_pSndFile); - if (gpSoundDevice) gpSoundDevice->Start(); - SetEvent(m_hAudioWakeUp); - return TRUE; +bool CMainFrame::PreparePlayback() +//-------------------------------- +{ + // open the audio device to update needed TrackerSettings mixer parameters + if(!audioOpenDevice()) return false; + return true; } -BOOL CMainFrame::PauseMod(CModDoc *pModDoc) +bool CMainFrame::StartPlayback() +//------------------------------ +{ + if(!m_pSndFile) return false; // nothing to play + if(!IsAudioDeviceOpen()) return false; + SetAudioThreadActive(true); + return true; +} + + +void CMainFrame::StopPlayback() +//----------------------------- +{ + if(!IsAudioDeviceOpen()) return; + SetAudioThreadActive(false); + audioCloseDevice(); +} + + +bool CMainFrame::PausePlayback() +//------------------------------ +{ + if(!IsAudioDeviceOpen()) return false; + SetAudioThreadActive(false); + return true; +} + + +void CMainFrame::GenerateStopNotification() //----------------------------------------- { - if ((pModDoc) && (pModDoc != m_pModPlaying)) return FALSE; - if (m_dwStatus & MODSTATUS_PLAYING) - { - m_dwStatus &= ~MODSTATUS_PLAYING; + MPTNOTIFICATION mn; + MemsetZero(mn); + mn.dwType = MPTNOTIFY_STOP; + SendMessage(WM_MOD_UPDATEPOSITION, 0, (LPARAM)&mn); +} - if (gpSoundDevice) gpSoundDevice->Reset(); - audioCloseDevice(); +void CMainFrame::UnsetPlaybackSoundFile() +//--------------------------------------- +{ + if(m_pSndFile) + { + m_pSndFile->SuspendPlugins(); + m_nMixChn = 0; + m_nAvgMixChn = 0; + if(m_pSndFile->GetpModDoc()) { - CriticalSection cs; - m_pSndFile->SuspendPlugins(); + m_wndTree.UpdatePlayPos(m_pSndFile->GetpModDoc(), NULL); } - - m_nMixChn = m_nAvgMixChn = 0; - Sleep(1); - if (m_hFollowSong) - { - MPTNOTIFICATION mn; - MemsetZero(mn); - mn.dwType = MPTNOTIFY_STOP; - ::SendMessage(m_hFollowSong, WM_MOD_UPDATEPOSITION, 0, (LPARAM)&mn); - } - } - if (m_pModPlaying) - { - m_wndTree.UpdatePlayPos(m_pModPlaying, NULL); - } - if (m_pSndFile) - { m_pSndFile->m_SongFlags.reset(SONG_PAUSED); - if (m_pSndFile == &m_WaveFile) + if(m_pSndFile == &m_WaveFile) { // Unload previewed instrument m_WaveFile.Destroy(); @@ -1440,45 +1348,165 @@ } } } - - m_pModPlaying = nullptr; m_pSndFile = nullptr; - m_hFollowSong = nullptr; - m_wndToolBar.SetCurrentSong(NULL); - return TRUE; + m_hFollowSong = NULL; + m_wndToolBar.SetCurrentSong(nullptr); + { + Util::lock_guard<Util::mutex> lock(m_NotificationBufferMutex); + m_NotifyBuffer.clear(); + } } -BOOL CMainFrame::StopMod(CModDoc *pModDoc) +void CMainFrame::SetPlaybackSoundFile(CSoundFile *pSndFile, HWND hPat, DWORD dwNotifyType) +//---------------------------------------------------------------------------------------- +{ + m_pSndFile = pSndFile; + m_hFollowSong = hPat; + m_dwNotifyType = dwNotifyType; +} + + +bool CMainFrame::PlayMod(CModDoc *pModDoc, HWND hPat, DWORD dwNotifyType) +//----------------------------------------------------------------------- +{ + CriticalSection::AssertUnlocked(); + if(!pModDoc) return false; + CSoundFile *pSndFile = pModDoc->GetSoundFile(); + if(!IsValidSoundFile(pSndFile)) return false; + + // if something is playing, pause it + PausePlayback(); + GenerateStopNotification(); + + UnsetPlaybackSoundFile(); + + // open audio device if not already open + if (!PreparePlayback()) return false; + + // set mixing parameters in CSoundFile + ApplyTrackerSettings(pSndFile); + + SetPlaybackSoundFile(pSndFile, hPat, dwNotifyType); + + const bool bPaused = m_pSndFile->IsPaused(); + const bool bPatLoop = m_pSndFile->m_SongFlags[SONG_PATTERNLOOP]; + + m_pSndFile... [truncated message content] |
From: <sag...@us...> - 2013-04-03 14:51:28
|
Revision: 1719 http://sourceforge.net/p/modplug/code/1719 Author: saga-games Date: 2013-04-03 14:51:10 +0000 (Wed, 03 Apr 2013) Log Message: ----------- [Reg] Removed poorly implemented Invert Stereo option. It's not 1995 anymore. [Mod] OpenMPT: Version is now 1.21.01.26 Modified Paths: -------------- trunk/OpenMPT/common/version.h trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/common/version.h =================================================================== --- trunk/OpenMPT/common/version.h 2013-04-03 13:25:13 UTC (rev 1718) +++ trunk/OpenMPT/common/version.h 2013-04-03 14:51:10 UTC (rev 1719) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 21 #define VER_MINOR 01 -#define VER_MINORMINOR 25 +#define VER_MINORMINOR 26 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-04-03 13:25:13 UTC (rev 1718) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-04-03 14:51:10 UTC (rev 1719) @@ -1089,10 +1089,6 @@ TrackerSettings::Instance().m_nBitsPerSample, TrackerSettings::Instance().m_nChannels, (TrackerSettings::Instance().m_dwSoundSetup & SOUNDSETUP_ENABLEMMX) ? TRUE : FALSE); - if (TrackerSettings::Instance().m_dwSoundSetup & SOUNDSETUP_STREVERSE) - CSoundFile::gdwSoundSetup |= SNDMIX_REVERSESTEREO; - else - CSoundFile::gdwSoundSetup &= ~SNDMIX_REVERSESTEREO; // Soft panning if (TrackerSettings::Instance().m_dwSoundSetup & SOUNDSETUP_SOFTPANNING) @@ -1256,8 +1252,6 @@ //---------------------------------------------------------- { if(!pSndFile) return; - if (TrackerSettings::Instance().m_dwSoundSetup & SOUNDSETUP_STREVERSE) CSoundFile::gdwSoundSetup |= SNDMIX_REVERSESTEREO; - else CSoundFile::gdwSoundSetup &= ~SNDMIX_REVERSESTEREO; pSndFile->SetWaveConfig(TrackerSettings::Instance().m_dwRate, TrackerSettings::Instance().m_nBitsPerSample, TrackerSettings::Instance().m_nChannels, (TrackerSettings::Instance().m_dwSoundSetup & SOUNDSETUP_ENABLEMMX) ? TRUE : FALSE); pSndFile->SetResamplingMode(TrackerSettings::Instance().m_nSrcMode); UpdateDspEffects(); @@ -1648,7 +1642,7 @@ m_WaveFile.m_nSamplePreAmp = 48; m_WaveFile.m_nDefaultTempo = 125; m_WaveFile.m_nDefaultSpeed = 6; - m_WaveFile.m_nType = MOD_TYPE_IT; + m_WaveFile.m_nType = MOD_TYPE_MPT; m_WaveFile.m_nChannels = 4; m_WaveFile.m_nInstruments = 1; m_WaveFile.m_nTempoMode = tempo_mode_classic; @@ -1737,10 +1731,6 @@ // No need to restart playback TrackerSettings::Instance().m_dwSoundSetup = q; CSoundFile::EnableMMX((TrackerSettings::Instance().m_dwSoundSetup & SOUNDSETUP_ENABLEMMX) != 0); - if (TrackerSettings::Instance().m_dwSoundSetup & SOUNDSETUP_STREVERSE) - CSoundFile::gdwSoundSetup |= SNDMIX_REVERSESTEREO; - else - CSoundFile::gdwSoundSetup &= ~SNDMIX_REVERSESTEREO; } return TRUE; } Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-04-03 13:25:13 UTC (rev 1718) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-04-03 14:51:10 UTC (rev 1719) @@ -19,7 +19,6 @@ #include "soundlib/snddev.h" class CInputHandler; -class CMainFrame; class CModDoc; class CAutoSaver; class ISoundDevice; @@ -112,7 +111,6 @@ #define SOUNDSETUP_ENABLEMMX 0x08 #define SOUNDSETUP_SOFTPANNING 0x10 -#define SOUNDSETUP_STREVERSE 0x20 #define SOUNDSETUP_SECONDARY 0x40 #define SOUNDSETUP_RESTARTMASK SOUNDSETUP_SECONDARY @@ -344,7 +342,6 @@ protected: - CSoundFile m_WaveFile; CModTreeBar m_wndTree; CStatusBar m_wndStatusBar; CMainToolBar m_wndToolBar; @@ -355,7 +352,10 @@ CSoundFile::samplecount_t m_dwTimeSec; UINT_PTR m_nTimer; UINT m_nAvgMixChn, m_nMixChn; - CHAR m_szUserText[512], m_szInfoText[512], m_szXInfoText[512]; //rewbs.xinfo + // Misc + CModDoc* m_pJustModifiedDoc; + class COptionsSoundcard *m_SoundCardOptionsDialog; + bool m_bOptionsLocked; // Notification Buffer Util::mutex m_NotificationBufferMutex; // to avoid deadlocks, this mutex should only be taken as a innermost lock, i.e. do not block on anything while holding this mutex @@ -364,11 +364,11 @@ HANDLE m_PendingNotificationSempahore; // protects the one notification that is in flight from the notification thread to the gui thread from being freed while the gui thread still uses it MPTNOTIFICATION m_PendingNotification; - // Misc - bool m_bOptionsLocked; //rewbs.customKeys - class COptionsSoundcard * m_SoundCardOptionsDialog; - CModDoc* m_pJustModifiedDoc; + // Instrument preview in tree view + CSoundFile m_WaveFile; + CHAR m_szUserText[512], m_szInfoText[512], m_szXInfoText[512]; //rewbs.xinfo + public: CMainFrame(/*CString regKeyExtension*/); void Initialize(); Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-04-03 13:25:13 UTC (rev 1718) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-04-03 14:51:10 UTC (rev 1719) @@ -123,7 +123,6 @@ CHAR s[128]; CPropertyPage::OnInitDialog(); - if (m_dwSoundSetup & SOUNDSETUP_STREVERSE) CheckDlgButton(IDC_CHECK1, MF_CHECKED); if (m_dwSoundSetup & SOUNDSETUP_SOFTPANNING) CheckDlgButton(IDC_CHECK2, MF_CHECKED); if (m_dwSoundSetup & SOUNDSETUP_ENABLEMMX) CheckDlgButton(IDC_CHECK3, MF_CHECKED); if (m_dwSoundSetup & SOUNDSETUP_SECONDARY) CheckDlgButton(IDC_CHECK4, MF_CHECKED); @@ -411,8 +410,7 @@ void COptionsSoundcard::OnOK() //---------------------------- { - m_dwSoundSetup &= ~(SOUNDSETUP_ENABLEMMX | SOUNDSETUP_SECONDARY | SOUNDSETUP_STREVERSE | SOUNDSETUP_SOFTPANNING); - if (IsDlgButtonChecked(IDC_CHECK1)) m_dwSoundSetup |= SOUNDSETUP_STREVERSE; + m_dwSoundSetup &= ~(SOUNDSETUP_ENABLEMMX | SOUNDSETUP_SECONDARY | SOUNDSETUP_SOFTPANNING); if (IsDlgButtonChecked(IDC_CHECK2)) m_dwSoundSetup |= SOUNDSETUP_SOFTPANNING; if (IsDlgButtonChecked(IDC_CHECK3)) m_dwSoundSetup |= SOUNDSETUP_ENABLEMMX; if (IsDlgButtonChecked(IDC_CHECK4)) m_dwSoundSetup |= SOUNDSETUP_SECONDARY; Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-04-03 13:25:13 UTC (rev 1718) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-04-03 14:51:10 UTC (rev 1719) @@ -100,6 +100,7 @@ recordQuantizeRows = 0; rowDisplayOffset = 0; + // Sample Editor m_nSampleUndoMaxBuffer = 0; // Real sample buffer undo size will be set later. GetDefaultColourScheme(rgbCustomColors); @@ -318,6 +319,8 @@ #endif // NO_ASIO m_nWaveDevice = CMainFrame::GetPrivateProfileLong("Sound Settings", "WaveDevice", defaultDevice, iniFile); m_dwSoundSetup = CMainFrame::GetPrivateProfileDWord("Sound Settings", "SoundSetup", m_dwSoundSetup, iniFile); + if(vIniVersion < MAKE_VERSION_NUMERIC(1, 21, 01, 26)) + m_dwSoundSetup &= ~0x20; // Reverse stereo m_dwQuality = CMainFrame::GetPrivateProfileDWord("Sound Settings", "Quality", m_dwQuality, iniFile); m_nSrcMode = CMainFrame::GetPrivateProfileDWord("Sound Settings", "SrcMode", m_nSrcMode, iniFile); m_dwRate = CMainFrame::GetPrivateProfileDWord("Sound Settings", "Mixing_Rate", 0, iniFile); @@ -580,7 +583,7 @@ if (RegOpenKeyEx(HKEY_CURRENT_USER, m_csRegKey, 0, KEY_READ, &key) == ERROR_SUCCESS) { RegQueryValueEx(key, "SoundSetup", NULL, &dwREG_DWORD, (LPBYTE)&m_dwSoundSetup, &dwDWORDSize); - RegQueryValueEx(key, "WaveDevice", NULL, &dwREG_DWORD, (LPBYTE)&m_nWaveDevice, &dwDWORDSize); + m_dwSoundSetup &= ~0x20; // Reverse stereo RegQueryValueEx(key, "Quality", NULL, &dwREG_DWORD, (LPBYTE)&m_dwQuality, &dwDWORDSize); RegQueryValueEx(key, "SrcMode", NULL, &dwREG_DWORD, (LPBYTE)&m_nSrcMode, &dwDWORDSize); RegQueryValueEx(key, "Mixing_Rate", NULL, &dwREG_DWORD, (LPBYTE)&m_dwRate, &dwDWORDSize); Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2013-04-03 13:25:13 UTC (rev 1718) +++ trunk/OpenMPT/mptrack/mptrack.rc 2013-04-03 14:51:10 UTC (rev 1719) @@ -1286,9 +1286,8 @@ COMBOBOX IDC_COMBO5,156,84,72,80,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Max. Polyphony:",IDC_STATIC,12,102,57,12,SS_CENTERIMAGE COMBOBOX IDC_COMBO4,78,102,72,88,CBS_DROPDOWNLIST | WS_TABSTOP - CONTROL "Soft Panning",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,138,64,12 - CONTROL "Reverse Stereo",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,84,138,62,12 - CONTROL "Enable MMX Acceleration",IDC_CHECK3,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,156,138,102,12 + CONTROL "Soft Panning",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,138,78,12 + CONTROL "Enable MMX Acceleration",IDC_CHECK3,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,96,138,156,12 LTEXT "Stereo Separation:",IDC_STATIC,12,157,62,8 LTEXT "100%",IDC_TEXT1,80,157,20,8 RTEXT "Low",IDC_STATIC,22,168,15,14,SS_CENTERIMAGE Modified: trunk/OpenMPT/soundlib/Snd_defs.h =================================================================== --- trunk/OpenMPT/soundlib/Snd_defs.h 2013-04-03 13:25:13 UTC (rev 1718) +++ trunk/OpenMPT/soundlib/Snd_defs.h 2013-04-03 14:51:10 UTC (rev 1719) @@ -272,7 +272,6 @@ #define SONG_PLAY_FLAGS (~SONG_FILE_FLAGS) // Global Options (Renderer) -#define SNDMIX_REVERSESTEREO 0x0001 // swap L/R audio channels #ifndef NO_DSP #define SNDMIX_NOISEREDUCTION 0x0002 // reduce hiss (do not use, it's just a simple low-pass filter) #endif // NO_DSP Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-04-03 13:25:13 UTC (rev 1718) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-04-03 14:51:10 UTC (rev 1719) @@ -1975,7 +1975,6 @@ pan /= 128; pan += 128; Limit(pan, 0, 256); - if (gdwSoundSetup & SNDMIX_REVERSESTEREO) pan = 256 - pan; LONG realvol; if (m_pConfig->getUseGlobalPreAmp()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-04-03 22:12:16
|
Revision: 1721 http://sourceforge.net/p/modplug/code/1721 Author: saga-games Date: 2013-04-03 22:12:01 +0000 (Wed, 03 Apr 2013) Log Message: ----------- [Ref] Turned various pointers in CVstPlugin into references. Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/SelectPluginDialog.cpp trunk/OpenMPT/mptrack/SelectPluginDialog.h trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/Vstplug.h trunk/OpenMPT/soundlib/SampleFormats.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/plugins/PlugInterface.h Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2013-04-03 14:57:18 UTC (rev 1720) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2013-04-03 22:12:01 UTC (rev 1721) @@ -173,9 +173,9 @@ if(error == VSTPresets::noError) { - CSoundFile *pSndFile = m_pVstPlugin->m_pSndFile; + const CSoundFile &sndFile = m_pVstPlugin->GetSoundFile(); CModDoc *pModDoc; - if(pSndFile != nullptr && pSndFile->GetModSpecifications().supportsPlugins && (pModDoc = pSndFile->GetpModDoc()) != nullptr) + if(sndFile.GetModSpecifications().supportsPlugins && (pModDoc = sndFile.GetpModDoc()) != nullptr) { pModDoc->SetModified(); } @@ -236,9 +236,9 @@ m_pMenu->ModifyMenu(8, MF_BYPOSITION, 0, m_pVstPlugin->GetFormattedProgramName(m_pVstPlugin->GetCurrentProgram())); } - + DrawMenuBar(); - + } @@ -250,8 +250,8 @@ { m_pVstPlugin->SetCurrentProgram(nIndex); UpdatePresetField(); - - if(m_pVstPlugin->m_pSndFile->GetModSpecifications().supportsPlugins) + + if(m_pVstPlugin->GetSoundFile().GetModSpecifications().supportsPlugins) { m_pVstPlugin->GetModDoc()->SetModified(); } @@ -265,7 +265,7 @@ if(m_pVstPlugin) { m_pVstPlugin->ToggleBypass(); - if(m_pVstPlugin->m_pSndFile->GetModSpecifications().supportsPlugins) + if(m_pVstPlugin->GetSoundFile().GetModSpecifications().supportsPlugins) { m_pVstPlugin->GetModDoc()->SetModified(); } @@ -309,25 +309,25 @@ if (pMsg) { //We handle keypresses before Windows has a chance to handle them (for alt etc..) - if(!m_pVstPlugin->m_bPassKeypressesToPlug && - (pMsg->message == WM_SYSKEYUP || pMsg->message == WM_KEYUP || + if(!m_pVstPlugin->m_bPassKeypressesToPlug && + (pMsg->message == WM_SYSKEYUP || pMsg->message == WM_KEYUP || pMsg->message == WM_SYSKEYDOWN || pMsg->message == WM_KEYDOWN) ) { CInputHandler *ih = (CMainFrame::GetMainFrame())->GetInputHandler(); - + //Translate message manually UINT nChar = pMsg->wParam; UINT nRepCnt = LOWORD(pMsg->lParam); UINT nFlags = HIWORD(pMsg->lParam); KeyEventType kT = ih->GetKeyEventType(nFlags); - + // If we successfully mapped to a command and plug does not listen for keypresses, no need to pass message on. if(ih->KeyEvent(kCtxVSTGUI, nChar, nRepCnt, nFlags, kT, (CWnd*)this) != kcNull) { return true; } - + // Don't forward key repeats if plug does not listen for keypresses // (avoids system beeps on note hold) if(kT == kKeyEventRepeat) @@ -341,12 +341,13 @@ } + void CAbstractVstEditor::SetTitle() //--------------------------------- { if(m_pVstPlugin && m_pVstPlugin->m_pMixStruct) { - CString Title; + CString Title; Title.Format("FX %02d: ", m_pVstPlugin->m_nSlot + 1); if(strcmp(m_pVstPlugin->m_pMixStruct->GetName(), "")) @@ -358,12 +359,13 @@ } } + LRESULT CAbstractVstEditor::OnCustomKeyMsg(WPARAM wParam, LPARAM /*lParam*/) //-------------------------------------------------------------------------- { if(wParam == kcNull) return NULL; - + // CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); switch(wParam) @@ -436,7 +438,7 @@ { return true; } - + } @@ -599,7 +601,7 @@ for(size_t nChn=0; nChn<inputChannels.size(); nChn++) { if(nChn == 0 && inputPlugs.size()) - { + { m_pInputMenu->AppendMenu(MF_SEPARATOR); } name.Format("Chn%02d: %s", inputChannels[nChn] + 1, pSndFile->ChnSettings[inputChannels[nChn]].szName); @@ -612,7 +614,7 @@ { bool checked = false; if(nIns == 0 && (inputPlugs.size() || inputChannels.size())) - { + { m_pInputMenu->AppendMenu(MF_SEPARATOR); } name.Format("Ins%02d: %s", inputInstruments[nIns], pSndFile->GetInstrumentName(inputInstruments[nIns])); @@ -662,7 +664,7 @@ name = "Master Output"; m_pOutputMenu->AppendMenu(MF_STRING | MF_GRAYED, NULL, name); } - + } pInfoMenu->InsertMenu(1, MF_BYPOSITION | MF_POPUP, reinterpret_cast<UINT_PTR>(m_pOutputMenu->m_hMenu), "Ou&tputs"); } @@ -704,9 +706,9 @@ if(macroType == sfx_unused) { - macroName = "Unused. Learn Param..."; + macroName = "Unused. Learn Param..."; action= ID_LEARN_MACRO_FROM_PLUGGUI + nMacro; - greyed = false; + greyed = false; } else { macroName = midiCfg.GetParameteredMacroName(nMacro, m_pVstPlugin->GetSlot(), *pModDoc->GetSoundFile()); @@ -733,7 +735,7 @@ CInputHandler *ih = (CMainFrame::GetMainFrame())->GetInputHandler(); m_pOptionsMenu->CreatePopupMenu(); - + //Bypass m_pOptionsMenu->AppendMenu(MF_STRING | m_pVstPlugin->IsBypassed() ? MF_CHECKED : 0, ID_PLUG_BYPASS, "&Bypass Plugin\t" + ih->GetKeyTextFromCommand(kcVSTGUIBypassPlug)); @@ -776,11 +778,11 @@ bool CAbstractVstEditor::CheckInstrument(INSTRUMENTINDEX ins) //----------------------------------------------------------- { - CSoundFile* pSndFile = m_pVstPlugin->GetSoundFile(); - - if(ins != INSTRUMENTINDEX_INVALID && ins < MAX_INSTRUMENTS && pSndFile->Instruments[ins] != nullptr) + const CSoundFile &sndFile = m_pVstPlugin->GetSoundFile(); + + if(ins != INSTRUMENTINDEX_INVALID && ins < MAX_INSTRUMENTS && sndFile.Instruments[ins] != nullptr) { - return (pSndFile->Instruments[ins]->nMixPlug) == (m_pVstPlugin->m_nSlot + 1); + return (sndFile.Instruments[ins]->nMixPlug) == (m_pVstPlugin->m_nSlot + 1); } return false; } @@ -819,7 +821,7 @@ void CAbstractVstEditor::OnSetPreviousVSTPreset() //----------------------------------------------- { - OnSetPreset(ID_PRESET_SET + m_pVstPlugin->GetCurrentProgram() - 1); + OnSetPreset(ID_PRESET_SET + m_pVstPlugin->GetCurrentProgram() - 1); } @@ -856,32 +858,32 @@ //----------------------------------------- { CModDoc *pModDoc = m_pVstPlugin->GetModDoc(); - CSoundFile *pSndFile = m_pVstPlugin->GetSoundFile(); - if(pModDoc == nullptr || pSndFile == nullptr) + CSoundFile &sndFile = m_pVstPlugin->GetSoundFile(); + if(pModDoc == nullptr) { return false; } - bool bFirst = (pSndFile->GetNumInstruments() == 0); - INSTRUMENTINDEX nIns = pModDoc->InsertInstrument(0); + const bool first = (sndFile.GetNumInstruments() == 0); + INSTRUMENTINDEX nIns = pModDoc->InsertInstrument(0); if(nIns == INSTRUMENTINDEX_INVALID) { return false; } - ModInstrument *pIns = pSndFile->Instruments[nIns]; + ModInstrument *pIns = sndFile.Instruments[nIns]; m_nInstrument = nIns; - _snprintf(pIns->name, CountOf(pIns->name) - 1, _T("%d: %s"), m_pVstPlugin->GetSlot() + 1, pSndFile->m_MixPlugins[m_pVstPlugin->GetSlot()].GetName()); - StringFixer::CopyN(pIns->filename, pSndFile->m_MixPlugins[m_pVstPlugin->GetSlot()].GetLibraryName()); + _snprintf(pIns->name, CountOf(pIns->name) - 1, _T("%d: %s"), m_pVstPlugin->GetSlot() + 1, sndFile.m_MixPlugins[m_pVstPlugin->GetSlot()].GetName()); + StringFixer::CopyN(pIns->filename, sndFile.m_MixPlugins[m_pVstPlugin->GetSlot()].GetLibraryName()); pIns->nMixPlug = (PLUGINDEX)m_pVstPlugin->GetSlot() + 1; pIns->nMidiChannel = 1; // People will forget to change this anyway, so the following lines can lead to some bad surprises after re-opening the module. //pIns->wMidiBank = (WORD)((m_pVstPlugin->GetCurrentProgram() >> 7) + 1); //pIns->nMidiProgram = (BYTE)((m_pVstPlugin->GetCurrentProgram() & 0x7F) + 1); - pModDoc->UpdateAllViews(NULL, (nIns << HINT_SHIFT_INS) | HINT_INSTRUMENT | HINT_INSNAMES | HINT_ENVELOPE | (bFirst ? HINT_MODTYPE : 0)); - if(pSndFile->GetModSpecifications().supportsPlugins) + pModDoc->UpdateAllViews(NULL, (nIns << HINT_SHIFT_INS) | HINT_INSTRUMENT | HINT_INSNAMES | HINT_ENVELOPE | (first ? HINT_MODTYPE : 0)); + if(sndFile.GetModSpecifications().supportsPlugins) { pModDoc->SetModified(); } Modified: trunk/OpenMPT/mptrack/SelectPluginDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2013-04-03 14:57:18 UTC (rev 1720) +++ trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2013-04-03 22:12:01 UTC (rev 1721) @@ -50,12 +50,11 @@ m_pModDoc = pModDoc; m_nPlugSlot = nPlugSlot; - if (m_pModDoc) + if(m_pModDoc) { - CSoundFile* pSndFile = pModDoc->GetSoundFile(); - if (pSndFile && (0 <= m_nPlugSlot && m_nPlugSlot < MAX_MIXPLUGINS)) + if(0 <= m_nPlugSlot && m_nPlugSlot < MAX_MIXPLUGINS) { - m_pPlugin = &pSndFile->m_MixPlugins[m_nPlugSlot]; + m_pPlugin = &(pModDoc->GetrSoundFile().m_MixPlugins[m_nPlugSlot]); } } @@ -105,10 +104,7 @@ void CSelectPluginDlg::OnOK() //--------------------------- { - // -> CODE#0002 - // -> DESC="list box to choose VST plugin presets (programs)" if(m_pPlugin==nullptr) { CDialog::OnOK(); return; } - // -! NEW_FEATURE#0002 bool changed = false; CVstPluginManager *pManager = theApp.GetPluginManager(); @@ -121,7 +117,7 @@ if (pFactory) { // Plugin selected - if ((!pCurrentPlugin) || (pCurrentPlugin->GetPluginFactory() != pFactory)) + if ((!pCurrentPlugin) || &pCurrentPlugin->GetPluginFactory() != pFactory) { CriticalSection cs; @@ -158,9 +154,9 @@ cs.Leave(); // Now, create the new plugin - if (pManager) + if(pManager && m_pModDoc) { - pManager->CreateMixPlugin(m_pPlugin, (m_pModDoc) ? m_pModDoc->GetSoundFile() : 0); + pManager->CreateMixPlugin(*m_pPlugin, m_pModDoc->GetrSoundFile()); if (m_pPlugin->pMixPlugin) { CHAR s[128]; @@ -211,8 +207,7 @@ if(m_pPlugin->Info.dwPluginId2) TrackerSettings::Instance().gnPlugWindowLast = m_pPlugin->Info.dwPluginId2; CDialog::OnOK(); - } - else + } else { CDialog::OnCancel(); } @@ -234,7 +229,7 @@ } -void CSelectPluginDlg::OnNameFilterChanged() +void CSelectPluginDlg::OnNameFilterChanged() //------------------------------------------ { GetDlgItem(IDC_NAMEFILTER)->GetWindowText(m_sNameFilter); @@ -271,7 +266,7 @@ { VSTPluginLib::catDMO, "DirectX Media Audio Effects" }, { VSTPluginLib::catSynth, "Instrument Plugins" }, }; - + std::bitset<VSTPluginLib::numCategories> categoryUsed; HTREEITEM categoryFolders[VSTPluginLib::numCategories]; for(size_t i = CountOf(categories); i != 0; ) @@ -322,7 +317,7 @@ { //Current slot's plugin CVstPlugin *pVstPlug = (CVstPlugin *)m_pPlugin->pMixPlugin; - if (pVstPlug->GetPluginFactory() == p) + if (&pVstPlug->GetPluginFactory() == p) { currentPlug = h; } @@ -413,7 +408,7 @@ } -bool CSelectPluginDlg::VerifyPlug(VSTPluginLib *plug) +bool CSelectPluginDlg::VerifyPlug(VSTPluginLib *plug) //--------------------------------------------------- { // TODO: Keep this list up-to-date. @@ -518,10 +513,10 @@ ::MoveWindow(GetDlgItem(IDC_STATIC_VSTNAMEFILTER)->m_hWnd, 8, 11, 40, 21, FALSE); ::MoveWindow(GetDlgItem(IDC_NAMEFILTER)->m_hWnd, 40, 8, cx - 136, 21, FALSE); - ::MoveWindow(GetDlgItem(IDC_TEXT_CURRENT_VSTPLUG)->m_hWnd, 8, cy - 20, cx - 22, 25, FALSE); + ::MoveWindow(GetDlgItem(IDC_TEXT_CURRENT_VSTPLUG)->m_hWnd, 8, cy - 20, cx - 22, 25, FALSE); ::MoveWindow(GetDlgItem(IDOK)->m_hWnd, cx-85, 8, 75, 23, FALSE); ::MoveWindow(GetDlgItem(IDCANCEL)->m_hWnd, cx-85, 39, 75, 23, FALSE); - ::MoveWindow(GetDlgItem(IDC_BUTTON1)->m_hWnd , cx-85, cy-80, 75, 23, FALSE); + ::MoveWindow(GetDlgItem(IDC_BUTTON1)->m_hWnd , cx-85, cy-80, 75, 23, FALSE); ::MoveWindow(GetDlgItem(IDC_BUTTON2)->m_hWnd, cx-85, cy-52, 75, 23, FALSE); Invalidate(); } @@ -535,4 +530,4 @@ CDialog::OnGetMinMaxInfo(lpMMI); } -#endif // NO_VST +#endif // NO_VST \ No newline at end of file Modified: trunk/OpenMPT/mptrack/SelectPluginDialog.h =================================================================== --- trunk/OpenMPT/mptrack/SelectPluginDialog.h 2013-04-03 14:57:18 UTC (rev 1720) +++ trunk/OpenMPT/mptrack/SelectPluginDialog.h 2013-04-03 22:12:01 UTC (rev 1721) @@ -29,7 +29,7 @@ HTREEITEM AddTreeItem(const char *title, int image, bool sort, HTREEITEM hParent = TVI_ROOT, LPARAM lParam = NULL); public: - CSelectPluginDlg(CModDoc *pModDoc, int nPlugSlot, CWnd *parent); //rewbs.plugDocAware + CSelectPluginDlg(CModDoc *pModDoc, int nPlugSlot, CWnd *parent); ~CSelectPluginDlg(); void DoClose(); void UpdatePluginsList(VstInt32 forceSelect = 0); @@ -48,4 +48,4 @@ afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI); }; -#endif // SELECTPLUGINDIALOG_H +#endif // SELECTPLUGINDIALOG_H \ No newline at end of file Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2013-04-03 14:57:18 UTC (rev 1720) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2013-04-03 22:12:01 UTC (rev 1721) @@ -69,15 +69,15 @@ } -BOOL CVstPluginManager::CreateMixPluginProc(SNDMIXPLUGIN *pMixPlugin, CSoundFile* pSndFile) -//----------------------------------------------------------------------------------------- +bool CVstPluginManager::CreateMixPluginProc(SNDMIXPLUGIN &mixPlugin, CSoundFile &sndFile) +//--------------------------------------------------------------------------------------- { CVstPluginManager *that = theApp.GetPluginManager(); - if (that) + if(that) { - return that->CreateMixPlugin(pMixPlugin, pSndFile); + return that->CreateMixPlugin(mixPlugin, sndFile); } - return FALSE; + return false; } @@ -110,7 +110,7 @@ } -BOOL CVstPluginManager::IsValidPlugin(const VSTPluginLib *pLib) +bool CVstPluginManager::IsValidPlugin(const VSTPluginLib *pLib) //------------------------------------------------------------- { VSTPluginLib *p = m_pVstHead; @@ -446,7 +446,7 @@ { delete p; } - + return (validPlug ? m_pVstHead : nullptr); } @@ -487,70 +487,65 @@ } -BOOL CVstPluginManager::CreateMixPlugin(SNDMIXPLUGIN *pMixPlugin, CSoundFile* pSndFile) -//------------------------------------------------------------------------------------- +bool CVstPluginManager::CreateMixPlugin(SNDMIXPLUGIN &mixPlugin, CSoundFile &sndFile) +//----------------------------------------------------------------------------------- { UINT nMatch = 0; VSTPluginLib *pFound = nullptr; - if (pMixPlugin) + VSTPluginLib *p = m_pVstHead; + + while (p) { - VSTPluginLib *p = m_pVstHead; - - while (p) + bool b1 = false, b2 = false; + if ((p->dwPluginId1 == mixPlugin.Info.dwPluginId1) + && (p->dwPluginId2 == mixPlugin.Info.dwPluginId2)) { - if (pMixPlugin) - { - bool b1 = false, b2 = false; - if ((p->dwPluginId1 == pMixPlugin->Info.dwPluginId1) - && (p->dwPluginId2 == pMixPlugin->Info.dwPluginId2)) - { - b1 = true; - } - if (!_strnicmp(p->szLibraryName, pMixPlugin->GetLibraryName(), 64)) - { - b2 = true; - } - if ((b1) && (b2)) - { - nMatch = 3; - pFound = p; - } else - if ((b1) && (nMatch < 2)) - { - nMatch = 2; - pFound = p; - } else - if ((b2) && (nMatch < 1)) - { - nMatch = 1; - pFound = p; - } - } - p = p->pNext; + b1 = true; } + if (!_strnicmp(p->szLibraryName, mixPlugin.GetLibraryName(), 64)) + { + b2 = true; + } + if ((b1) && (b2)) + { + nMatch = 3; + pFound = p; + } else + if ((b1) && (nMatch < 2)) + { + nMatch = 2; + pFound = p; + } else + if ((b2) && (nMatch < 1)) + { + nMatch = 1; + pFound = p; + } + p = p->pNext; } - if (pMixPlugin->Info.dwPluginId1 == kDmoMagic) + + if (mixPlugin.Info.dwPluginId1 == kDmoMagic) { if (!pFound) return FALSE; AEffect *pEffect = DmoToVst(pFound); if ((pEffect) && (pEffect->dispatcher) && (pEffect->magic == kDmoMagic)) { - BOOL bOk = FALSE; + bool result = false; CriticalSection cs; - CVstPlugin *pVstPlug = new CVstPlugin(NULL, pFound, pMixPlugin, pEffect); - if (pVstPlug) + CVstPlugin *pVstPlug = new CVstPlugin(NULL, *pFound, mixPlugin, *pEffect, sndFile); + if(pVstPlug) { - pVstPlug->Initialize(pSndFile); - bOk = TRUE; + pVstPlug->Initialize(); + result = true; } - return bOk; + return result; } } - if ((!pFound) && strcmp(pMixPlugin->GetLibraryName(), "")) + if ((!pFound) && strcmp(mixPlugin.GetLibraryName(), "")) { // Try finding the plugin DLL in the plugin directory instead. CHAR s[_MAX_PATH]; @@ -564,17 +559,17 @@ { strcat(s, "\\"); } - strncat(s, pMixPlugin->GetLibraryName(), CountOf(s)); + strncat(s, mixPlugin.GetLibraryName(), CountOf(s)); strncat(s, ".dll", CountOf(s)); StringFixer::SetNullTerminator(s); - + pFound = AddPlugin(s); if (!pFound) { CString cacheSection = "PluginCache"; CString cacheFile = theApp.GetPluginCacheFileName(); - CString IDs = CMainFrame::GetPrivateProfileCString(cacheSection, pMixPlugin->GetLibraryName(), "", cacheFile); + CString IDs = CMainFrame::GetPrivateProfileCString(cacheSection, mixPlugin.GetLibraryName(), "", cacheFile); if (IDs.GetLength() >= 16) { CString strFullPath = CMainFrame::GetPrivateProfileCString(cacheSection, IDs, "", cacheFile); @@ -615,8 +610,8 @@ CMainFrame::WritePrivateProfileLong(cacheSection, flagsKey, pFound->EncodeCacheFlags(), cacheFile); } - CVstPlugin *pVstPlug = new CVstPlugin(hLibrary, pFound, pMixPlugin, pEffect); - if (pVstPlug) pVstPlug->Initialize(pSndFile); + CVstPlugin *pVstPlug = new CVstPlugin(hLibrary, *pFound, mixPlugin, *pEffect, sndFile); + if (pVstPlug) pVstPlug->Initialize(); } if(!validPlugin) @@ -636,7 +631,7 @@ Log("Unknown plugin\n"); #endif } - return FALSE; + return false; } @@ -737,14 +732,14 @@ MemsetZero(timeInfo); timeInfo.sampleRate = CMainFrame::GetMainFrame()->GetSampleRate(); - CSoundFile *pSndFile; - if(pVstPlugin && (pSndFile = pVstPlugin->GetSoundFile()) != nullptr) + if(pVstPlugin) { + CSoundFile &sndFile = pVstPlugin->GetSoundFile(); if(pVstPlugin->IsSongPlaying()) { timeInfo.flags |= kVstTransportPlaying; - timeInfo.samplePos = pSndFile->GetTotalSampleCount(); - if(pSndFile->HasPositionChanged()) + timeInfo.samplePos = sndFile.GetTotalSampleCount(); + if(sndFile.HasPositionChanged()) { timeInfo.flags |= kVstTransportChanged; } @@ -763,7 +758,7 @@ timeInfo.flags |= kVstPpqPosValid; if (timeInfo.flags & kVstTransportPlaying) { - timeInfo.ppqPos = (timeInfo.samplePos / timeInfo.sampleRate) * (pSndFile->GetCurrentBPM() / 60.0); + timeInfo.ppqPos = (timeInfo.samplePos / timeInfo.sampleRate) * (sndFile.GetCurrentBPM() / 60.0); } else { timeInfo.ppqPos = 0; @@ -771,7 +766,7 @@ } if((value & kVstTempoValid)) { - timeInfo.tempo = pSndFile->GetCurrentBPM(); + timeInfo.tempo = sndFile.GetCurrentBPM(); if (timeInfo.tempo) { timeInfo.flags |= kVstTempoValid; @@ -783,7 +778,7 @@ // Time signature. numerator = rows per beats / rows pear measure (should sound somewhat logical to you). // the denominator is a bit more tricky, since it cannot be set explicitely. so we just assume quarters for now. - timeInfo.timeSigNumerator = pSndFile->m_nCurrentRowsPerMeasure / max(pSndFile->m_nCurrentRowsPerBeat, 1); + timeInfo.timeSigNumerator = sndFile.m_nCurrentRowsPerMeasure / max(sndFile.m_nCurrentRowsPerBeat, 1); timeInfo.timeSigDenominator = 4; //gcd(pSndFile->m_nCurrentRowsPerMeasure, pSndFile->m_nCurrentRowsPerBeat); } } @@ -808,14 +803,10 @@ //Screw it! Let's just return the tempo at this point in time (might be a bit wrong). if (pVstPlugin != nullptr) { - CSoundFile *pSndFile = pVstPlugin->GetSoundFile(); - if (pSndFile) - { - return (VstInt32)(pSndFile->GetCurrentBPM() * 10000); - } + return (VstInt32)(pVstPlugin->GetSoundFile().GetCurrentBPM() * 10000); } return (VstInt32)(125 * 10000); - + // parameters - DEPRECATED in VST 2.4 case audioMasterGetNumAutomatableParameters: //Log("VST plugin to host: Get Num Automatable Parameters\n"); @@ -824,12 +815,12 @@ return pVstPlugin->GetNumParameters(); } break; - + // Apparently, this one is broken in VST SDK anyway. - DEPRECATED in VST 2.4 case audioMasterGetParameterQuantization: Log("VST plugin to host: Audio Master Get Parameter Quantization\n"); break; - + // numInputs and/or numOutputs has changed case audioMasterIOChanged: if (pVstPlugin != nullptr) @@ -838,7 +829,7 @@ return pVstPlugin->InitializeIOBuffers() ? 1 : 0; } break; - + // plug needs idle calls (outside its editor window) - DEPRECATED in VST 2.4 case audioMasterNeedIdle: if (pVstPlugin != nullptr) @@ -847,7 +838,7 @@ } return 1; - + // index: width, value: height case audioMasterSizeWindow: if (pVstPlugin != nullptr) @@ -860,22 +851,22 @@ } Log("VST plugin to host: Size Window\n"); return 1; - + case audioMasterGetSampleRate: return CMainFrame::GetMainFrame()->GetSampleRate(); - + case audioMasterGetBlockSize: return MIXBUFFERSIZE; - + case audioMasterGetInputLatency: Log("VST plugin to host: Get Input Latency\n"); break; - + case audioMasterGetOutputLatency: { return Util::muldiv(TrackerSettings::Instance().m_LatencyMS, CMainFrame::GetMainFrame()->GetSampleRate(), 1000); } - + // input pin in <value> (-1: first to come), returns cEffect* - DEPRECATED in VST 2.4 case audioMasterGetPreviousPlug: if(pVstPlugin != nullptr) @@ -886,7 +877,7 @@ return ToVstPtr(list[0]); } break; - + // output pin in <value> (-1: first to come), returns cEffect* - DEPRECATED in VST 2.4 case audioMasterGetNextPlug: if(pVstPlugin != nullptr) @@ -897,19 +888,19 @@ return ToVstPtr(list[0]); } break; - + // realtime info // returns: 0: not supported, 1: replace, 2: accumulate - DEPRECATED in VST 2.4 (replace is default) case audioMasterWillReplaceOrAccumulate: return 1; //we replace. - + case audioMasterGetCurrentProcessLevel: if(CMainFrame::GetMainFrame()->IsRendering()) return kVstProcessLevelOffline; else return kVstProcessLevelRealtime; break; - + // returns 0: not supported, 1: off, 2:read, 3:write, 4:read/write case audioMasterGetAutomationState: // Not entirely sure what this means. We can write automation TO the plug. @@ -920,33 +911,33 @@ case audioMasterOfflineStart: Log("VST plugin to host: Offlinestart\n"); break; - + case audioMasterOfflineRead: Log("VST plugin to host: Offlineread\n"); break; - + case audioMasterOfflineWrite: Log("VST plugin to host: Offlinewrite\n"); break; - + case audioMasterOfflineGetCurrentPass: Log("VST plugin to host: OfflineGetcurrentpass\n"); break; - + case audioMasterOfflineGetCurrentMetaPass: Log("VST plugin to host: OfflineGetCurrentMetapass\n"); break; - + // for variable i/o, sample rate in <opt> - DEPRECATED in VST 2.4 case audioMasterSetOutputSampleRate: Log("VST plugin to host: Set Output Sample Rate\n"); break; - + // result in ret - DEPRECATED in VST 2.4 case audioMasterGetOutputSpeakerArrangement: Log("VST plugin to host: Get Output Speaker Arrangement\n"); break; - + case audioMasterGetVendorString: strcpy((char *) ptr, s_szHostVendorString); //strcpy((char*)ptr,"Steinberg"); @@ -965,12 +956,12 @@ case audioMasterVendorSpecific: return 0; - + // void* in <ptr>, format not defined yet - DEPRECATED in VST 2.4 case audioMasterSetIcon: Log("VST plugin to host: Set Icon\n"); break; - + // string in ptr, see below case audioMasterCanDo: //Other possible Can Do strings are: @@ -1008,17 +999,17 @@ case audioMasterOpenWindow: Log("VST plugin to host: Open Window\n"); break; - + // close window, platform specific handle in <ptr> - DEPRECATED in VST 2.4 case audioMasterCloseWindow: Log("VST plugin to host: Close Window\n"); break; - + // get plug directory, FSSpec on MAC, else char* case audioMasterGetDirectory: //Log("VST plugin to host: Get Directory\n"); return ToVstPtr(TrackerSettings::Instance().GetDefaultDirectory(DIR_PLUGINS)); - + // something has changed, update 'multi-fx' display case audioMasterUpdateDisplay: if (pVstPlugin != nullptr) @@ -1043,7 +1034,7 @@ case audioMasterEndEdit: Log("VST plugin to host: End Edit\n"); break; - + // open a fileselector window with VstFileSelect* in <ptr> case audioMasterOpenFileSelector: @@ -1057,7 +1048,7 @@ case audioMasterEditFile: Log("VST plugin to host: Edit File\n"); break; - + // get the native path of currently loading bank or project // (called from writeChunk) void* in <ptr> (char[2048], or sizeof(FSSpec)) - DEPRECATED in VST 2.4 case audioMasterGetChunkFile: @@ -1289,34 +1280,27 @@ // CVstPlugin // -CVstPlugin::CVstPlugin(HMODULE hLibrary, VSTPluginLib *pFactory, SNDMIXPLUGIN *pMixStruct, AEffect *pEffect) -//---------------------------------------------------------------------------------------------------------- +CVstPlugin::CVstPlugin(HMODULE hLibrary, VSTPluginLib &factory, SNDMIXPLUGIN &mixStruct, AEffect &effect, CSoundFile &sndFile) : m_SndFile(sndFile), m_Factory(factory), m_Effect(effect) +//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- { m_hLibrary = hLibrary; m_nRefCount = 1; m_pPrev = nullptr; m_pNext = nullptr; - m_pFactory = pFactory; - m_pMixStruct = pMixStruct; - m_pEffect = pEffect; + m_pMixStruct = &mixStruct; m_pEditor = nullptr; m_nInputs = m_nOutputs = 0; m_nEditorX = m_nEditorY = -1; -#ifdef MODPLUG_TRACKER - m_pModDoc = nullptr; //rewbs.plugDocAware -#endif // MODPLUG_TRACKER m_pProcessFP = nullptr; // Insert ourselves in the beginning of the list - if (m_pFactory) + m_pNext = m_Factory.pPluginsList; + if(m_Factory.pPluginsList) { - m_pNext = m_pFactory->pPluginsList; - if (m_pFactory->pPluginsList) - { - m_pFactory->pPluginsList->m_pPrev = this; - } - m_pFactory->pPluginsList = this; + m_Factory.pPluginsList->m_pPrev = this; } + m_Factory.pPluginsList = this; + m_MixState.dwFlags = 0; m_MixState.nVolDecayL = 0; m_MixState.nVolDecayR = 0; @@ -1336,8 +1320,8 @@ } -void CVstPlugin::Initialize(CSoundFile* pSndFile) -//----------------------------------------------- +void CVstPlugin::Initialize() +//--------------------------- { m_bNeedIdle = false; m_bRecordAutomation = false; @@ -1346,14 +1330,8 @@ //rewbs.VSTcompliance //Store a pointer so we can get the CVstPlugin object from the basic VST effect object. - m_pEffect->resvd1 = ToVstPtr(this); - //rewbs.plugDocAware - m_pSndFile = pSndFile; -#ifdef MODPLUG_TRACKER - m_pModDoc = pSndFile->GetpModDoc(); -#endif // MODPLUG_TRACKER + m_Effect.resvd1 = ToVstPtr(this); m_nSlot = FindSlot(); - //end rewbs.plugDocAware Dispatch(effOpen, 0, 0, nullptr, 0.0f); // VST 2.0 plugins return 2 here, VST 2.4 plugins return 2400... Great! @@ -1387,24 +1365,24 @@ sa.speakers[i].type = kSpeakerUndefined; break; } - } + } // For now, input setup = output setup. Dispatch(effSetSpeakerArrangement, 0, ToVstPtr(&sa), &sa, 0.0f); - // Dummy pin properties collection. + // Dummy pin properties collection. // We don't use them but some plugs might do inits in here. VstPinProperties tempPinProperties; Dispatch(effGetInputProperties, 0, 0, &tempPinProperties, 0); Dispatch(effGetOutputProperties, 0, 0, &tempPinProperties, 0); Dispatch(effConnectInput, 0, 1, nullptr, 0.0f); - if (m_pEffect->numInputs > 1) Dispatch(effConnectInput, 1, 1, nullptr, 0.0f); + if (m_Effect.numInputs > 1) Dispatch(effConnectInput, 1, 1, nullptr, 0.0f); Dispatch(effConnectOutput, 0, 1, nullptr, 0.0f); - if (m_pEffect->numOutputs > 1) Dispatch(effConnectOutput, 1, 1, nullptr, 0.0f); + if (m_Effect.numOutputs > 1) Dispatch(effConnectOutput, 1, 1, nullptr, 0.0f); //rewbs.VSTCompliance: disable all inputs and outputs beyond stereo left and right: - for (int i=2; i<m_pEffect->numInputs; i++) + for (int i=2; i<m_Effect.numInputs; i++) Dispatch(effConnectInput, i, 0, nullptr, 0.0f); - for (int i=2; i<m_pEffect->numOutputs; i++) + for (int i=2; i<m_Effect.numOutputs; i++) Dispatch(effConnectOutput, i, 0, nullptr, 0.0f); //end rewbs.VSTCompliance @@ -1413,7 +1391,7 @@ m_nSampleRate = CSoundFile::gdwMixingFreq; Dispatch(effSetSampleRate, 0, 0, nullptr, static_cast<float>(CSoundFile::gdwMixingFreq)); Dispatch(effSetBlockSize, 0, MIXBUFFERSIZE, nullptr, 0.0f); - if (m_pEffect->numPrograms > 0) + if (m_Effect.numPrograms > 0) { Dispatch(effSetProgram, 0, 0, nullptr, 0); } @@ -1424,8 +1402,8 @@ #ifdef VST_LOG Log("%s: vst ver %d.0, flags=%04X, %d programs, %d parameters\n", - m_pFactory->szLibraryName, (m_bIsVst2) ? 2 : 1, m_pEffect->flags, - m_pEffect->numPrograms, m_pEffect->numParams); + m_Factory.szLibraryName, (m_bIsVst2) ? 2 : 1, m_Effect.flags, + m_Effect.numPrograms, m_Effect.numParams); #endif // Update Mix structure if (m_pMixStruct) @@ -1437,7 +1415,7 @@ //rewbs.VSTcompliance m_bIsInstrument = isInstrument(); RecalculateGain(); - m_pProcessFP = (m_pEffect->flags & effFlagsCanReplacing) ? m_pEffect->processReplacing : m_pEffect->process; + m_pProcessFP = (m_Effect.flags & effFlagsCanReplacing) ? m_Effect.processReplacing : m_Effect.process; // issue samplerate again here, cos some plugs like it before the block size, other like it right at the end. Dispatch(effSetSampleRate, 0, 0, nullptr, static_cast<float>(CSoundFile::gdwMixingFreq)); @@ -1460,8 +1438,8 @@ bool CVstPlugin::InitializeIOBuffers() //------------------------------------ { - m_nInputs = m_pEffect->numInputs; - m_nOutputs = m_pEffect->numOutputs; + m_nInputs = m_Effect.numInputs; + m_nOutputs = m_Effect.numOutputs; // Input pointer array size must be >= 2 for now - the input buffer assignment might write to non allocated mem. otherwise bool result = mixBuffer.Initialize(max(m_nInputs, 2), m_nOutputs); @@ -1481,7 +1459,7 @@ CriticalSection cs; // First thing to do, if we don't want to hang in a loop - if ((m_pFactory) && (m_pFactory->pPluginsList == this)) m_pFactory->pPluginsList = m_pNext; + if (m_Factory.pPluginsList == this) m_Factory.pPluginsList = m_pNext; if (m_pMixStruct) { m_pMixStruct->pMixPlugin = nullptr; @@ -1501,14 +1479,13 @@ if (m_bIsVst2) { Dispatch(effConnectInput, 0, 0, nullptr, 0); - if (m_pEffect->numInputs > 1) Dispatch(effConnectInput, 1, 0, nullptr, 0); + if (m_Effect.numInputs > 1) Dispatch(effConnectInput, 1, 0, nullptr, 0); Dispatch(effConnectOutput, 0, 0, nullptr, 0); - if (m_pEffect->numOutputs > 1) Dispatch(effConnectOutput, 1, 0, nullptr, 0); + if (m_Effect.numOutputs > 1) Dispatch(effConnectOutput, 1, 0, nullptr, 0); } Suspend(); CVstPlugin::Dispatch(effClose, 0, 0, nullptr, 0); - m_pFactory = nullptr; - if (m_hLibrary) + if(m_hLibrary) { FreeLibrary(m_hLibrary); m_hLibrary = nullptr; @@ -1540,45 +1517,34 @@ //------------------------------------------- { pszType[0] = 0; - if (m_pEffect) - { - if (m_pEffect->numInputs < 1) strcpy(pszType, "No input"); else - if (m_pEffect->numInputs == 1) strcpy(pszType, "Mono-In"); else - strcpy(pszType, "Stereo-In"); - strcat(pszType, ", "); - if (m_pEffect->numOutputs < 1) strcat(pszType, "No output"); else - if (m_pEffect->numInputs == 1) strcat(pszType, "Mono-Out"); else - strcat(pszType, "Stereo-Out"); - } + if (m_Effect.numInputs < 1) strcpy(pszType, "No input"); else + if (m_Effect.numInputs == 1) strcpy(pszType, "Mono-In"); else + strcpy(pszType, "Stereo-In"); + strcat(pszType, ", "); + if (m_Effect.numOutputs < 1) strcat(pszType, "No output"); else + if (m_Effect.numInputs == 1) strcat(pszType, "Mono-Out"); else + strcat(pszType, "Stereo-Out"); } bool CVstPlugin::HasEditor() //-------------------------- { - return (m_pEffect != nullptr) && (m_pEffect->flags & effFlagsHasEditor); + return (m_Effect.flags & effFlagsHasEditor) != 0; } -//rewbs.VSTcompliance: changed from BOOL to long + VstInt32 CVstPlugin::GetNumPrograms() //----------------------------------- { - if ((m_pEffect) && (m_pEffect->numPrograms > 0)) - { - return m_pEffect->numPrograms; - } - return 0; + return Util::Max(m_Effect.numPrograms, VstInt32(0)); } PlugParamIndex CVstPlugin::GetNumParameters() //------------------------------------------- { - if ((m_pEffect) && (m_pEffect->numParams > 0)) - { - return m_pEffect->numParams; - } - return 0; + return Util::Max(m_Effect.numParams, VstInt32(0)); } @@ -1593,32 +1559,24 @@ VstInt32 CVstPlugin::GetUID() const //--------------------------------- { - if (!(m_pEffect)) - return 0; - return m_pEffect->uniqueID; + return m_Effect.uniqueID; } VstInt32 CVstPlugin::GetVersion() const //------------------------------------- { - if (!(m_pEffect)) - return 0; - - return m_pEffect->version; + return m_Effect.version; } bool CVstPlugin::GetParams(float *param, VstInt32 min, VstInt32 max) //------------------------------------------------------------------ { - if (!(m_pEffect)) - return false; + LimitMax(max, m_Effect.numParams); - LimitMax(max, m_pEffect->numParams); - for(VstInt32 p = min; p < max; p++) - param[p - min]=GetParameter(p); + param[p - min] = GetParameter(p); return true; @@ -1628,15 +1586,12 @@ bool CVstPlugin::RandomizeParams(PlugParamIndex minParam, PlugParamIndex maxParam) //-------------------------------------------------------------------------------- { - if (!(m_pEffect)) - return false; - if (minParam == 0 && maxParam == 0) { - maxParam = m_pEffect->numParams; + maxParam = m_Effect.numParams; } - LimitMax(maxParam, PlugParamIndex(m_pEffect->numParams)); + LimitMax(maxParam, PlugParamIndex(m_Effect.numParams)); for(PlugParamIndex p = minParam; p < maxParam; p++) { @@ -1654,7 +1609,7 @@ bool useDefaultDir = !defaultDir.empty(); if(!useDefaultDir) { - defaultDir = m_pFactory->szDllPath; + defaultDir = m_Factory.szDllPath; defaultDir = defaultDir.substr(0, defaultDir.find_last_of("\\/")); } @@ -1672,7 +1627,7 @@ { TrackerSettings::Instance().SetWorkingDirectory(files.workingDirectory.c_str(), DIR_PLUGINPRESETS, true); } - + bool bank = !_strnicmp(files.first_file.substr(files.first_file.length() - 3).c_str(), "fxb", 3); std::fstream f; @@ -1696,7 +1651,7 @@ bool useDefaultDir = !defaultDir.empty(); if(!useDefaultDir) { - defaultDir = m_pFactory->szDllPath; + defaultDir = m_Factory.szDllPath; defaultDir = defaultDir.substr(0, defaultDir.find_last_of("\\/")); } @@ -1729,7 +1684,7 @@ if(errorStr == nullptr) { - if(GetModDoc() != nullptr && GetSoundFile() != nullptr && GetSoundFile()->GetModSpecifications().supportsPlugins) + if(GetModDoc() != nullptr && GetSoundFile().GetModSpecifications().supportsPlugins) { GetModDoc()->SetModified(); } @@ -1745,30 +1700,30 @@ VstIntPtr CVstPlugin::Dispatch(VstInt32 opCode, VstInt32 index, VstIntPtr value, void *ptr, float opt) //---------------------------------------------------------------------------------------------------- { - VstIntPtr lresult = 0; + VstIntPtr result = 0; try { - if ((m_pEffect) && (m_pEffect->dispatcher)) + if(m_Effect.dispatcher != nullptr) { #ifdef VST_LOG - Log("About to Dispatch(%d) (Plugin=\"%s\"), index: %d, value: %d, value: %h, value: %f!\n", opCode, m_pFactory->szLibraryName, index, value, ptr, opt); + Log("About to Dispatch(%d) (Plugin=\"%s\"), index: %d, value: %d, value: %h, value: %f!\n", opCode, m_Factory.szLibraryName, index, value, ptr, opt); #endif - lresult = m_pEffect->dispatcher(m_pEffect, opCode, index, value, ptr, opt); + result = m_Effect.dispatcher(&m_Effect, opCode, index, value, ptr, opt); } } catch (...) { - CVstPluginManager::ReportPlugException("Exception in Dispatch(%d) (Plugin=\"%s\")!\n", opCode, m_pFactory->szLibraryName); + CVstPluginManager::ReportPlugException("Exception in Dispatch(%d) (Plugin=\"%s\")!\n", opCode, m_Factory.szLibraryName); } - return lresult; + return result; } VstInt32 CVstPlugin::GetCurrentProgram() //-------------------------------------- { - if ((m_pEffect) && (m_pEffect->numPrograms > 0)) + if(m_Effect.numPrograms > 0) { return Dispatch(effGetProgram, 0, 0, nullptr, 0); } @@ -1779,7 +1734,7 @@ bool CVstPlugin::GetProgramNameIndexed(VstInt32 index, VstIntPtr category, char *text) //------------------------------------------------------------------------------------ { - if ((m_pEffect) && (m_pEffect->numPrograms > 0)) + if(m_Effect.numPrograms > 0) { return (Dispatch(effGetProgramNameIndexed, index, category, text, 0) == 1); } @@ -1825,12 +1780,12 @@ } -void CVstPlugin::SetCurrentProgram(UINT nIndex) -//--------------------------------------------- +void CVstPlugin::SetCurrentProgram(VstInt32 nIndex) +//------------------------------------------------- { - if ((m_pEffect) && (m_pEffect->numPrograms > 0)) + if(m_Effect.numPrograms > 0) { - if (nIndex < (UINT)m_pEffect->numPrograms) + if(nIndex < m_Effect.numPrograms) { Dispatch(effSetProgram, 0, nIndex, nullptr, 0); } @@ -1842,14 +1797,14 @@ //------------------------------------------------------------ { float fResult = 0; - if ((m_pEffect) && (nIndex < m_pEffect->numParams) && (m_pEffect->getParameter)) + if(nIndex < m_Effect.numParams && m_Effect.getParameter != nullptr) { try { - fResult = m_pEffect->getParameter(m_pEffect, nIndex); + fResult = m_Effect.getParameter(&m_Effect, nIndex); } catch (...) { - //CVstPluginManager::ReportPlugException("Exception in getParameter (Plugin=\"%s\")!\n", m_pFactory->szLibraryName); + //CVstPluginManager::ReportPlugException("Exception in getParameter (Plugin=\"%s\")!\n", m_Factory.szLibraryName); } } //rewbs.VSTcompliance @@ -1868,14 +1823,14 @@ { try { - if ((m_pEffect) && (nIndex < m_pEffect->numParams) && (m_pEffect->setParameter)) + if(nIndex < m_Effect.numParams && m_Effect.setParameter) { if ((fValue >= 0.0f) && (fValue <= 1.0f)) - m_pEffect->setParameter(m_pEffect, nIndex, fValue); + m_Effect.setParameter(&m_Effect, nIndex, fValue); } } catch (...) { - CVstPluginManager::ReportPlugException("Exception in SetParameter(%d, 0.%03d) (Plugin=%s)\n", nIndex, (int)(fValue*1000), m_pFactory->szLibraryName); + CVstPluginManager::ReportPlugException("Exception in SetParameter(%d, 0.%03d) (Plugin=%s)\n", nIndex, (int)(fValue*1000), m_Factory.szLibraryName); } } @@ -1887,7 +1842,7 @@ CHAR s[max(kVstMaxParamStrLen + 1, 64)]; // Increased to 64 bytes since 32 bytes doesn't seem to suffice for all plugs. Kind of ridiculous if you consider that kVstMaxParamStrLen = 8... s[0] = '\0'; - if(m_pEffect != nullptr && m_pEffect->numParams > 0 && param < m_pEffect->numParams) + if(m_Effect.numParams > 0 && param < m_Effect.numParams) { Dispatch(opcode, param, 0, s, 0); StringFixer::SetNullTerminator(s); @@ -1979,7 +1934,7 @@ m_bPlugResumed = true; } catch (...) { - CVstPluginManager::ReportPlugException("Exception in Resume() (Plugin=%s)\n", m_pFactory->szLibraryName); + CVstPluginManager::ReportPlugException("Exception in Resume() (Plugin=%s)\n", m_Factory.szLibraryName); } @@ -1997,7 +1952,7 @@ m_bPlugResumed = false; } catch (...) { - CVstPluginManager::ReportPlugException("Exception in Suspend() (Plugin=%s)\n", m_pFactory->szLibraryName); + CVstPluginManager::ReportPlugException("Exception in Suspend() (Plugin=%s)\n", m_Factory.szLibraryName); } } } @@ -2008,15 +1963,15 @@ //--------------------------------- { // Process VST events - if(m_pEffect != nullptr && m_pEffect->dispatcher != nullptr && vstEvents.Finalise() > 0) + if(m_Effect.dispatcher != nullptr && vstEvents.Finalise() > 0) { try { - m_pEffect->dispatcher(m_pEffect, effProcessEvents, 0, 0, &vstEvents, 0); + m_Effect.dispatcher(&m_Effect, effProcessEvents, 0, 0, &vstEvents, 0); } catch (...) { CVstPluginManager::ReportPlugException("Exception in ProcessVSTEvents() (Plugin=%s, numEvents:%d)\n", - m_pFactory->szLibraryName, vstEvents.GetNumEvents()); + m_Factory.szLibraryName, vstEvents.GetNumEvents()); } } } @@ -2026,7 +1981,7 @@ void CVstPlugin::ReceiveVSTEvents(const VstEvents *events) const //-------------------------------------------------------------- { - if(m_pSndFile == nullptr || m_pMixStruct == nullptr) + if(m_pMixStruct == nullptr) { return; } @@ -2034,10 +1989,10 @@ // I think we should only route events to plugins that are explicitely specified as output plugins of the current plugin. // This should probably use GetOutputPlugList here if we ever get to support multiple output plugins. PLUGINDEX receiver = m_pMixStruct->GetOutputPlugin(); - + if(receiver != PLUGINDEX_INVALID) { - SNDMIXPLUGIN &mixPlug = m_pSndFile->m_MixPlugins[receiver]; + SNDMIXPLUGIN &mixPlug = m_SndFile.m_MixPlugins[receiver]; CVstPlugin *vstPlugin = dynamic_cast<CVstPlugin *>(mixPlug.pMixPlugin); if(vstPlugin != nullptr) { @@ -2072,10 +2027,10 @@ float gain = 0.1f * static_cast<float>(m_pMixStruct ? m_pMixStruct->GetGain() : 10); if(gain < 0.1f) gain = 1.0f; - if(m_bIsInstrument && m_pSndFile) + if(m_bIsInstrument) { - gain /= m_pSndFile->m_pConfig->getVSTiAttenuation(); - gain = static_cast<float>(gain * (m_pSndFile->m_nVSTiVolume / m_pSndFile->m_pConfig->getNormalVSTiVol())); + gain /= m_SndFile.m_pConfig->getVSTiAttenuation(); + gain = static_cast<float>(gain * (m_SndFile.m_nVSTiVolume / m_SndFile.m_pConfig->getNormalVSTiVol())); } m_fGain = gain; } @@ -2095,13 +2050,13 @@ ProcessVSTEvents(); //If the plug is found & ok, continue - if ((m_pEffect) && (m_pProcessFP) && (mixBuffer.GetInputBufferArray()) && (mixBuffer.GetOutputBufferArray()) && (m_pMixStruct)) + if(m_pProcessFP != nullptr && (mixBuffer.GetInputBufferArray()) && mixBuffer.GetOutputBufferArray() && m_pMixStruct != nullptr) { //RecalculateGain(); // Merge stereo input before sending to the plug if the plug can only handle one input. - if (m_pEffect->numInputs == 1) + if (m_Effect.numInputs == 1) { for (size_t i = 0; i < nSamples; i++) { @@ -2116,11 +2071,11 @@ try { ASSERT(nSamples <= MIXBUFFERSIZE); - m_pProcessFP(m_pEffect, mixBuffer.GetInputBufferArray(), outputBuffers, nSamples); + m_pProcessFP(&m_Effect, mixBuffer.GetInputBufferArray(), outputBuffers, nSamples); } catch (...) { Bypass(); - CString processMethod = (m_pEffect->flags & effFlagsCanReplacing) ? "processReplacing" : "process"; + CString processMethod = (m_Effect.flags & effFlagsCanReplacing) ? "processReplacing" : "process"; CVstPluginManager::ReportPlugException("The plugin %s threw an exception in %s. It has automatically been set to \"Bypass\".", m_pMixStruct->GetName(), processMethod); vstEvents.Clear(); } @@ -2181,11 +2136,11 @@ float *leftPlugOutput; float *rightPlugOutput; - if(m_pEffect->numOutputs == 1) + if(m_Effect.numOutputs == 1) { // If there was just the one plugin output we copy it into our 2 outputs leftPlugOutput = rightPlugOutput = mixBuffer.GetOutputBuffer(0); - } else if(m_pEffect->numOutputs > 1) + } else if(m_Effect.numOutputs > 1) { // Otherwise we actually only cater for two outputs max (outputs > 2 have been mixed together already). leftPlugOutput = mixBuffer.GetOutputBuffer(0); @@ -2217,7 +2172,7 @@ float dryRatio = m_bIsInstrument ? 1 : m_pMixStruct->fDryRatio; // Always mix full dry if this is an instrument // Wet / Dry range expansion [0,1] -> [-1,1] - if(m_pEffect->numInputs > 0 && m_pMixStruct->IsExpandedMix()) + if(m_Effect.numInputs > 0 && m_pMixStruct->IsExpandedMix()) { wetRatio = 2.0f * wetRatio - 1.0f; dryRatio = -wetRatio; @@ -2376,7 +2331,7 @@ LimitMax(nController, MIDIEvents::MIDICC_end); LimitMax(nParam, uint8(127)); - if(m_pSndFile && m_pSndFile->GetModFlag(MSF_MIDICC_BUGEMULATION)) + if(m_SndFile.GetModFlag(MSF_MIDICC_BUGEMULATION)) MidiSend(MIDIEvents::Event(MIDIEvents::evControllerChange, nMidiCh, nParam, static_cast<uint8>(nController))); // param and controller are swapped (old broken implementation) else MidiSend(MIDIEvents::CC(nController, nMidiCh, nParam)); @@ -2400,7 +2355,7 @@ void CVstPlugin::MidiPitchBend(uint8 nMidiCh, int32 increment, int8 pwd) //---------------------------------------------------------------------- { - if(m_pSndFile && m_pSndFile->GetModFlag(MSF_OLD_MIDI_PITCHBENDS)) + if(m_SndFile.GetModFlag(MSF_OLD_MIDI_PITCHBENDS)) { // OpenMPT Legacy: Old pitch slides never were really accurate, but setting the PWD to 13 in plugins would give the closest results. increment = (increment * 0x800 * 13) / (0xFF * pwd); @@ -2662,7 +2617,7 @@ void CVstPlugin::SaveAllParameters() //---------------------------------- { - if ((m_pEffect) && (m_pMixStruct)) + if (m_pMixStruct) { m_pMixStruct->defaultProgram = -1; @@ -2705,7 +2660,7 @@ } } // This plug doesn't support chunks: save parameters - PlugParamIndex nParams = (m_pEffect->numParams > 0) ? m_pEffect->numParams : 0; + PlugParamIndex nParams = (m_Effect.numParams > 0) ? m_Effect.numParams : 0; UINT nLen = nParams * sizeof(float); if (!nLen) return; nLen += 4; @@ -2740,9 +2695,9 @@ void CVstPlugin::RestoreAllParameters(long nProgram) //-------------------------------------------------- { - if ((m_pEffect) && (m_pMixStruct) && (m_pMixStruct->pPluginData) && (m_pMixStruct->nPluginDataSize >= 4)) + if(m_pMixStruct != nullptr && m_pMixStruct->pPluginData != nullptr && m_pMixStruct->nPluginDataSize >= 4) { - UINT nParams = (m_pEffect->numParams > 0) ? m_pEffect->numParams : 0; + UINT nParams = (m_Effect.numParams > 0) ? m_Effect.numParams : 0; UINT nLen = nParams * sizeof(float); ULONG nType = *(ULONG *)m_pMixStruct->pPluginData; @@ -2751,7 +2706,7 @@ void *p = nullptr; Dispatch(effGetChunk, 0,0, &p, 0); //init plug for chunk reception - if ((nProgram>=0) && (nProgram < m_pEffect->numPrograms)) + if ((nProgram>=0) && (nProgram < m_Effect.numPrograms)) { // Bank Dispatch(effSetChunk, 0, m_pMixStruct->nPluginDataSize - 4, ((BYTE *)m_pMixStruct->pPluginData) + 4, 0); @@ -2781,8 +2736,6 @@ void CVstPlugin::ToggleEditor() //----------------------------- { - if (!m_pEffect) return; - try { if ((m_pEditor) && (!m_pEditor->m_hWnd)) @@ -2807,7 +2760,7 @@ } } catch (...) { - CVstPluginManager::ReportPlugException("Exception in ToggleEditor() (Plugin=%s)\n", m_pFactory->szLibraryName); + CVstPluginManager::ReportPlugException("Exception in ToggleEditor() (Plugin=%s)\n", m_Factory.szLibraryName); } } @@ -2815,11 +2768,7 @@ BOOL CVstPlugin::GetCommandName(UINT nIndex, LPSTR pszName) //--------------------------------------------------------- { - if (m_pEffect) - { - return Dispatch(effGetParamName, nIndex, 0, pszName, 0.0f); - } - return 0; + return Dispatch(effGetParamName, nIndex, 0, pszName, 0.0f); } @@ -2838,8 +2787,8 @@ Dispatch(effSetBypass, bypass ? 1 : 0, 0, nullptr, 0.0f); #ifdef MODPLUG_TRACKER - if(m_pModDoc) - m_pModDoc->UpdateAllViews(nullptr, HINT_MIXPLUGINS, nullptr); + if(m_SndFile.GetpModDoc()) + m_SndFile.GetpModDoc()->UpdateAllViews(nullptr, HINT_MIXPLUGINS, nullptr); #endif // MODPLUG_TRACKER } @@ -2855,12 +2804,9 @@ //------------------------------ { PLUGINDEX slot = 0; - if(m_pSndFile) + while(m_pMixStruct != &(m_SndFile.m_MixPlugins[slot]) && slot < MAX_MIXPLUGINS - 1) { - while(m_pMixStruct != &(m_pSndFile->m_MixPlugins[slot]) && slot < MAX_MIXPLUGINS - 1) - { - slot++; - } + slot++; } return slot; } @@ -2886,13 +2832,11 @@ m_pMixStruct = p; } -//end rewbs.VSTcompliance -bool CVstPlugin::isInstrument() // ericus 18/02/2005 +bool CVstPlugin::isInstrument() //----------------------------- { - if(m_pEffect) return ((m_pEffect->flags & effFlagsIsSynth) || (!m_pEffect->numInputs)); // rewbs.dryRatio - return false; + return ((m_Effect.flags & effFlagsIsSynth) || (!m_Effect.numInputs)); } @@ -2915,9 +2859,9 @@ if(!m_pMixStruct->IsOutputToMaster()) { PLUGINDEX nOutput = m_pMixStruct->GetOutputPlugin(); - if(m_pSndFile && nOutput > m_nSlot && nOutput != PLUGINDEX_INVALID) + if(nOutput > m_nSlot && nOutput != PLUGINDEX_INVALID) { - outputPlug = dynamic_cast<CVstPlugin *>(m_pSndFile->m_MixPlugins[nOutput].pMixPlugin); + outputPlug = dynamic_cast<CVstPlugin *>(m_SndFile.m_MixPlugins[nOutput].pMixPlugin); } } list.push_back(outputPlug); @@ -2927,22 +2871,20 @@ // Get a list of plugins that send data to this plugin. -size_t CVstPlugin::GetInputPlugList(vector<CVstPlugin *> &list) -//------------------------------------------------------------- +size_t CVstPlugin::GetInputPlugList(std::vector<CVstPlugin *> &list) +//------------------------------------------------------------------ { - if(m_pSndFile == nullptr) return 0; - - vector<CVstPlugin *> candidatePlugOutputs; + std::vector<CVstPlugin *> candidatePlugOutputs; list.clear(); for(PLUGINDEX plug = 0; plug < MAX_MIXPLUGINS; plug++) { - CVstPlugin *candidatePlug = dynamic_cast<CVstPlugin *>(m_pSndFile->m_MixPlugins[plug].pMixPlugin); + CVstPlugin *candidatePlug = dynamic_cast<CVstPlugin *>(m_SndFile.m_MixPlugins[plug].pMixPlugin); if(candidatePlug) { candidatePlug->GetOutputPlugList(candidatePlugOutputs); - for(vector<CVstPlugin *>::iterator iter = candidatePlugOutputs.begin(); iter != candidatePlugOutputs.end(); iter++) + for(std::vector<CVstPlugin *>::iterator iter = candidatePlugOutputs.begin(); iter != candidatePlugOutputs.end(); iter++) { if(*iter == this) { @@ -2958,16 +2900,15 @@ // Get a list of instruments that send data to this plugin. -size_t CVstPlugin::GetInputInstrumentList(vector<INSTRUMENTINDEX> &list) -//---------------------------------------------------------------------- +size_t CVstPlugin::GetInputInstrumentList(std::vector<INSTRUMENTINDEX> &list) +//--------------------------------------------------------------------------- { list.clear(); - if(m_pSndFile == nullptr) return 0; + const PLUGINDEX nThisMixPlug = m_nSlot + 1; //m_nSlot is position in mixplug array. - const PLUGINDEX nThisMixPlug = m_nSlot + 1; //m_nSlot is position in mixplug array. - for(INSTRUMENTINDEX ins = 0; ins <= m_pSndFile->GetNumInstruments(); ins++) + for(INSTRUMENTINDEX ins = 0; ins <= m_SndFile.GetNumInstruments(); ins++) { - if(m_pSndFile->Instruments[ins] != nullptr && (m_pSndFile->Instruments[ins]->nMixPlug == nThisMixPlug)) + if(m_SndFile.Instruments[ins] != nullptr && m_SndFile.Instruments[ins]->nMixPlug == nThisMixPlug) { list.push_back(ins); } @@ -2977,17 +2918,16 @@ } -size_t CVstPlugin::GetInputChannelList(vector<CHANNELINDEX> &list) -//---------------------------------------------------------------- +size_t CVstPlugin::GetInputChannelList(std::vector<CHANNELINDEX> &list) +//--------------------------------------------------------------------- { - if(m_pSndFile == nullptr) return 0; list.clear(); - UINT nThisMixPlug = m_nSlot+1; //m_nSlot is position in mixplug array. - const CHANNELINDEX chnCount = m_pSndFile->GetNumChannels(); - for (CHANNELINDEX nChn=0; nChn<chnCount; nChn++) + PLUGINDEX nThisMixPlug = m_nSlot + 1; //m_nSlot is position in mixplug array. + const CHANNELINDEX chnCount = m_SndFile.GetNumChannels(); + for(CHANNELINDEX nChn=0; nChn<chnCount; nChn++) { - if (m_pSndFile->ChnSettings[nChn].nMixPlugin==nThisMixPlug) + if(m_SndFile.ChnSettings[nChn].nMixPlugin == nThisMixPlug) { list.push_back(nChn); } @@ -3542,4 +3482,4 @@ { return mpt::String(); } -} +} \ No newline at end of file Modified: trunk/OpenMPT/mptrack/Vstplug.h =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.h 2013-04-03 14:57:18 UTC (rev 1720) +++ trunk/OpenMPT/mptrack/Vstplug.h 2013-04-03 22:12:01 UTC (rev 1721) @@ -119,7 +119,7 @@ class CVstPlugin: public IMixPlugin //================================= { - friend class CAbstractVstEditor; //rewbs.defaultPlugGUI + friend class CAbstractVstEditor; friend class CVstPluginManager; #ifndef NO_VST protected: @@ -133,19 +133,16 @@ vstPitchBendShift = 12, // Use lowest 12 bits for fractional part and vibrato flag => 16.11 fixed point precision vstPitchBendMask = (~1), vstVibratoFlag = 1, - }; + }; CVstPlugin *m_pNext, *m_pPrev; HINSTANCE m_hLibrary; - VSTPluginLib *m_pFactory; + VSTPluginLib &m_Factory; SNDMIXPLUGIN *m_pMixStruct; - AEffect *m_pEffect; + AEffect &m_Effect; void (*m_pProcessFP)(AEffect*, float**, float**, VstInt32); //Function pointer to AEffect processReplacing if supported, else process. CAbstractVstEditor *m_pEditor; -#ifdef MODPLUG_TRACKER - CModDoc *m_pModDoc; -#endif // MODPLUG_TRACKER - CSoundFile *m_pSndFile; + CSoundFile &m_SndFile; size_t m_nRefCount; static const uint32 nInvalidSampleRate = UINT_MAX; @@ -173,12 +170,12 @@ bool m_bRecordMIDIOut; public: - CVstPlugin(HINSTANCE hLibrary, VSTPluginLib *pFactory, SNDMIXPLUGIN *pMixPlugin, AEffect *pEffect); + CVstPlugin(HINSTANCE hLibrary, VSTPluginLib &factory, SNDMIXPLUGIN &mixPlugin, AEffect &effect, CSoundFile &sndFile); virtual ~CVstPlugin(); - void Initialize(CSoundFile* pSndFile); + void Initialize(); public: - VSTPluginLib *GetPluginFactory() const { return m_pFactory; } + VSTPluginLib &GetPluginFactory() const { return m_Factory; } bool HasEditor(); VstInt32 GetNumPrograms(); PlugParamIndex GetNumParameters(); @@ -190,15 +187,15 @@ VstInt32 GetUID() const; VstInt32 GetVersion() const; // Check if programs should be stored as chunks or parameters - bool ProgramsAreChunks() const { return m_pEffect && (m_pEffect->flags & effFlagsProgramChunks) != 0; } + bool ProgramsAreChunks() const { return (m_Effect.flags & effFlagsProgramChunks) != 0; } bool GetParams(float* param, VstInt32 min, VstInt32 max); bool RandomizeParams(PlugParamIndex minParam = 0, PlugParamIndex maxParam = 0); #ifdef MODPLUG_TRACKER - inline CModDoc *GetModDoc() { return m_pModDoc; } - inline const CModDoc *GetModDoc() const { return m_pModDoc; } + inline CModDoc *GetModDoc() { return m_SndFile.GetpModDoc(); } + inline const CModDoc *GetModDoc() const { return m_SndFile.GetpModDoc(); } #endif // MODPLUG_TRACKER - inline CSoundFile *GetSoundFile() { return m_pSndFile; } - inline const CSoundFile *GetSoundFile() const { return m_pSndFile; } + inline CSoundFile &GetSoundFile() { return m_SndFile; } + inline const CSoundFile &GetSoundFile() const { return m_SndFile; } PLUGINDEX FindSlot(); void SetSlot(PLUGINDEX slot); PLUGINDEX GetSlot(); @@ -207,7 +204,7 @@ void SetEditorPos(int x, int y) { m_nEditorX = x; m_nEditorY = y; } void GetEditorPos(int &x, int &y) const { x = m_nEditorX; y = m_nEditorY; } - void SetCurrentProgram(UINT nIndex); + void SetCurrentProgram(VstInt32 nIndex); PlugParamValue GetParameter(PlugParamIndex nIndex); void SetParameter(PlugParamIndex nIndex, PlugParamValue fValue); @@ -230,16 +227,16 @@ bool isInstrument(); bool CanRecieveMidiEvents(); - size_t GetOutputPlugList(vector<CVstPlugin *> &list); - size_t GetInputPlugList(vector<CVstPlugin *> &list); - size_t GetInputInstrumentList(vector<INSTRUMENTINDEX> &list); - size_t GetInputChannelList(vector<CHANNELINDEX> &list); + size_t GetOutputPlugList(std::vector<CVstPlugin *> &list); + size_t GetInputPlugList(std::vector<CVstPlugin *> &list); + size_t GetInputInstrumentList(std::vector<INSTRUMENTINDEX> &list); + size_t GetInputChannelList(std::vector<CHANNELINDEX> &list); public: size_t AddRef() { return ++m_nRefCount; } size_t Release(); void SaveAllParameters(); - void RestoreAllParameters(long nProg=-1); //rewbs.plugDefaultProgram - added param + void RestoreAllParameters(long nProg=-1); //rewbs.plugDefaultProgram - added param void RecalculateGain(); void Process(float *pOutL, float *pOutR, size_t nSamples); bool MidiSend(DWORD dwMidiCode); @@ -312,7 +309,7 @@ PlugParamValue GetParameter(PlugParamIndex) { return 0; } bool LoadProgram() { return false; } bool SaveProgram() { return false; } - void SetCurrentProgram(UINT) {} + void SetCurrentProgram(VstInt32) {} void SetSlot(UINT) {} void UpdateMixStructPtr(void*) {} void Bypass(bool = true) { } @@ -336,10 +333,10 @@ public: VSTPluginLib *GetFirstPlugin() const { return m_pVstHead; } - BOOL IsValidPlugin(const VSTPluginLib *pLib); + bool IsValidPlugin(const VSTPluginLib *pLib); VSTPluginLib *AddPlugin(LPCSTR pszDllPath, bool fromCache = true, const bool checkFileExistence = false, CString* const errStr = 0); bool RemovePlugin(VSTPluginLib *); - BOOL CreateMixPlugin(SNDMIXPLUGIN *, CSoundFile *); + bool CreateMixPlugin(SNDMIXPLUGIN &, CSoundFile &); void OnIdle(); static void ReportPlugException(LPCSTR format,...); @@ -351,7 +348,7 @@ VstIntPtr VstCallback(AEffect *effect, VstInt32 opcode, VstInt32 index, VstIntPtr value, void *ptr, float opt); VstIntPtr VstFileSelector(bool destructor, VstFileSelect *fileSel, const AEffect *effect); static VstIntPtr VSTCALLBACK MasterCallBack(AEffect *effect, VstInt32 opcode, VstInt32 index, VstIntPtr value, void *ptr, float opt); - static BOOL __cdecl CreateMixPluginProc(SNDMIXPLUGIN *, CSoundFile *); + static bool __cdecl CreateMixPluginProc(SNDMIXPLUGIN &, CSoundFile &); VstTimeInfo timeInfo; //rewbs.VSTcompliance public: @@ -365,4 +362,4 @@ VSTPluginLib *GetFirstPlugin() const { return 0; } void OnIdle() {} #endif // NO_VST -}; +}; \ No newline at end of file Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-04-03 14:57:18 UTC (rev 1720) +++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-04-03 22:12:01 UTC (rev 1721) @@ -229,7 +229,7 @@ { return false; } - + DestroyInstrument(targetInstr, deleteAssociatedSamples); Instruments[targetInstr] = pIns; Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-04-03 14:57:18 UTC (rev 1720) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-04-03 22:12:01 UTC (rev 1721) @@ -484,7 +484,7 @@ m_pModDoc = pModDoc; #else BOOL CSoundFile::Create(LPCBYTE lpStream, void *pModDoc, DWORD dwMemLength) -//-------------------------------------------------------------------------- +//------------------------------------------------------------------------- { #endif // MODPLUG_TRACKER @@ -737,7 +737,7 @@ { if(m_MixPlugins[iPlug].IsValidPlugin()) { - gpMixPluginCreateProc(&m_MixPlugins[iPlug], this); + gpMixPluginCreateProc(m_MixPlugins[iPlug], *this); if (m_MixPlugins[iPlug].pMixPlugin) { // plugin has been found @@ -916,7 +916,7 @@ //------------------------------------------------------------------------------------------ { CriticalSection cs; - DWORD d = gdwSoundSetup; + DWORD d = gdwSoundSetup; if ((bReverb) && (gdwSysInfo & SYSMIX_ENABLEMMX)) d |= SNDMIX_REVERB; else d &= ~SNDMIX_REVERB; #ifndef NO_DSP if (bSurround) d |= SNDMIX_SURROUND; else d &= ~SNDMIX_SURROUND; @@ -2194,4 +2194,4 @@ } Patterns.ForEachModCommand(UpgradePatternData(this)); -} +} \ No newline at end of file Modified: trunk/OpenMPT/soundlib/plugins/PlugInterface.h =================================================================== --- trunk/OpenMPT/soundlib/plugins/PlugInterface.h 2013-04-03 14:57:18 UTC (rev 1720) +++ trunk/OpenMPT/soundlib/plugins/PlugInterface.h 2013-04-03 22:12:01 UTC (rev 1721) @@ -46,13 +46,13 @@ virtual void MidiVibrato(uint8 nMidiCh, int32 depth, int8 pwd) = 0; virtual void MidiCommand(uint8 nMidiCh, uint8 nMidiProg, uint16 wMidiBank, uint16 note, uint16 vol, CHANNELINDEX trackChannel) = 0; virtual void HardAllNotesOff() = 0; //rewbs.VSTCompliance - virtual void RecalculateGain() = 0; + virtual void RecalculateGain() = 0; virt... [truncated message content] |
From: <sag...@us...> - 2013-04-06 13:32:02
|
Revision: 1749 http://sourceforge.net/p/modplug/code/1749 Author: saga-games Date: 2013-04-06 13:31:47 +0000 (Sat, 06 Apr 2013) Log Message: ----------- [Mod] Updated release package [Mod] Updated default keybindings, DE_jojo.mkb and US_mptit_(coda).mkb [Mod] OpenMPT: Version is now 1.22.01.00 Modified Paths: -------------- trunk/OpenMPT/common/version.h trunk/OpenMPT/installer/install-unmo3-free.iss trunk/OpenMPT/installer/packageTemplate/readme.txt trunk/OpenMPT/mptrack/res/defaultKeybindings.mkb trunk/OpenMPT/packageTemplate/History.txt trunk/OpenMPT/packageTemplate/extraKeymaps/DE_jojo.mkb trunk/OpenMPT/packageTemplate/extraKeymaps/US_mptit_(coda).mkb trunk/OpenMPT/packageTemplate/readme.txt Added Paths: ----------- trunk/OpenMPT/packageTemplate/OMPT_1.22_ReleaseNotes.html trunk/OpenMPT/packageTemplate/ReleaseNotesImages/1.22/ trunk/OpenMPT/packageTemplate/ReleaseNotesImages/1.22/clipboardmanager.png trunk/OpenMPT/packageTemplate/ReleaseNotesImages/1.22/soundsettings.png Modified: trunk/OpenMPT/common/version.h =================================================================== --- trunk/OpenMPT/common/version.h 2013-04-06 13:18:05 UTC (rev 1748) +++ trunk/OpenMPT/common/version.h 2013-04-06 13:31:47 UTC (rev 1749) @@ -17,9 +17,9 @@ //Version definitions. The only thing that needs to be changed when changing version number. #define VER_MAJORMAJOR 1 -#define VER_MAJOR 21 +#define VER_MAJOR 22 #define VER_MINOR 01 -#define VER_MINORMINOR 26 +#define VER_MINORMINOR 00 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of Modified: trunk/OpenMPT/installer/install-unmo3-free.iss =================================================================== --- trunk/OpenMPT/installer/install-unmo3-free.iss 2013-04-06 13:18:05 UTC (rev 1748) +++ trunk/OpenMPT/installer/install-unmo3-free.iss 2013-04-06 13:31:47 UTC (rev 1749) @@ -6,7 +6,9 @@ ; This file is provided for creating an install package without the proprietary unmo3.dll (for example for the SourceForge package). ; Instead of including the file in the setup package, the user instead has the possibility to automatically download unmo3.dll from ; our servers. -; The download code requires the ISTool IDE with its downloader extension. You can download it from http://www.istool.org/ +; The download code requires the InnoScript Studio or ISTool IDE with its downloader extension. +; You can download InnoScript Studio from https://www.kymoto.org/products/inno-script-studio/overview +; or download ISTool from http://www.istool.org/ #define DOWNLOAD_MO3 #define BaseNameAddition "_sf" Modified: trunk/OpenMPT/installer/packageTemplate/readme.txt =================================================================== --- trunk/OpenMPT/installer/packageTemplate/readme.txt 2013-04-06 13:18:05 UTC (rev 1748) +++ trunk/OpenMPT/installer/packageTemplate/readme.txt 2013-04-06 13:31:47 UTC (rev 1749) @@ -1,5 +1,5 @@ ****************** -* OpenMPT 1.21 * +* OpenMPT 1.22 * ****************** @@ -58,7 +58,7 @@ OpenMPT is partially under the following license: -> Copyright (c) 2004-2012, OpenMPT contributors +> Copyright (c) 2004-2013, OpenMPT contributors > Copyright (c) 1997-2003, Olivier Lapicque > All rights reserved. > @@ -90,11 +90,12 @@ For more information about SoundTouch, see folder SoundTouch. -PortMidi --------- -OpenMPT's MIDI plugins make use of the PortMidi library, which is released under -the MIT license. -Visit http://portmedia.sourceforge.net/ for more information. +PortAudio / PortMidi +-------------------- +OpenMPT uses PortAudio for WASAPI output. OpenMPT's MIDI plugins make use of the +PortMidi library, which are both released under the MIT license. +Visit http://www.portaudio.com/ and http://portmedia.sourceforge.net/ for more +information. unmo3.dll --------- @@ -146,3 +147,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Visit http://flac.sourceforge.net/ for more information. + +libmpg123 +--------- +OpenMPT makes use of libmpg123, which is released under the LGPL license. +A copy of the LGPL license can be found in SoundTouch\COPYING.TXT +Visit http://mpg123.de/ for more information. \ No newline at end of file Modified: trunk/OpenMPT/mptrack/res/defaultKeybindings.mkb =================================================================== --- trunk/OpenMPT/mptrack/res/defaultKeybindings.mkb 2013-04-06 13:18:05 UTC (rev 1748) +++ trunk/OpenMPT/mptrack/res/defaultKeybindings.mkb 2013-04-06 13:31:47 UTC (rev 1749) @@ -92,6 +92,10 @@ 2:1819:2:69:1 //Split Keyboard Settings dialog: Ctrl+E (KeyDown) 2:1776:1:122:1 //Toggle Loop Pattern: Shift+F11 (KeyDown) 2:1780:2:84:1 //Show playback time at current row: Ctrl+T (KeyDown) +2:1892:4:81:1 //Quantize Settings: Alt+Q (KeyDown) +2:1900:3:77:1 //Toggle Clipboard Manager: Shift+Ctrl+M (KeyDown) +2:1901:3:37:1 //Cycle to Previous Clipboard: Shift+Ctrl+LEFT (KeyDown) +2:1902:3:39:1 //Cycle to Next Clipboard: Shift+Ctrl+RIGHT (KeyDown) 2:1005:0:121:1 //Mute current Channel: F10 (KeyDown) 2:1006:2:121:1 //Solo current Channel: Ctrl+F10 (KeyDown) 2:1771:6:121:1 //Unmute all channels: Ctrl+Alt+F10 (KeyDown) Modified: trunk/OpenMPT/packageTemplate/History.txt =================================================================== --- trunk/OpenMPT/packageTemplate/History.txt 2013-04-06 13:18:05 UTC (rev 1748) +++ trunk/OpenMPT/packageTemplate/History.txt 2013-04-06 13:31:47 UTC (rev 1749) @@ -14,6 +14,7 @@ <initials> nick name / real name [email @openmpt.org] <al> Relabs / Ahti Leppänen [relabs] <ec> Ericus / Eric Chavanon [ericus] + <jh> manx / Joern Heusipp [manx] <js> Saga Musix / Johannes Schultz [sagamusix] <rf> rewbs / Robin Fernandes [rewbs] <sp> pelya / Sergiy Pylypenko [pelya] @@ -24,6 +25,147 @@ <ks> coda / Ken Snyder +v1.22.01.00 (6 April 2013, revision 1749) +----------------------------------------- +Pattern tab + [New] <js> Can now copy multiple patterns at once (http://forum.openmpt.org/index.php?topic=3706.0). + [New] <js> Added the Pattern Clipboard Manager to use more than one internal clipboard (http://bugs.openmpt.org/view.php?id=41). + [New] <js> Chord Editor: Added the possibility to make chords relative to a note entered in the pattern instead of a fixed base note (http://bugs.openmpt.org/view.php?id=360). + [New] <js> Added shortcut to find nearest instrument number in a channel (tx coda). + [New] <js> Added shortcuts to toggle PC keyboard / MIDI record note off (http://bugs.openmpt.org/view.php?id=326). + [New] <js> Added shortcuts: Select Row, Select Event (http://forum.openmpt.org/index.php?topic=3247.0). + [New] <ks> Added hidden setting "RowDisplayOffset" in [Pattern Editor] to specify displayed row offset in the pattern editor (does not affect Goto dialog or pattern effects). + [Imp] <js> Added fake grace note support for record quantization: If there's already a note on the quantized row, move one row downwards. + [Imp] <js> Chord mode does now also work if no record channels are selected. + [Imp] <js> "Record Note Off" also works with chords now. + [Imp] <js> Higher live record precision. + [Mod] <js> Play Whole Row While Recording is now also applied to Quick Paste and Clear+Step commands (tx coda). + [Fix] <js> Play Whole Row While Recording didn't work properly when Row Spacing was set to a value other than 0. Note stops didn't work, either (tx coda). + [Fix] <jh> Pattern display no longer lags with high Wave Out latency values. + [Fix] <js> When entering a chord, notes played via instrument plugins were not stopped on key-up. + [Fix] <js> Setting channel panning from Quick Channel Settings dialog didn't reset the surround flag live. + [Fix] <js> When inputting MIDI notes > B-9, they are now stopped properly on key-up (tx Knoeki). + [Reg] <js> Removed possibility to copy parts of the order list in favour of the new multi-pattern copying. + +Pattern tab::Find/Replace + [Imp] <js> Replacing has been sped up significantly, especially with large modules (http://bugs.openmpt.org/view.php?id=334). + +Sample tab + [New] <ks> Can now import MPEG samples (MP1 / MP2 / MP3, requires mpg123). + [Imp] <js> ITI files can now also be read as samples (only reads the first sample, naturally). + [Imp] <js> Sustain loop preview is now updated instantly (http://bugs.openmpt.org/view.php?id=108). + [Mod] <js> 8-Bit/Mono conversion items are now also shown in the context menu if a selection has been made. + [Fix] <js> Memory was leaked when loading a sample into an empty sample slot and undoing that action. + [Fix] <js> Inserting samples did not clear previously existing sample names since some time ago. + [Fix] <js> The sample filename wasn't imported properly when loading a FLAC sample with RIFF chunks. + [Fix] <js> Selection length display didn't show the correct in length in seconds for long samples. + +Instrument tab + [Imp] <js> Mouse wheel and middle mouse button can be used in Sample Map (http://bugs.openmpt.org/view.php?id=345). + [Imp] <js> Next / Previous Instrument shortcuts and the tab key also work on the sample map now (tx coda). + [Imp] <js> Revised sample slot allocation behaviour when loading sample files as instruments. + [Mod] <js> Filter mode is now disabled for IT modules (defaults to "Channel default"). + [Fix] <js> After cleaning up instruments, inserting a new instrument would reveal the old (deleted) samples. + +Tree view + [New] <js> Some items (order list, pattern / sequence / sample / instrument names) can now be edited directly from the tree view. + [Imp] <js> Previewing instruments does not open the audio device for every new preview anymore. Previewing the same file multiple times in a row no longer reloads it from disk everytime. + [Imp] <js> It is now possible to switch between the upper and lower part of the tree view by pressing the Tab key (http://bugs.openmpt.org/view.php?id=101). + [Imp] <js> Soundfont instruments can now also be previewed for other notes than middle-C. + [Imp] <js> Pause / Stop playback keyboard shortcuts also work when no module is loaded (to stop preview in tree view). + [Imp] <js> Navigating with keyboard (e.g. using alphanumeric keys in the instrument browser) should work much better now. + [Fix] <js> Previewing instruments only worked about every other time. + +Mod Conversion + [Imp] <js> Volume column a/b/c/d slide memory is now fixed when converting to MOD / XM / S3M. + [Imp] <js> 000 (arpeggio with no parameters) commands are now removed when converting from MOD / XM to other formats. + [Fix] <js> When resizing small patterns to 64 rows for MOD / S3M, the pattern break command was inserted on the new last row (63) instead of the original last row. + +VST / DMO Plugins + [New] <js> Can now load and save FXB (plugin preset bank) files. + [New] <js> Can now copy & paste current preset in the plugin editor. + [New] <js> Added an option in the plugin editor to route a plugin's MIDI output to the pattern / sample / instrument editor. + [Imp] <js> If no default directory for presets is specified, the plugin's directory is suggested in the load / save dialog by default. + [Imp] <js> Current program name is now suggested when saving FXP files. + [Imp] <js> Better preset list creation for plugins that don't support retrieval of indexed program names (such as VOPM). + [Imp] <js> Plugin Selection Dialog: Selecting "no plugin" no longer makes OpenMPT forget the last used plugin. + [Imp] <js> Offline rendering state is sent to plugins that request it. + [Fix] <js> The preset menu is now updated correctly if the plugin requests a GUI update (e.g. internal bank switching). + +Playback + [Imp] <js> Instrument envelopes are now also evaluated if no sample, but a MIDI channel is assigned to the instrument - great for automating plugins using envelopes and macros. + [Imp] <js> Retrigger note also works with instrument plugins on rows without a note, and also with Cxx volume commands in XM (not that it really matters, anyway...). + [Mod] <jh> In quad surround mode, the surround channel settings overwrites the reverb channel setting now (previously, it was the other way around). + [Fix] <js> Fixed problem where one had to press the play button twice after stopping playback (http://bugs.openmpt.org/view.php?id=325). + [Fix] <js> A crash could occour when using reverb with a mixing frequency higher than 50 KHz (http://bugs.openmpt.org/view.php?id=329). + +IT / MPTM + [New] <js> Experimental support for saving IT-compressed samples. To enable, set the ITCompressionMono=x and/or ITCompressionStereo=x (x is a sum of the following possible values: 1 = normal IT; 2 = Compatibility Export IT; 4 = MPTM) in mptrack.ini's [Misc] section; set ITCompressionVerification=1 to verify if samples are compressed correctly. Compressed stereo samples won't load in older versions of OpenMPT, and compressed samples will cause trouble when reading extended song or instrument properties in old versions, so be careful if you want to be backwards-compatible. + +IT::Compatible Playback Mode + [Imp] <js> Slightly changed arpeggio tick processing to be more accurate with pattern delays. + [Fix] <js> Retrigger note (Qxy) was broken for instrument plugins in IT compatible mode since OpenMPT 1.20.01.00 (tx Nahkranoth). + [Fix] <js> There is no unified effect memory between the volume column effects, and the volume slide commands there also don't share their effect memory with the effect column slides. + [Fix] <js> Envelope reset should now work correctly (http://bugs.openmpt.org/view.php?id=330). + [Fix] <js> pxx should also reset the surround flag, like all other panning commands. + [Fix] <js> SCx shouldn't "click" anymore (just like normal note cuts). + [Fix] <js> Various fixes regarding portamento between different samples, and especially portamento in multisample instruments. + +XM::Compatible Playbay Mode + [Fix] Reverted envelope handling changes made in OpenMPT 1.20.01.00 to fix gh-kott.xm. + +XM::Loading + [Mod] <js> Less false positives when trying to detect old versions of MPT. + +S3M + [Fix] <js> SCx shouldn't "click" anymore (just like normal note cuts). + +S3M::Loading and Saving + [Imp] <js> Added support for loading SAx panning (as found in PANIC.S3M, automatically translated to S8x panning). + [Mod] <js> The channel order is now written in a L1 L2 L3... R1 R2 R3... scheme, instead of L1 R1 L2 R2 L3 R3..., so that channels are evaluated in the same order in ST3 and OpenMPT (ST3 first evaluates "left" channels, then "right" channels - note that this change does not affect the actual panning, though). + +MOD + [Imp] <js> Vibrato and Tremolo are not applied on first tick anymore in ProTracker 1.x mode. + [Imp] <js> Added ProTracker arpeggio wrap-around emulation in ProTracker 1.x mode (fixes the snare sound in doh's "Jim is dead"). + [Fix] <js> In ProTracker 1.x mode, the frequency range is now limited properly by taking the sample's finetune setting into account. + +MOD::Loading and Saving + [Imp] <js> Drastically improved support for 15-sample (Ultimate Soundtracker and clones) modules. For example, original Ultimate Soundtracker effects are now handled much better (e.g. in sll7.mod). + [Mod] <js> Sample pre-amp volume is based on the number of channels, to have the highest possible sample pre-amp without clipping. + [Mod] <js> Changed heuristic ProTracker 1.x detection: If there are more than four sample swaps between two notes, ProTracker 1.x mode is enabled (previously it was just 16 sample swaps per pattern). This fixes e.g. hoisaga1.mod by Ramon. + [Mod] <js> Can now create MODs with up to 99 channels. + +Other formats + [Imp] <js> WAV Loader: Loops that only cover the first sample point are ignored during import now. + [Imp] <js> ITP Saver: If an instrument cannot be saved, a warning is shown. + [Fix] <js> PAT Loader: Sample frequency was not imported correctly since OpenMPT 1.20.02.00. + [Fix] <js> MTM Loader: Files with only one pattern were rejected (tx ant1). + [Fix] <js> Tenative fix for some DLS sounds not loading correctly (http://bugs.openmpt.org/view.php?id=331). + +Module cleanup + [Mod] <js> "Reset variables" also resets channel settings now. + [Fix] <js> After rearranging samples, some bogus sample slots became visible again when adding a new sample afterwards. + +Misc + [New] <jh> Added support for WASAPI output devices. + [New] <js> Added keyboard shortcut: Play song from start of pattern (same as play pattern from start, but doesn't loop the pattern). + [New] <jh> Add hidden setting "ShowSplashScreen" in [Display]. + [Imp] <js> Elapsed time display in the status bar is a lot more accurate now (no more rounding errors that pile up over time). + [Imp] <js> Exclusive file reading rights are no longer requested, so it is now possible to open files that are being read by other applications at the same time (http://bugs.openmpt.org/view.php?id=352). + [Imp] <js> Editing sample / instrument names on the comments page limits the name length during input instead of just trimming long strings afterwards. + [Imp] <js> When clicking the "MIDI Record" button and the device is not ready, opening the device is now tried again after the popup settings dialog is closed. + [Imp] <js> Reduced memory usage. + [Mod] <jh> Options Dialog: Changed "Buffer Length" value into "Latency" (real audio latency) and "Update Interval" (for GUI updates). Old buffer length settings are automatically converted to the new quantities. + [Mod] <js> Improved extension detection when reading files from zip files. When no preferred file extension is found, the biggest file in the archive is now preferred. + [Mod] <js> Changed default song name to be empty instead of "untitled". + [Fix] <jh> Reported ASIO latency was slightly off, so that pattern playback syncing might have been a little off (not very noticeable since ASIO has very low latencies anyway). + [Reg] <js> Removed poorly implemented Invert Stereo option. It's not 1995 anymore. + +Bundled plugins + [Imp] <js> The MIDI Input / Output Plugin now stores device names in presets / modules, so that the order of MIDI devices is no longer important (when having e.g. more than one USB to MIDI interface, their device IDs might change depending on which one was plugged in first). + [Fix] <js> The MIDI Input / Output plugin could crash when changing devices while MIDI data was being processed. + + v1.21.01.00 (22 December 2012, revision 1472) --------------------------------------------- Pattern tab @@ -41,12 +183,12 @@ [Imp] <js> Added shortcuts for "Zoom into Selection" (http://forum.openmpt.org/index.php?topic=4877.0), 8-bit and mono conversion. [Imp] <js> When triggering a note, the note frequency is displayed next to the note name in the status bar. [Imp] <js> It is now possible to drag and drop multiple samples from explorer. - [Imp] <js> When saving a sample, the actual sample is now suggested if no sample filename is specified in IT / S3M / MPTM modules. + [Imp] <js> When saving a sample, the actual sample name is now suggested if no sample filename is specified in IT / S3M / MPTM modules. [Imp] <js> Added hidden INI setting "DefaultFormat" in the [Sample Editor] section to specify the default format to use when saving samples (possible values: wav, flac, raw). [Imp] <js> Added hidden INI setting "FLACCompressionLevel" in the [Sample Editor] section to set the compression level (0...8) when saving FLAC samples. [Fix] <js> Reducing the size of the sample undo buffer could sometimes lead to freezes (http://bugs.openmpt.org/view.php?id=314). - [Fix] <js> Fixed a possible crash when creating undo points (e.g. when using loop crossfade). - [Fix] <js> Saved WAV files should now finally have a file size in the header. + [Fix] <js> Fixed a possible crash when creating undo points (e.g. when using loop crossfade with an invalid crossfade length). + [Fix] <js> Saved WAV files should now finally have a correct file size in the header. Instrument tab [Imp] <js> Moving the envelope tail (using Ctrl + Drag) also works properly if the distance between the moved point and the following point is small. @@ -99,7 +241,7 @@ [Fix] <js> Loading XI files as samples could lead to a crash (tx Lucas). [Fix] <js> Mass sample export file names were sometimes not sanitized correctly (http://bugs.openmpt.org/view.php?id=300). -Treev iew +Tree view [New] <js> It is now possible to rearrange (drag and drop), insert and duplicate (through the context menu) samples and instruments. VST / DMO Plugins @@ -486,7 +628,7 @@ S3M [Fix] <js> Some commands (Dxy, Exx, Fxx, Ixy, Jxy, Kxy, Lxy, Qxy, Rxy, Sxy) use the last non-zero effect parameter as memory. This fixes for example Satellite One by Purple Motion. - [Fix] <js> Pattern loops have no per-channel memory in ST3 (tx Greasemonkey). + [Fix] <js> Pattern loops have no per-channel memory in ST3 (tx GreaseMonkey). [Fix] <js> Amiga limits are now enfored correctly if the "preserve amiga limits" flag is set. [Fix] <js> If there are multiple row delay commands on the same row, only the leftmost command is considered. [Fix] <js> Delayed notes that are on the same row as a row delay effect are be retriggered. @@ -522,7 +664,7 @@ [New] <al> Example modules can now be loaded from the "Help" menu. [New] <ks> Keyboard shortcuts can now be assigned to incoming MIDI CCs. For now, this only works if the pattern, sample or instrument editor is focussed. [New] <js> Instead of multiple modal message boxes, a single dialog with a list of unsaved files is now shown when closing the main window. If you don't like the new behaviour, use "Disable modern close dialog" in the general settings. - [New] <js> The default module type can now be set in mptrack.ini by setting DefaultModType in the [Misc] section, e.g. "DefaultModType=mptm" (tx herodotas, http://forum.openmpt.org/index.php?topic=4411.0). + [New] <js> The default module type can now be set in mptrack.ini by setting DefaultModType in the [Misc] section, e.g. "DefaultModType=mptm" (http://forum.openmpt.org/index.php?topic=4411.0). [New] <js> Recent file list length can now be set through a hidden INI option, MRUListLength in [Misc] (up to 15 entries). [New] <js> If a crash is encountered, OpenMPT tries to close the audio device (if it is still in use) and rescue all modified files. A memory dump is also created and can be used for debugging. [New] <js> Added "Close All" shortcut + menu item (tx Wayfinder). @@ -600,9 +742,9 @@ [Fix] <js> Using the "Paste Pattern" menu entry in the order list didn't refresh the pattern display. Sample tab - [Imp] <js> When selecting parts of the sample, the selection range is now also displayed in samples, not only seconds (tx jmkz, http://bugs.openmpt.org/view.php?id=136). + [Imp] <js> When selecting parts of the sample, the selection range is now also displayed in samples, not only seconds (http://bugs.openmpt.org/view.php?id=136). [Imp] <js> When changing the sample's global volume while removing DC offset, the change is now instantly applied to all channels that are currently playing the sample. - [Fix] <js> 8-Bit Stereo samples were not saved correctly (tx jmkz, http://bugs.openmpt.org/view.php?id=153). + [Fix] <js> 8-Bit Stereo samples were not saved correctly (http://bugs.openmpt.org/view.php?id=153). Instrument tab [Imp] <js> Two envelope points cannot share the same tick anymore in compatible mode. @@ -757,7 +899,7 @@ VST::Specific Plugin Fixes [Fix] <js> Speaker arrangement is now sent to the plugins upon initialization. This fixes Voxengo SPAN 2 (a VST 2.4 plugin). - [Fix] <js> The EnergyXT GUI does now also work after closing and re-opening the VST editor (tx Nahkranoth, http://forum.openmpt.org/index.php?topic=2307.0). + [Fix] <js> The EnergyXT GUI does now also work after closing and re-opening the VST editor (http://forum.openmpt.org/index.php?topic=2307.0). Mod Conversion [Imp] <js> If the new format doesn't support restart positions, it is now tried to convert the restart position to a pattern command. @@ -984,7 +1126,7 @@ [Reg] <js> Creating a selection using the Shift key + Mouse click now only works if there was previously no selection made; This seems reasonable as the old shift - behaviour seems to be widely used. Pattern tab::GUI - [New] <js> When the PT1x mode or the S3M "Amiga" flag are enabled, dodgy notes (i.e lower than C-4 or higher than B-6) are marked red. + [New] <js> When the ProTracker 1.x mode or the S3M "Amiga" flag are enabled, dodgy notes (i.e lower than C-4 or higher than B-6) are marked red. [Imp] <js> The status bar shows plugin and parameter names for Parameter Control Events now as well. [Imp] <js> Effect vis: Make use of song's own row highlighting variables instead of fixed global ones. [Fix] <js> The status bar ("Position x of y") only the showed order length for the first sub tune if sub tunes were separated by an "---" order item. @@ -1089,7 +1231,7 @@ MOD [Imp] <js> Module creation: When creating a new .MOD, it has 31 sample slots by default. - [Imp] <js> Playback: When the PT1x flag is activated, Amiga note range limits are automatically taken into account. + [Imp] <js> Playback: When the ProTracker 1.x flag is activated, Amiga note range limits are automatically taken into account. [Fix] <js> Saving: Samples were shifted badly if the sample size was odd (wow, this is an OLD bug!). [Fix] <js> Saving: If a sample had loop points set, but loop disabled, they were still saved in the .MOD file, resulting in the loop being enabled automatically. [Fix] <js> Loading: Very short loops (4-8 bytes long) are not ignored anymore. This fixes "Crew Generation" by Necros. @@ -1292,14 +1434,13 @@ [Fix] <js> Command X ModPlug extensions are now ignored in FT2 compatibility mode. MOD - [Imp] <js> Mod Creation: Ensure that the order length fits the current mod specifications (this was problematic when creating .MOD files). - [Fix] <js> Mod Creation: MOD Panning scheme is set up correctly now. + [Imp] <js> Mod Creation: The default empty order list was too long, allowing for overly long songs to be created which would then not be saved correctly. + [Fix] <js> Mod Creation: MOD Panning scheme is now set up correctly. [Fix] <js> Loading: 8Chn Startrekker modules ("FLT8") are loaded correctly now. MOD::Playback compatibility - [New] <js> Added song flag "PT 1.x Mode" (for .MOD files) that enabled on-the-fly sample swapping as ProTracker did it. + [New] <js> Added song flag "ProTracker 1.x Mode" (for .MOD files) that enabled on-the-fly sample swapping as ProTracker did it. 8xx and E8x panning commands are also ignored in this mode. [New] <js> Support for the EFx command (Invert Loop). One has to pay attention when working with this command as it effectively trashes samples. - [Imp] <js> MOD Playback: if PT1.x playback flag is set, 8xx and E8x panning commands are now ignored. Module cleanup [New] <js> New cleanup feature: Merge sequences. Added: trunk/OpenMPT/packageTemplate/OMPT_1.22_ReleaseNotes.html =================================================================== --- trunk/OpenMPT/packageTemplate/OMPT_1.22_ReleaseNotes.html (rev 0) +++ trunk/OpenMPT/packageTemplate/OMPT_1.22_ReleaseNotes.html 2013-04-06 13:31:47 UTC (rev 1749) @@ -0,0 +1,187 @@ +<?xml version="1.0" ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> + <head> + <title>OpenMPT 1.22 Release Notes</title> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + <meta name="language" content="en" /> + <style type="text/css"> + * { font-family: Calibri, sans-serif; } + body + { + color: #222; + background: #eee; + font-size: 13pt; + margin: 0 0 1em 0; + padding: 0; + border: none; + } + + a { color: #b30; text-decoration: none; } + a:visited { color: #910; text-decoration: none; } + a:hover { text-decoration: underline; } + + .screenshots + { + float:right; + text-align:right; + } + + .screenshots img, h1 + { + border: 1px solid #ccc; + padding: 3px; + background: #f0f0f0; + margin: 0 0 3px 3px; + } + + p { margin: 0.5em 1em; padding: 0; } + + h1 + { + margin: 0 0 1em 0; + padding: 10px; + font-size: 24pt; + color: #444; + text-shadow: 1px 1px 1px #999; + background: #ddd; + background-image: linear-gradient(bottom, #ddd 20%, #eee 60%); + background-image: -o-linear-gradient(bottom, #ddd 20%, #eee 60%); + background-image: -moz-linear-gradient(bottom, #ddd 20%, #eee 60%); + background-image: -webkit-linear-gradient(bottom, #ddd 20%, #eee 60%); + background-image: -ms-linear-gradient(bottom, #ddd 20%, #eee 60%); + background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0.2, #ddd), color-stop(0.6, #eee)); + border-width: 0 0 1px 0; + } + + h1 img { vertical-align: middle; margin-right: 1em; } + + h2, h3, h4 + { + border: 1px solid #ccc; + border-width: 0 0 0 3em; + margin: 1em 0.5em; + padding: 0px 5px; + font-size: 18pt; + color: #333; + text-shadow: 1px 1px #fff; + } + + h3 { border-left-width: 2em; } + h4 { border-left-width: 1em; } + + li {list-style-type: none; padding: 0 0 0.5em 0; } + li:before { content: "» "; } + + li li { padding: 0; } + + /* use this for pattern data */ + pre + { + font-family: monospace; + display: inline; + color: #006; + } + + tt + { + font-family: monospace; + } + + </style> + </head> + <body> + + <h1> + <img src="ReleaseNotesImages/general/modplug.png" width="81" height="80" alt="OpenMPT Logo" /> + OpenMPT 1.22 - Release Notes + </h1> + + <p> + Not much time has passed since the last official release (version 1.21.01.00), but nevertheless this new major version of OpenMPT has introduced a significant number of noteworthy new features. + This document should give a rough overview about the greatest changes in OpenMPT 1.22. + </p> + + <h2>What's new?</h2> + + <h3>General</h3> + <div class="screenshots"> + <a href="ReleaseNotesImages/1.22/soundsettings.png"><img src="ReleaseNotesImages/1.22/soundsettings.png" width="255" height="119" alt="New sound card options" title="New sound card options (click to view big screenshot)" /></a> + </div> + <ul> + <li><strong>Please read</strong>: In the <strong>options dialog</strong>, the "Buffer Length" has been changed into "Latency" (real audio latency) and "Update Interval" (for GUI updates). + Old buffer length settings are <strong>converted automatically</strong> to their new equivalent values. + Yes, the new latency value is higher than the previous buffer length value, but that is intended, because previously, the real latency was three times the buffer length. + If you are still in doubt, read the <a href="http://wiki.openmpt.org/Manual:_Frequently_Asked_Questions#OpenMPT_produces_clicks_at_a_buffer_length_that_previously_worked_just_fine">FAQ</a>.</li> + <li>Added support for <strong>WASAPI output devices</strong>.</li> + <li><strong>Elapsed time display</strong> in the status bar is a lot more accurate now (no more rounding errors that pile up over time).</li> + </ul> + + <div class="screenshots"> + <a href="ReleaseNotesImages/1.22/clipboardmanager.png"><img src="ReleaseNotesImages/1.22/clipboardmanager.png" width="255" height="349" alt="Clipboard Manager" title="Clipboard Manager" /></a> + </div> + <h3>Pattern Editor</h3> + <ul> + <li>It is now possibly to <strong>copy multiple patterns at once</strong> - simply make an order list selection and copy the orders with all their content!</li> + <li>The <strong>Clipboard Manager</strong> can be used to manage a virtually unlimited number of internal pattern clipboards to speed up copy and paste workflow.</li> + <li>The Chord Editor features a <strong>relative base note mode</strong>, which enters chords that are relative to a previously entered base note instead of a fixed base note. Chord mode also works without having to select any record channel beforehand now.</li> + <li>Higher <strong>live record precision</strong>.</li> + </ul> + + <h3>Tree view</h3> + <ul> + <li>It is now possible to <strong>edit some items</strong> (order list, pattern / sequence / sample / instrument names) directly.</li> + <li>The Tab key can now be used to <strong>switch between tree view panels</strong>, for fast navigation between folders.</li> + <li>Optimized <strong>preview behaviour</strong>: The sound device is not re-opened for every preview, and when the same file multiple times in a row, it is not reloaded every time.</li> + <li><strong>Soundfont instruments</strong> can now also be previewed for other notes than middle-C.</li> + </ul> + + <h3>Plugins</h3> + <ul> + <li>It is now possible to <strong>load and save FXB</strong> (plugin preset bank) files.</li> + <li>Plugin presets can now be <strong>copied and pasted</strong> between several instances of the same plugin.</li> + <li>Added an option in the plugin editor to <strong>route a plugin's MIDI output</strong> to the pattern / sample / instrument editor.</li> + </ul> + + <h3>Instrument Editor</h3> + <ul> + <li>The <strong>mouse wheel</strong> can now be used to navigate in the note map.</li> + <li>Instrument envelopes are now also evaluated if no sample, but a MIDI channel is assigned to the instrument - great for <strong>automating plugins using envelopes</strong> and macros by using the volume and panning macro variables.</li> + </ul> + + <h3>File Format Support</h3> + <ul> + <li>Support for importing <strong>MP3 samples</strong> has been added. libmpeg123 is required for this to work, which is not shipped with MP3 due to the patent troubles involved with MP3 technology. The OpenMPT manual <a href="http://wiki.openmpt.org/Manual:_Frequently_Asked_Questions#I_can.27t_load_any_MP3_samples">explains</a> where to download and where to put libmpg123 to work with OpenMPT.</li> + <li>Drastically improved support for 15-sample <strong>SoundTracker MODs</strong>!</li> + <li>Experimental support for <strong>saving IT-compressed samples</strong> has been added. Compressed stereo samples won't load in older versions of OpenMPT, and compressed samples will cause trouble when reading extended song or instrument properties in old versions, so be careful if you want to be backwards-compatible.</li> + </ul> + + <h3>There's more...</h3> + <p> + For a detailed description of what has changed, check <a href="History.txt">History.txt</a>. If you are new to OpenMPT, be sure to read the manual as well. + </p> + + <h2>Known Issues</h2> + <p> + <i>This list has mostly been copied over from the old OpenMPT 1.17 RC2 release notes, so this not very comprehensive... :-)</i> + </p> + <ul> + <li>Far from perfect VST support (no buses for audio / MIDI routing, only a few tracker effects are supported, etc...)</li> + <li>Previewing samples from the treeview's file browser stops the playing module.</li> + <li>Cannot preview instruments directly from the MIDI Library in the tree view.</li> + <li>Excessive performance drop when dragging over the graphical parameter editor during playback.</li> + <li>The Right Alt (or Alt Gr) key is not handled well by the keyboard configuration.</li> + <li>In Windows 98, the graphical parameter editor and instrument envelope editor grid display are messed up.</li> + <li>There is no really <em>convenient</em> way to find out what features of the tracker are supported by the original trackers (Impulse Tracker, Fasttracker 2, etc...) when working with those file formats...</li> + </ul> + + <h2>Contact</h2> + <p> + Helpful bug reports, new ideas and brave volunteers to test early development builds or contribute to the code are more than welcome!<br /> + Our issue tracker is located at <a href="http://bugs.openmpt.org/">http://bugs.openmpt.org/</a> and can be used to report bugs and feature requests.<br /> + You can also meet us at the ModPlug Central forums: <a href="http://forum.openmpt.org/">http://forum.openmpt.org/</a>. + </p> + + </body> +</html> \ No newline at end of file Index: trunk/OpenMPT/packageTemplate/ReleaseNotesImages/1.22 =================================================================== --- trunk/OpenMPT/packageTemplate/ReleaseNotesImages/1.22 2013-04-06 13:18:05 UTC (rev 1748) +++ trunk/OpenMPT/packageTemplate/ReleaseNotesImages/1.22 2013-04-06 13:31:47 UTC (rev 1749) Property changes on: trunk/OpenMPT/packageTemplate/ReleaseNotesImages/1.22 ___________________________________________________________________ Added: tsvn:logminsize ## -0,0 +1 ## +10 \ No newline at end of property Added: trunk/OpenMPT/packageTemplate/ReleaseNotesImages/1.22/clipboardmanager.png =================================================================== (Binary files differ) Index: trunk/OpenMPT/packageTemplate/ReleaseNotesImages/1.22/clipboardmanager.png =================================================================== --- trunk/OpenMPT/packageTemplate/ReleaseNotesImages/1.22/clipboardmanager.png 2013-04-06 13:18:05 UTC (rev 1748) +++ trunk/OpenMPT/packageTemplate/ReleaseNotesImages/1.22/clipboardmanager.png 2013-04-06 13:31:47 UTC (rev 1749) Property changes on: trunk/OpenMPT/packageTemplate/ReleaseNotesImages/1.22/clipboardmanager.png ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: trunk/OpenMPT/packageTemplate/ReleaseNotesImages/1.22/soundsettings.png =================================================================== (Binary files differ) Index: trunk/OpenMPT/packageTemplate/ReleaseNotesImages/1.22/soundsettings.png =================================================================== --- trunk/OpenMPT/packageTemplate/ReleaseNotesImages/1.22/soundsettings.png 2013-04-06 13:18:05 UTC (rev 1748) +++ trunk/OpenMPT/packageTemplate/ReleaseNotesImages/1.22/soundsettings.png 2013-04-06 13:31:47 UTC (rev 1749) Property changes on: trunk/OpenMPT/packageTemplate/ReleaseNotesImages/1.22/soundsettings.png ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Modified: trunk/OpenMPT/packageTemplate/extraKeymaps/DE_jojo.mkb =================================================================== --- trunk/OpenMPT/packageTemplate/extraKeymaps/DE_jojo.mkb 2013-04-06 13:18:05 UTC (rev 1748) +++ trunk/OpenMPT/packageTemplate/extraKeymaps/DE_jojo.mkb 2013-04-06 13:31:47 UTC (rev 1749) @@ -17,9 +17,10 @@ 0:1031:0:119:1 //Pause Song: F8 (KeyDown) 0:1375:0:27:1 //Stop Song: ESC (KeyDown) 0:1029:0:117:1 //Play Song from Start: F6 (KeyDown) -0:1028:2:117:1 //Play Song from Cursor: Ctrl+F6 (KeyDown) -0:1027:0:118:5 //Play pattern from start: F7 (KeyDown|KeyHold) -0:1026:2:118:5 //Play pattern from cursor: Ctrl+F7 (KeyDown|KeyHold) +0:1028:2:116:1 //Play Song from Cursor: Ctrl+F5 (KeyDown) +0:1898:2:117:1 //Play Song from Pattern Start: Ctrl+F6 (KeyDown) +0:1027:0:118:5 //Play Pattern from Start: F7 (KeyDown|KeyHold) +0:1026:2:118:5 //Play Pattern from Cursor: Ctrl+F7 (KeyDown|KeyHold) 0:1376:0:120:1 //Toggle MIDI Record: F9 (KeyDown) 0:1359:2:90:5 //Undo: Ctrl+Z (KeyDown|KeyHold) 0:1360:2:88:1 //Cut: Ctrl+X (KeyDown) @@ -99,6 +100,9 @@ 2:1819:2:69:1 //Split Keyboard Settings dialog: Ctrl+E (KeyDown) 2:1780:2:80:1 //Show playback time at current row: Ctrl+P (KeyDown) 2:1892:4:81:1 //Quantize Settings: Alt+Q (KeyDown) +2:1900:3:77:1 //Toggle Clipboard Manager: Shift+Ctrl+M (KeyDown) +2:1901:3:37:1 //Cycle to Previous Clipboard: Shift+Ctrl+NACH-LINKS (KeyDown) +2:1902:3:39:1 //Cycle to Next Clipboard: Shift+Ctrl+NACH-RECHTS (KeyDown) 2:1005:2:85:1 //Mute current Channel: Ctrl+U (KeyDown) 2:1883:2:49:1 //Channel Record Select: Ctrl+1 (KeyDown) 2:1884:2:50:1 //Channel Split Record Select: Ctrl+2 (KeyDown) @@ -338,9 +342,10 @@ 13:1782:0:38:1 //Plugin preset backward jump: NACH-OBEN (KeyDown) 13:1783:0:40:1 //Plugin preset forward jump: NACH-UNTEN (KeyDown) 13:1765:2:80:1 //Randomize Plugin Parameters: Ctrl+P (KeyDown) -13:1839:2:82:1 //Toggle parameter recording: Ctrl+R (KeyDown) -13:1840:2:75:1 //Pass key presses to plugin: Ctrl+K (KeyDown) -13:1841:2:66:1 //Bypass plugin: Ctrl+B (KeyDown) +13:1839:2:82:1 //Toggle Parameter Recording: Ctrl+R (KeyDown) +13:1899:2:77:1 //Record MIDI Out to Pattern Editor: Ctrl+M (KeyDown) +13:1840:2:75:1 //Pass Key Presses to Plugin: Ctrl+K (KeyDown) +13:1841:2:66:1 //Bypass Plugin: Ctrl+B (KeyDown) //----( General Context [top] (14) )------------ Modified: trunk/OpenMPT/packageTemplate/extraKeymaps/US_mptit_(coda).mkb =================================================================== --- trunk/OpenMPT/packageTemplate/extraKeymaps/US_mptit_(coda).mkb 2013-04-06 13:18:05 UTC (rev 1748) +++ trunk/OpenMPT/packageTemplate/extraKeymaps/US_mptit_(coda).mkb 2013-04-06 13:31:47 UTC (rev 1749) @@ -12,10 +12,10 @@ 0:1349:2:83:1 //File/Save: Ctrl+S (KeyDown) 0:1350:2:87:1 //File/Save As: Ctrl+W (KeyDown) 0:1350:0:121:1 //File/Save As: F10 (KeyDown) -0:1030:0:116:2 //Play song/Pause song: F5 (KeyUp) -0:1031:0:119:1 //Pause song: F8 (KeyDown) -0:1029:2:116:1 //Play song from start: Ctrl+F5 (KeyDown) -0:1028:0:118:1 //Play song from cursor: F7 (KeyDown) +0:1030:2:116:2 //Play Song / Pause song: Ctrl+F5 (KeyUp) +0:1031:0:119:1 //Pause Song: F8 (KeyDown) +0:1029:0:116:2 //Play Song from Start: F5 (KeyUp) +0:1028:0:118:1 //Play Song from Cursor: F7 (KeyDown) 0:1027:0:117:5 //Play pattern from start: F6 (KeyDown|KeyHold) 0:1026:2:118:5 //Play pattern from cursor: Ctrl+F7 (KeyDown|KeyHold) 0:1374:2:80:1 //Estimate Song Length: Ctrl+P (KeyDown) @@ -34,15 +34,15 @@ 0:1367:4:122:1 //Toggle Main View: Alt+F11 (KeyDown) 0:1368:4:122:2 //Toggle Tree View: Alt+F11 (KeyUp) 0:1369:0:123:1 //View Options: F12 (KeyDown) -0:1370:0:112:1 //Help (to do): F1 (KeyDown) -0:1032:1:188:5 //Previous instrument: Shift+, (KeyDown|KeyHold) -0:1032:2:38:5 //Previous instrument: Ctrl+Up (KeyDown|KeyHold) -0:1033:1:190:5 //Next instrument: Shift+. (KeyDown|KeyHold) -0:1033:2:40:5 //Next instrument: Ctrl+Down (KeyDown|KeyHold) -0:1036:0:111:5 //Previous octave: Num / (KeyDown|KeyHold) -0:1037:0:106:5 //Next octave: Num * (KeyDown|KeyHold) -0:1034:2:37:5 //Previous order: Ctrl+Left (KeyDown|KeyHold) -0:1035:2:39:5 //Next order: Ctrl+Right (KeyDown|KeyHold) +0:1370:0:112:1 //Help: F1 (KeyDown) +0:1032:1:188:5 //Previous Instrument: Shift+, (KeyDown|KeyHold) +0:1032:2:38:5 //Previous Instrument: Ctrl+Up (KeyDown|KeyHold) +0:1033:1:190:5 //Next Instrument: Shift+. (KeyDown|KeyHold) +0:1033:2:40:5 //Next Instrument: Ctrl+Down (KeyDown|KeyHold) +0:1036:0:111:5 //Previous Octave: Num / (KeyDown|KeyHold) +0:1037:0:106:5 //Next Octave: Num * (KeyDown|KeyHold) +0:1034:2:37:5 //Previous Order: Ctrl+Left (KeyDown|KeyHold) +0:1035:2:39:5 //Next Order: Ctrl+Right (KeyDown|KeyHold) //----( General Context [bottom] (1) )------------ @@ -70,14 +70,21 @@ 2:1050:1:16:1 //Selection key: Shift+Shift (KeyDown) 2:1051:2:17:1 //Copy select key: Ctrl+Ctrl (KeyDown) 2:1011:4:76:1 //Select channel / Select all: Alt+L (KeyDown) -2:1003:0:13:1 //Quick copy: Enter (KeyDown) -2:1004:0:32:5 //Quick paste: Space (KeyDown|KeyHold) -2:1002:0:56:1 //Play row: 8 (KeyDown) -2:1317:4:18:1 //Set row jump on note entry: Alt+Alt (KeyDown) -2:1062:0:93:1 //Show note properties: Application (KeyDown) -2:1063:2:93:1 //Show context (right-click) menu: Ctrl+Application (KeyDown) -2:1005:4:120:1 //Mute current channel: Alt+F9 (KeyDown) -2:1006:4:121:1 //Solo current channel: Alt+F10 (KeyDown) +2:1663:2:3:1 //Toggle follow song: Ctrl+Scroll Lock (KeyDown) +2:1004:0:32:5 //Quick Paste: Space (KeyDown|KeyHold) +2:1897:0:13:1 //Pick up nearest instrument number: Enter (KeyDown) +2:1002:0:56:1 //Play Row: 8 (KeyDown) +2:1317:4:18:1 //Set row spacing on note entry: Alt+Alt (KeyDown) +2:1672:3:68:1 //Insert new pattern: Shift+Ctrl+D (KeyDown) +2:1806:2:68:1 //Duplicate pattern: Ctrl+D (KeyDown) +2:1062:0:93:1 //Show Note Properties: Application (KeyDown) +2:1776:0:117:2 //Toggle Loop Pattern: F6 (KeyUp) +2:1063:2:93:1 //Show Context (Right-Click) Menu: Ctrl+Application (KeyDown) +2:1900:3:77:1 //Toggle Clipboard Manager: Shift+Ctrl+M (KeyDown) +2:1901:3:37:1 //Cycle to Previous Clipboard: Shift+Ctrl+NACH-LINKS (KeyDown) +2:1902:3:39:1 //Cycle to Next Clipboard: Shift+Ctrl+NACH-RECHTS (KeyDown) +2:1005:4:120:1 //Mute current Channel: Alt+F9 (KeyDown) +2:1006:4:121:1 //Solo current Channel: Alt+F10 (KeyDown) 2:1671:4:67:1 //Copy and lose selection: Alt+C (KeyDown) 2:1007:4:81:5 //Transpose +1: Alt+Q (KeyDown|KeyHold) 2:1008:4:65:5 //Transpose -1: Alt+A (KeyDown|KeyHold) @@ -85,9 +92,9 @@ 2:1010:6:65:5 //Transpose -12: Ctrl+Alt+A (KeyDown|KeyHold) 2:1881:2:84:1 //Transpose Custom: Ctrl+T (KeyDown) 2:1012:4:74:1 //Amplify selection: Alt+J (KeyDown) -2:1014:4:75:1 //Interpolate volume: Alt+K (KeyDown) -2:1015:4:88:1 //Interpolate effect: Alt+X (KeyDown) -2:1016:4:66:1 //Open effect visualizer: Alt+B (KeyDown) +2:1014:4:75:1 //Interpolate Volume: Alt+K (KeyDown) +2:1015:4:88:1 //Interpolate Effect: Alt+X (KeyDown) +2:1016:4:66:1 //Open Effect Visualizer: Alt+B (KeyDown) 2:1013:4:83:1 //Apply current instrument: Alt+S (KeyDown) 2:1664:0:46:1 //Clear field (IT Style): Delete (KeyDown) 2:1665:0:190:5 //Clear field and step (IT Style): . (KeyDown|KeyHold) @@ -144,8 +151,8 @@ 3:1220:0:104:1 //Set octave 8: Num 8 (KeyDown) 3:1221:0:105:1 //Set octave 9: Num 9 (KeyDown) 3:1316:1:16:1 //Chord Modifier: Shift+Shift (KeyDown) -3:1667:0:49:1 //Note Cut (don't remember instrument): 1 (KeyDown) -3:1668:0:192:1 //Note Off (don't remember instrument): ` (KeyDown) +3:1667:0:49:1 //Note Cut (without instrument number): 1 (KeyDown) +3:1668:0:192:5 //Note Off (without instrument number): ` (KeyDown|KeyHold) 3:1788:1:49:1 //Parameter control(MPTm only): Shift+1 (KeyDown) 3:1789:3:49:1 //Parameter control(smooth)(MPTm only): Shift+Ctrl+1 (KeyDown) @@ -190,53 +197,54 @@ 5:1230:0:56:1 //Set volume digit 8: 8 (KeyDown) 5:1231:0:57:1 //Set volume digit 9: 9 (KeyDown) 5:1231:0:105:1 //Set volume digit 9: Num 9 (KeyDown) -5:1232:0:86:1 //Vol command - volume: V (KeyDown) -5:1233:0:80:1 //Vol command - pan: P (KeyDown) -5:1234:0:67:1 //Vol command - vol slide up: C (KeyDown) -5:1235:0:68:1 //Vol command - vol slide down: D (KeyDown) -5:1236:0:65:1 //Vol command - vol fine slide up: A (KeyDown) -5:1237:0:66:1 //Vol command - vol fine slide down: B (KeyDown) -5:1238:0:85:1 //Vol command - vibrato speed: U (KeyDown) -5:1239:0:72:1 //Vol command - vibrato: H (KeyDown) -5:1240:0:76:1 //Vol command - XM pan left: L (KeyDown) -5:1241:0:82:1 //Vol command - XM pan right: R (KeyDown) -5:1242:0:71:1 //Vol command - Portamento: G (KeyDown) -5:1243:0:70:1 //Vol command - Portamento Up: F (KeyDown) -5:1244:0:69:1 //Vol command - Portamento Down: E (KeyDown) -5:1246:0:79:1 //Vol command - Offset: O (KeyDown) +5:1232:0:86:1 //Volume Command - Volume: V (KeyDown) +5:1233:0:80:1 //Volume Command - Panning: P (KeyDown) +5:1234:0:67:1 //Volume Command - Volume Slide Up: C (KeyDown) +5:1235:0:68:1 //Volume Command - Volume Slide Down: D (KeyDown) +5:1236:0:65:1 //Volume Command - Fine Volume Slide Up: A (KeyDown) +5:1237:0:66:1 //Volume Command - Fine Volume Slide Down: B (KeyDown) +5:1238:0:85:1 //Volume Command - Vibrato Speed: U (KeyDown) +5:1239:0:72:1 //Volume Command - Vibrato Depth: H (KeyDown) +5:1240:0:76:1 //Volume Command - XM Pan Slide Left: L (KeyDown) +5:1241:0:82:1 //Volume Command - XM Pan Slide Right: R (KeyDown) +5:1242:0:71:1 //Volume Command - Portamento: G (KeyDown) +5:1243:0:70:1 //Volume Command - Portamento Up: F (KeyDown) +5:1244:0:69:1 //Volume Command - Portamento Down: E (KeyDown) +5:1246:0:79:1 //Volume Command - Offset: O (KeyDown) //----( Pattern Context [bottom] - FX Col (6) )------------ +6:1294:0:220:1 //Smooth MIDI Macro Slide: \ (KeyDown) //----( Pattern Context [bottom] - Param Col (7) )------------ -7:1247:0:48:1 //FX Param digit 0: 0 (KeyDown) -7:1248:0:49:1 //FX Param digit 1: 1 (KeyDown) -7:1249:0:50:1 //FX Param digit 2: 2 (KeyDown) -7:1250:0:51:1 //FX Param digit 3: 3 (KeyDown) -7:1251:0:52:1 //FX Param digit 4: 4 (KeyDown) -7:1252:0:53:1 //FX Param digit 5: 5 (KeyDown) -7:1253:0:54:1 //FX Param digit 6: 6 (KeyDown) -7:1254:0:55:1 //FX Param digit 7: 7 (KeyDown) -7:1255:0:56:1 //FX Param digit 8: 8 (KeyDown) -7:1256:0:57:1 //FX Param digit 9: 9 (KeyDown) -7:1257:0:65:1 //FX Param digit A: A (KeyDown) -7:1258:0:66:1 //FX Param digit B: B (KeyDown) -7:1259:0:67:1 //FX Param digit C: C (KeyDown) -7:1260:0:68:1 //FX Param digit D: D (KeyDown) -7:1261:0:69:1 //FX Param digit E: E (KeyDown) -7:1262:0:70:1 //FX Param digit F: F (KeyDown) +7:1247:0:48:1 //Effect Parameter Digit 0: 0 (KeyDown) +7:1248:0:49:1 //Effect Parameter Digit 1: 1 (KeyDown) +7:1249:0:50:1 //Effect Parameter Digit 2: 2 (KeyDown) +7:1250:0:51:1 //Effect Parameter Digit 3: 3 (KeyDown) +7:1251:0:52:1 //Effect Parameter Digit 4: 4 (KeyDown) +7:1252:0:53:1 //Effect Parameter Digit 5: 5 (KeyDown) +7:1253:0:54:1 //Effect Parameter Digit 6: 6 (KeyDown) +7:1254:0:55:1 //Effect Parameter Digit 7: 7 (KeyDown) +7:1255:0:56:1 //Effect Parameter Digit 8: 8 (KeyDown) +7:1256:0:57:1 //Effect Parameter Digit 9: 9 (KeyDown) +7:1257:0:65:1 //Effect Parameter Digit A: A (KeyDown) +7:1258:0:66:1 //Effect Parameter Digit B: B (KeyDown) +7:1259:0:67:1 //Effect Parameter Digit C: C (KeyDown) +7:1260:0:68:1 //Effect Parameter Digit D: D (KeyDown) +7:1261:0:69:1 //Effect Parameter Digit E: E (KeyDown) +7:1262:0:70:1 //Effect Parameter Digit F: F (KeyDown) //----( Sample Context [bottom] (8) )------------ -8:1673:0:13:1 //Load a Sample: Enter (KeyDown) -8:1673:4:79:1 //Load a Sample: Alt+O (KeyDown) +8:1673:0:13:1 //Load Sample: Enter (KeyDown) +8:1673:4:79:1 //Load Sample: Alt+O (KeyDown) 8:1674:4:83:1 //Save Sample: Alt+S (KeyDown) 8:1675:0:45:1 //New Sample: Insert (KeyDown) 8:1380:4:66:1 //Trim sample around loop points: Alt+B (KeyDown) 8:1380:4:76:1 //Trim sample around loop points: Alt+L (KeyDown) -8:1383:0:190:1 //Silence sample selection: . (KeyDown) +8:1383:0:190:1 //Silence Sample Selection: . (KeyDown) 8:1384:4:78:1 //Normalise Sample: Alt+N (KeyDown) 8:1385:4:77:1 //Amplify Sample: Alt+M (KeyDown) -8:1381:4:71:1 //Reverse sample: Alt+G (KeyDown) -8:1382:0:46:1 //Delete sample selection: Delete (KeyDown) +8:1381:4:71:1 //Reverse Sample: Alt+G (KeyDown) +8:1382:0:46:1 //Delete Sample Selection: Delete (KeyDown) 8:1386:0:107:1 //Zoom Out: Num + (KeyDown) 8:1387:0:109:1 //Zoom In: Num - (KeyDown) 8:1784:2:73:1 //Invert sample phase: Ctrl+I (KeyDown) @@ -253,13 +261,13 @@ 9:1821:0:37:5 //Move envelope point left: Left (KeyDown|KeyHold) 9:1822:0:39:5 //Move envelope point right: Right (KeyDown|KeyHold) 9:1823:0:38:5 //Move envelope point up: Up (KeyDown|KeyHold) -9:1834:0:33:5 //Move envelope point up (big step): Page Up (KeyDown|KeyHold) +9:1834:0:33:5 //Move envelope point up (Coarse): Page Up (KeyDown|KeyHold) 9:1824:0:40:5 //Move envelope point down: Down (KeyDown|KeyHold) -9:1835:0:34:5 //Move envelope point down (big step): Page Down (KeyDown|KeyHold) -9:1827:0:45:5 //Insert envelope point: Insert (KeyDown|KeyHold) -9:1828:0:46:5 //Remove envelope point: Delete (KeyDown|KeyHold) -9:1829:0:36:1 //Set loop start: Home (KeyDown) -9:1830:0:35:1 //Set loop end: End (KeyDown) +9:1835:0:34:5 //Move envelope point down (Coarse): Page Down (KeyDown|KeyHold) +9:1827:0:45:5 //Insert Envelope Point: Insert (KeyDown|KeyHold) +9:1828:0:46:5 //Remove Envelope Point: Delete (KeyDown|KeyHold) +9:1829:0:36:1 //Set Loop Start: Home (KeyDown) +9:1830:0:35:1 //Set Loop End: End (KeyDown) 9:1831:2:36:1 //Set sustain loop start: Ctrl+Home (KeyDown) 9:1832:2:35:1 //Set sustain loop end: Ctrl+End (KeyDown) 9:1833:2:82:1 //Toggle release node: Ctrl+R (KeyDown) @@ -287,16 +295,16 @@ //----( Sample Context [top] (16) )------------ //----( Instrument Context [top] (17) )------------ -17:1851:2:68:1 //Duplicate instrument: Ctrl+D (KeyDown) -17:1850:3:69:1 //Edit sample map: Shift+Ctrl+E (KeyDown) -17:1849:2:69:1 //Edit current sample: Ctrl+E (KeyDown) +17:1851:2:68:1 //Duplicate Instrument: Ctrl+D (KeyDown) +17:1850:3:69:1 //Edit Sample Map: Shift+Ctrl+E (KeyDown) +17:1849:2:69:1 //Edit Current Sample: Ctrl+E (KeyDown) 17:1846:3:77:1 //Map all notes to selected note: Shift+Ctrl+M (KeyDown) 17:1847:2:77:1 //Map all notes to selected sample: Ctrl+M (KeyDown) -17:1848:2:82:1 //Reset note mapping: Ctrl+R (KeyDown) -17:1843:4:81:1 //Transpose +1 (note map): Alt+Q (KeyDown) -17:1842:4:65:1 //Transpose -1 (note map): Alt+A (KeyDown) -17:1845:6:81:1 //Transpose +12 (note map): Ctrl+Alt+Q (KeyDown) -17:1844:6:65:1 //Transpose -12 (note map): Ctrl+Alt+A (KeyDown) +17:1848:2:82:1 //Reset Note Mapping: Ctrl+R (KeyDown) +17:1843:4:81:1 //Transpose +1 (Note Map): Alt+Q (KeyDown) +17:1842:4:65:1 //Transpose -1 (Note Map): Alt+A (KeyDown) +17:1845:6:81:1 //Transpose +12 (Note Map): Ctrl+Alt+Q (KeyDown) +17:1844:6:65:1 //Transpose -12 (Note Map): Ctrl+Alt+A (KeyDown) //----( Comments Context [top] (18) )------------ @@ -339,3 +347,10 @@ 19:1854:0:32:1 //Invalid (---) Index: Space (KeyDown) 19:1875:2:76:1 //Lock Playback to Selection: Ctrl+L (KeyDown) 19:1876:2:85:1 //Unlock Playback: Ctrl+U (KeyDown) + +//----( Quick Channel Settings Context (20) )------------ +20:1878:1:37:5 //Previous Channel: Shift+Left (KeyDown|KeyHold) +20:1878:1:8:5 //Previous Channel: Shift+Backspace (KeyDown|KeyHold) +20:1879:1:39:5 //Next Channel: Shift+Right (KeyDown|KeyHold) +20:1879:1:13:5 //Next Channel: Shift+ENTER (KeyDown|KeyHold) +20:1880:0:13:1 //Switch to Pattern Editor: ENTER (KeyDown) Modified: trunk/OpenMPT/packageTemplate/readme.txt =================================================================== --- trunk/OpenMPT/packageTemplate/readme.txt 2013-04-06 13:18:05 UTC (rev 1748) +++ trunk/OpenMPT/packageTemplate/readme.txt 2013-04-06 13:31:47 UTC (rev 1749) @@ -1,5 +1,5 @@ ****************** -* OpenMPT 1.21 * +* OpenMPT 1.22 * ****************** @@ -75,7 +75,7 @@ OpenMPT is partially under the following license: -> Copyright (c) 2004-2012, OpenMPT contributors +> Copyright (c) 2004-2013, OpenMPT contributors > Copyright (c) 1997-2003, Olivier Lapicque > All rights reserved. > @@ -107,11 +107,12 @@ For more information about SoundTouch, see folder SoundTouch. -PortMidi --------- -OpenMPT's MIDI plugins make use of the PortMidi library, which is released under -the MIT license. -Visit http://portmedia.sourceforge.net/ for more information. +PortAudio / PortMidi +-------------------- +OpenMPT uses PortAudio for WASAPI output. OpenMPT's MIDI plugins make use of the +PortMidi library, which are both released under the MIT license. +Visit http://www.portaudio.com/ and http://portmedia.sourceforge.net/ for more +information. unmo3.dll --------- @@ -163,3 +164,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Visit http://flac.sourceforge.net/ for more information. + +libmpg123 +--------- +OpenMPT makes use of libmpg123, which is released under the LGPL license. +A copy of the LGPL license can be found in SoundTouch\COPYING.TXT +Visit http://mpg123.de/ for more information. \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-04-06 14:55:15
|
Revision: 1750 http://sourceforge.net/p/modplug/code/1750 Author: saga-games Date: 2013-04-06 14:55:00 +0000 (Sat, 06 Apr 2013) Log Message: ----------- [Ref] Split up MPTNOTIFICATION::dwType into type and and item variables [Ref] Renamed MPTNOTIFICATION to Notification, MPTNOTIFY_* are now members of Notification Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_gen.cpp trunk/OpenMPT/mptrack/Draw_pat.cpp trunk/OpenMPT/mptrack/Globals.cpp trunk/OpenMPT/mptrack/Globals.h trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainbar.cpp trunk/OpenMPT/mptrack/Mainbar.h trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/PatternEditorDialogs.h trunk/OpenMPT/mptrack/View_ins.cpp trunk/OpenMPT/mptrack/View_ins.h trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_pat.h trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/View_smp.h trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/View_tre.h trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/soundlib/Dlsbank.cpp trunk/OpenMPT/soundlib/Dlsbank.h Modified: trunk/OpenMPT/mptrack/Ctrl_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2013-04-06 13:31:47 UTC (rev 1749) +++ trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2013-04-06 14:55:00 UTC (rev 1750) @@ -145,8 +145,8 @@ //--------------------------------------- { CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); - if (m_pModDoc) m_pModDoc->SetFollowWnd(m_hWnd, MPTNOTIFY_DEFAULT); - if (pMainFrm) pMainFrm->SetFollowSong(m_pModDoc, m_hWnd, TRUE, MPTNOTIFY_DEFAULT); + if (m_pModDoc) m_pModDoc->SetFollowWnd(m_hWnd, Notification::Default); + if (pMainFrm) pMainFrm->SetFollowSong(m_pModDoc, m_hWnd, TRUE, Notification::Default); PostViewMessage(VIEWMSG_SETACTIVE, NULL); SetFocus(); @@ -158,7 +158,7 @@ void CCtrlGeneral::OnDeactivatePage() //----------------------------------- { - if (m_pModDoc) m_pModDoc->SetFollowWnd(NULL, 0); + if (m_pModDoc) m_pModDoc->SetFollowWnd(NULL, Notification::None); m_VuMeterLeft.SetVuMeter(0); m_VuMeterRight.SetVuMeter(0); } @@ -524,11 +524,11 @@ LRESULT CCtrlGeneral::OnUpdatePosition(WPARAM, LPARAM lParam) //----------------------------------------------------------- { - MPTNOTIFICATION *pnotify = (MPTNOTIFICATION *)lParam; + Notification *pnotify = (Notification *)lParam; if (pnotify) { - m_VuMeterLeft.SetVuMeter(pnotify->MasterVuLeft); - m_VuMeterRight.SetVuMeter(pnotify->MasterVuRight); + m_VuMeterLeft.SetVuMeter(pnotify->masterVu[0]); + m_VuMeterRight.SetVuMeter(pnotify->masterVu[1]); } return 0; } Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Draw_pat.cpp 2013-04-06 13:31:47 UTC (rev 1749) +++ trunk/OpenMPT/mptrack/Draw_pat.cpp 2013-04-06 14:55:00 UTC (rev 1750) @@ -1701,8 +1701,8 @@ //end rewbs.xinfo -void CViewPattern::UpdateAllVUMeters(MPTNOTIFICATION *pnotify) -//------------------------------------------------------------ +void CViewPattern::UpdateAllVUMeters(Notification *pnotify) +//--------------------------------------------------------- { CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); const CModDoc *pModDoc = GetDocument(); @@ -1714,7 +1714,6 @@ int x, xofs; if ((!pModDoc) || (!pMainFrm)) return; - memset(ChnVUMeters, 0, sizeof(ChnVUMeters)); GetClientRect(&rcClient); xofs = GetXScrollPos(); pSndFile = pModDoc->GetSoundFile(); @@ -1724,8 +1723,8 @@ nChn = xofs; while ((nChn < pSndFile->m_nChannels) && (x < rcClient.right)) { - ChnVUMeters[nChn] = (WORD)pnotify->dwPos[nChn]; - if ((!bPlaying) || (pnotify->dwType & MPTNOTIFY_STOP)) ChnVUMeters[nChn] = 0; + ChnVUMeters[nChn] = (WORD)pnotify->pos[nChn]; + if ((!bPlaying) || pnotify->type[Notification::Stop]) ChnVUMeters[nChn] = 0; DrawChannelVUMeter(hdc, x + 1, rcClient.top + COLHDR_HEIGHT, nChn); nChn++; x += m_szCell.cx; Modified: trunk/OpenMPT/mptrack/Globals.cpp =================================================================== --- trunk/OpenMPT/mptrack/Globals.cpp 2013-04-06 13:31:47 UTC (rev 1749) +++ trunk/OpenMPT/mptrack/Globals.cpp 2013-04-06 14:55:00 UTC (rev 1750) @@ -642,7 +642,7 @@ if (pMainFrm->GetFollowSong(pModDoc) == m_hWnd) { pMainFrm->SetFollowSong(pModDoc, NULL, FALSE); - pModDoc->SetFollowWnd(NULL, 0); + pModDoc->SetFollowWnd(NULL, Notification::None); } if (pMainFrm->GetMidiRecordWnd() == m_hWnd) { @@ -656,7 +656,7 @@ LRESULT CModScrollView::OnUpdatePosition(WPARAM, LPARAM lParam) //------------------------------------------------------------- { - MPTNOTIFICATION *pnotify = (MPTNOTIFICATION *)lParam; + Notification *pnotify = (Notification *)lParam; if (pnotify) return OnPlayerNotify(pnotify); return 0; } Modified: trunk/OpenMPT/mptrack/Globals.h =================================================================== --- trunk/OpenMPT/mptrack/Globals.h 2013-04-06 13:31:47 UTC (rev 1749) +++ trunk/OpenMPT/mptrack/Globals.h 2013-04-06 14:55:00 UTC (rev 1750) @@ -214,7 +214,7 @@ virtual void UpdateView(DWORD, CObject *) {} virtual LRESULT OnModViewMsg(WPARAM wParam, LPARAM lParam); virtual BOOL OnDragonDrop(BOOL, LPDRAGONDROP) { return FALSE; } - virtual LRESULT OnPlayerNotify(MPTNOTIFICATION *) { return 0; } + virtual LRESULT OnPlayerNotify(Notification *) { return 0; } //}}AFX_VIRTUAL protected: Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-04-06 13:31:47 UTC (rev 1749) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-04-06 14:55:00 UTC (rev 1750) @@ -196,7 +196,7 @@ m_hWndMidi = NULL; m_pSndFile = nullptr; m_dwTimeSec = 0; - m_dwNotifyType = 0; + m_notifyItem = 0; m_nTimer = 0; m_nAvgMixChn = m_nMixChn = 0; m_szUserText[0] = 0; @@ -662,11 +662,14 @@ // Notify thread DWORD WINAPI CMainFrame::NotifyThreadWrapper(LPVOID) +//-------------------------------------------------- { return ((CMainFrame*)theApp.m_pMainWnd)->NotifyThread(); } + + DWORD CMainFrame::NotifyThread() -//------------------------------------------- +//------------------------------ { // initialize thread message queue MSG msg; @@ -690,7 +693,7 @@ break; case WAIT_OBJECT_0: { - const MPTNOTIFICATION * pnotify = nullptr; + const Notification * pnotify = nullptr; { int64 currenttotalsamples = 0; Util::lock_guard<Util::mutex> lock(m_NotificationBufferMutex); @@ -702,11 +705,11 @@ currenttotalsamples = m_TotalSamplesRendered; } // advance to the newest notification, drop the obsolete ones - const MPTNOTIFICATION * p = m_NotifyBuffer.peek_p(); - if(p && currenttotalsamples >= p->TimestampSamples) + const Notification * p = m_NotifyBuffer.peek_p(); + if(p && currenttotalsamples >= p->timestampSamples) { pnotify = p; - while(m_NotifyBuffer.peek_next_p() && currenttotalsamples >= m_NotifyBuffer.peek_next_p()->TimestampSamples) + while(m_NotifyBuffer.peek_next_p() && currenttotalsamples >= m_NotifyBuffer.peek_next_p()->timestampSamples) { m_NotifyBuffer.pop(); p = m_NotifyBuffer.peek_p(); @@ -774,18 +777,16 @@ ULONG CMainFrame::AudioRead(PVOID pvData, ULONG MaxSamples) //--------------------------------------------------------- { - DWORD dwSamplesRead = m_pSndFile->Read(pvData, MaxSamples); - //m_dTotalCPU = m_pPerfCounter->StartStop()/(static_cast<double>(dwSamplesRead)/m_dwRate); - return dwSamplesRead; + return m_pSndFile->Read(pvData, MaxSamples); } -void CMainFrame::AudioDone(ULONG SamplesWritten, ULONG SamplesLatency, bool end_of_stream) -//---------------------------------------------------------------------------------------- +void CMainFrame::AudioDone(ULONG SamplesWritten, ULONG SamplesLatency, bool endOfStream) +//-------------------------------------------------------------------------------------- { - if (SamplesWritten > 0) + if(SamplesWritten > 0) { - DoNotification(SamplesWritten, SamplesLatency, end_of_stream); + DoNotification(SamplesWritten, SamplesLatency, endOfStream); } } @@ -935,8 +936,8 @@ } -BOOL CMainFrame::DoNotification(DWORD dwSamplesRead, DWORD SamplesLatency, bool end_of_stream) -//------------------------------------------------------------------- +BOOL CMainFrame::DoNotification(DWORD dwSamplesRead, DWORD SamplesLatency, bool endOfStream) +//------------------------------------------------------------------------------------------ { int64 notificationtimestamp = 0; { @@ -950,10 +951,10 @@ notificationtimestamp = m_TotalSamplesRendered + SamplesLatency; } } - if (!m_pSndFile) return FALSE; - if (m_nMixChn < m_pSndFile->m_nMixStat) m_nMixChn++; - if (m_nMixChn > m_pSndFile->m_nMixStat) m_nMixChn--; - if (!(m_dwNotifyType & MPTNOTIFY_TYPEMASK)) return FALSE; + if(!m_pSndFile) return FALSE; + if(m_nMixChn < m_pSndFile->m_nMixStat) m_nMixChn++; + if(m_nMixChn > m_pSndFile->m_nMixStat) m_nMixChn--; + if(m_notifyType == Notification::None) return FALSE; // Notify Client //if(m_NotifyBuffer.read_size() > 0) { @@ -961,86 +962,95 @@ } // Add an entry to the notification history - MPTNOTIFICATION notification; - MemsetZero(notification); - MPTNOTIFICATION *p = ¬ification; + Notification notification; + Notification *p = ¬ification; - p->dwType = m_dwNotifyType | (end_of_stream ? MPTNOTIFY_EOS : 0); - p->TimestampSamples = notificationtimestamp; - p->nOrder = m_pSndFile->m_nCurrentOrder; - p->nRow = m_pSndFile->m_nRow; - p->nPattern = m_pSndFile->m_nPattern; - p->nTick = m_pSndFile->m_nTickCount; - if (m_dwNotifyType & MPTNOTIFY_SAMPLE) + p->type = m_notifyType; + p->item = m_notifyItem; + if(endOfStream) p->type.set(Notification::EOS); + p->timestampSamples = notificationtimestamp; + + p->row = m_pSndFile->m_nRow; + p->tick = m_pSndFile->m_nTickCount; + p->order = m_pSndFile->m_nCurrentOrder; + p->pattern = m_pSndFile->m_nPattern; + + if(m_notifyType[Notification::Sample]) + { + // Sample positions + SAMPLEINDEX smp = m_notifyItem; + for(CHANNELINDEX k = 0; k < MAX_CHANNELS; k++) + { + const ModChannel &chn = m_pSndFile->Chn[k]; + if(smp && smp <= m_pSndFile->GetNumSamples() && chn.nLength && chn.pSample // There is a sample and it's playing + && chn.pSample == m_pSndFile->GetSample(smp).pSample // And it's the correct sample + && (!chn.dwFlags[CHN_NOTEFADE] || chn.nFadeOutVol)) // And it hasn't completely faded out yet, so it's still playing { - SAMPLEINDEX nSmp = m_dwNotifyType & 0xFFFF; - for (CHANNELINDEX k = 0; k < MAX_CHANNELS; k++) - { - ModChannel *pChn = &m_pSndFile->Chn[k]; - p->dwPos[k] = 0; - if ((nSmp) && (nSmp <= m_pSndFile->GetNumSamples()) && (pChn->nLength) - && (pChn->pSample) && (pChn->pSample == m_pSndFile->GetSample(nSmp).pSample) - && ((!(pChn->dwFlags & CHN_NOTEFADE)) || (pChn->nFadeOutVol))) - { - p->dwPos[k] = MPTNOTIFY_POSVALID | (DWORD)(pChn->nPos); - } - } - } else if (m_dwNotifyType & (MPTNOTIFY_VOLENV|MPTNOTIFY_PANENV|MPTNOTIFY_PITCHENV)) + p->pos[k] = chn.nPos; + } else { - UINT nIns = m_dwNotifyType & 0xFFFF; - for (CHANNELINDEX k = 0; k < MAX_CHANNELS; k++) + p->pos[k] = Notification::PosInvalid; + } + } + } else if(m_notifyType[Notification::VolEnv | Notification::PanEnv | Notification::PitchEnv]) + { + // Instrument envelopes + INSTRUMENTINDEX ins = m_notifyItem; + for(CHANNELINDEX k = 0; k < MAX_CHANNELS; k++) + { + const ModChannel &chn = m_pSndFile->Chn[k]; + if(ins != 0 && ins <= m_pSndFile->GetNumInstruments() // There is an instrument + && chn.pModInstrument && chn.pModInstrument == m_pSndFile->Instruments[ins] // And it's the correct instrument + && (chn.nLength || chn.pModInstrument->HasValidMIDIChannel()) // And it's playing something (sample or instrument) + && (!chn.dwFlags[CHN_NOTEFADE] || chn.nFadeOutVol)) // And it hasn't completely faded out yet, so it's still playing + { + enmEnvelopeTypes notifyEnv = ENV_VOLUME; + if(m_notifyType[Notification::PitchEnv]) + notifyEnv = ENV_PITCH; + else if(m_notifyType[Notification::PanEnv]) + notifyEnv = ENV_PANNING; + + const ModChannel::EnvInfo &chnEnv = chn.GetEnvelope(notifyEnv); + if(chnEnv.flags[ENV_ENABLED]) { - ModChannel *pChn = &m_pSndFile->Chn[k]; - p->dwPos[k] = 0; - if(nIns != 0 && nIns <= m_pSndFile->GetNumInstruments() // There is an instrument - && pChn->pModInstrument && pChn->pModInstrument == m_pSndFile->Instruments[nIns] // And it's the correct instrument - && (pChn->nLength || pChn->pModInstrument->HasValidMIDIChannel()) // And it's playing something (sample or instrument) - && (!pChn->dwFlags[CHN_NOTEFADE] || pChn->nFadeOutVol)) // And it hasn't completely faded out yet, so it's still playing + uint32 pos = chnEnv.nEnvPosition; + if(m_pSndFile->IsCompatibleMode(TRK_IMPULSETRACKER)) { - enmEnvelopeTypes notifyEnv = ENV_VOLUME; - if (m_dwNotifyType & MPTNOTIFY_PITCHENV) - notifyEnv = ENV_PITCH; - else if (m_dwNotifyType & MPTNOTIFY_PANENV) - notifyEnv = ENV_PANNING; - - const ModChannel::EnvInfo &chnEnv = pChn->GetEnvelope(notifyEnv); - - if(chnEnv.flags[ENV_ENABLED]) - { - uint32 pos = chnEnv.nEnvPosition; - if(m_pSndFile->IsCompatibleMode(TRK_IMPULSETRACKER)) - { - // Impulse Tracker envelope handling (see e.g. CSoundFile::IncrementEnvelopePosition in SndMix.cpp for details) - if(pos > 0) - pos--; - else - continue; - } - p->dwPos[k] = MPTNOTIFY_POSVALID | pos; - } + // Impulse Tracker envelope handling (see e.g. CSoundFile::IncrementEnvelopePosition in SndMix.cpp for details) + if(pos > 0) + pos--; + else + continue; } + p->pos[k] = pos; } - } else if (m_dwNotifyType & (MPTNOTIFY_VUMETERS)) + } else { - for (UINT k=0; k<MAX_CHANNELS; k++) - { - ModChannel *pChn = &m_pSndFile->Chn[k]; - UINT vul = pChn->nLeftVU; - UINT vur = pChn->nRightVU; - p->dwPos[k] = (vul << 8) | (vur); - } + p->pos[k] = Notification::PosInvalid; } - { - DWORD lVu = (gnLVuMeter >> 11); - DWORD rVu = (gnRVuMeter >> 11); - if (lVu > 0x10000) lVu = 0x10000; - if (rVu > 0x10000) rVu = 0x10000; - p->MasterVuLeft = lVu; - p->MasterVuRight = rVu; - DWORD dwVuDecay = Util::muldiv(dwSamplesRead, 120000, TrackerSettings::Instance().m_dwRate) + 1; - if (lVu >= dwVuDecay) gnLVuMeter = (lVu - dwVuDecay) << 11; else gnLVuMeter = 0; - if (rVu >= dwVuDecay) gnRVuMeter = (rVu - dwVuDecay) << 11; else gnRVuMeter = 0; - } + } + } else if(m_notifyType[Notification::VUMeters]) + { + // Pattern channel VU meters + for(CHANNELINDEX k = 0; k < m_pSndFile->GetNumChannels(); k++) + { + uint32 vul = m_pSndFile->Chn[k].nLeftVU; + uint32 vur = m_pSndFile->Chn[k].nRightVU; + p->pos[k] = (vul << 8) | (vur); + } + } + { + // Master VU meter + uint32 lVu = (gnLVuMeter >> 11); + uint32 rVu = (gnRVuMeter >> 11); + if(lVu > 0x10000) lVu = 0x10000; + if(rVu > 0x10000) rVu = 0x10000; + p->masterVu[0] = lVu; + p->masterVu[1] = rVu; + uint32 dwVuDecay = Util::muldiv(dwSamplesRead, 120000, TrackerSettings::Instance().m_dwRate) + 1; + if (lVu >= dwVuDecay) gnLVuMeter = (lVu - dwVuDecay) << 11; else gnLVuMeter = 0; + if (rVu >= dwVuDecay) gnRVuMeter = (rVu - dwVuDecay) << 11; else gnRVuMeter = 0; + } { Util::lock_guard<Util::mutex> lock(m_NotificationBufferMutex); @@ -1306,9 +1316,8 @@ void CMainFrame::GenerateStopNotification() //----------------------------------------- { - MPTNOTIFICATION mn; - MemsetZero(mn); - mn.dwType = MPTNOTIFY_STOP; + Notification mn; + mn.type = Notification::Stop; SendMessage(WM_MOD_UPDATEPOSITION, 0, (LPARAM)&mn); } @@ -1323,7 +1332,7 @@ m_nAvgMixChn = 0; if(m_pSndFile->GetpModDoc()) { - m_wndTree.UpdatePlayPos(m_pSndFile->GetpModDoc(), NULL); + m_wndTree.UpdatePlayPos(m_pSndFile->GetpModDoc(), nullptr); } m_pSndFile->m_SongFlags.reset(SONG_PAUSED); if(m_pSndFile == &m_WaveFile) @@ -1352,17 +1361,18 @@ } -void CMainFrame::SetPlaybackSoundFile(CSoundFile *pSndFile, HWND hPat, DWORD dwNotifyType) -//---------------------------------------------------------------------------------------- +void CMainFrame::SetPlaybackSoundFile(CSoundFile *pSndFile, HWND hPat, Notification::Type notifyType, Notification::Item notifyItem) +//---------------------------------------------------------------------------------------------------------------------------------- { m_pSndFile = pSndFile; m_hFollowSong = hPat; - m_dwNotifyType = dwNotifyType; + m_notifyType = notifyType; + m_notifyItem = notifyItem; } -bool CMainFrame::PlayMod(CModDoc *pModDoc, HWND hPat, DWORD dwNotifyType) -//----------------------------------------------------------------------- +bool CMainFrame::PlayMod(CModDoc *pModDoc, HWND hPat, Notification::Type notifyType, Notification::Item notifyItem) +//----------------------------------------------------------------------------------------------------------------- { CriticalSection::AssertUnlocked(); if(!pModDoc) return false; @@ -1381,7 +1391,7 @@ // set mixing parameters in CSoundFile ApplyTrackerSettings(pSndFile); - SetPlaybackSoundFile(pSndFile, hPat, dwNotifyType); + SetPlaybackSoundFile(pSndFile, hPat, notifyType, notifyItem); const bool bPaused = m_pSndFile->IsPaused(); const bool bPatLoop = m_pSndFile->m_SongFlags[SONG_PATTERNLOOP]; @@ -1513,7 +1523,7 @@ { CriticalSection cs; InitPreview(); - if(CTrackApp::gpDLSBanks[nDLSBank]->ExtractInstrument(&m_WaveFile, 1, nIns, nRgn)) + if(CTrackApp::gpDLSBanks[nDLSBank]->ExtractInstrument(m_WaveFile, 1, nIns, nRgn)) { PreparePreview(note); ok = true; @@ -1682,24 +1692,28 @@ } -BOOL CMainFrame::SetFollowSong(CModDoc *pDoc, HWND hwnd, BOOL bFollowSong, DWORD dwType) -//-------------------------------------------------------------------------------------- +BOOL CMainFrame::SetFollowSong(CModDoc *pDoc, HWND hwnd, BOOL bFollowSong, Notification::Type type, Notification::Item item) +//-------------------------------------------------------------------------------------------------------------------------- { - if ((!pDoc) || (pDoc != GetModPlaying())) return FALSE; - if (bFollowSong) + if((!pDoc) || (pDoc != GetModPlaying())) return FALSE; + if(bFollowSong) { m_hFollowSong = hwnd; } else { - if (hwnd == m_hFollowSong) m_hFollowSong = NULL; + if(hwnd == m_hFollowSong) m_hFollowSong = NULL; } - if (dwType) m_dwNotifyType = dwType; + if(type != Notification::None) + { + m_notifyType = type; + m_notifyItem = item; + } return TRUE; } BOOL CMainFrame::SetupSoundCard(DWORD q, DWORD rate, UINT nBits, UINT nChns, UINT latency_ms, UINT updateinterval_ms, LONG wd) -//------------------------------------------------------------------------------------------------- +//---------------------------------------------------------------------------------------------------------------------------- { const bool isPlaying = (IsPlaying() != 0); if ((TrackerSettings::Instance().m_dwRate != rate) || ((TrackerSettings::Instance().m_dwSoundSetup & SOUNDSETUP_RESTARTMASK) != (q & SOUNDSETUP_RESTARTMASK)) @@ -1724,7 +1738,7 @@ CriticalSection cs; UpdateAudioParameters(FALSE); } - if (pActiveMod) PlayMod(pActiveMod, hFollow, m_dwNotifyType); + if (pActiveMod) PlayMod(pActiveMod, hFollow, m_notifyType); UpdateWindow(); } else { @@ -2268,7 +2282,7 @@ LRESULT CMainFrame::OnUpdatePositionThreaded(WPARAM, LPARAM) //----------------------------------------------------------------- { - MPTNOTIFICATION * pnotify = &m_PendingNotification; + Notification * pnotify = &m_PendingNotification; LRESULT retval = OnUpdatePosition(0, (LPARAM)pnotify); // for all notifications which were delivered via the notification thread, release the semaphore ReleaseSemaphore(m_PendingNotificationSempahore, 1, NULL); @@ -2278,10 +2292,10 @@ LRESULT CMainFrame::OnUpdatePosition(WPARAM, LPARAM lParam) //--------------------------------------------------------- { - MPTNOTIFICATION *pnotify = (MPTNOTIFICATION *)lParam; + Notification *pnotify = (Notification *)lParam; if (pnotify) { - if(pnotify->dwType & MPTNOTIFY_EOS) + if(pnotify->type[Notification::EOS]) { PostMessage(WM_COMMAND, ID_PLAYER_STOP); } Modified: trunk/OpenMPT/mptrack/Mainbar.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mainbar.cpp 2013-04-06 13:31:47 UTC (rev 1749) +++ trunk/OpenMPT/mptrack/Mainbar.cpp 2013-04-06 14:55:00 UTC (rev 1750) @@ -937,8 +937,8 @@ } -VOID CModTreeBar::UpdatePlayPos(CModDoc *pModDoc, MPTNOTIFICATION *pNotify) -//------------------------------------------------------------------------- +VOID CModTreeBar::UpdatePlayPos(CModDoc *pModDoc, Notification *pNotify) +//---------------------------------------------------------------------- { if (m_pModTree) m_pModTree->UpdatePlayPos(pModDoc, pNotify); } Modified: trunk/OpenMPT/mptrack/Mainbar.h =================================================================== --- trunk/OpenMPT/mptrack/Mainbar.h 2013-04-06 13:31:47 UTC (rev 1749) +++ trunk/OpenMPT/mptrack/Mainbar.h 2013-04-06 14:55:00 UTC (rev 1750) @@ -116,7 +116,7 @@ VOID OnDocumentCreated(CModDoc *pModDoc); VOID OnDocumentClosed(CModDoc *pModDoc); VOID OnUpdate(CModDoc *pModDoc, DWORD lHint=0, CObject *pHint=NULL); - VOID UpdatePlayPos(CModDoc *pModDoc, MPTNOTIFICATION *pNotify); + VOID UpdatePlayPos(CModDoc *pModDoc, Notification *pNotify); HWND GetModTreeHWND(); //rewbs.customKeys BOOL PostMessageToModTree(UINT cmdID, WPARAM wParam, LPARAM lParam); //rewbs.customKeys Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-04-06 13:31:47 UTC (rev 1749) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-04-06 14:55:00 UTC (rev 1750) @@ -258,41 +258,9 @@ // Player position notification #define MAX_UPDATE_HISTORY 256 // same as SNDDEV_MAXBUFFERS +#include "Notification.h" -#define MPTNOTIFY_TYPEMASK 0x01FF0000 // HiWord = type, LoWord = subtype (smp/instr #) -#define MPTNOTIFY_DEFAULT 0x00010000 // -#define MPTNOTIFY_POSITION 0x00010000 // -#define MPTNOTIFY_SAMPLE 0x00020000 // dwPos[i] contains sample position -#define MPTNOTIFY_VOLENV 0x00040000 // dwPos[i] contains volume envelope position -#define MPTNOTIFY_PANENV 0x00080000 // dwPos[i] contains panning envelope position -#define MPTNOTIFY_PITCHENV 0x00100000 // dwPos[i] contains pitch envelope position -#define MPTNOTIFY_VUMETERS 0x00200000 // dwPos[i] contains VU meter for every channel -#define MPTNOTIFY_EOS 0x00800000 // end of stream reached, the gui should stop the audio device -#define MPTNOTIFY_STOP 0x01000000 // audio device has been stopped -> reset GUI -#define MPTNOTIFY_POSVALID 0x80000000 // dwPos[i] is valid (if it contains sample or envelope position) -// struct MPTNOTIFICATION requires working copy constructor / copy assignment, keep in mind when extending -struct MPTNOTIFICATION -{ - /* - TimestampSamples is kind of confusing at the moment: - If gpSoundDevice->HasGetStreamPosition(), - then it contains the sample timestamp as when it was generated and the output stream is later queried when this exact timestamp has actually reached the speakers. - If !gpSoundDevice->HasGetStreamPosition(), - then it contains a sample timestamp in the future, incremented by the current latency estimation of the sound buffers. It is later checked against the total number of rendered samples at that time. - */ - int64 TimestampSamples; - DWORD dwType; - ROWINDEX nRow; // Always valid - UINT nTick; // dito - ORDERINDEX nOrder; // dito - PATTERNINDEX nPattern; // dito - DWORD MasterVuLeft; // dito - DWORD MasterVuRight; // dito - DWORD dwPos[MAX_CHANNELS]; // sample/envelope pos for each channel if >= 0 -}; - - ///////////////////////////////////////////////////////////////////////// // Misc. Macros @@ -339,7 +307,6 @@ public: static HMIDIIN shMidiIn; - protected: CModTreeBar m_wndTree; @@ -348,7 +315,9 @@ CImageList m_ImageList; CSoundFile *m_pSndFile; // != NULL only when currently playing or rendering HWND m_hFollowSong, m_hWndMidi; - DWORD m_dwNotifyType; + // Kind of notification that should be generated + FlagSet<Notification::Type, uint16> m_notifyType; + Notification::Item m_notifyItem; CSoundFile::samplecount_t m_dwTimeSec; UINT_PTR m_nTimer; UINT m_nAvgMixChn, m_nMixChn; @@ -360,9 +329,9 @@ // Notification Buffer Util::mutex m_NotificationBufferMutex; // to avoid deadlocks, this mutex should only be taken as a innermost lock, i.e. do not block on anything while holding this mutex int64 m_TotalSamplesRendered; - Util::fixed_size_queue<MPTNOTIFICATION,MAX_UPDATE_HISTORY> m_NotifyBuffer; + Util::fixed_size_queue<Notification,MAX_UPDATE_HISTORY> m_NotifyBuffer; HANDLE m_PendingNotificationSempahore; // protects the one notification that is in flight from the notification thread to the gui thread from being freed while the gui thread still uses it - MPTNOTIFICATION m_PendingNotification; + Notification m_PendingNotification; // Instrument preview in tree view CSoundFile m_WaveFile; @@ -386,14 +355,14 @@ // from ISoundSource void FillAudioBufferLocked(IFillAudioBuffer &callback); ULONG AudioRead(PVOID pData, ULONG MaxSamples); - void AudioDone(ULONG SamplesWritten, ULONG SamplesLatency, bool end_of_stream); + void AudioDone(ULONG SamplesWritten, ULONG SamplesLatency, bool endOfStream); bool audioTryOpeningDevice(UINT channels, UINT bits, UINT samplespersec); bool audioOpenDevice(); bool audioReopenDevice(); void audioCloseDevice(); bool IsAudioDeviceOpen() const; - BOOL DoNotification(DWORD dwSamplesRead, DWORD SamplesLatency, bool end_of_stream); + BOOL DoNotification(DWORD dwSamplesRead, DWORD SamplesLatency, bool endOfStream); // Midi Input Functions public: @@ -475,11 +444,11 @@ bool PausePlayback(); bool IsPlaybackRunning() const { return m_IsPlaybackRunning; } static bool IsValidSoundFile(CSoundFile *pSndFile) { return pSndFile && pSndFile->GetType(); } - void SetPlaybackSoundFile(CSoundFile *pSndFile, HWND hPat=NULL, DWORD dwNotifyType=0); + void SetPlaybackSoundFile(CSoundFile *pSndFile, HWND hPat = NULL, Notification::Type notifyType = Notification::None, Notification::Item notifyItem = 0); void UnsetPlaybackSoundFile(); void GenerateStopNotification(); - bool PlayMod(CModDoc *, HWND hPat=NULL, DWORD dwNotifyType=0); + bool PlayMod(CModDoc *, HWND hPat=NULL, Notification::Type notifyType = Notification::None, Notification::Item notifyItem = 0); bool StopMod(CModDoc *pDoc=NULL); bool PauseMod(CModDoc *pDoc=NULL); @@ -507,7 +476,7 @@ BOOL SetupMidi(DWORD d, LONG n); void SetPreAmp(UINT n); HWND GetFollowSong(const CModDoc *pDoc) const { return (pDoc == GetModPlaying()) ? m_hFollowSong : NULL; } - BOOL SetFollowSong(CModDoc *, HWND hwnd, BOOL bFollowSong=TRUE, DWORD dwType=MPTNOTIFY_DEFAULT); + BOOL SetFollowSong(CModDoc *, HWND hwnd, BOOL bFollowSong=TRUE, Notification::Type type = Notification::Default, Notification::Item item = 0); void ResetNotificationBuffer(); Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-04-06 13:31:47 UTC (rev 1749) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-04-06 14:55:00 UTC (rev 1750) @@ -271,7 +271,7 @@ dwKey, &nDlsIns))) { if (dwKey < 0x80) nDrumRgn = pEmbeddedBank->GetRegionFromKey(nDlsIns, dwKey); - if (pEmbeddedBank->ExtractInstrument(&m_SndFile, nIns, nDlsIns, nDrumRgn)) + if (pEmbeddedBank->ExtractInstrument(m_SndFile, nIns, nDlsIns, nDrumRgn)) { pIns = m_SndFile.Instruments[nIns]; // Reset pIns because ExtractInstrument may delete the previous value. if ((dwKey >= 24) && (dwKey < 100)) @@ -314,7 +314,7 @@ dwKey, &nDlsIns))) { if (dwKey < 0x80) nDrumRgn = pDLSBank->GetRegionFromKey(nDlsIns, dwKey); - pDLSBank->ExtractInstrument(&m_SndFile, nIns, nDlsIns, nDrumRgn); + pDLSBank->ExtractInstrument(m_SndFile, nIns, nDlsIns, nDrumRgn); pIns = m_SndFile.Instruments[nIns]; // Reset pIns because ExtractInstrument may delete the previous value. if ((dwKey >= 24) && (dwKey < 24+61)) { @@ -937,7 +937,7 @@ if (pMainFrm->GetModPlaying() != this) { m_SndFile.m_SongFlags.set(SONG_PAUSED); - pMainFrm->PlayMod(this, m_hWndFollow, m_dwNotifyType); + pMainFrm->PlayMod(this, m_hWndFollow, m_notifyType, m_notifyItem); } CriticalSection cs; @@ -1420,13 +1420,14 @@ } -void CModDoc::SetFollowWnd(HWND hwnd, DWORD dwType) -//------------------------------------------------- +void CModDoc::SetFollowWnd(HWND hwnd, Notification::Type type, Notification::Item item) +//------------------------------------------------------------------------------------- { CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); m_hWndFollow = hwnd; - m_dwNotifyType = dwType; - if(pMainFrm) pMainFrm->SetFollowSong(this, m_hWndFollow, TRUE, m_dwNotifyType); + m_notifyType = type; + m_notifyItem = item; + if(pMainFrm) pMainFrm->SetFollowSong(this, m_hWndFollow, TRUE, m_notifyType, m_notifyItem); } @@ -1926,7 +1927,7 @@ cs.Leave(); m_SndFile.m_SongFlags.reset(SONG_STEP | SONG_PAUSED | SONG_PATTERNLOOP); - pMainFrm->PlayMod(this, m_hWndFollow, m_dwNotifyType); + pMainFrm->PlayMod(this, m_hWndFollow, m_notifyType, m_notifyItem); } } @@ -2011,7 +2012,7 @@ cs.Leave(); - pMainFrm->PlayMod(this, m_hWndFollow, m_dwNotifyType); + pMainFrm->PlayMod(this, m_hWndFollow, m_notifyType, m_notifyItem); } } @@ -2325,7 +2326,7 @@ if(pModPlaying != this) { - pMainFrm->PlayMod(this, followSonghWnd, m_dwNotifyType|MPTNOTIFY_POSITION|MPTNOTIFY_VUMETERS); //rewbs.fix2977 + pMainFrm->PlayMod(this, followSonghWnd, m_notifyType|Notification::Position|Notification::VUMeters, m_notifyItem); //rewbs.fix2977 } } //SwitchToView(); @@ -2381,7 +2382,7 @@ if(pModPlaying != this) { - pMainFrm->PlayMod(this, followSonghWnd, m_dwNotifyType|MPTNOTIFY_POSITION|MPTNOTIFY_VUMETERS); //rewbs.fix2977 + pMainFrm->PlayMod(this, followSonghWnd, m_notifyType | Notification::Position | Notification::VUMeters, m_notifyItem); //rewbs.fix2977 } } //SwitchToView(); @@ -2440,7 +2441,7 @@ if(pModPlaying != this) { - pMainFrm->PlayMod(this, followSonghWnd, m_dwNotifyType|MPTNOTIFY_POSITION|MPTNOTIFY_VUMETERS); //rewbs.fix2977 + pMainFrm->PlayMod(this, followSonghWnd, m_notifyType | Notification::Position | Notification::VUMeters, m_notifyItem); //rewbs.fix2977 } } //SwitchToView(); Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2013-04-06 13:31:47 UTC (rev 1749) +++ trunk/OpenMPT/mptrack/Moddoc.h 2013-04-06 14:55:00 UTC (rev 1750) @@ -13,6 +13,7 @@ #include "sndfile.h" #include "../common/misc_util.h" #include "Undo.h" +#include "Notification.h" #include <time.h> @@ -153,7 +154,8 @@ CSoundFile m_SndFile; HWND m_hWndFollow; - DWORD m_dwNotifyType; + FlagSet<Notification::Type, uint16> m_notifyType; + Notification::Item m_notifyItem; CSize m_szOldPatternScrollbarsPos; CPatternUndo m_PatternUndo; @@ -206,7 +208,7 @@ void ViewSample(UINT nSmp); void ViewInstrument(UINT nIns); HWND GetFollowWnd() const { return m_hWndFollow; } - void SetFollowWnd(HWND hwnd, DWORD dwType); + void SetFollowWnd(HWND hwnd, Notification::Type type, Notification::Item item = 0); void ActivateWindow(); Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.h =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.h 2013-04-06 13:31:47 UTC (rev 1749) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.h 2013-04-06 14:55:00 UTC (rev 1750) @@ -60,7 +60,7 @@ void ChangeVolCmd(); public: - CFindReplaceTab(UINT nIDD, bool bReplaceTab, CModDoc *pModDoc) : CPropertyPage(nIDD), effectInfo(*pModDoc->GetSoundFile()) { ASSERT(pModDoc != nullptr); m_bReplace = bReplaceTab; m_pModDoc = pModDoc; } + CFindReplaceTab(UINT nIDD, bool bReplaceTab, CModDoc *pModDoc) : CPropertyPage(nIDD), effectInfo(pModDoc->GetrSoundFile()) { ASSERT(pModDoc != nullptr); m_bReplace = bReplaceTab; m_pModDoc = pModDoc; } protected: virtual BOOL OnInitDialog(); @@ -127,7 +127,7 @@ bool m_bInitialized; public: - CPageEditCommand(CModDoc *pModDoc, CEditCommand *parent, UINT id) : CPropertyPage(id), m_pModDoc(pModDoc), effectInfo(*pModDoc->GetSoundFile()), m_pParent(parent), m_bInitialized(false) {}; + CPageEditCommand(CModDoc *pModDoc, CEditCommand *parent, UINT id) : CPropertyPage(id), m_pModDoc(pModDoc), effectInfo(pModDoc->GetrSoundFile()), m_pParent(parent), m_bInitialized(false) {}; virtual ~CPageEditCommand() {} virtual BOOL OnInitDialog(); Modified: trunk/OpenMPT/mptrack/View_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_ins.cpp 2013-04-06 13:31:47 UTC (rev 1749) +++ trunk/OpenMPT/mptrack/View_ins.cpp 2013-04-06 14:55:00 UTC (rev 1750) @@ -124,11 +124,13 @@ m_rcClient.bottom = 2; m_dwStatus = 0; m_nBtnMouseOver = 0xFFFF; - m_dwNotifyPos.assign(MAX_CHANNELS, 0); + for(CHANNELINDEX i = 0; i < MAX_CHANNELS; i++) + { + m_dwNotifyPos[i] = Notification::PosInvalid; + } MemsetZero(m_NcButtonState); m_bmpEnvBar.Create(IDB_ENVTOOLBAR, 20, 0, RGB(192,192,192)); - m_baPlayingNote.assign(128, false); - m_nPlayingChannel = CHANNELINDEX_INVALID; //rewbs.customKeys + m_baPlayingNote.reset(); //rewbs.envRowGrid m_bGrid=true; m_bGridForceRedraw=false; @@ -190,18 +192,18 @@ //------------------------------------------------------------------------------------- { CModDoc *pModDoc = GetDocument(); - DWORD dwNotify; + Notification::Type type; if ((!pModDoc) || (nIns < 1) || (nIns >= MAX_INSTRUMENTS)) return FALSE; if (nEnv) m_nEnv = nEnv; m_nInstrument = nIns; switch(m_nEnv) { - case ENV_PANNING: dwNotify = MPTNOTIFY_PANENV; break; - case ENV_PITCH: dwNotify = MPTNOTIFY_PITCHENV; break; - default: m_nEnv = ENV_VOLUME; dwNotify = MPTNOTIFY_VOLENV; break; + case ENV_PANNING: type = Notification::PanEnv; break; + case ENV_PITCH: type = Notification::PitchEnv; break; + default: m_nEnv = ENV_VOLUME; type = Notification::VolEnv; break; } - pModDoc->SetFollowWnd(m_hWnd, dwNotify|m_nInstrument); + pModDoc->SetFollowWnd(m_hWnd, type, m_nInstrument); UpdateScrollSize(); UpdateNcButtonState(); InvalidateRect(NULL, FALSE); @@ -356,7 +358,7 @@ //---------------------------------------------------------------- { InstrumentEnvelope *pEnv = GetEnvelopePtr(); - if(pEnv != nullptr && pEnv->dwFlags[dwFlag]) return true; + if(pEnv != nullptr) return pEnv->dwFlags[dwFlag]; return false; } @@ -479,12 +481,12 @@ if(nPoint < 0 || nPoint > (int)EnvGetLastPoint()) return false; // We won't do any security checks here as GetEnvelopePtr() does that for us. - CSoundFile *pSndFile = GetDocument()->GetSoundFile(); + CSoundFile &sndFile = GetDocument()->GetrSoundFile(); if (nPoint != envelope->nSustainStart) { envelope->nSustainStart = (BYTE)nPoint; - if ((envelope->nSustainEnd < nPoint) || (pSndFile->m_nType & MOD_TYPE_XM)) envelope->nSustainEnd = (BYTE)nPoint; + if ((envelope->nSustainEnd < nPoint) || (sndFile.GetType() & MOD_TYPE_XM)) envelope->nSustainEnd = (BYTE)nPoint; return true; } else { @@ -501,12 +503,12 @@ if(nPoint < 0 || nPoint > (int)EnvGetLastPoint()) return false; // We won't do any security checks here as GetEnvelopePtr() does that for us. - CSoundFile *pSndFile = GetDocument()->GetSoundFile(); + CSoundFile &sndFile = GetDocument()->GetrSoundFile(); if (nPoint != envelope->nSustainEnd) { envelope->nSustainEnd = (BYTE)nPoint; - if ((envelope->nSustainStart > nPoint) || (pSndFile->m_nType & MOD_TYPE_XM)) envelope->nSustainStart = (BYTE)nPoint; + if ((envelope->nSustainStart > nPoint) || (sndFile.GetType() & MOD_TYPE_XM)) envelope->nSustainStart = (BYTE)nPoint; return true; } else { @@ -523,7 +525,7 @@ if(nPoint < 1 || nPoint > (int)EnvGetLastPoint()) return false; // Don't allow release nodes in IT/XM. GetDocument()/... nullptr check is done in GetEnvelopePtr, so no need to check twice. - if(!GetDocument()->GetSoundFile()->GetModSpecifications().hasReleaseNode) + if(!GetDocument()->GetrSoundFile().GetModSpecifications().hasReleaseNode) { if(envelope->nReleaseNode != ENV_RELEASE_NODE_UNSET) { @@ -556,16 +558,11 @@ } -bool CViewInstrument::EnvToggleEnv(enmEnvelopeTypes envelope, CSoundFile *pSndFile, ModInstrument *pIns, bool enable, BYTE defaultValue, EnvelopeFlags extraFlags) -//---------------------------------------------------------------------------------------------------------------------------------------------------------------- +bool CViewInstrument::EnvToggleEnv(enmEnvelopeTypes envelope, CSoundFile &sndFile, ModInstrument &ins, bool enable, BYTE defaultValue, EnvelopeFlags extraFlags) +//-------------------------------------------------------------------------------------------------------------------------------------------------------------- { - if(pIns == nullptr || pSndFile == nullptr) - { - return false; - } + InstrumentEnvelope &env = ins.GetEnvelope(envelope); - InstrumentEnvelope &env = pIns->GetEnvelope(envelope); - const EnvelopeFlags flags = (ENV_ENABLED | extraFlags); env.dwFlags.set(flags, enable); @@ -583,9 +580,9 @@ // Update mixing flags... for(CHANNELINDEX nChn = 0; nChn < MAX_CHANNELS; nChn++) { - if(pSndFile->Chn[nChn].pModInstrument == pIns) + if(sndFile.Chn[nChn].pModInstrument == &ins) { - pSndFile->Chn[nChn].GetEnvelope(envelope).flags.set(flags, enable); + sndFile.Chn[nChn].GetEnvelope(envelope).flags.set(flags, enable); } } @@ -598,9 +595,7 @@ { ModInstrument *pIns = GetInstrumentPtr(); if(pIns == nullptr) return false; - CSoundFile *pSndFile = GetDocument()->GetSoundFile(); // security checks are done in GetInstrumentPtr() - - return EnvToggleEnv(ENV_VOLUME, pSndFile, pIns, bEnable, 64); + return EnvToggleEnv(ENV_VOLUME, GetDocument()->GetrSoundFile(), *pIns, bEnable, 64); } @@ -609,9 +604,7 @@ { ModInstrument *pIns = GetInstrumentPtr(); if(pIns == nullptr) return false; - CSoundFile *pSndFile = GetDocument()->GetSoundFile(); // security checks are done in GetInstrumentPtr() - - return EnvToggleEnv(ENV_PANNING, pSndFile, pIns, bEnable, 32); + return EnvToggleEnv(ENV_PANNING, GetDocument()->GetrSoundFile(), *pIns, bEnable, 32); } @@ -620,10 +613,9 @@ { ModInstrument *pIns = GetInstrumentPtr(); if(pIns == nullptr) return false; - CSoundFile *pSndFile = GetDocument()->GetSoundFile(); // security checks are done in GetInstrumentPtr() pIns->PitchEnv.dwFlags.reset(ENV_FILTER); - return EnvToggleEnv(ENV_PITCH, pSndFile, pIns, bEnable, 32); + return EnvToggleEnv(ENV_PITCH, GetDocument()->GetrSoundFile(), *pIns, bEnable, 32); } @@ -632,9 +624,8 @@ { ModInstrument *pIns = GetInstrumentPtr(); if(pIns == nullptr) return false; - CSoundFile *pSndFile = GetDocument()->GetSoundFile(); // security checks are done in GetInstrumentPtr() - return EnvToggleEnv(ENV_PITCH, pSndFile, pIns, bEnable, 64, ENV_FILTER); + return EnvToggleEnv(ENV_PITCH, GetDocument()->GetrSoundFile(), *pIns, bEnable, 64, ENV_FILTER); } @@ -735,11 +726,10 @@ //----------------------------------------- { CModDoc *pModDoc = GetDocument(); - CSoundFile *pSndFile; + if(!pModDoc) return; + CSoundFile &sndFile = pModDoc->GetrSoundFile(); + CDC *pDC = NULL; - - if (!pModDoc) return; - pSndFile = pModDoc->GetSoundFile(); for (UINT i=0; i<ENV_LEFTBAR_BUTTONS; i++) if (cLeftBarButtons[i] != ID_SEPARATOR) { DWORD dwStyle = 0; @@ -748,17 +738,17 @@ { case ID_ENVSEL_VOLUME: if (m_nEnv == ENV_VOLUME) dwStyle |= NCBTNS_CHECKED; break; case ID_ENVSEL_PANNING: if (m_nEnv == ENV_PANNING) dwStyle |= NCBTNS_CHECKED; break; - case ID_ENVSEL_PITCH: if (!(pSndFile->m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT))) dwStyle |= NCBTNS_DISABLED; + case ID_ENVSEL_PITCH: if (!(sndFile.GetType() & (MOD_TYPE_IT|MOD_TYPE_MPT))) dwStyle |= NCBTNS_DISABLED; else if (m_nEnv == ENV_PITCH) dwStyle |= NCBTNS_CHECKED; break; case ID_ENVELOPE_SETLOOP: if (EnvGetLoop()) dwStyle |= NCBTNS_CHECKED; break; case ID_ENVELOPE_SUSTAIN: if (EnvGetSustain()) dwStyle |= NCBTNS_CHECKED; break; - case ID_ENVELOPE_CARRY: if (!(pSndFile->m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT))) dwStyle |= NCBTNS_DISABLED; + case ID_ENVELOPE_CARRY: if (!(sndFile.GetType() & (MOD_TYPE_IT|MOD_TYPE_MPT))) dwStyle |= NCBTNS_DISABLED; else if (EnvGetCarry()) dwStyle |= NCBTNS_CHECKED; break; case ID_ENVELOPE_VOLUME: if (EnvGetVolEnv()) dwStyle |= NCBTNS_CHECKED; break; case ID_ENVELOPE_PANNING: if (EnvGetPanEnv()) dwStyle |= NCBTNS_CHECKED; break; - case ID_ENVELOPE_PITCH: if (!(pSndFile->m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT))) dwStyle |= NCBTNS_DISABLED; else + case ID_ENVELOPE_PITCH: if (!(sndFile.GetType() & (MOD_TYPE_IT|MOD_TYPE_MPT))) dwStyle |= NCBTNS_DISABLED; else if (EnvGetPitchEnv()) dwStyle |= NCBTNS_CHECKED; break; - case ID_ENVELOPE_FILTER: if (!(pSndFile->m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT))) dwStyle |= NCBTNS_DISABLED; else + case ID_ENVELOPE_FILTER: if (!(sndFile.GetType() & (MOD_TYPE_IT|MOD_TYPE_MPT))) dwStyle |= NCBTNS_DISABLED; else if (EnvGetFilterEnv()) dwStyle |= NCBTNS_CHECKED; break; case ID_ENVELOPE_VIEWGRID: if (m_bGrid) dwStyle |= NCBTNS_CHECKED; break; case ID_ENVELOPE_ZOOM_IN: if (m_fZoom >= ENV_MAX_ZOOM) dwStyle |= NCBTNS_DISABLED; break; @@ -826,15 +816,15 @@ m_pbmpOldGrid = m_dcGrid.SelectObject(&m_bmpGrid); //do draw - CSoundFile *pSndFile; int width = m_rcClient.right - m_rcClient.left; int nPrevTick = -1; int nTick, nRow; int nRowsPerBeat = 1, nRowsPerMeasure = 1; - if(GetDocument() != nullptr && (pSndFile = GetDocument()->GetSoundFile()) != nullptr) + CModDoc *modDoc = GetDocument(); + if(modDoc != nullptr) { - nRowsPerBeat = pSndFile->m_nDefaultRowsPerBeat; - nRowsPerMeasure = pSndFile->m_nDefaultRowsPerMeasure; + nRowsPerBeat = modDoc->GetrSoundFile().m_nDefaultRowsPerBeat; + nRowsPerMeasure = modDoc->GetrSoundFile().m_nDefaultRowsPerMeasure; } for (int x = 3; x < width; x++) @@ -869,7 +859,6 @@ RECT rect; int nScrollPos = GetScrollPos(SB_HORZ); CModDoc *pModDoc = GetDocument(); - CSoundFile *pSndFile; HGDIOBJ oldpen; //HDC hdc; UINT maxpoint; @@ -896,13 +885,12 @@ //end rewbs.envRowGrid if ((!pModDoc) || (!pDC)) return; - pSndFile = pModDoc->GetSoundFile(); //hdc = pDC->m_hDC; oldpen = m_dcMemMain.SelectObject(CMainFrame::penDarkGray); m_dcMemMain.FillRect(&m_rcClient, CBrush::FromHandle(CMainFrame::brushBlack)); if (m_bGrid) { - DrawGrid(&m_dcMemMain, pSndFile->m_nMusicSpeed); + DrawGrid(&m_dcMemMain, pModDoc->GetrSoundFile().m_nMusicSpeed); } // Middle line (half volume or pitch / panning center) @@ -1024,8 +1012,7 @@ CModDoc *pModDoc = GetDocument(); if ((pModDoc) && (nPoint <= EnvGetLastPoint())) { - CSoundFile *pSndFile = pModDoc->GetSoundFile(); - ModInstrument *pIns = pSndFile->Instruments[m_nInstrument]; + ModInstrument *pIns = pModDoc->GetrSoundFile().Instruments[m_nInstrument]; if (pIns) { InstrumentEnvelope *envelope = GetEnvelopePtr(); @@ -1069,8 +1056,8 @@ CModDoc *pModDoc = GetDocument(); if (pModDoc) { - CSoundFile *pSndFile = pModDoc->GetSoundFile(); - ModInstrument *pIns = pSndFile->Instruments[m_nInstrument]; + CSoundFile &sndFile = pModDoc->GetrSoundFile(); + ModInstrument *pIns = sndFile.Instruments[m_nInstrument]; if (pIns) { if(nTick < 0) return 0; @@ -1103,7 +1090,7 @@ return 0; } - if (envelope->nNodes < pSndFile->GetModSpecifications().envelopePointsMax) + if (envelope->nNodes < sndFile.GetModSpecifications().envelopePointsMax) { if (!envelope->nNodes) { @@ -1143,10 +1130,10 @@ //---------------------------------------------- { CRect rect; - for(UINT i = 0; i < MAX_CHANNELS; i++) if (m_dwNotifyPos[i] & MPTNOTIFY_POSVALID) + for(UINT i = 0; i < MAX_CHANNELS; i++) if (m_dwNotifyPos[i] != Notification::PosInvalid) { rect.top = -2; - rect.left = TickToScreen(m_dwNotifyPos[i] & 0xFFFF); + rect.left = TickToScreen(m_dwNotifyPos[i]); rect.right = rect.left + 1; rect.bottom = m_rcClient.bottom + 1; InvertRect(hdc, &rect); @@ -1154,39 +1141,40 @@ } -LRESULT CViewInstrument::OnPlayerNotify(MPTNOTIFICATION *pnotify) -//--------------------------------------------------------------- +LRESULT CViewInstrument::OnPlayerNotify(Notification *pnotify) +//------------------------------------------------------------ { - DWORD dwType; + Notification::Type type; CModDoc *pModDoc = GetDocument(); if ((!pnotify) || (!pModDoc)) return 0; switch(m_nEnv) { - case ENV_PANNING: dwType = MPTNOTIFY_PANENV; break; - case ENV_PITCH: dwType = MPTNOTIFY_PITCHENV; break; - default: dwType = MPTNOTIFY_VOLENV; break; + case ENV_PANNING: type = Notification::PanEnv; break; + case ENV_PITCH: type = Notification::PitchEnv; break; + default: type = Notification::VolEnv; break; } - if (pnotify->dwType & MPTNOTIFY_STOP) + if (pnotify->type[Notification::Stop]) { + bool invalidate = false; for(CHANNELINDEX i = 0; i < MAX_CHANNELS; i++) { - if(m_dwNotifyPos[i]) + if(m_dwNotifyPos[i] != Notification::PosInvalid) { - m_dwNotifyPos.assign(MAX_CHANNELS, 0); - InvalidateEnvelope(); - break; + m_dwNotifyPos[i] = Notification::PosInvalid; + invalidate = true; } - m_baPlayingNote.assign(128, false); - m_nPlayingChannel = CHANNELINDEX_INVALID; //rewbs.instViewNNA } - } else - if ((pnotify->dwType & dwType) && ((pnotify->dwType & 0xFFFF) == m_nInstrument)) + if(invalidate) + { + InvalidateEnvelope(); + } + m_baPlayingNote.reset(); + } else if(pnotify->type[type] && pnotify->item == m_nInstrument) { BOOL bUpdate = FALSE; for (CHANNELINDEX i = 0; i < MAX_CHANNELS; i++) { - //DWORD newpos = (pSndFile->dwSongFlags & SONG_PAUSED) ? pnotify->dwPos[i] : 0; - DWORD newpos = pnotify->dwPos[i]; + uint32 newpos = pnotify->pos[i]; if (m_dwNotifyPos[i] != newpos) { bUpdate = TRUE; @@ -1200,7 +1188,7 @@ for (CHANNELINDEX j = 0; j < MAX_CHANNELS; j++) { //DWORD newpos = (pSndFile->m_SongFlags[SONG_PAUSED]) ? pnotify->dwPos[j] : 0; - DWORD newpos = pnotify->dwPos[j]; + DWORD newpos = pnotify->pos[j]; m_dwNotifyPos[j] = newpos; } DrawPositionMarks(hdc); @@ -1690,8 +1678,7 @@ { const CModDoc *pModDoc = GetDocument(); if(!pModDoc) return; - const CSoundFile *pSndFile = GetDocument()->GetSoundFile(); - if(!pSndFile) return; + const CSoundFile &sndFile = GetDocument()->GetrSoundFile(); CMenu Menu; if (m_dwStatus & INSSTATUS_DRAGGING) return; @@ -1701,13 +1688,13 @@ if (pSubMenu != NULL) { m_nDragItem = ScreenToPoint(pt.x, pt.y) + 1; - const uint32 maxPoint = (pSndFile->GetType() == MOD_TYPE_XM) ? 11 : 24; + const uint32 maxPoint = (sndFile.GetType() == MOD_TYPE_XM) ? 11 : 24; const uint32 lastpoint = EnvGetLastPoint(); - const bool forceRelease = !pSndFile->GetModSpecifications().hasReleaseNode && (EnvGetReleaseNode() != ENV_RELEASE_NODE_UNSET); + const bool forceRelease = !sndFile.GetModSpecifications().hasReleaseNode && (EnvGetReleaseNode() != ENV_RELEASE_NODE_UNSET); pSubMenu->EnableMenuItem(ID_ENVELOPE_INSERTPOINT, (lastpoint < maxPoint) ? MF_ENABLED : MF_GRAYED); pSubMenu->EnableMenuItem(ID_ENVELOPE_REMOVEPOINT, ((m_nDragItem) && (lastpoint > 0)) ? MF_ENABLED : MF_GRAYED); - pSubMenu->EnableMenuItem(ID_ENVELOPE_CARRY, (pSndFile->GetType() & (MOD_TYPE_IT|MOD_TYPE_MPT)) ? MF_ENABLED : MF_GRAYED); - pSubMenu->EnableMenuItem(ID_ENVELOPE_TOGGLERELEASENODE, ((pSndFile->GetModSpecifications().hasReleaseNode && m_nEnv == ENV_VOLUME) || forceRelease) ? MF_ENABLED : MF_GRAYED); + pSubMenu->EnableMenuItem(ID_ENVELOPE_CARRY, (sndFile.GetType() & (MOD_TYPE_IT|MOD_TYPE_MPT)) ? MF_ENABLED : MF_GRAYED); + pSubMenu->EnableMenuItem(ID_ENVELOPE_TOGGLERELEASENODE, ((sndFile.GetModSpecifications().hasReleaseNode && m_nEnv == ENV_VOLUME) || forceRelease) ? MF_ENABLED : MF_GRAYED); pSubMenu->CheckMenuItem(ID_ENVELOPE_SETLOOP, (EnvGetLoop()) ? MF_CHECKED : MF_UNCHECKED); pSubMenu->CheckMenuItem(ID_ENVELOPE_SUSTAIN, (EnvGetSustain()) ? MF_CHECKED : MF_UNCHECKED); pSubMenu->CheckMenuItem(ID_ENVELOPE_CARRY, (EnvGetCarry()) ? MF_CHECKED : MF_UNCHECKED); @@ -1960,14 +1947,14 @@ } } */ - ModInstrument *pIns = pModDoc->GetSoundFile()->Instruments[m_nInstrument]; + ModInstrument *pIns = pModDoc->GetrSoundFile().Instruments[m_nInstrument]; if ((!pIns) || (!pIns->Keyboard[note - NOTE_MIN] && !pIns->nMixPlug)) return; m_baPlayingNote[note] = true; //rewbs.instViewNNA - m_nPlayingChannel = pModDoc->PlayNote(note, m_nInstrument, 0, false); //rewbs.instViewNNA + pModDoc->PlayNote(note, m_nInstrument, 0, false); //rewbs.instViewNNA s[0] = 0; if ((note) && (note <= NOTE_MAX)) { - const std::string temp = pModDoc->GetSoundFile()->GetNoteName(static_cast<int16>(note), m_nInstrument); + const std::string temp = pModDoc->GetrSoundFile().GetNoteName(static_cast<int16>(note), m_nInstrument); if(temp.size() >= sizeofS) wsprintf(s, "%s", "..."); else @@ -2018,19 +2005,18 @@ //----------------------------------------------------------------------- { CModDoc *pModDoc = GetDocument(); - CSoundFile *pSndFile; BOOL bCanDrop = FALSE; BOOL bUpdate; if ((!lpDropInfo) || (!pModDoc)) return FALSE; - pSndFile = pModDoc->GetSoundFile(); + CSoundFile &sndFile = pModDoc->GetrSoundFile(); switch(lpDropInfo->dwDropType) { case DRAGONDROP_INSTRUMENT: if (lpDropInfo->pModDoc == pModDoc) { bCanDrop = ((lpDropInfo->dwDropItem) - && (lpDropInfo->dwDropItem <= pSndFile->m_nInstruments) + && (lpDropInfo->dwDropItem <= sndFile.m_nInstruments) && (lpDropInfo->pModDoc == pModDoc)); } else { @@ -2051,11 +2037,11 @@ break; } if ((!bCanDrop) || (!bDoDrop)) return bCanDrop; - if ((!pSndFile->m_nInstruments) && (pSndFile->m_nType & (MOD_TYPE_XM|MOD_TYPE_IT|MOD_TYPE_MPT))) + if ((!sndFile.GetNumInstruments()) && sndFile.GetModSpecifications().instrumentsMax > 0) { SendCtrlMessage(CTRLMSG_INS_NEWINSTRUMENT); } - if ((!m_nInstrument) || (m_nInstrument > pSndFile->m_nInstruments)) return FALSE; + if ((!m_nInstrument) || (m_nInstrument > sndFile.GetNumInstruments())) return FALSE; // Do the drop bUpdate = FALSE; BeginWaitCursor(); @@ -2095,7 +2081,7 @@ if (pDlsIns) { CriticalSection cs; - bCanDrop = dlsbank.ExtractInstrument(pSndFile, m_nInstrument, nIns, nRgn); + bCanDrop = dlsbank.ExtractInstrument(sndFile, m_nInstrument, nIns, nRgn); } bUpdate = TRUE; break; @@ -2123,7 +2109,7 @@ CriticalSection cs; - bCanDrop = pDLSBank->ExtractInstrument(pSndFile, m_nInstrument, nIns, nRgn); + bCanDrop = pDLSBank->ExtractInstrument(sndFile, m_nInstrument, nIns, nRgn); bUpdate = TRUE; } break; @@ -2152,12 +2138,15 @@ static BYTE midivolume = 127; CModDoc *pModDoc = GetDocument(); + if(pModDoc == nullptr) + { + return 0; + } + CSoundFile &sndFile = pModDoc->GetrSoundFile(); + BYTE midiByte1 = MIDIEvents::GetDataByte1FromEvent(dwMidiData); BYTE midiByte2 = MIDIEvents::GetDataByte2FromEvent(dwMidiData); - CSoundFile* pSndFile = (pModDoc) ? pModDoc->GetSoundFile() : nullptr; - if(!pSndFile) return 0; - uint8 nNote = midiByte1 + NOTE_MIN; int nVol = midiByte2; MIDIEvents::EventType event = MIDIEvents::GetTypeFromEvent(dwMidiData); @@ -2165,7 +2154,7 @@ BYTE mappedIndex = 0, paramValue = 0; uint32 paramIndex = 0; - bool captured = pSndFile->GetMIDIMapper().OnMIDImsg(dwMidiData, mappedIndex, paramIndex, paramValue); + bool captured = sndFile.GetMIDIMapper().OnMIDImsg(dwMidiData, mappedIndex, paramIndex, paramValue); // Handle MIDI messages assigned to shortcuts CInputHandler *ih = CMainFrame::GetMainFrame()->GetInputHandler(); @@ -2209,13 +2198,13 @@ if((TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_MIDITOPLUG) && CMainFrame::GetMainFrame()->GetModPlaying() == pModDoc) { const INSTRUMENTINDEX instr = m_nInstrument; - IMixPlugin* plug = pSndFile->GetInstrumentPlugin(instr); + IMixPlugin* plug = sndFile.GetInstrumentPlugin(instr); if(plug) { plug->MidiSend(dwMidiData); // Sending midi may modify the plug. For now, if MIDI data // is not active sensing or aftertouch messages, set modified. - if(dwMidiData != MIDIEvents::System(MIDIEvents::sysActiveSense) && event != MIDIEvents::evPolyAftertouch && event != MIDIEvents::evChannelAftertouch && pSndFile->GetModSpecifications().supportsPlugins) + if(dwMidiData != MIDIEvents::System(MIDIEvents::sysActiveSense) && event != MIDIEvents::evPolyAftertouch && event != MIDIEvents::evChannelAftertouch && sndFile.GetModSpecifications().supportsPlugins) { CMainFrame::GetMainFrame()->ThreadSafeSetModified(pModDoc); } @@ -2263,7 +2252,6 @@ CModDoc *pModDoc = GetDocument(); if(!pModDoc) return NULL; - //CSoundFile *pSndFile = pModDoc->GetSoundFile(); CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); switch(wParam) @@ -2318,13 +2306,13 @@ //-------------------------------------------- { CModDoc *pModDoc = GetDocument(); - CSoundFile *pSndFile = (pModDoc) ? pModDoc->GetSoundFile() : NULL; - if(pSndFile == nullptr) + if(pModDoc == nullptr) return; + const CSoundFile &sndFile = pModDoc->GetrSoundFile(); if(m_nInstrument >= 1 && - m_nInstrument <= pSndFile->GetNumInstruments() && - pSndFile->Instruments[m_nInstrument]) + m_nInstrument <= sndFile.GetNumInstruments() && + sndFile.Instruments[m_nInstrument]) { // "Center" y value of the envelope. For panning and pitch, this is 32, for volume and filter it is 0 (minimum). int nOffset = ((m_nEnv != ENV_VOLUME) && !GetEnvelopePtr()->dwFlags[ENV_FILTER]) ? 32 : 0; @@ -2336,8 +2324,6 @@ pModDoc->UpdateAllViews(NULL, (m_nInstrument << HINT_SHIFT_INS) | HINT_ENVELOPE, NULL); } } - - } @@ -2542,11 +2528,10 @@ { CModDoc *pModDoc = GetDocument(); if(pModDoc == nullptr) return nullptr; - CSoundFile *pSndFile = pModDoc->GetSoundFile(); - if(pSndFile == nullptr) return nullptr; - return pSndFile->Instruments[m_nInstrument]; + return pModDoc->GetrSoundFile().Instruments[m_nInstrument]; } + // Get a pointer to the currently selected envelope. // This function also implicitely validates the moddoc and soundfile pointers. InstrumentEnvelope *CViewInstrument::GetEnvelopePtr() const Modified: trunk/OpenMPT/mptrack/View_ins.h =================================================================== --- trunk/OpenMPT/mptrack/View_ins.h 2013-04-06 13:31:47 UTC (rev 1749) +++ trunk/OpenMPT/mptrack/View_ins.h 2013-04-06 14:55:00 UTC (rev 1750) @@ -26,28 +26,32 @@ CImageList m_bmpEnvBar; POINT m_ptMenu; RECT m_rcClient; - vector<bool> m_baPlayingNote; - vector<DWORD> m_dwNotifyPos; - INSTRUMENTINDEX m_nInstrument; + + CBitmap m_bmpGrid; + CBitmap m_bmpMemMain; + CBitmap *m_pbmpOldGrid; + CBitmap *oldBitmap; + enmEnvelopeTypes m_nEnv; - UINT m_nDragItem, m_nBtnMouseOver, m_nPlayingChannel; + UINT m_nDragItem, m_nBtnMouseOver; DWORD m_dwStatus; DWORD m_NcButtonState[ENV_LEFTBAR_BUTTONS]; - //rewbs.envRowGrid - bool m_bGrid; - bool m_bGridForceRedraw; - CBitmap *m_pbmpOldGrid; - CBitmap m_bmpGrid; + + INSTRUMENTINDEX m_nInstrument; + + CDC m_dcMemMain; CDC m_dcGrid; int m_GridScrollPos; int m_GridSpeed; - CDC m_dcMemMain; - CBitmap m_bmpMemMain; - CBitmap* oldBitmap; float m_fZoom; - //rewbs.envRowGrid + bool m_bGrid; + bool m_bGridForceRedraw; + + std::bitset<128> m_baPlayingNote; + uint32 m_dwNotifyPos[MAX_CHANNELS]; + public: CViewInstrument(); DECLARE_SERIAL(CViewInstrument) @@ -101,7 +105,7 @@ bool EnvToggleReleaseNode(int nPoint); // Set envelope status - bool EnvToggleEnv(enmEnvelopeTypes envelope, CSoundFile *pSndFile, ModInstrument *pIns, bool enable, BYTE defaultValue, EnvelopeFlags extraFlags = EnvelopeFlags(0)); + bool EnvToggleEnv(enmEnvelopeTypes envelope, CSoundFile &sndFile, ModInstrument &ins, bool enable, BYTE defaultValue, EnvelopeFlags extraFlags = EnvelopeFlags(0)); bool EnvSetVolEnv(bool bEnable); bool EnvSetPanEnv(bool bEnable); bool EnvSetPitchEnv(bool bEnable); @@ -159,7 +163,7 @@ virtual void UpdateView(DWORD dwHintMask=0, CObject *pObj=NULL); virtual LRESULT OnModViewMsg(WPARAM, LPARAM); virtual BOOL OnDragonDrop(BOOL, LPDRAGONDROP); - virtual LRESULT OnPlayerNotify(MPTNOTIFICATION *); + virtual LRESULT OnPlayerNotify(Notification *); //}}AFX_VIRTUAL protected: Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2013-04-06 13:31:47 UTC (rev 1749) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2013-04-06 14:55:00 UTC (rev 1750) @@ -767,7 +767,7 @@ CModDoc *pModDoc = GetDocument(); if (pModDoc) { - pModDoc->SetFollowWnd(m_hWnd, MPTNOTIFY_POSITION|MPTNOTIFY_VUMETERS); + pModDoc->SetFollowWnd(m_hWnd, Notification::Position | Notification::VUMeters); UpdateIndicator(); } } @@ -2467,7 +2467,7 @@ if (pMainFrm->GetModPlaying() != pModDoc) { - pMainFrm->PlayMod(pModDoc, m_hWnd, MPTNOTIFY_POSITION|MPTNOTIFY_VUMETERS); + pMainFrm->PlayMod(pModDoc, m_hWnd, Notification::Position|Notification::VUMeters); } if(row == ROWINDEX_INVALID) { @@ -3492,8 +3492,8 @@ } -LRESULT CViewPattern::OnPlayerNotify(MPTNOTIFICATION *pnotify) -//------------------------------------------------------------ +LRESULT CViewPattern::OnPlayerNotify(Notification *pnotify) +//--------------------------------------------------------- { CSoundFile *pSndFile = GetSoundFile(); if(pSndFile == nullptr || pnotify == nullptr) @@ -3501,11 +3501,11 @@ return 0; } - if (pnotify->dwType & MPTNOTIFY_POSITION) + if(pnotify->type[Notification::Position]) { - ORDERINDEX nOrd = pnotify->nOrder; - ROWINDEX nRow = pnotify->nRow; - PATTERNINDEX nPat = pnotify->nPattern; //get player pattern + ORDERINDEX nOrd = pnotify->order; + ROWINDEX nRow = pnotify->row; + PATTERNINDEX nPat = pnotify->pattern; //get player pattern bool updateOrderList = false; if(m_nLastPlayedOrder != nOrd) @@ -3559,11 +3559,11 @@ } } SetPlayCursor(nPat, nRow); - m_nPlayTick = pnotify->nTick; + m_nPlayTick = pnotify->tick; - } //Ends condition "if(pnotify->dwType & MPTNOTIFY_POSITION)" + } //Ends condition "if(pnotify->dwType & MPTNotification::_POSITION)" - if((pnotify->dwType & (MPTNOTIFY_VUMETERS|MPTNOTIFY_STOP)) && m_Status[psShowVUMeters]) + if(pnotify->type[Notification::VUMeters | Notification::Stop] && m_Status[psShowVUMeters]) { UpdateAllVUMeters(pnotify); } @@ -3928,8 +3928,8 @@ CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); CModDoc *pModDoc = GetDocument(); m_Status.set(psFollowSong); - if (pModDoc) pModDoc->SetFollowWnd(m_hWnd, MPTNOTIFY_POSITION|MPTNOTIFY_VUMETERS); - if (pMainFrm) pMainFrm->SetFollowSong(pModDoc, m_hWnd, TRUE, MPTNOTIFY_POSITION|MPTNOTIFY_VUMETERS); + if (pModDoc) pModDoc->SetFollowWnd(m_hWnd, Notification::Position|Notification::VUMeters); + if (pMainFrm) pMainFrm->SetFollowSong(pModDoc, m_hWnd, TRUE, Notification::Position|Notification::VUMeters); SetFocus(); } else { Modified: trunk/OpenMPT/mptrack/View_pat.h =================================================================== --- trunk/OpenMPT/mptrack/View_pat.h 2013-04-06 13:31:47 UTC (rev 1749) +++ trunk/OpenMPT/mptrack/View_pat.h 2013-04-06 14:55:00 UTC (rev 1750) @@ -292,7 +292,7 @@ void DrawInstrument(int x, int y, UINT instr); void DrawVolumeCommand(int x, int y... [truncated message content] |
From: <sag...@us...> - 2013-04-07 15:24:13
|
Revision: 1766 http://sourceforge.net/p/modplug/code/1766 Author: saga-games Date: 2013-04-07 15:23:54 +0000 (Sun, 07 Apr 2013) Log Message: ----------- [Ref] More references, less pointers. Modified Paths: -------------- trunk/OpenMPT/mptrack/CleanupSong.cpp trunk/OpenMPT/mptrack/CleanupSong.h trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Ctrl_ins.h trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/Ctrl_smp.h trunk/OpenMPT/mptrack/MPTHacks.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp trunk/OpenMPT/mptrack/PatternEditorDialogs.h trunk/OpenMPT/mptrack/Undo.cpp trunk/OpenMPT/mptrack/Undo.h trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/mptrack/dlg_misc.h trunk/OpenMPT/soundlib/SampleFormats.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/modsmp_ctrl.cpp trunk/OpenMPT/soundlib/modsmp_ctrl.h Modified: trunk/OpenMPT/mptrack/CleanupSong.cpp =================================================================== --- trunk/OpenMPT/mptrack/CleanupSong.cpp 2013-04-07 13:12:30 UTC (rev 1765) +++ trunk/OpenMPT/mptrack/CleanupSong.cpp 2013-04-07 15:23:54 UTC (rev 1766) @@ -101,16 +101,15 @@ CheckDlgButton(m_nCleanupIDtoDlgID[i], (m_bCheckBoxes[i]) ? BST_CHECKED : BST_UNCHECKED); } - CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); - if(pSndFile == nullptr) return FALSE; + CSoundFile &sndFile = modDoc.GetrSoundFile(); - GetDlgItem(m_nCleanupIDtoDlgID[CU_MERGE_SEQUENCES])->EnableWindow((pSndFile->m_nType & MOD_TYPE_MPT) ? TRUE : FALSE); + GetDlgItem(m_nCleanupIDtoDlgID[CU_MERGE_SEQUENCES])->EnableWindow((sndFile.GetType() & MOD_TYPE_MPT) ? TRUE : FALSE); - GetDlgItem(m_nCleanupIDtoDlgID[CU_REMOVE_SAMPLES])->EnableWindow((pSndFile->m_nSamples > 0) ? TRUE : FALSE); - GetDlgItem(m_nCleanupIDtoDlgID[CU_REARRANGE_SAMPLES])->EnableWindow((pSndFile->m_nSamples > 1) ? TRUE : FALSE); + GetDlgItem(m_nCleanupIDtoDlgID[CU_REMOVE_SAMPLES])->EnableWindow((sndFile.GetNumSamples() > 0) ? TRUE : FALSE); + GetDlgItem(m_nCleanupIDtoDlgID[CU_REARRANGE_SAMPLES])->EnableWindow((sndFile.GetNumSamples() > 1) ? TRUE : FALSE); - GetDlgItem(m_nCleanupIDtoDlgID[CU_CLEANUP_INSTRUMENTS])->EnableWindow((pSndFile->m_nInstruments > 0) ? TRUE : FALSE); - GetDlgItem(m_nCleanupIDtoDlgID[CU_REMOVE_INSTRUMENTS])->EnableWindow((pSndFile->m_nInstruments > 0) ? TRUE : FALSE); + GetDlgItem(m_nCleanupIDtoDlgID[CU_CLEANUP_INSTRUMENTS])->EnableWindow((sndFile.GetNumInstruments() > 0) ? TRUE : FALSE); + GetDlgItem(m_nCleanupIDtoDlgID[CU_REMOVE_INSTRUMENTS])->EnableWindow((sndFile.GetNumInstruments() > 0) ? TRUE : FALSE); EnableToolTips(TRUE); return TRUE; @@ -126,7 +125,7 @@ } bool bModified = false; - m_pModDoc->ClearLog(); + modDoc.ClearLog(); // Orders if(m_bCheckBoxes[CU_MERGE_SEQUENCES]) bModified |= MergeSequences(); @@ -138,7 +137,7 @@ if(m_bCheckBoxes[CU_REARRANGE_PATTERNS]) bModified |= RemoveUnusedPatterns(false); // Instruments - if(m_pModDoc->GetSoundFile()->m_nInstruments > 0) + if(modDoc.GetSoundFile()->m_nInstruments > 0) { if(m_bCheckBoxes[CU_REMOVE_INSTRUMENTS]) bModified |= RemoveAllInstruments(); if(m_bCheckBoxes[CU_CLEANUP_INSTRUMENTS]) bModified |= RemoveUnusedInstruments(); @@ -148,7 +147,7 @@ if(m_bCheckBoxes[CU_REMOVE_SAMPLES]) bModified |= RemoveAllSamples(); if(m_bCheckBoxes[CU_CLEANUP_SAMPLES]) bModified |= RemoveUnusedSamples(); if(m_bCheckBoxes[CU_OPTIMIZE_SAMPLES]) bModified |= OptimizeSamples(); - if(m_pModDoc->GetSoundFile()->m_nSamples > 1) + if(modDoc.GetSoundFile()->m_nSamples > 1) { if(m_bCheckBoxes[CU_REARRANGE_SAMPLES]) bModified |= RearrangeSamples(); } @@ -160,9 +159,9 @@ // Create samplepack if(m_bCheckBoxes[CU_RESET_VARIABLES]) bModified |= ResetVariables(); - if(bModified) m_pModDoc->SetModified(); - m_pModDoc->UpdateAllViews(NULL, HINT_MODTYPE | HINT_MODSEQUENCE | HINT_MODGENERAL | HINT_SMPNAMES | HINT_INSNAMES); - m_pModDoc->ShowLog("Cleanup", this); + if(bModified) modDoc.SetModified(); + modDoc.UpdateAllViews(NULL, HINT_MODTYPE | HINT_MODSEQUENCE | HINT_MODGENERAL | HINT_SMPNAMES | HINT_INSNAMES); + modDoc.ShowLog("Cleanup", this); CDialog::OnOK(); } @@ -362,12 +361,11 @@ bool CModCleanupDlg::RemoveUnusedPatterns(bool bRemove) //----------------------------------------------------- { - CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); - if(pSndFile == nullptr) return false; + CSoundFile &sndFile = modDoc.GetrSoundFile(); - const SEQUENCEINDEX maxSeqIndex = pSndFile->Order.GetNumSequences(); - const PATTERNINDEX maxPatIndex = pSndFile->Patterns.Size(); - vector<OrigPatSettings> patternSettings(maxPatIndex, defaultSettings); + const SEQUENCEINDEX maxSeqIndex = sndFile.Order.GetNumSequences(); + const PATTERNINDEX maxPatIndex = sndFile.Patterns.Size(); + std::vector<OrigPatSettings> patternSettings(maxPatIndex, defaultSettings); CHAR s[512]; bool bReordered = false; @@ -379,9 +377,9 @@ PATTERNINDEX maxpat = 0; for(SEQUENCEINDEX nSeq = 0; nSeq < maxSeqIndex; nSeq++) { - for (ORDERINDEX nOrd = 0; nOrd < pSndFile->Order.GetSequence(nSeq).GetLength(); nOrd++) + for (ORDERINDEX nOrd = 0; nOrd < sndFile.Order.GetSequence(nSeq).GetLength(); nOrd++) { - PATTERNINDEX n = pSndFile->Order.GetSequence(nSeq)[nOrd]; + PATTERNINDEX n = sndFile.Order.GetSequence(nSeq)[nOrd]; if (n < maxPatIndex) { if (n >= maxpat) maxpat = n + 1; @@ -397,18 +395,18 @@ while (imax > 0) { imax--; - if ((pSndFile->Patterns[imax]) && (patternSettings[imax].isPatUsed)) break; + if ((sndFile.Patterns[imax]) && (patternSettings[imax].isPatUsed)) break; } nMinToRemove = imax + 1; } // Remove all completely empty patterns above last used pattern (those are safe to remove) CriticalSection cs; - for (PATTERNINDEX nPat = maxpat; nPat < maxPatIndex; nPat++) if ((pSndFile->Patterns[nPat]) && (nPat >= nMinToRemove)) + for (PATTERNINDEX nPat = maxpat; nPat < maxPatIndex; nPat++) if ((sndFile.Patterns[nPat]) && (nPat >= nMinToRemove)) { - if(pSndFile->Patterns.IsPatternEmpty(nPat)) + if(sndFile.Patterns.IsPatternEmpty(nPat)) { - pSndFile->Patterns.Remove(nPat); + sndFile.Patterns.Remove(nPat); nPatRemoved++; } } @@ -417,7 +415,7 @@ size_t nWaste = 0; for (UINT ichk=0; ichk < maxPatIndex; ichk++) { - if ((pSndFile->Patterns[ichk]) && (!patternSettings[ichk].isPatUsed)) nWaste++; + if ((sndFile.Patterns[ichk]) && (!patternSettings[ichk].isPatUsed)) nWaste++; } if ((bRemove) && (nWaste)) @@ -433,21 +431,21 @@ for(PATTERNINDEX i = 0; i < maxPatIndex; i++) patternSettings[i].newIndex = PATTERNINDEX_INVALID; - SEQUENCEINDEX oldSequence = pSndFile->Order.GetCurrentSequenceIndex(); // workaround, as GetSequence doesn't allow writing to sequences ATM + SEQUENCEINDEX oldSequence = sndFile.Order.GetCurrentSequenceIndex(); // workaround, as GetSequence doesn't allow writing to sequences ATM // Re-order pattern numbers based on sequence PATTERNINDEX nPats = 0; // last used index for(SEQUENCEINDEX nSeq = 0; nSeq < maxSeqIndex; nSeq++) { - pSndFile->Order.SetSequence(nSeq); + sndFile.Order.SetSequence(nSeq); ORDERINDEX imap = 0; - for (imap = 0; imap < pSndFile->Order.GetSequence(nSeq).GetLength(); imap++) + for (imap = 0; imap < sndFile.Order.GetSequence(nSeq).GetLength(); imap++) { - PATTERNINDEX n = pSndFile->Order.GetSequence(nSeq)[imap]; + PATTERNINDEX n = sndFile.Order.GetSequence(nSeq)[imap]; if (n < maxPatIndex) { if (patternSettings[n].newIndex == PATTERNINDEX_INVALID) patternSettings[n].newIndex = nPats++; - pSndFile->Order[imap] = patternSettings[n].newIndex; + sndFile.Order[imap] = patternSettings[n].newIndex; } } // Add unused patterns at the end @@ -455,19 +453,19 @@ { for(PATTERNINDEX iadd = 0; iadd < maxPatIndex; iadd++) { - if((pSndFile->Patterns[iadd]) && (patternSettings[iadd].newIndex >= maxPatIndex)) + if((sndFile.Patterns[iadd]) && (patternSettings[iadd].newIndex >= maxPatIndex)) { patternSettings[iadd].newIndex = nPats++; } } } - while (imap < pSndFile->Order.GetSequence(nSeq).GetLength()) + while (imap < sndFile.Order.GetSequence(nSeq).GetLength()) { - pSndFile->Order[imap++] = pSndFile->Order.GetInvalidPatIndex(); + sndFile.Order[imap++] = sndFile.Order.GetInvalidPatIndex(); } } - pSndFile->Order.SetSequence(oldSequence); + sndFile.Order.SetSequence(oldSequence); // Reorder patterns & Delete unused patterns { @@ -477,26 +475,26 @@ if (k < maxPatIndex) { if (i != k) bReordered = true; - patternSettings[k].numRows = pSndFile->Patterns[i].GetNumRows(); - patternSettings[k].data = pSndFile->Patterns[i]; - if(pSndFile->Patterns[i].GetOverrideSignature()) + patternSettings[k].numRows = sndFile.Patterns[i].GetNumRows(); + patternSettings[k].data = sndFile.Patterns[i]; + if(sndFile.Patterns[i].GetOverrideSignature()) { - patternSettings[k].rowsPerBeat = pSndFile->Patterns[i].GetRowsPerBeat(); - patternSettings[k].rowsPerMeasure = pSndFile->Patterns[i].GetRowsPerMeasure(); + patternSettings[k].rowsPerBeat = sndFile.Patterns[i].GetRowsPerBeat(); + patternSettings[k].rowsPerMeasure = sndFile.Patterns[i].GetRowsPerMeasure(); } - patternSettings[k].name = pSndFile->Patterns[i].GetName(); + patternSettings[k].name = sndFile.Patterns[i].GetName(); } else - if (pSndFile->Patterns[i]) + if (sndFile.Patterns[i]) { - pSndFile->Patterns.Remove(i); + sndFile.Patterns.Remove(i); nPatRemoved++; } } for (PATTERNINDEX nPat = 0; nPat < maxPatIndex; nPat++) { - pSndFile->Patterns[nPat].SetData(patternSettings[nPat].data, patternSettings[nPat].numRows); - pSndFile->Patterns[nPat].SetSignature(patternSettings[nPat].rowsPerBeat, patternSettings[nPat].rowsPerMeasure); - pSndFile->Patterns[nPat].SetName(patternSettings[nPat].name); + sndFile.Patterns[nPat].SetData(patternSettings[nPat].data, patternSettings[nPat].numRows); + sndFile.Patterns[nPat].SetSignature(patternSettings[nPat].rowsPerBeat, patternSettings[nPat].rowsPerMeasure); + sndFile.Patterns[nPat].SetName(patternSettings[nPat].name); } } @@ -504,11 +502,11 @@ EndWaitCursor(); if ((nPatRemoved) || (bReordered)) { - m_pModDoc->GetPatternUndo().ClearUndo(); + modDoc.GetPatternUndo().ClearUndo(); if (nPatRemoved) { wsprintf(s, "%d pattern%s removed.\n", nPatRemoved, (nPatRemoved == 1) ? "" : "s"); - m_pModDoc->AddToLog(s); + modDoc.AddToLog(s); } return true; } @@ -520,46 +518,45 @@ bool CModCleanupDlg::RemoveUnusedSamples() //---------------------------------------- { - CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); - if(pSndFile == nullptr) return false; + CSoundFile &sndFile = modDoc.GetrSoundFile(); CHAR s[512]; - vector<bool> samplesUsed(pSndFile->GetNumSamples() + 1, true); + std::vector<bool> samplesUsed(sndFile.GetNumSamples() + 1, true); BeginWaitCursor(); // Check if any samples are not referenced in the patterns (sample mode) or by an instrument (instrument mode). // This doesn't check yet if a sample is referenced by an instrument, but actually unused in the patterns. - for(SAMPLEINDEX smp = 1; smp <= pSndFile->GetNumSamples(); smp++) if (pSndFile->GetSample(smp).pSample) + for(SAMPLEINDEX smp = 1; smp <= sndFile.GetNumSamples(); smp++) if (sndFile.GetSample(smp).pSample) { - if(!pSndFile->IsSampleUsed(smp)) + if(!sndFile.IsSampleUsed(smp)) { samplesUsed[smp] = false; - m_pModDoc->GetSampleUndo().PrepareUndo(smp, sundo_delete); + modDoc.GetSampleUndo().PrepareUndo(smp, sundo_delete); } } - SAMPLEINDEX nRemoved = pSndFile->RemoveSelectedSamples(samplesUsed); + SAMPLEINDEX nRemoved = sndFile.RemoveSelectedSamples(samplesUsed); - const SAMPLEINDEX unusedInsSamples = pSndFile->DetectUnusedSamples(samplesUsed); + const SAMPLEINDEX unusedInsSamples = sndFile.DetectUnusedSamples(samplesUsed); EndWaitCursor(); - if(unusedInsSamples && !((pSndFile->GetType() == MOD_TYPE_IT) && pSndFile->m_SongFlags[SONG_ITPROJECT])) + if(unusedInsSamples && !((sndFile.GetType() == MOD_TYPE_IT) && sndFile.m_SongFlags[SONG_ITPROJECT])) { // We don't remove an instrument's unused samples in an ITP. wsprintf(s, "OpenMPT detected %d sample%s referenced by an instrument,\n" "but not used in the song. Do you want to remove them?", unusedInsSamples, (unusedInsSamples == 1) ? "" : "s"); if(Reporting::Confirm(s, "Sample Cleanup", false, false, this) == cnfYes) { - nRemoved += pSndFile->RemoveSelectedSamples(samplesUsed); + nRemoved += sndFile.RemoveSelectedSamples(samplesUsed); } } if(nRemoved > 0) { wsprintf(s, "%d unused sample%s removed\n" , nRemoved, (nRemoved == 1) ? "" : "s"); - m_pModDoc->AddToLog(s); + modDoc.AddToLog(s); } return (nRemoved > 0); @@ -570,14 +567,13 @@ bool CModCleanupDlg::OptimizeSamples() //------------------------------------ { - CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); - if(pSndFile == nullptr) return false; + CSoundFile &sndFile = modDoc.GetrSoundFile(); SAMPLEINDEX numLoopOpt = 0; - for(SAMPLEINDEX smp = 1; smp <= pSndFile->GetNumSamples(); smp++) + for(SAMPLEINDEX smp = 1; smp <= sndFile.GetNumSamples(); smp++) { - const ModSample &sample = pSndFile->GetSample(smp); + const ModSample &sample = sndFile.GetSample(smp); // Determine how much of the sample will be played SmpLength loopLength = sample.nLength; @@ -599,9 +595,9 @@ "Do you want to optimize %s and remove this unused data?", numLoopOpt, (numLoopOpt == 1) ? " has" : "s have", (numLoopOpt == 1) ? "it" : "them"); if(Reporting::Confirm(s, "Sample Optimization", false, false, this) == cnfYes) { - for(SAMPLEINDEX nSmp = 1; nSmp <= pSndFile->m_nSamples; nSmp++) + for(SAMPLEINDEX nSmp = 1; nSmp <= sndFile.m_nSamples; nSmp++) { - ModSample &sample = pSndFile->GetSample(nSmp); + ModSample &sample = sndFile.GetSample(nSmp); // Determine how much of the sample will be played SmpLength loopLength = sample.nLength; @@ -621,13 +617,13 @@ SmpLength lmax = loopLength + 2; if(lmax < sample.nLength && lmax >= 2) { - m_pModDoc->GetSampleUndo().PrepareUndo(nSmp, sundo_delete, lmax, sample.nLength); - ctrlSmp::ResizeSample(sample, lmax, pSndFile); + modDoc.GetSampleUndo().PrepareUndo(nSmp, sundo_delete, lmax, sample.nLength); + ctrlSmp::ResizeSample(sample, lmax, sndFile); } } } wsprintf(s, "%d sample loop%s optimized\n" ,numLoopOpt, (numLoopOpt == 1) ? "" : "s"); - m_pModDoc->AddToLog(s); + modDoc.AddToLog(s); return true; } @@ -638,30 +634,29 @@ bool CModCleanupDlg::RearrangeSamples() //------------------------------------- { - CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); - - if(pSndFile == nullptr || pSndFile->GetNumSamples() < 2) + CSoundFile &sndFile = modDoc.GetrSoundFile(); + if(sndFile.GetNumSamples() < 2) return false; std::vector<SAMPLEINDEX> sampleMap; - sampleMap.reserve(pSndFile->GetNumSamples()); + sampleMap.reserve(sndFile.GetNumSamples()); // First, find out which sample slots are unused and create the new sample map only with used samples - for(SAMPLEINDEX i = 1; i <= pSndFile->GetNumSamples(); i++) + for(SAMPLEINDEX i = 1; i <= sndFile.GetNumSamples(); i++) { - if(pSndFile->GetSample(i).pSample != nullptr) + if(sndFile.GetSample(i).pSample != nullptr) { sampleMap.push_back(i); } } // Nothing found to remove... - if(pSndFile->GetNumSamples() == sampleMap.size()) + if(sndFile.GetNumSamples() == sampleMap.size()) { return false; } - return (m_pModDoc->ReArrangeSamples(sampleMap) != SAMPLEINDEX_INVALID); + return (modDoc.ReArrangeSamples(sampleMap) != SAMPLEINDEX_INVALID); } @@ -669,13 +664,12 @@ bool CModCleanupDlg::RemoveUnusedInstruments() //-------------------------------------------- { - CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); - - if(pSndFile == nullptr || !pSndFile->GetNumInstruments()) + CSoundFile &sndFile = modDoc.GetrSoundFile(); + if(!sndFile.GetNumInstruments()) return false; deleteInstrumentSamples removeSamples = doNoDeleteAssociatedSamples; - if(!pSndFile->m_SongFlags[SONG_ITPROJECT]) // Never remove an instrument's samples in ITP. + if(!sndFile.m_SongFlags[SONG_ITPROJECT]) // Never remove an instrument's samples in ITP. { if(Reporting::Confirm("Remove samples associated with unused instruments?", "Removing unused instruments", false, false, this) == cnfYes) { @@ -688,12 +682,12 @@ BeginWaitCursor(); - vector<bool> instrUsed(pSndFile->GetNumInstruments()); + std::vector<bool> instrUsed(sndFile.GetNumInstruments()); bool prevUsed = true, reorder = false; INSTRUMENTINDEX numUsed = 0, lastUsed = 1; - for(INSTRUMENTINDEX i = 0; i < pSndFile->GetNumInstruments(); i++) + for(INSTRUMENTINDEX i = 0; i < sndFile.GetNumInstruments(); i++) { - instrUsed[i] = (pSndFile->IsInstrumentUsed(i + 1)); + instrUsed[i] = (sndFile.IsInstrumentUsed(i + 1)); if(instrUsed[i]) { numUsed++; @@ -716,15 +710,15 @@ reorder = false; } - const INSTRUMENTINDEX numRemoved = pSndFile->GetNumInstruments() - numUsed; + const INSTRUMENTINDEX numRemoved = sndFile.GetNumInstruments() - numUsed; if(numRemoved != 0) { BeginWaitCursor(); - vector<INSTRUMENTINDEX> instrMap; - instrMap.reserve(pSndFile->GetNumInstruments()); - for(INSTRUMENTINDEX i = 0; i < pSndFile->GetNumInstruments(); i++) + std::vector<INSTRUMENTINDEX> instrMap; + instrMap.reserve(sndFile.GetNumInstruments()); + for(INSTRUMENTINDEX i = 0; i < sndFile.GetNumInstruments(); i++) { if(instrUsed[i]) { @@ -735,13 +729,13 @@ } } - m_pModDoc->ReArrangeInstruments(instrMap, removeSamples); + modDoc.ReArrangeInstruments(instrMap, removeSamples); EndWaitCursor(); char s[64]; wsprintf(s, "%d unused instrument%s removed\n", numRemoved, (numRemoved == 1) ? "" : "s"); - m_pModDoc->AddToLog(s); + modDoc.AddToLog(s); return true; } return false; @@ -752,18 +746,17 @@ bool CModCleanupDlg::RemoveUnusedPlugins() //---------------------------------------- { - CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); - if(pSndFile == nullptr) return false; + CSoundFile &sndFile = modDoc.GetrSoundFile(); - vector<bool> usedmap(MAX_MIXPLUGINS, false); + std::vector<bool> usedmap(MAX_MIXPLUGINS, false); for(PLUGINDEX nPlug = 0; nPlug < MAX_MIXPLUGINS; nPlug++) { // Is the plugin assigned to a channel? - for(CHANNELINDEX nChn = 0; nChn < pSndFile->GetNumChannels(); nChn++) + for(CHANNELINDEX nChn = 0; nChn < sndFile.GetNumChannels(); nChn++) { - if (pSndFile->ChnSettings[nChn].nMixPlugin == nPlug + 1) + if (sndFile.ChnSettings[nChn].nMixPlugin == nPlug + 1) { usedmap[nPlug] = true; break; @@ -771,9 +764,9 @@ } // Is the plugin used by an instrument? - for(INSTRUMENTINDEX nIns = 1; nIns <= pSndFile->GetNumInstruments(); nIns++) + for(INSTRUMENTINDEX nIns = 1; nIns <= sndFile.GetNumInstruments(); nIns++) { - if (pSndFile->Instruments[nIns] && (pSndFile->Instruments[nIns]->nMixPlug == nPlug + 1)) + if (sndFile.Instruments[nIns] && (sndFile.Instruments[nIns]->nMixPlug == nPlug + 1)) { usedmap[nPlug] = true; break; @@ -781,15 +774,15 @@ } // Is the plugin assigned to master? - if(pSndFile->m_MixPlugins[nPlug].IsMasterEffect()) + if(sndFile.m_MixPlugins[nPlug].IsMasterEffect()) usedmap[nPlug] = true; // All outputs of used plugins count as used if(usedmap[nPlug] != false) { - if(!pSndFile->m_MixPlugins[nPlug].IsOutputToMaster()) + if(!sndFile.m_MixPlugins[nPlug].IsOutputToMaster()) { - PLUGINDEX output = pSndFile->m_MixPlugins[nPlug].GetOutputPlugin(); + PLUGINDEX output = sndFile.m_MixPlugins[nPlug].GetOutputPlugin(); if(output != PLUGINDEX_INVALID) { usedmap[output] = true; @@ -799,7 +792,7 @@ } - UINT nRemoved = m_pModDoc->RemovePlugs(usedmap); + UINT nRemoved = modDoc.RemovePlugs(usedmap); return (nRemoved > 0); } @@ -809,61 +802,59 @@ bool CModCleanupDlg::ResetVariables() //----------------------------------- { - CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); - if(pSndFile == nullptr) return false; + CSoundFile &sndFile = modDoc.GetrSoundFile(); - //jojo.compocleanup if(Reporting::Confirm(TEXT("WARNING: OpenMPT will convert the module to IT format and reset all song, sample and instrument attributes to default values. Continue?"), TEXT("Resetting variables"), false, false, this) == cnfNo) return false; // Stop play. - CMainFrame::GetMainFrame()->StopMod(m_pModDoc); + CMainFrame::GetMainFrame()->StopMod(&modDoc); BeginWaitCursor(); CriticalSection cs; // convert to IT... - m_pModDoc->ChangeModType(MOD_TYPE_IT); - pSndFile->m_nMixLevels = mixLevels_compatible; - pSndFile->m_nTempoMode = tempo_mode_classic; - pSndFile->m_SongFlags = SONG_LINEARSLIDES; - pSndFile->m_MidiCfg.Reset(); + modDoc.ChangeModType(MOD_TYPE_IT); + sndFile.m_nMixLevels = mixLevels_compatible; + sndFile.m_nTempoMode = tempo_mode_classic; + sndFile.m_SongFlags = SONG_LINEARSLIDES; + sndFile.m_MidiCfg.Reset(); // Global vars - pSndFile->m_nDefaultTempo = 125; - pSndFile->m_nDefaultSpeed = 6; - pSndFile->m_nDefaultGlobalVolume = MAX_GLOBAL_VOLUME; - pSndFile->m_nSamplePreAmp = 48; - pSndFile->m_nVSTiVolume = 48; - pSndFile->m_nRestartPos = 0; + sndFile.m_nDefaultTempo = 125; + sndFile.m_nDefaultSpeed = 6; + sndFile.m_nDefaultGlobalVolume = MAX_GLOBAL_VOLUME; + sndFile.m_nSamplePreAmp = 48; + sndFile.m_nVSTiVolume = 48; + sndFile.m_nRestartPos = 0; // reset instruments (if there are any) - for(INSTRUMENTINDEX i = 1; i <= pSndFile->GetNumInstruments(); i++) if(pSndFile->Instruments[i]) + for(INSTRUMENTINDEX i = 1; i <= sndFile.GetNumInstruments(); i++) if(sndFile.Instruments[i]) { - pSndFile->Instruments[i]->nFadeOut = 256; - pSndFile->Instruments[i]->nGlobalVol = 64; - pSndFile->Instruments[i]->nPan = 128; - pSndFile->Instruments[i]->dwFlags.reset(INS_SETPANNING); - pSndFile->Instruments[i]->nMixPlug = 0; + sndFile.Instruments[i]->nFadeOut = 256; + sndFile.Instruments[i]->nGlobalVol = 64; + sndFile.Instruments[i]->nPan = 128; + sndFile.Instruments[i]->dwFlags.reset(INS_SETPANNING); + sndFile.Instruments[i]->nMixPlug = 0; - pSndFile->Instruments[i]->nVolSwing = 0; - pSndFile->Instruments[i]->nPanSwing = 0; - pSndFile->Instruments[i]->nCutSwing = 0; - pSndFile->Instruments[i]->nResSwing = 0; + sndFile.Instruments[i]->nVolSwing = 0; + sndFile.Instruments[i]->nPanSwing = 0; + sndFile.Instruments[i]->nCutSwing = 0; + sndFile.Instruments[i]->nResSwing = 0; } - for(CHANNELINDEX i = 0; i <= pSndFile->GetNumChannels(); i++) + for(CHANNELINDEX i = 0; i <= sndFile.GetNumChannels(); i++) { - pSndFile->ChnSettings[i].Reset(); + sndFile.ChnSettings[i].Reset(); } // reset samples - ctrlSmp::ResetSamples(*pSndFile, ctrlSmp::SmpResetCompo); + ctrlSmp::ResetSamples(sndFile, ctrlSmp::SmpResetCompo); // Set modflags. - pSndFile->SetModFlag(MSF_MIDICC_BUGEMULATION, false); - pSndFile->SetModFlag(MSF_OLDVOLSWING, false); - pSndFile->SetModFlag(MSF_COMPATIBLE_PLAY, true); + sndFile.SetModFlag(MSF_MIDICC_BUGEMULATION, false); + sndFile.SetModFlag(MSF_OLDVOLSWING, false); + sndFile.SetModFlag(MSF_COMPATIBLE_PLAY, true); cs.Leave(); EndWaitCursor(); @@ -875,13 +866,12 @@ bool CModCleanupDlg::RemoveAllPatterns() //-------------------------------------- { - CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); - if(pSndFile == nullptr) return false; + CSoundFile &sndFile = modDoc.GetrSoundFile(); - if (pSndFile->Patterns.Size() == 0) return false; - pSndFile->Patterns.Init(); - pSndFile->Patterns.Insert(0, 64); - pSndFile->SetCurrentOrder(0); + if(sndFile.Patterns.Size() == 0) return false; + sndFile.Patterns.Init(); + sndFile.Patterns.Insert(0, 64); + sndFile.SetCurrentOrder(0); return true; } @@ -889,17 +879,16 @@ bool CModCleanupDlg::RemoveAllOrders() //------------------------------------ { - CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); - if(pSndFile == nullptr) return false; + CSoundFile &sndFile = modDoc.GetrSoundFile(); - pSndFile->Order.SetSequence(0); - while(pSndFile->Order.GetNumSequences() > 1) + sndFile.Order.SetSequence(0); + while(sndFile.Order.GetNumSequences() > 1) { - pSndFile->Order.RemoveSequence(1); + sndFile.Order.RemoveSequence(1); } - pSndFile->Order.Init(); - pSndFile->Order[0] = 0; - pSndFile->SetCurrentOrder(0); + sndFile.Order.Init(); + sndFile.Order[0] = 0; + sndFile.SetCurrentOrder(0); return true; } @@ -907,15 +896,14 @@ bool CModCleanupDlg::RemoveAllSamples() //------------------------------------- { - CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); - if(pSndFile == nullptr) return false; + CSoundFile &sndFile = modDoc.GetrSoundFile(); - if (pSndFile->GetNumSamples() == 0) return false; + if (sndFile.GetNumSamples() == 0) return false; - vector<bool> keepSamples(pSndFile->GetNumSamples() + 1, false); - pSndFile->RemoveSelectedSamples(keepSamples); + std::vector<bool> keepSamples(sndFile.GetNumSamples() + 1, false); + sndFile.RemoveSelectedSamples(keepSamples); - ctrlSmp::ResetSamples(*pSndFile, ctrlSmp::SmpResetInit, 1, MAX_SAMPLES - 1); + ctrlSmp::ResetSamples(sndFile, ctrlSmp::SmpResetInit, 1, MAX_SAMPLES - 1); return true; } @@ -924,19 +912,18 @@ bool CModCleanupDlg::RemoveAllInstruments() //----------------------------------------- { - CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); - if(pSndFile == nullptr) return false; + CSoundFile &sndFile = modDoc.GetrSoundFile(); - if(pSndFile->GetNumInstruments() == 0) return false; + if(sndFile.GetNumInstruments() == 0) return false; - m_pModDoc->ConvertInstrumentsToSamples(); + modDoc.ConvertInstrumentsToSamples(); - for(INSTRUMENTINDEX i = 1; i <= pSndFile->GetNumInstruments(); i++) + for(INSTRUMENTINDEX i = 1; i <= sndFile.GetNumInstruments(); i++) { - pSndFile->DestroyInstrument(i, doNoDeleteAssociatedSamples); + sndFile.DestroyInstrument(i, doNoDeleteAssociatedSamples); } - pSndFile->m_nInstruments = 0; + sndFile.m_nInstruments = 0; return true; } @@ -944,8 +931,8 @@ bool CModCleanupDlg::RemoveAllPlugins() //------------------------------------- { - vector<bool> keepMask(MAX_MIXPLUGINS, false); - m_pModDoc->RemovePlugs(keepMask); + std::vector<bool> keepMask(MAX_MIXPLUGINS, false); + modDoc.RemovePlugs(keepMask); return true; } @@ -953,5 +940,5 @@ bool CModCleanupDlg::MergeSequences() //----------------------------------- { - return m_pModDoc->GetSoundFile()->Order.MergeSequences(); + return modDoc.GetSoundFile()->Order.MergeSequences(); } Modified: trunk/OpenMPT/mptrack/CleanupSong.h =================================================================== --- trunk/OpenMPT/mptrack/CleanupSong.h 2013-04-07 13:12:30 UTC (rev 1765) +++ trunk/OpenMPT/mptrack/CleanupSong.h 2013-04-07 15:23:54 UTC (rev 1766) @@ -42,8 +42,7 @@ //================================== { private: - CModDoc *m_pModDoc; - CWnd *m_wParent; + CModDoc &modDoc; static bool m_bCheckBoxes[CU_MAX_CLEANUP_OPTIONS]; // Checkbox state static const WORD m_nCleanupIDtoDlgID[CU_MAX_CLEANUP_OPTIONS]; // Checkbox -> Control ID LUT static const ENUM_CLEANUP_OPTIONS m_nMutuallyExclusive[CU_MAX_CLEANUP_OPTIONS]; // Options that are mutually exclusive to each other. @@ -70,7 +69,7 @@ bool ResetVariables(); // Turn module into samplepack (convert to IT, remove patterns, etc.) public: - CModCleanupDlg(CModDoc *pModDoc, CWnd *parent):CDialog(IDD_CLEANUP_SONG, parent) { m_pModDoc = pModDoc; m_wParent = parent; } + CModCleanupDlg(CModDoc &modParent, CWnd *parent) : CDialog(IDD_CLEANUP_SONG, parent), modDoc(modParent) { } protected: //{{AFX_VIRTUAL(CModCleanupDlg) Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2013-04-07 13:12:30 UTC (rev 1765) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2013-04-07 15:23:54 UTC (rev 1766) @@ -1123,7 +1123,7 @@ LPDRAGONDROP pDropInfo = (LPDRAGONDROP)lParam; CSoundFile *pSndFile = (CSoundFile *)(pDropInfo->lDropParam); if (pDropInfo->pModDoc) pSndFile = pDropInfo->pModDoc->GetSoundFile(); - if (pSndFile) return OpenInstrument(pSndFile, pDropInfo->dwDropItem); + if (pSndFile) return OpenInstrument(*pSndFile, pDropInfo->dwDropItem); } break; @@ -1508,16 +1508,16 @@ } -BOOL CCtrlInstruments::OpenInstrument(CSoundFile *pSndFile, UINT nInstr) -//---------------------------------------------------------------------- +BOOL CCtrlInstruments::OpenInstrument(CSoundFile &sndFile, INSTRUMENTINDEX nInstr) +//-------------------------------------------------------------------------------- { - if ((!pSndFile) || (!nInstr) || (nInstr > pSndFile->m_nInstruments)) return FALSE; + if((!nInstr) || (nInstr > sndFile.GetNumInstruments())) return FALSE; BeginWaitCursor(); CriticalSection cs; bool bFirst = false; - if (!m_pSndFile->m_nInstruments) + if (!m_pSndFile->GetNumInstruments()) { bFirst = true; m_pSndFile->m_nInstruments = 1; @@ -1530,7 +1530,7 @@ m_nInstrument = 1; bFirst = true; } - m_pSndFile->ReadInstrumentFromSong(m_nInstrument, pSndFile, nInstr); + m_pSndFile->ReadInstrumentFromSong(m_nInstrument, sndFile, nInstr); cs.Leave(); @@ -2528,11 +2528,11 @@ { if ((m_nInstrument) && (m_pModDoc)) { - CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); - ModInstrument *pIns = pSndFile->Instruments[m_nInstrument]; + CSoundFile &sndFile = m_pModDoc->GetrSoundFile(); + ModInstrument *pIns = sndFile.Instruments[m_nInstrument]; if (pIns) { - CSampleMapDlg dlg(pSndFile, m_nInstrument, this); + CSampleMapDlg dlg(sndFile, m_nInstrument, this); if (dlg.DoModal() == IDOK) { m_pModDoc->SetModified(); Modified: trunk/OpenMPT/mptrack/Ctrl_ins.h =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.h 2013-04-07 13:12:30 UTC (rev 1765) +++ trunk/OpenMPT/mptrack/Ctrl_ins.h 2013-04-07 15:23:54 UTC (rev 1766) @@ -127,7 +127,7 @@ void SetInstrumentModified(const bool modified = true); BOOL SetCurrentInstrument(UINT nIns, BOOL bUpdNum=TRUE); BOOL OpenInstrument(LPCSTR lpszFileName); - BOOL OpenInstrument(CSoundFile *pSndFile, UINT nInstr); + BOOL OpenInstrument(CSoundFile &sndFile, INSTRUMENTINDEX nInstr); BOOL EditSample(UINT nSample); VOID UpdateFilterText(); LONG* GetSplitPosRef() {return &TrackerSettings::Instance().glInstrumentWindowHeight;} //rewbs.varWindowSize Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-04-07 13:12:30 UTC (rev 1765) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-04-07 15:23:54 UTC (rev 1766) @@ -443,7 +443,7 @@ LPDRAGONDROP pDropInfo = (LPDRAGONDROP)lParam; CSoundFile *pSndFile = (CSoundFile *)(pDropInfo->lDropParam); if (pDropInfo->pModDoc) pSndFile = pDropInfo->pModDoc->GetSoundFile(); - if (pSndFile) return OpenSample(pSndFile, (SAMPLEINDEX)pDropInfo->dwDropItem) ? TRUE : FALSE; + if (pSndFile) return OpenSample(*pSndFile, (SAMPLEINDEX)pDropInfo->dwDropItem) ? TRUE : FALSE; } break; @@ -863,17 +863,17 @@ } -bool CCtrlSamples::OpenSample(const CSoundFile *pSndFile, SAMPLEINDEX nSample) -//---------------------------------------------------------------------------- +bool CCtrlSamples::OpenSample(const CSoundFile &sndFile, SAMPLEINDEX nSample) +//--------------------------------------------------------------------------- { - if ((!pSndFile) || (!nSample) || (nSample > pSndFile->m_nSamples)) return false; + if(!nSample || nSample > sndFile.GetNumSamples()) return false; BeginWaitCursor(); m_pModDoc->GetSampleUndo().PrepareUndo(m_nSample, sundo_replace); - m_pSndFile->ReadSampleFromSong(m_nSample, pSndFile, nSample); + m_pSndFile->ReadSampleFromSong(m_nSample, sndFile, nSample); ModSample &sample = m_pSndFile->GetSample(m_nSample); - if ((m_pSndFile->GetType() & MOD_TYPE_XM) && (!(sample.uFlags & CHN_PANNING))) + if((m_pSndFile->GetType() & MOD_TYPE_XM) && (!(sample.uFlags & CHN_PANNING))) { sample.nPan = 128; sample.uFlags |= CHN_PANNING; @@ -940,13 +940,13 @@ if(smp != SAMPLEINDEX_INVALID) { SAMPLEINDEX nOldSmp = m_nSample; - CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); + CSoundFile &sndFile = m_pModDoc->GetrSoundFile(); SetCurrentSample(smp); - if(duplicate && nOldSmp >= 1 && nOldSmp <= pSndFile->GetNumSamples()) + if(duplicate && nOldSmp >= 1 && nOldSmp <= sndFile.GetNumSamples()) { m_pModDoc->GetSampleUndo().PrepareUndo(smp, sundo_replace); - pSndFile->ReadSampleFromSong(smp, pSndFile, nOldSmp); + sndFile.ReadSampleFromSong(smp, sndFile, nOldSmp); } m_pModDoc->UpdateAllViews(NULL, (smp << HINT_SHIFT_SMP) | HINT_SAMPLEINFO | HINT_SAMPLEDATA | HINT_SMPNAMES); @@ -1352,7 +1352,7 @@ m_pModDoc->GetSampleUndo().PrepareUndo(iSmp, sundo_update, iStart, iEnd); - const float fOffset = ctrlSmp::RemoveDCOffset(m_pSndFile->GetSample(iSmp), iStart, iEnd, m_pSndFile->GetType(), m_pSndFile); + const float fOffset = ctrlSmp::RemoveDCOffset(m_pSndFile->GetSample(iSmp), iStart, iEnd, m_pSndFile->GetType(), *m_pSndFile); if(fOffset == 0.0f) // No offset removed. continue; @@ -1541,7 +1541,7 @@ if (sample.nSustainEnd > dwStart) sample.nSustainEnd += (sample.nSustainEnd - dwStart); sample.uFlags |= CHN_16BIT; - ctrlSmp::ReplaceSample(sample, (LPSTR)pNewSample, dwNewLen, m_pSndFile); + ctrlSmp::ReplaceSample(sample, (LPSTR)pNewSample, dwNewLen, *m_pSndFile); if(!selection.selectionActive) { if(!(m_pSndFile->GetType() & MOD_TYPE_MOD)) @@ -1657,7 +1657,7 @@ if (sample.nSustainEnd > dwStart) sample.nSustainEnd -= (sample.nSustainEnd - dwStart)/2; if (sample.nSustainEnd > dwNewLen) sample.nSustainEnd = dwNewLen; - ctrlSmp::ReplaceSample(sample, (LPSTR)pNewSample, dwNewLen, m_pSndFile); + ctrlSmp::ReplaceSample(sample, (LPSTR)pNewSample, dwNewLen, *m_pSndFile); if(!selection.selectionActive) { if(!(m_pSndFile->GetType() & MOD_TYPE_MOD)) @@ -2011,7 +2011,7 @@ m_pModDoc->GetSampleUndo().PrepareUndo(m_nSample, sundo_replace); // Swap sample buffer pointer to new buffer, update song + sample data & free old sample buffer - ctrlSmp::ReplaceSample(sample, (LPSTR)pNewSample, Util::Min(nLengthCounter, nNewSampleLength), m_pSndFile); + ctrlSmp::ReplaceSample(sample, (LPSTR)pNewSample, Util::Min(nLengthCounter, nNewSampleLength), *m_pSndFile); // Free progress bar brushes DeleteObject((HBRUSH)green); @@ -2210,7 +2210,7 @@ SampleSelectionPoints selection = GetSelectionPoints(); m_pModDoc->GetSampleUndo().PrepareUndo(m_nSample, sundo_reverse, selection.nStart, selection.nEnd); - if(ctrlSmp::ReverseSample(sample, selection.nStart, selection.nEnd, m_pSndFile) == true) + if(ctrlSmp::ReverseSample(sample, selection.nStart, selection.nEnd, *m_pSndFile)) { m_pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEDATA, NULL); m_pModDoc->SetModified(); @@ -2231,7 +2231,7 @@ SampleSelectionPoints selection = GetSelectionPoints(); m_pModDoc->GetSampleUndo().PrepareUndo(m_nSample, sundo_invert, selection.nStart, selection.nEnd); - if(ctrlSmp::InvertSample(sample, selection.nStart, selection.nEnd, m_pSndFile) == true) + if(ctrlSmp::InvertSample(sample, selection.nStart, selection.nEnd, *m_pSndFile) == true) { m_pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEDATA, NULL); m_pModDoc->SetModified(); @@ -2257,7 +2257,7 @@ SampleSelectionPoints selection = GetSelectionPoints(); m_pModDoc->GetSampleUndo().PrepareUndo(m_nSample, sundo_unsign, selection.nStart, selection.nEnd); - if(ctrlSmp::UnsignSample(sample, selection.nStart, selection.nEnd, m_pSndFile) == true) + if(ctrlSmp::UnsignSample(sample, selection.nStart, selection.nEnd, *m_pSndFile) == true) { m_pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEDATA, NULL); m_pModDoc->SetModified(); @@ -3155,7 +3155,7 @@ sample.nLoopStart = fadeLength; } - if(ctrlSmp::XFadeSample(sample, fadeLength, m_pSndFile)) + if(ctrlSmp::XFadeSample(sample, fadeLength, *m_pSndFile)) { m_pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEDATA | HINT_SAMPLEINFO, NULL); m_pModDoc->SetModified(); Modified: trunk/OpenMPT/mptrack/Ctrl_smp.h =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.h 2013-04-07 13:12:30 UTC (rev 1765) +++ trunk/OpenMPT/mptrack/Ctrl_smp.h 2013-04-07 15:23:54 UTC (rev 1766) @@ -66,7 +66,7 @@ bool SetCurrentSample(SAMPLEINDEX nSmp, LONG lZoom = -1, bool bUpdNum = true); bool OpenSample(LPCSTR lpszFileName); - bool OpenSample(const CSoundFile *pSndFile, SAMPLEINDEX nSample); + bool OpenSample(const CSoundFile &sndFile, SAMPLEINDEX nSample); LONG* GetSplitPosRef() {return &TrackerSettings::Instance().glSampleWindowHeight;} //rewbs.varWindowSize public: Modified: trunk/OpenMPT/mptrack/MPTHacks.cpp =================================================================== --- trunk/OpenMPT/mptrack/MPTHacks.cpp 2013-04-07 13:12:30 UTC (rev 1765) +++ trunk/OpenMPT/mptrack/MPTHacks.cpp 2013-04-07 15:23:54 UTC (rev 1766) @@ -350,7 +350,7 @@ foundHere = foundHacks = true; if(autofix) { - ctrlSmp::ConvertToMono(smp, &m_SndFile, ctrlSmp::mixChannels); + ctrlSmp::ConvertToMono(smp, m_SndFile, ctrlSmp::mixChannels); } else { break; Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-04-07 13:12:30 UTC (rev 1765) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-04-07 15:23:54 UTC (rev 1766) @@ -1614,16 +1614,16 @@ } -BOOL CMainFrame::PlaySoundFile(CSoundFile *pSong, INSTRUMENTINDEX nInstrument, SAMPLEINDEX nSample, ModCommand::NOTE note) -//------------------------------------------------------------------------------------------------------------------------ +BOOL CMainFrame::PlaySoundFile(CSoundFile &sndFile, INSTRUMENTINDEX nInstrument, SAMPLEINDEX nSample, ModCommand::NOTE note) +//-------------------------------------------------------------------------------------------------------------------------- { bool ok = false; BeginWaitCursor(); { CriticalSection cs; InitPreview(); - m_WaveFile.m_nType = pSong->m_nType; - if ((nInstrument) && (nInstrument <= pSong->GetNumInstruments())) + m_WaveFile.m_nType = sndFile.GetType(); + if ((nInstrument) && (nInstrument <= sndFile.GetNumInstruments())) { m_WaveFile.m_nInstruments = 1; m_WaveFile.m_nSamples = 32; @@ -1632,12 +1632,12 @@ m_WaveFile.m_nInstruments = 0; m_WaveFile.m_nSamples = 1; } - if (nInstrument != INSTRUMENTINDEX_INVALID && nInstrument <= pSong->GetNumInstruments()) + if (nInstrument != INSTRUMENTINDEX_INVALID && nInstrument <= sndFile.GetNumInstruments()) { - m_WaveFile.ReadInstrumentFromSong(1, pSong, nInstrument); - } else if(nSample != SAMPLEINDEX_INVALID && nSample <= pSong->GetNumSamples()) + m_WaveFile.ReadInstrumentFromSong(1, sndFile, nInstrument); + } else if(nSample != SAMPLEINDEX_INVALID && nSample <= sndFile.GetNumSamples()) { - m_WaveFile.ReadSampleFromSong(1, pSong, nSample); + m_WaveFile.ReadSampleFromSong(1, sndFile, nSample); } PreparePreview(note); ok = true; Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-04-07 13:12:30 UTC (rev 1765) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-04-07 15:23:54 UTC (rev 1766) @@ -452,7 +452,7 @@ bool StopSoundFile(CSoundFile *); bool PlaySoundFile(CSoundFile *); BOOL PlaySoundFile(LPCSTR lpszFileName, ModCommand::NOTE note); - BOOL PlaySoundFile(CSoundFile *pSong, INSTRUMENTINDEX nInstrument, SAMPLEINDEX nSample, ModCommand::NOTE note); + BOOL PlaySoundFile(CSoundFile &sndFile, INSTRUMENTINDEX nInstrument, SAMPLEINDEX nSample, ModCommand::NOTE note); BOOL PlayDLSInstrument(UINT nDLSBank, UINT nIns, UINT nRgn, ModCommand::NOTE note); void InitPreview(); Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-04-07 13:12:30 UTC (rev 1765) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-04-07 15:23:54 UTC (rev 1766) @@ -118,8 +118,8 @@ ///////////////////////////////////////////////////////////////////////////// // CModDoc construction/destruction -CModDoc::CModDoc() -//---------------- +CModDoc::CModDoc() : m_PatternUndo(*this), m_SampleUndo(*this) +//------------------------------------------------------------ { m_bHasValidPath = false; m_lpszLog = NULL; @@ -128,9 +128,6 @@ m_notifyType = Notification::None; m_notifyItem = 0; - m_PatternUndo.SetParent(this); - m_SampleUndo.SetParent(this); - // Set the creation date of this file (or the load time if we're loading an existing file) time(&m_creationTime); m_FileHistory.clear(); @@ -2065,7 +2062,7 @@ void CModDoc::OnShowCleanup() //--------------------------- { - CModCleanupDlg dlg(this, CMainFrame::GetMainFrame()); + CModCleanupDlg dlg(*this, CMainFrame::GetMainFrame()); dlg.DoModal(); } @@ -2656,7 +2653,7 @@ void CModDoc::SongProperties() //---------------------------- { - CModTypeDlg dlg(GetSoundFile(), CMainFrame::GetMainFrame()); + CModTypeDlg dlg(m_SndFile, CMainFrame::GetMainFrame()); if (dlg.DoModal() == IDOK) { bool bShowLog = false; Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2013-04-07 13:12:30 UTC (rev 1765) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2013-04-07 15:23:54 UTC (rev 1766) @@ -61,7 +61,7 @@ nFound = GetNumChannels(); } - CRemoveChannelsDlg rem(&m_SndFile, nChnToRemove, showCancelInRemoveDlg); + CRemoveChannelsDlg rem(m_SndFile, nChnToRemove, showCancelInRemoveDlg); CheckUsedChannels(rem.m_bKeepMask, nFound); if (rem.DoModal() != IDOK) return false; @@ -330,7 +330,7 @@ // This sample slot is referenced multiple times, so we have to copy the actual sample. m_SndFile.GetSample(i + 1).pSample = m_SndFile.AllocateSample(m_SndFile.GetSample(i + 1).GetSampleSizeInBytes()); memcpy(m_SndFile.GetSample(i + 1).pSample, sampleHeaders[origSlot].pSample, m_SndFile.GetSample(i + 1).GetSampleSizeInBytes()); - ctrlSmp::AdjustEndOfSample(m_SndFile.GetSample(i + 1), &m_SndFile); + ctrlSmp::AdjustEndOfSample(m_SndFile.GetSample(i + 1), m_SndFile); } strcpy(m_SndFile.m_szNames[i + 1], sampleNames[origSlot].c_str()); } else @@ -588,7 +588,7 @@ ModSample &sample = m_SndFile.GetSample(nSample); if ((!sample.nLength) || (!sample.pSample)) return FALSE; - ctrlSmp::AdjustEndOfSample(sample, &m_SndFile); + ctrlSmp::AdjustEndOfSample(sample, m_SndFile); return TRUE; } Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2013-04-07 13:12:30 UTC (rev 1765) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2013-04-07 15:23:54 UTC (rev 1766) @@ -19,8 +19,8 @@ // -> CODE#0010 // -> DESC="add extended parameter mechanism to pattern effects" -void getXParam(BYTE command, PATTERNINDEX nPat, ROWINDEX nRow, CHANNELINDEX nChannel, CSoundFile *pSndFile, UINT &xparam, UINT &multiplier) -//----------------------------------------------------------------------------------------------------------------------------------------- +static void getXParam(BYTE command, PATTERNINDEX nPat, ROWINDEX nRow, CHANNELINDEX nChannel, CSoundFile &sndFile, UINT &xparam, UINT &multiplier) +//----------------------------------------------------------------------------------------------------------------------------------------------- { UINT xp = 0, mult = 1; int nCmdRow = (int)nRow; @@ -33,7 +33,7 @@ // Try to find previous command parameter to be extended while(nCmdRow >= 0) { - const ModCommand *m = pSndFile->Patterns[nPat].GetpModCommand(nCmdRow, nChannel); + const ModCommand *m = sndFile.Patterns[nPat].GetpModCommand(nCmdRow, nChannel); if(m->command == CMD_OFFSET || m->command == CMD_PATTERNBREAK || m->command == CMD_PATTERNBREAK) break; if(m->command != CMD_XPARAM) @@ -52,13 +52,13 @@ if(nCmdRow >= 0) { // An 'extendable' command parameter has been found - const ModCommand *m = pSndFile->Patterns[nPat].GetpModCommand(nCmdRow, nChannel); + const ModCommand *m = sndFile.Patterns[nPat].GetpModCommand(nCmdRow, nChannel); // Find extension resolution (8 to 24 bits) ROWINDEX n = 1; - while(n < 4 && nCmdRow + n < pSndFile->Patterns[nPat].GetNumRows()) + while(n < 4 && nCmdRow + n < sndFile.Patterns[nPat].GetNumRows()) { - if(pSndFile->Patterns[nPat].GetpModCommand(nCmdRow + n, nChannel)->command != CMD_XPARAM) break; + if(sndFile.Patterns[nPat].GetpModCommand(nCmdRow + n, nChannel)->command != CMD_XPARAM) break; n++; } @@ -74,7 +74,7 @@ // its value is changed by user for(UINT j = 0; j < n; j++) { - m = pSndFile->Patterns[nPat].GetpModCommand(nCmdRow + j, nChannel); + m = sndFile.Patterns[nPat].GetpModCommand(nCmdRow + j, nChannel); UINT k = 8 * (n - j - 1); if(nCmdRow + j == nRow) @@ -123,11 +123,8 @@ { CHAR s[256]; CComboBox *combo; - CSoundFile *pSndFile; CPropertyPage::OnInitDialog(); - if(!m_pModDoc) return TRUE; - pSndFile = m_pModDoc->GetSoundFile(); // Search flags CheckDlgButton(IDC_CHECK1, m_Flags[FindReplace::Note] ? MF_CHECKED : MF_UNCHECKED); CheckDlgButton(IDC_CHECK2, m_Flags[FindReplace::Instr] ? MF_CHECKED : MF_UNCHECKED); @@ -170,7 +167,7 @@ { combo->SetItemData(combo->AddString("any"), findAny); } - AppendNotesToControlEx(*combo, pSndFile); + AppendNotesToControlEx(*combo, &sndFile); UINT ncount = combo->GetCount(); for (UINT i=0; i<ncount; i++) if (m_Cmd.note == combo->GetItemData(i)) @@ -190,12 +187,12 @@ } for (UINT n=1; n<MAX_INSTRUMENTS; n++) { - if (pSndFile->m_nInstruments) + if(sndFile.GetNumInstruments()) { - wsprintf(s, "%03d:%s", n, pSndFile->GetInstrumentName(n)); + wsprintf(s, "%03d:%s", n, sndFile.GetInstrumentName(n)); } else { - wsprintf(s, "%03d:%s", n, pSndFile->m_szNames[n]); + wsprintf(s, "%03d:%s", n, sndFile.m_szNames[n]); } combo->SetItemData(combo->AddString(s), n); } @@ -460,13 +457,14 @@ CComboBox *combo; CDialog::OnInitDialog(); combo = (CComboBox *)GetDlgItem(IDC_COMBO1); - const CSoundFile *pSndFile = (m_pModDoc) ? m_pModDoc->GetSoundFile() : nullptr; - if ((pSndFile) && (m_nPattern < pSndFile->Patterns.Size()) && (combo)) + const CSoundFile &sndFile = modDoc.GetrSoundFile(); + + if(m_nPattern < sndFile.Patterns.Size() && combo) { CHAR s[256]; - UINT nrows = pSndFile->Patterns[m_nPattern].GetNumRows(); + UINT nrows = sndFile.Patterns[m_nPattern].GetNumRows(); - const CModSpecifications& specs = pSndFile->GetModSpecifications(); + const CModSpecifications& specs = sndFile.GetModSpecifications(); for (UINT irow = specs.patternRowsMin; irow <= specs.patternRowsMax; irow++) { wsprintf(s, "%d", irow); @@ -475,13 +473,13 @@ combo->SetCurSel(nrows - specs.patternRowsMin); wsprintf(s, "Pattern #%d: %d row%s (%dK)", m_nPattern, - pSndFile->Patterns[m_nPattern].GetNumRows(), - (pSndFile->Patterns[m_nPattern].GetNumRows() == 1) ? "" : "s", - (pSndFile->Patterns[m_nPattern].GetNumRows() * pSndFile->GetNumChannels() * sizeof(ModCommand)) / 1024); + sndFile.Patterns[m_nPattern].GetNumRows(), + (sndFile.Patterns[m_nPattern].GetNumRows() == 1) ? "" : "s", + (sndFile.Patterns[m_nPattern].GetNumRows() * sndFile.GetNumChannels() * sizeof(ModCommand)) / 1024); SetDlgItemText(IDC_TEXT1, s); // Window title - const CString patternName = pSndFile->Patterns[m_nPattern].GetName(); + const CString patternName = sndFile.Patterns[m_nPattern].GetName(); wsprintf(s, "Pattern Properties for Pattern #%d", m_nPattern); if(!patternName.IsEmpty()) { @@ -492,12 +490,12 @@ SetWindowText(s); // pattern time signature - const bool bOverride = pSndFile->Patterns[m_nPattern].GetOverrideSignature(); - UINT nRPB = pSndFile->Patterns[m_nPattern].GetRowsPerBeat(), nRPM = pSndFile->Patterns[m_nPattern].GetRowsPerMeasure(); - if(nRPB == 0 || !bOverride) nRPB = pSndFile->m_nDefaultRowsPerBeat; - if(nRPM == 0 || !bOverride) nRPM = pSndFile->m_nDefaultRowsPerMeasure; + const bool bOverride = sndFile.Patterns[m_nPattern].GetOverrideSignature(); + UINT nRPB = sndFile.Patterns[m_nPattern].GetRowsPerBeat(), nRPM = sndFile.Patterns[m_nPattern].GetRowsPerMeasure(); + if(nRPB == 0 || !bOverride) nRPB = sndFile.m_nDefaultRowsPerBeat; + if(nRPM == 0 || !bOverride) nRPM = sndFile.m_nDefaultRowsPerMeasure; - GetDlgItem(IDC_CHECK1)->EnableWindow(pSndFile->GetModSpecifications().hasPatternSignatures ? TRUE : FALSE); + GetDlgItem(IDC_CHECK1)->EnableWindow(sndFile.GetModSpecifications().hasPatternSignatures ? TRUE : FALSE); CheckDlgButton(IDC_CHECK1, bOverride ? MF_CHECKED : MF_UNCHECKED); SetDlgItemInt(IDC_EDIT_ROWSPERBEAT, nRPB, FALSE); SetDlgItemInt(IDC_EDIT_ROWSPERMEASURE, nRPM, FALSE); @@ -510,14 +508,12 @@ void CPatternPropertiesDlg::OnHalfRowNumber() //------------------------------------------- { - const CSoundFile *pSndFile = (m_pModDoc) ? m_pModDoc->GetSoundFile() : nullptr; - if(pSndFile == nullptr) - return; + const CSoundFile &sndFile = modDoc.GetrSoundFile(); UINT nRows = GetDlgItemInt(IDC_COMBO1, NULL, FALSE); nRows /= 2; - if(nRows < pSndFile->GetModSpecifications().patternRowsMin) - nRows = pSndFile->GetModSpecifications().patternRowsMin; + if(nRows < sndFile.GetModSpecifications().patternRowsMin) + nRows = sndFile.GetModSpecifications().patternRowsMin; SetDlgItemInt(IDC_COMBO1, nRows, FALSE); } @@ -525,14 +521,12 @@ void CPatternPropertiesDlg::OnDoubleRowNumber() //--------------------------------------------- { - const CSoundFile *pSndFile = (m_pModDoc) ? m_pModDoc->GetSoundFile() : nullptr; - if(pSndFile == nullptr) - return; + const CSoundFile &sndFile = modDoc.GetrSoundFile(); UINT nRows = GetDlgItemInt(IDC_COMBO1, NULL, FALSE); nRows *= 2; - if(nRows > pSndFile->GetModSpecifications().patternRowsMax) - nRows = pSndFile->GetModSpecifications().patternRowsMax; + if(nRows > sndFile.GetModSpecifications().patternRowsMax) + nRows = sndFile.GetModSpecifications().patternRowsMax; SetDlgItemInt(IDC_COMBO1, nRows, FALSE); } @@ -548,58 +542,55 @@ void CPatternPropertiesDlg::OnOK() //-------------------------------- { - CSoundFile *pSndFile = (m_pModDoc) ? m_pModDoc->GetSoundFile() : nullptr; - if(pSndFile) + CSoundFile &sndFile = modDoc.GetrSoundFile(); + // Update pattern signature if necessary + if(sndFile.GetModSpecifications().hasPatternSignatures) { - // Update pattern signature if necessary - if(pSndFile->GetModSpecifications().hasPatternSignatures) + if(IsDlgButtonChecked(IDC_CHECK1)) // Enable signature { - if(IsDlgButtonChecked(IDC_CHECK1)) // Enable signature + ROWINDEX nNewBeat = (ROWINDEX)GetDlgItemInt(IDC_EDIT_ROWSPERBEAT, NULL, FALSE), nNewMeasure = (ROWINDEX)GetDlgItemInt(IDC_EDIT_ROWSPERMEASURE, NULL, FALSE); + if(nNewBeat != sndFile.Patterns[m_nPattern].GetRowsPerBeat() || nNewMeasure != sndFile.Patterns[m_nPattern].GetRowsPerMeasure()) { - ROWINDEX nNewBeat = (ROWINDEX)GetDlgItemInt(IDC_EDIT_ROWSPERBEAT, NULL, FALSE), nNewMeasure = (ROWINDEX)GetDlgItemInt(IDC_EDIT_ROWSPERMEASURE, NULL, FALSE); - if(nNewBeat != pSndFile->Patterns[m_nPattern].GetRowsPerBeat() || nNewMeasure != pSndFile->Patterns[m_nPattern].GetRowsPerMeasure()) + if(!sndFile.Patterns[m_nPattern].SetSignature(nNewBeat, nNewMeasure)) { - if(!pSndFile->Patterns[m_nPattern].SetSignature(nNewBeat, nNewMeasure)) - { - Reporting::Error("Invalid time signature!", "Pattern Properties"); - GetDlgItem(IDC_EDIT_ROWSPERBEAT)->SetFocus(); - return; - } - m_pModDoc->SetModified(); + Reporting::Error("Invalid time signature!", "Pattern Properties"); + GetDlgItem(IDC_EDIT_ROWSPERBEAT)->SetFocus(); + return; } - } else // Disable signature + modDoc.SetModified(); + } + } else // Disable signature + { + if(sndFile.Patterns[m_nPattern].GetOverrideSignature()) { - if(pSndFile->Patterns[m_nPattern].GetOverrideSignature()) - { - pSndFile->Patterns[m_nPattern].RemoveSignature(); - m_pModDoc->SetModified(); - } + sndFile.Patterns[m_nPattern].RemoveSignature(); + modDoc.SetModified(); } } + } - const ROWINDEX newSize = (ROWINDEX)GetDlgItemInt(IDC_COMBO1, NULL, FALSE); + const ROWINDEX newSize = (ROWINDEX)GetDlgItemInt(IDC_COMBO1, NULL, FALSE); - // Check if any pattern data would be removed. - bool resize = (newSize != pSndFile->Patterns[m_nPattern].GetNumRows()); - for(ROWINDEX row = newSize; row < pSndFile->Patterns[m_nPattern].GetNumRows(); row++) + // Check if any pattern data would be removed. + bool resize = (newSize != sndFile.Patterns[m_nPattern].GetNumRows()); + for(ROWINDEX row = newSize; row < sndFile.Patterns[m_nPattern].GetNumRows(); row++) + { + if(!sndFile.Patterns[m_nPattern].IsEmptyRow(row)) { - if(!pSndFile->Patterns[m_nPattern].IsEmptyRow(row)) - { - resize = (Reporting::Confirm("Data at the end of the pattern will be lost.\nDo you want to continue?", "Shrink Pattern") == cnfYes); - break; - } + resize = (Reporting::Confirm("Data at the end of the pattern will be lost.\nDo you want to continue?", "Shrink Pattern") == cnfYes); + break; } + } - if(resize) + if(resize) + { + modDoc.GetPatternUndo().PrepareUndo(m_nPattern, 0, 0, sndFile.Patterns[m_nPattern].GetNumChannels(), sndFile.Patterns[m_nPattern].GetNumRows()); + modDoc.BeginWaitCursor(); + if(sndFile.Patterns[m_nPattern].Resize(newSize)) { - m_pModDoc->GetPatternUndo().PrepareUndo(m_nPattern, 0, 0, pSndFile->Patterns[m_nPattern].GetNumChannels(), pSndFile->Patterns[m_nPattern].GetNumRows()); - m_pModDoc->BeginWaitCursor(); - if(pSndFile->Patterns[m_nPattern].Resize(newSize)) - { - m_pModDoc->SetModified(); - } - m_pModDoc->EndWaitCursor(); + modDoc.SetModified(); } + modDoc.EndWaitCursor(); } CDialog::OnOK(); } @@ -636,9 +627,9 @@ if ((!parent) || (!pModDoc)) return FALSE; m_hWndView = parent->m_hWnd; m_pModDoc = pModDoc; - m_pageNote = new CPageEditNote(m_pModDoc, this); - m_pageVolume = new CPageEditVolume(m_pModDoc, this); - m_pageEffect = new CPageEditEffect(m_pModDoc, this); + m_pageNote = new CPageEditNote(m_pModDoc->GetrSoundFile(), this); + m_pageVolume = new CPageEditVolume(m_pModDoc->GetrSoundFile(), this); + m_pageEffect = new CPageEditEffect(m_pModDoc->GetrSoundFile(), this); AddPage(m_pageNote); AddPage(m_pageVolume); AddPage(m_pageEffect); @@ -689,14 +680,14 @@ //------------------------------------------------------------------------------- { CHAR s[64]; - CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); + CSoundFile &sndFile = m_pModDoc->GetrSoundFile(); const ROWINDEX nRow = cursor.GetRow(); const CHANNELINDEX nChannel = cursor.GetChannel(); - if ((nPat >= pSndFile->Patterns.Size()) || (!m_pModDoc) - || (nRow >= pSndFile->Patterns[nPat].GetNumRows()) || (nChannel >= pSndFile->GetNumChannels()) - || (!pSndFile->Patterns[nPat])) return FALSE; - m_Command = *pSndFile->Patterns[nPat].GetpModCommand(nRow, nChannel); + if ((nPat >= sndFile.Patterns.Size()) || (!m_pModDoc) + || (nRow >= sndFile.Patterns[nPat].GetNumRows()) || (nChannel >= sndFile.GetNumChannels()) + || (!sndFile.Patterns[nPat])) return FALSE; + m_Command = *sndFile.Patterns[nPat].GetpModCommand(nRow, nChannel); m_nRow = nRow; m_nChannel = nChannel; m_nPattern = nPat; @@ -711,7 +702,7 @@ if (m_pageEffect) { UINT xp = 0, ml = 1; - getXParam(m_Command.command, nPat, nRow, nChannel, pSndFile, xp, ml); + getXParam(m_Command.command, nPat, nRow, nChannel, sndFile, xp, ml); m_pageEffect->Init(m_Command); m_pageEffect->XInit(xp,ml); } @@ -794,19 +785,19 @@ void CEditCommand::UpdateEffect(ModCommand::COMMAND command, ModCommand::PARAM param) //----------------------------------------------------------------------------------- { - CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); - if ((m_nPattern >= pSndFile->Patterns.Size()) || (!m_pModDoc) - || (m_nRow >= pSndFile->Patterns[m_nPattern].GetNumRows()) - || (m_nChannel >= pSndFile->GetNumChannels()) - || (!pSndFile->Patterns[m_nPattern])) return; - ModCommand *m = pSndFile->Patterns[m_nPattern].GetpModCommand(m_nRow, m_nChannel); + CSoundFile &sndFile = m_pModDoc->GetrSoundFile(); + if ((m_nPattern >= sndFile.Patterns.Size()) || (!m_pModDoc) + || (m_nRow >= sndFile.Patterns[m_nPattern].GetNumRows()) + || (m_nChannel >= sndFile.GetNumChannels()) + || (!sndFile.Patterns[m_nPattern])) return; + ModCommand *m = sndFile.Patterns[m_nPattern].GetpModCommand(m_nRow, m_nChannel); // -> CODE#0010 // -> DESC="add extended parameter mechanism to pattern effects" if(command == CMD_OFFSET || command == CMD_PATTERNBREAK || command == CMD_TEMPO || command == CMD_XPARAM) { UINT xp = 0, ml = 1; - getXParam(command, m_nPattern, m_nRow, m_nChannel, pSndFile, xp, ml); + getXParam(command, m_nPattern, m_nRow, m_nChannel, sndFile, xp, ml); m_pageEffect->XInit(xp,ml); m_pageEffect->UpdateDialog(); } @@ -866,21 +857,20 @@ { char s[64]; CComboBox *combo; - CSoundFile *pSndFile; - if ((!m_bInitialized) || (!m_pModDoc)) return; - pSndFile = m_pModDoc->GetSoundFile(); + if ((!m_bInitialized)) return; + // Note if ((combo = (CComboBox *)GetDlgItem(IDC_COMBO1)) != NULL) { combo->ResetContent(); combo->SetItemData(combo->AddString("No note"), 0); - AppendNotesToControlEx(*combo, pSndFile, m_nInstr); + AppendNotesToControlEx(*combo, &sndFile, m_nInstr); if (ModCommand::IsNoteOrEmpty(m_nNote)) { // Normal note / no note - const ModCommand::NOTE noteStart = (pSndFile != nullptr) ? pSndFile->GetModSpecifications().noteMin : 1; + const ModCommand::NOTE noteStart = sndFile.GetModSpecifications().noteMin; combo->SetCurSel(m_nNote - (noteStart - 1)); } else @@ -906,23 +896,23 @@ { // control plugin param note combo->SetItemData(combo->AddString("No Effect"), 0); - AddPluginNamesToCombobox(*combo, pSndFile->m_MixPlugins, false); + AddPluginNamesToCombobox(*combo, sndFile.m_MixPlugins, false); } else { // instrument / sample combo->SetItemData(combo->AddString("No Instrument"), 0); - const UINT nmax = pSndFile->GetNumInstruments() ? pSndFile->GetNumInstruments() : pSndFile->GetNumSamples(); + const UINT nmax = sndFile.GetNumInstruments() ? sndFile.GetNumInstruments() : sndFile.GetNumSamples(); for (UINT i = 1; i <= nmax; i++) { wsprintf(s, "%02d: ", i); int k = strlen(s); // instrument / sample - if (pSndFile->GetNumInstruments()) + if (sndFile.GetNumInstruments()) { - if (pSndFile->Instruments[i]) - memcpy(s + k, pSndFile->Instruments[i]->name, CountOf(pSndFile->Instruments[i]->name)); + if (sndFile.Instruments[i]) + memcpy(s + k, sndFile.Instruments[i]->name, CountOf(sndFile.Instruments[i]->name)); } else - memcpy(s+k, pSndFile->m_szNames[i], MAX_SAMPLENAME); + memcpy(s+k, sndFile.m_szNames[i], MAX_SAMPLENAME); s[k+32] = 0; combo->SetItemData(combo->AddString(s), i); } @@ -949,12 +939,11 @@ if(n >= 0) { const ModCommand::INSTR oldInstr = m_nInstr; - CSoundFile* pSndFile = m_pModDoc->GetSoundFile(); m_nInstr = static_cast<ModCommand::INSTR>(combo->GetItemData(n)); //Checking whether note names should be recreated. - if(!ModCommand::IsPcNote(m_nNote) && pSndFile && pSndFile->Instruments[m_nInstr] && pSndFile->Instruments[oldInstr]) + if(!ModCommand::IsPcNote(m_nNote) && sndFile.Instruments[m_nInstr] && sndFile.Instruments[oldInstr]) { - if(pSndFile->Instruments[m_nInstr]->pTuning != pSndFile->Instruments[oldInstr]->pTuning) + if(sndFile.Instruments[m_nInstr]->pTuning != sndFile.Instruments[oldInstr]->pTuning) ... [truncated message content] |
From: <sag...@us...> - 2013-04-07 22:43:48
|
Revision: 1772 http://sourceforge.net/p/modplug/code/1772 Author: saga-games Date: 2013-04-07 22:43:38 +0000 (Sun, 07 Apr 2013) Log Message: ----------- [Ref] Made CSoundFile::m_pConfig a normal member instead of pointer. Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_gen.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/ModConvert.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/sounddsp/EQ.cpp trunk/OpenMPT/sounddsp/EQ.h trunk/OpenMPT/soundlib/Fastmix.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp trunk/OpenMPT/soundlib/SoundFilePlayConfig.cpp trunk/OpenMPT/soundlib/SoundFilePlayConfig.h Modified: trunk/OpenMPT/mptrack/Ctrl_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2013-04-07 21:29:10 UTC (rev 1771) +++ trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2013-04-07 22:43:38 UTC (rev 1772) @@ -539,20 +539,20 @@ const char moreRecentMixModeNote[] = "Use a more recent mixmode to see dB offsets."; if ((pszText) && (uId)) { - const bool displayDBValues = m_pSndFile->m_pConfig->getDisplayDBValues(); + const bool displayDBValues = m_pSndFile->m_PlayConfig.getDisplayDBValues(); switch(uId) { case IDC_SLIDER_SAMPLEPREAMP: - (displayDBValues) ? setAsDecibels(pszText, m_pSndFile->m_nSamplePreAmp, m_pSndFile->m_pConfig->getNormalSamplePreAmp()) : wsprintf(pszText, moreRecentMixModeNote); + (displayDBValues) ? setAsDecibels(pszText, m_pSndFile->m_nSamplePreAmp, m_pSndFile->m_PlayConfig.getNormalSamplePreAmp()) : wsprintf(pszText, moreRecentMixModeNote); return TRUE; break; case IDC_SLIDER_VSTIVOL: - (displayDBValues) ? setAsDecibels(pszText, m_pSndFile->m_nVSTiVolume, m_pSndFile->m_pConfig->getNormalVSTiVol()) : wsprintf(pszText, moreRecentMixModeNote); + (displayDBValues) ? setAsDecibels(pszText, m_pSndFile->m_nVSTiVolume, m_pSndFile->m_PlayConfig.getNormalVSTiVol()) : wsprintf(pszText, moreRecentMixModeNote); return TRUE; break; case IDC_SLIDER_GLOBALVOL: - (displayDBValues) ? setAsDecibels(pszText, m_pSndFile->m_nGlobalVolume, m_pSndFile->m_pConfig->getNormalGlobalVol()) : wsprintf(pszText, moreRecentMixModeNote); + (displayDBValues) ? setAsDecibels(pszText, m_pSndFile->m_nGlobalVolume, m_pSndFile->m_PlayConfig.getNormalGlobalVol()) : wsprintf(pszText, moreRecentMixModeNote); return TRUE; break; } Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-04-07 21:29:10 UTC (rev 1771) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-04-07 22:43:38 UTC (rev 1772) @@ -1660,7 +1660,7 @@ m_WaveFile.Destroy(); m_WaveFile.Create(NULL, 0); // Avoid global volume ramping when trying samples in the treeview. - m_WaveFile.m_pConfig->setGlobalVolumeAppliesToMaster(false); + m_WaveFile.m_PlayConfig.setGlobalVolumeAppliesToMaster(false); m_WaveFile.m_nDefaultGlobalVolume = m_WaveFile.m_nGlobalVolume = MAX_GLOBAL_VOLUME; m_WaveFile.m_nSamplePreAmp = 48; m_WaveFile.m_nDefaultTempo = 125; Modified: trunk/OpenMPT/mptrack/ModConvert.cpp =================================================================== --- trunk/OpenMPT/mptrack/ModConvert.cpp 2013-04-07 21:29:10 UTC (rev 1771) +++ trunk/OpenMPT/mptrack/ModConvert.cpp 2013-04-07 22:43:38 UTC (rev 1772) @@ -490,7 +490,7 @@ if(newTypeIsMOD || newTypeIsS3M) { m_SndFile.m_nMixLevels = mixLevels_compatible; - m_SndFile.m_pConfig->SetMixLevels(mixLevels_compatible); + m_SndFile.m_PlayConfig.SetMixLevels(mixLevels_compatible); } if(oldTypeIsMPT && m_SndFile.m_nMixLevels != mixLevels_compatible) { Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-04-07 21:29:10 UTC (rev 1771) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-04-07 22:43:38 UTC (rev 1772) @@ -699,7 +699,7 @@ // Refresh mix levels now that the correct mod type has been set m_SndFile.m_nMixLevels = m_SndFile.GetModSpecifications().defaultMixLevels; - m_SndFile.m_pConfig->SetMixLevels(m_SndFile.m_nMixLevels); + m_SndFile.m_PlayConfig.SetMixLevels(m_SndFile.m_nMixLevels); // ...and the order length m_SndFile.Order.resize(min(ModSequenceSet::s_nCacheSize, m_SndFile.GetModSpecifications().ordersMax)); Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2013-04-07 21:29:10 UTC (rev 1771) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2013-04-07 22:43:38 UTC (rev 1772) @@ -2029,8 +2029,8 @@ if(m_bIsInstrument) { - gain /= m_SndFile.m_pConfig->getVSTiAttenuation(); - gain = static_cast<float>(gain * (m_SndFile.m_nVSTiVolume / m_SndFile.m_pConfig->getNormalVSTiVol())); + gain /= m_SndFile.m_PlayConfig.getVSTiAttenuation(); + gain = static_cast<float>(gain * (m_SndFile.m_nVSTiVolume / m_SndFile.m_PlayConfig.getNormalVSTiVol())); } m_fGain = gain; } Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp 2013-04-07 21:29:10 UTC (rev 1771) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp 2013-04-07 22:43:38 UTC (rev 1772) @@ -362,7 +362,7 @@ if (sel >= 0) { sndFile.m_nMixLevels = m_PlugMixBox.GetItemData(sel); - sndFile.m_pConfig->SetMixLevels(sndFile.m_nMixLevels); + sndFile.m_PlayConfig.SetMixLevels(sndFile.m_nMixLevels); sndFile.RecalculateGainForAllPlugs(); } Modified: trunk/OpenMPT/sounddsp/EQ.cpp =================================================================== --- trunk/OpenMPT/sounddsp/EQ.cpp 2013-04-07 21:29:10 UTC (rev 1771) +++ trunk/OpenMPT/sounddsp/EQ.cpp 2013-04-07 22:43:38 UTC (rev 1772) @@ -326,20 +326,20 @@ #endif -void CEQ::ProcessMono(int *pbuffer, UINT nCount, CSoundFilePlayConfig *pConfig) -//------------------------------------------------------------------------ +void CEQ::ProcessMono(int *pbuffer, UINT nCount, CSoundFilePlayConfig &config) +//---------------------------------------------------------------------------- { - X86_MonoMixToFloat(pbuffer, MixFloatBuffer, nCount, pConfig->getIntToFloat()); + X86_MonoMixToFloat(pbuffer, MixFloatBuffer, nCount, config.getIntToFloat()); for (UINT b=0; b<MAX_EQ_BANDS; b++) { if ((gEQ[b].bEnable) && (gEQ[b].Gain != 1.0f)) EQFilter(&gEQ[b], MixFloatBuffer, nCount); } - X86_FloatToMonoMix(MixFloatBuffer, pbuffer, nCount, pConfig->getFloatToInt()); + X86_FloatToMonoMix(MixFloatBuffer, pbuffer, nCount, config.getFloatToInt()); } -void CEQ::ProcessStereo(int *pbuffer, UINT nCount, CSoundFilePlayConfig *pConfig, DWORD SoundSetupFlags, DWORD SysInfoFlags) -//--------------------------------------------------------------------------------------------------------------------------- +void CEQ::ProcessStereo(int *pbuffer, UINT nCount, CSoundFilePlayConfig &config, DWORD SoundSetupFlags, DWORD SysInfoFlags) +//------------------------------------------------------------------------------------------------------------------------- { #ifdef ENABLE_SSE @@ -348,9 +348,9 @@ // Still allow the check, because the user can turn this on/off if ((SysInfoFlags & SYSMIX_SSE) && (SoundSetupFlags & SNDMIX_ENABLEMMX)) - { + { int sse_state, sse_eqstate; - SSE_MonoMixToFloat(pbuffer, MixFloatBuffer, nCount*2, pConfig->getIntToFloat()); + SSE_MonoMixToFloat(pbuffer, MixFloatBuffer, nCount*2, config.getIntToFloat()); _asm stmxcsr sse_state; sse_eqstate = sse_state | 0xFF80; @@ -362,7 +362,7 @@ } _asm ldmxcsr sse_state; - X86_FloatToMonoMix(MixFloatBuffer, pbuffer, nCount*2, pConfig->getFloatToInt()); + X86_FloatToMonoMix(MixFloatBuffer, pbuffer, nCount*2, config.getFloatToInt()); } else @@ -370,12 +370,12 @@ #endif // ENABLE_SSE #ifdef ENABLE_3DNOW - - // We still perform the MMX check because the user can enable/disable this + // We still perform the MMX check because the user can enable/disable this + if ((SysInfoFlags & SYSMIX_3DNOW) && (SoundSetupFlags & SNDMIX_ENABLEMMX)) { - AMD_MonoMixToFloat(pbuffer, MixFloatBuffer, nCount*2, pConfig->getIntToFloat()); + AMD_MonoMixToFloat(pbuffer, MixFloatBuffer, nCount*2, config.getIntToFloat()); for (UINT b=0; b<MAX_EQ_BANDS; b++) { @@ -384,13 +384,13 @@ AMD_StereoEQ(&gEQ[b], &gEQ[b+MAX_EQ_BANDS], MixFloatBuffer, nCount); } - AMD_FloatToMonoMix(MixFloatBuffer, pbuffer, nCount*2, pConfig->getFloatToInt()); + AMD_FloatToMonoMix(MixFloatBuffer, pbuffer, nCount*2, config.getFloatToInt()); } else #endif // ENABLE_3DNOW { - X86_StereoMixToFloat(pbuffer, MixFloatBuffer, MixFloatBuffer+MIXBUFFERSIZE, nCount, pConfig->getIntToFloat()); + X86_StereoMixToFloat(pbuffer, MixFloatBuffer, MixFloatBuffer+MIXBUFFERSIZE, nCount, config.getIntToFloat()); for (UINT bl=0; bl<MAX_EQ_BANDS; bl++) { @@ -401,7 +401,7 @@ if ((gEQ[br].bEnable) && (gEQ[br].Gain != 1.0f)) EQFilter(&gEQ[br], MixFloatBuffer+MIXBUFFERSIZE, nCount); } - X86_FloatToStereoMix(MixFloatBuffer, MixFloatBuffer+MIXBUFFERSIZE, pbuffer, nCount, pConfig->getFloatToInt()); + X86_FloatToStereoMix(MixFloatBuffer, MixFloatBuffer+MIXBUFFERSIZE, pbuffer, nCount, config.getFloatToInt()); } } Modified: trunk/OpenMPT/sounddsp/EQ.h =================================================================== --- trunk/OpenMPT/sounddsp/EQ.h 2013-04-07 21:29:10 UTC (rev 1771) +++ trunk/OpenMPT/sounddsp/EQ.h 2013-04-07 22:43:38 UTC (rev 1772) @@ -40,8 +40,8 @@ ~CEQ() {} public: void Initialize(BOOL bReset, DWORD MixingFreq); - void ProcessStereo(int *pbuffer, UINT nCount, CSoundFilePlayConfig *pConfig, DWORD SoundSetupFlags, DWORD SysInfoFlags); - void ProcessMono(int *pbuffer, UINT nCount, CSoundFilePlayConfig *pConfig); + void ProcessStereo(int *pbuffer, UINT nCount, CSoundFilePlayConfig &config, DWORD SoundSetupFlags, DWORD SysInfoFlags); + void ProcessMono(int *pbuffer, UINT nCount, CSoundFilePlayConfig &config); void SetEQGains(const UINT *pGains, UINT nGains, const UINT *pFreqs, BOOL bReset, DWORD MixingFreq); }; Modified: trunk/OpenMPT/soundlib/Fastmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Fastmix.cpp 2013-04-07 21:29:10 UTC (rev 1771) +++ trunk/OpenMPT/soundlib/Fastmix.cpp 2013-04-07 22:43:38 UTC (rev 1772) @@ -1804,20 +1804,20 @@ #ifdef ENABLE_SSE if(gdwSysInfo & SYSMIX_SSE) { - SSE_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, m_pConfig->getIntToFloat()); + SSE_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, m_PlayConfig.getIntToFloat()); return; } #endif // ENABLE_SSE #ifdef ENABLE_3DNOW if(gdwSysInfo & SYSMIX_3DNOW) { - AMD_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, m_pConfig->getIntToFloat()); + AMD_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, m_PlayConfig.getIntToFloat()); return; } #endif // ENABLE_3DNOW } - X86_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, m_pConfig->getIntToFloat()); + X86_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, m_PlayConfig.getIntToFloat()); } @@ -1830,12 +1830,12 @@ #ifdef ENABLE_3DNOW if(gdwSysInfo & SYSMIX_3DNOW) { - AMD_FloatToStereoMix(pIn1, pIn2, pOut, nCount, m_pConfig->getFloatToInt()); + AMD_FloatToStereoMix(pIn1, pIn2, pOut, nCount, m_PlayConfig.getFloatToInt()); return; } #endif // ENABLE_3DNOW } - X86_FloatToStereoMix(pIn1, pIn2, pOut, nCount, m_pConfig->getFloatToInt()); + X86_FloatToStereoMix(pIn1, pIn2, pOut, nCount, m_PlayConfig.getFloatToInt()); } @@ -1847,19 +1847,19 @@ #ifdef ENABLE_SSE if(gdwSysInfo & SYSMIX_SSE) { - SSE_MonoMixToFloat(pSrc, pOut, nCount, m_pConfig->getIntToFloat()); + SSE_MonoMixToFloat(pSrc, pOut, nCount, m_PlayConfig.getIntToFloat()); return; } #endif // ENABLE_SSE #ifdef ENABLE_3DNOW if(gdwSysInfo & SYSMIX_3DNOW) { - AMD_MonoMixToFloat(pSrc, pOut, nCount, m_pConfig->getIntToFloat()); + AMD_MonoMixToFloat(pSrc, pOut, nCount, m_PlayConfig.getIntToFloat()); return; } #endif // ENABLE_3DNOW } - X86_MonoMixToFloat(pSrc, pOut, nCount, m_pConfig->getIntToFloat()); + X86_MonoMixToFloat(pSrc, pOut, nCount, m_PlayConfig.getIntToFloat()); } @@ -1872,12 +1872,12 @@ #ifdef ENABLE_3DNOW if(gdwSysInfo & SYSMIX_3DNOW) { - AMD_FloatToMonoMix(pIn, pOut, nCount, m_pConfig->getFloatToInt()); + AMD_FloatToMonoMix(pIn, pOut, nCount, m_PlayConfig.getFloatToInt()); return; } #endif // ENABLE_3DNOW } - X86_FloatToMonoMix(pIn, pOut, nCount, m_pConfig->getFloatToInt()); + X86_FloatToMonoMix(pIn, pOut, nCount, m_PlayConfig.getFloatToInt()); } Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-04-07 21:29:10 UTC (rev 1771) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-04-07 22:43:38 UTC (rev 1772) @@ -463,7 +463,6 @@ m_lTotalSampleCount = 0; m_bPositionChanged = true; - m_pConfig = new CSoundFilePlayConfig(); m_pTuningsTuneSpecific = new CTuningCollection("Tune specific tunings"); } @@ -471,7 +470,6 @@ CSoundFile::~CSoundFile() //----------------------- { - delete m_pConfig; delete m_pTuningsTuneSpecific; Destroy(); } @@ -792,7 +790,7 @@ #endif // NO_VST // Set up mix levels - m_pConfig->SetMixLevels(m_nMixLevels); + m_PlayConfig.SetMixLevels(m_nMixLevels); RecalculateGainForAllPlugs(); if(GetType() != MOD_TYPE_NONE) Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-04-07 21:29:10 UTC (rev 1771) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-04-07 22:43:38 UTC (rev 1772) @@ -318,7 +318,7 @@ char m_szNames[MAX_SAMPLES][MAX_SAMPLENAME]; // Song and sample names std::bitset<MAX_BASECHANNELS> m_bChannelMuteTogglePending; - CSoundFilePlayConfig* m_pConfig; + CSoundFilePlayConfig m_PlayConfig; DWORD m_dwCreatedWithVersion; DWORD m_dwLastSavedWithVersion; Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-04-07 21:29:10 UTC (rev 1771) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-04-07 22:43:38 UTC (rev 1772) @@ -306,7 +306,7 @@ if (nMaxPlugins) ProcessPlugins(lCount); // Apply global volume - if (m_pConfig->getGlobalVolumeAppliesToMaster()) + if (m_PlayConfig.getGlobalVolumeAppliesToMaster()) { ApplyGlobalVolume(MixSoundBuffer, MixRearBuffer, lSampleCount); } @@ -322,7 +322,7 @@ X86_MonoFromStereo(MixSoundBuffer, lCount); // Apply global volume - if (m_pConfig->getGlobalVolumeAppliesToMaster()) + if (m_PlayConfig.getGlobalVolumeAppliesToMaster()) { ApplyGlobalVolume(MixSoundBuffer, nullptr, lSampleCount); } @@ -337,9 +337,9 @@ if (gdwSoundSetup & SNDMIX_EQ) { if (gnChannels >= 2) - m_EQ.ProcessStereo(MixSoundBuffer, lCount, m_pConfig, gdwSoundSetup, gdwSysInfo); + m_EQ.ProcessStereo(MixSoundBuffer, lCount, m_PlayConfig, gdwSoundSetup, gdwSysInfo); else - m_EQ.ProcessMono(MixSoundBuffer, lCount, m_pConfig); + m_EQ.ProcessMono(MixSoundBuffer, lCount, m_PlayConfig); } #endif // NO_EQ @@ -1664,7 +1664,7 @@ DWORD mastervol; - if (m_pConfig->getUseGlobalPreAmp()) + if (m_PlayConfig.getUseGlobalPreAmp()) { int realmastervol = m_nMasterVolume; if (realmastervol > 0x80) @@ -1684,7 +1684,7 @@ mastervol = Util::muldiv(mastervol, m_nGlobalFadeSamples, m_nGlobalFadeMaxSamples); } - if (m_pConfig->getUseGlobalPreAmp()) + if (m_PlayConfig.getUseGlobalPreAmp()) { UINT attenuation = #ifndef NO_AGC @@ -1797,7 +1797,7 @@ if(pChn->dwFlags[CHN_SYNCMUTE]) { pChn->nRealVolume = 0; - } else if (m_pConfig->getGlobalVolumeAppliesToMaster()) + } else if (m_PlayConfig.getGlobalVolumeAppliesToMaster()) { // Don't let global volume affect level of sample if // Global volume is going to be applied to master output anyway. @@ -1962,7 +1962,7 @@ #endif #ifdef MODPLUG_TRACKER - const UINT kChnMasterVol = pChn->dwFlags[CHN_EXTRALOUD] ? 0x100 : nMasterVol; + const UINT kChnMasterVol = pChn->dwFlags[CHN_EXTRALOUD] ? (UINT)m_PlayConfig.getNormalSamplePreAmp() : nMasterVol; #else #define kChnMasterVol nMasterVol #endif // MODPLUG_TRACKER @@ -1977,7 +1977,7 @@ Limit(pan, 0, 256); LONG realvol; - if (m_pConfig->getUseGlobalPreAmp()) + if (m_PlayConfig.getUseGlobalPreAmp()) { realvol = (pChn->nRealVolume * kChnMasterVol) >> 7; } else @@ -1986,7 +1986,7 @@ realvol = (pChn->nRealVolume * kChnMasterVol) >> 8; } - const forcePanningMode panningMode = m_pConfig->getForcePanningMode(); + const forcePanningMode panningMode = m_PlayConfig.getForcePanningMode(); if (panningMode == forceSoftPanning || (panningMode == dontForcePanningMode && (gdwSoundSetup & SNDMIX_SOFTPANNING))) { if (pan < 128) @@ -2054,7 +2054,7 @@ pChn->nNewRightVol >>= MIXING_ATTENUATION; pChn->nNewLeftVol >>= MIXING_ATTENUATION; }*/ - const int extraAttenuation = m_pConfig->getExtraSampleAttenuation(); + const int extraAttenuation = m_PlayConfig.getExtraSampleAttenuation(); pChn->nNewRightVol >>= extraAttenuation; pChn->nNewLeftVol >>= extraAttenuation; Modified: trunk/OpenMPT/soundlib/SoundFilePlayConfig.cpp =================================================================== --- trunk/OpenMPT/soundlib/SoundFilePlayConfig.cpp 2013-04-07 21:29:10 UTC (rev 1771) +++ trunk/OpenMPT/soundlib/SoundFilePlayConfig.cpp 2013-04-07 22:43:38 UTC (rev 1772) @@ -31,7 +31,7 @@ { // Olivier's version gives us floats in [-0.5; 0.5] and slightly saturates VSTis. - case mixLevels_original: + case mixLevels_original: setVSTiAttenuation(NO_ATTENUATION); setIntToFloat(1.0f/static_cast<float>(1<<28)); setFloatToInt(static_cast<float>(1<<28)); @@ -39,7 +39,7 @@ setUseGlobalPreAmp(true); setForcePanningMode(dontForcePanningMode); setDisplayDBValues(false); - setNormalSamplePreAmp(128.0); + setNormalSamplePreAmp(256.0); setNormalVSTiVol(100.0); setNormalGlobalVol(128.0); setExtraSampleAttenuation(MIXING_ATTENUATION); @@ -47,7 +47,7 @@ // Ericus' version gives us floats in [-0.06;0.06] and requires attenuation to // avoid massive VSTi saturation. - case mixLevels_117RC1: + case mixLevels_117RC1: setVSTiAttenuation(32.0f); setIntToFloat(1.0f/static_cast<float>(0x07FFFFFFF)); setFloatToInt(static_cast<float>(0x07FFFFFFF)); @@ -55,7 +55,7 @@ setUseGlobalPreAmp(true); setForcePanningMode(dontForcePanningMode); setDisplayDBValues(false); - setNormalSamplePreAmp(128.0); + setNormalSamplePreAmp(256.0); setNormalVSTiVol(100.0); setNormalGlobalVol(128.0); setExtraSampleAttenuation(MIXING_ATTENUATION); @@ -72,7 +72,7 @@ setUseGlobalPreAmp(true); setForcePanningMode(dontForcePanningMode); setDisplayDBValues(false); - setNormalSamplePreAmp(128.0); + setNormalSamplePreAmp(256.0); setNormalVSTiVol(100.0); setNormalGlobalVol(128.0); setExtraSampleAttenuation(MIXING_ATTENUATION); @@ -114,7 +114,7 @@ break; } - + return; } Modified: trunk/OpenMPT/soundlib/SoundFilePlayConfig.h =================================================================== --- trunk/OpenMPT/soundlib/SoundFilePlayConfig.h 2013-04-07 21:29:10 UTC (rev 1771) +++ trunk/OpenMPT/soundlib/SoundFilePlayConfig.h 2013-04-07 22:43:38 UTC (rev 1772) @@ -18,11 +18,11 @@ MIXING_CLIPMAX = 0x07FFFFFF, }; -enum +enum tempoMode { - tempo_mode_classic = 0, - tempo_mode_alternative = 1, - tempo_mode_modern = 2, + tempo_mode_classic = 0, + tempo_mode_alternative = 1, + tempo_mode_modern = 2, }; enum mixLevels @@ -64,7 +64,7 @@ void setVSTiVolume(float); float getVSTiVolume(); - void setGlobalVolumeAppliesToMaster(bool); + void setGlobalVolumeAppliesToMaster(bool); bool getGlobalVolumeAppliesToMaster(); void setUseGlobalPreAmp(bool); @@ -90,13 +90,13 @@ private: -//calculated internally (getters only): +//calculated internally (getters only): float getVSTiGainFactor(); float m_IntToFloat; float m_FloatToInt; - float m_VSTiAttenuation; - float m_VSTiVolume; + float m_VSTiAttenuation; + float m_VSTiVolume; double m_normalSamplePreAmp; double m_normalVSTiVol; @@ -108,8 +108,5 @@ bool m_displayDBValues; int m_extraAttenuation; - - DWORD m_LastSavedWithVersion; - DWORD m_CreatedWithVersion; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |