From: <sag...@us...> - 2010-05-08 15:35:46
|
Revision: 588 http://modplug.svn.sourceforge.net/modplug/?rev=588&view=rev Author: saga-games Date: 2010-05-08 15:35:40 +0000 (Sat, 08 May 2010) Log Message: ----------- [Fix] Instrument Editor: New instruments are now assigning samples properly again (forgot to commit ctrl_ins in rev. 586) [Imp] Further improvments to automatic instrument creation. Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/AbstractVstEditor.h trunk/OpenMPT/mptrack/CleanupSong.cpp trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/dlg_misc.cpp Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2010-05-07 21:36:23 UTC (rev 587) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2010-05-08 15:35:40 UTC (rev 588) @@ -320,32 +320,23 @@ case kcVSTGUIToggleSendKeysToPlug: OnPassKeypressesToPlug(); return wParam; case kcVSTGUIBypassPlug: OnBypassPlug(); return wParam; } - if (wParam>=kcVSTGUIStartNotes && wParam<=kcVSTGUIEndNotes) + if (wParam >= kcVSTGUIStartNotes && wParam <= kcVSTGUIEndNotes) { - if (!CheckInstrument(m_nInstrument)) { - m_nInstrument = GetBestInstrumentCandidate(); - } - - if(QueryAddInstrumentIfNeeded()) + if(ValidateCurrentInstrument()) { CModDoc* pModDoc = m_pVstPlugin->GetModDoc(); CMainFrame* pMainFrm = CMainFrame::GetMainFrame(); - pModDoc->PlayNote(wParam-kcVSTGUIStartNotes+1+pMainFrm->GetBaseOctave()*12, m_nInstrument, 0, FALSE); + pModDoc->PlayNote(wParam - kcVSTGUIStartNotes + 1 + pMainFrm->GetBaseOctave() * 12, m_nInstrument, 0, FALSE); } return wParam; } - if (wParam>=kcVSTGUIStartNoteStops && wParam<=kcVSTGUIEndNoteStops) + if (wParam >= kcVSTGUIStartNoteStops && wParam <= kcVSTGUIEndNoteStops) { - if (!CheckInstrument(m_nInstrument)) + if(ValidateCurrentInstrument()) { - m_nInstrument = GetBestInstrumentCandidate(); - } - - if(QueryAddInstrumentIfNeeded()) - { CModDoc* pModDoc = m_pVstPlugin->GetModDoc(); CMainFrame* pMainFrm = CMainFrame::GetMainFrame(); - pModDoc->NoteOff(wParam-kcVSTGUIStartNoteStops+1+pMainFrm->GetBaseOctave()*12, FALSE, m_nInstrument); + pModDoc->NoteOff(wParam - kcVSTGUIStartNoteStops + 1 + pMainFrm->GetBaseOctave() * 12, FALSE, m_nInstrument); } return wParam; } @@ -354,17 +345,20 @@ } -// Weird name! :-P // When trying to play a note using this plugin, but no instrument is assigned to it, // the user is asked whether a new instrument should be added. -bool CAbstractVstEditor::QueryAddInstrumentIfNeeded() -//--------------------------------------------------- +bool CAbstractVstEditor::ValidateCurrentInstrument() +//-------------------------------------------------- { - //only send warning if plug is able to process notes. + if (!CheckInstrument(m_nInstrument)) + m_nInstrument = GetBestInstrumentCandidate(); + + //only show messagebox if plug is able to process notes. if(m_nInstrument < 0 && m_pVstPlugin->CanRecieveMidiEvents()) { CModDoc *pModDoc = m_pVstPlugin->GetModDoc(); - if(!pModDoc || !pModDoc->GetSoundFile()) + CSoundFile *pSndFile = m_pVstPlugin->GetSoundFile(); + if(!pModDoc || !pSndFile) return false; if(pModDoc->GetSoundFile()->GetModSpecifications().instrumentsMax == 0 || @@ -374,20 +368,25 @@ } else { // try to set up a new instrument + bool bFirst = (pSndFile->GetNumInstruments() == 0); INSTRUMENTINDEX nIns = pModDoc->InsertInstrument(0); if(nIns == INSTRUMENTINDEX_INVALID) return false; - MODINSTRUMENT *pIns = pModDoc->GetSoundFile()->Instruments[nIns]; + MODINSTRUMENT *pIns = pSndFile->Instruments[nIns]; m_nInstrument = nIns; - _snprintf(pIns->name, ARRAYELEMCOUNT(pIns->name) - 1, _T("%d: %s"), m_pVstPlugin->GetSlot() + 1, pModDoc->GetSoundFile()->m_MixPlugins[m_pVstPlugin->GetSlot()].Info.szName); - _snprintf(pIns->filename, ARRAYELEMCOUNT(pIns->filename) - 1, _T("FX %d"), m_pVstPlugin->GetSlot() + 1); - pIns->nMixPlug = m_pVstPlugin->GetSlot() + 1; + _snprintf(pIns->name, ARRAYELEMCOUNT(pIns->name) - 1, _T("%d: %s"), m_pVstPlugin->GetSlot() + 1, pSndFile->m_MixPlugins[m_pVstPlugin->GetSlot()].Info.szName); + strncpy(pIns->filename, pSndFile->m_MixPlugins[m_pVstPlugin->GetSlot()].Info.szLibraryName, ARRAYELEMCOUNT(pIns->filename) - 1); + pIns->nMixPlug = (PLUGINDEX)m_pVstPlugin->GetSlot() + 1; pIns->nMidiChannel = 1; - pIns->wMidiBank = (m_pVstPlugin->GetCurrentProgram() >> 7) + 1; - pIns->nMidiProgram = (m_pVstPlugin->GetCurrentProgram() & 0x7F) + 1; + 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->SetModified(); + return true; } } else @@ -558,9 +557,9 @@ pInfoMenu->InsertMenu(1, MF_BYPOSITION|MF_POPUP, (UINT)m_pOutputMenu->m_hMenu, "Ou&tputs"); } -void CAbstractVstEditor::UpdateMacroMenu() { -//------------------------------------------ - +void CAbstractVstEditor::UpdateMacroMenu() +//---------------------------------------- +{ CString label, macroName, macroText; char paramName[128]; bool greyed; @@ -697,7 +696,8 @@ //Then just take the first instrument that points to this plug.. CArray<UINT, UINT> plugInstrumentList; m_pVstPlugin->GetInputInstrumentList(plugInstrumentList); - if (plugInstrumentList.GetSize()) { + if (plugInstrumentList.GetSize()) + { return plugInstrumentList[0]; } Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.h =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.h 2010-05-07 21:36:23 UTC (rev 587) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.h 2010-05-08 15:35:40 UTC (rev 588) @@ -64,7 +64,7 @@ void UpdateOptionsMenu(); int GetBestInstrumentCandidate(); bool CheckInstrument(int instrument); - bool QueryAddInstrumentIfNeeded(); + bool ValidateCurrentInstrument(); int m_nInstrument; int m_nLearnMacro; Modified: trunk/OpenMPT/mptrack/CleanupSong.cpp =================================================================== --- trunk/OpenMPT/mptrack/CleanupSong.cpp 2010-05-07 21:36:23 UTC (rev 587) +++ trunk/OpenMPT/mptrack/CleanupSong.cpp 2010-05-08 15:35:40 UTC (rev 588) @@ -330,7 +330,7 @@ else { ::MultiByteToWideChar(CP_ACP , 0, strTipText, strTipText.GetLength() + 1, - pTTTW->szText, sizeof(pTTTW->szText)/(sizeof pTTTW->szText[0])); + pTTTW->szText, ARRAYELEMCOUNT(pTTTW->szText)); } return TRUE; Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2010-05-07 21:36:23 UTC (rev 587) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2010-05-08 15:35:40 UTC (rev 588) @@ -1546,8 +1546,8 @@ OnInstrumentDuplicate(); return; } - BOOL bFirst = (pSndFile->m_nInstruments) ? FALSE : TRUE; - LONG ins = m_pModDoc->InsertInstrument(0); + bool bFirst = (pSndFile->GetNumInstruments() == 0); + LONG ins = m_pModDoc->InsertInstrument(); if (ins != INSTRUMENTINDEX_INVALID) { SetCurrentInstrument(ins); @@ -1569,7 +1569,7 @@ if ((pSndFile->m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT)) && (pSndFile->m_nInstruments > 0)) { BOOL bFirst = (pSndFile->m_nInstruments) ? FALSE : TRUE; - LONG ins = m_pModDoc->InsertInstrument(0, m_nInstrument); + LONG ins = m_pModDoc->InsertInstrument(INSTRUMENTINDEX_INVALID, m_nInstrument); if (ins != INSTRUMENTINDEX_INVALID) { SetCurrentInstrument(ins); Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp 2010-05-07 21:36:23 UTC (rev 587) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp 2010-05-08 15:35:40 UTC (rev 588) @@ -546,7 +546,7 @@ strTipText = "Gxx and Exx/Fxx won't share effect memory. Gxx resets instrument envelopes."; break; case IDC_CHECK5: - strTipText = "The resonant filter's frequency range is incresed from about 4KHz to 10KHz"; + strTipText = "The resonant filter's frequency range is incresed from about 4KHz to 10KHz."; break; case IDC_CHECK6: strTipText = "The instrument settings of the external ITI files will be ignored."; @@ -569,7 +569,7 @@ else { ::MultiByteToWideChar(CP_ACP , 0, strTipText, strTipText.GetLength() + 1, - pTTTW->szText, sizeof(pTTTW->szText)/(sizeof pTTTW->szText[0])); + pTTTW->szText, ARRAYELEMCOUNT(pTTTW->szText)); } return TRUE; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |