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] |