From: <sag...@us...> - 2011-10-06 15:37:44
|
Revision: 1093 http://modplug.svn.sourceforge.net/modplug/?rev=1093&view=rev Author: saga-games Date: 2011-10-06 15:37:37 +0000 (Thu, 06 Oct 2011) Log Message: ----------- [New] Pattern Editor: Option to display default volume in the volume column if it is empty (obviously inspired by Impulse Tracker) [Mod] Internal: Changed floating point model to fast, explicitely enabled intrinsics (though /O2 should enable the implicitely) [Mod] OpenMPT: Version is now 1.20.00.39 Modified Paths: -------------- trunk/OpenMPT/mptrack/Draw_pat.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Moptions.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/View_pat.h trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/version.h Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Draw_pat.cpp 2011-10-06 12:21:52 UTC (rev 1092) +++ trunk/OpenMPT/mptrack/Draw_pat.cpp 2011-10-06 15:37:37 UTC (rev 1093) @@ -160,13 +160,23 @@ BYTE r,g,b; m_Dib.SetAllColors(0, MAX_MODCOLORS, CMainFrame::GetSettings().rgbCustomColors); + r = hilightcolor(GetRValue(CMainFrame::GetSettings().rgbCustomColors[MODCOLOR_BACKHILIGHT]), + GetRValue(CMainFrame::GetSettings().rgbCustomColors[MODCOLOR_BACKNORMAL])); + g = hilightcolor(GetGValue(CMainFrame::GetSettings().rgbCustomColors[MODCOLOR_BACKHILIGHT]), + GetGValue(CMainFrame::GetSettings().rgbCustomColors[MODCOLOR_BACKNORMAL])); + b = hilightcolor(GetBValue(CMainFrame::GetSettings().rgbCustomColors[MODCOLOR_BACKHILIGHT]), + GetBValue(CMainFrame::GetSettings().rgbCustomColors[MODCOLOR_BACKNORMAL])); + m_Dib.SetColor(MODCOLOR_2NDHIGHLIGHT, RGB(r,g,b)); + + r = hilightcolor(GetRValue(CMainFrame::GetSettings().rgbCustomColors[MODCOLOR_VOLUME]), GetRValue(CMainFrame::GetSettings().rgbCustomColors[MODCOLOR_BACKNORMAL])); - g = hilightcolor(GetGValue(CMainFrame::GetSettings().rgbCustomColors[MODCOLOR_BACKHILIGHT]), + g = hilightcolor(GetGValue(CMainFrame::GetSettings().rgbCustomColors[MODCOLOR_VOLUME]), GetGValue(CMainFrame::GetSettings().rgbCustomColors[MODCOLOR_BACKNORMAL])); - b = hilightcolor(GetBValue(CMainFrame::GetSettings().rgbCustomColors[MODCOLOR_BACKHILIGHT]), + b = hilightcolor(GetBValue(CMainFrame::GetSettings().rgbCustomColors[MODCOLOR_VOLUME]), GetBValue(CMainFrame::GetSettings().rgbCustomColors[MODCOLOR_BACKNORMAL])); - m_Dib.SetColor(MODCOLOR_2NDHIGHLIGHT, RGB(r,g,b)); + m_Dib.SetColor(MODCOLOR_DEFAULTVOLUME, RGB(r,g,b)); + m_Dib.SetBlendColor(CMainFrame::GetSettings().rgbCustomColors[MODCOLOR_BLENDCOLOR]); } @@ -429,8 +439,8 @@ } -void CViewPattern::DrawVolumeCommand(int x, int y, const MODCOMMAND mc) -//--------------------------------------------------------------------- +void CViewPattern::DrawVolumeCommand(int x, int y, const MODCOMMAND &mc, bool drawDefaultVolume) +//---------------------------------------------------------------------------------------------- { PCPATTERNFONT pfnt = GetCurrentPatternFont(); @@ -448,10 +458,34 @@ } else { - if (mc.volcmd) + static_assert(MAX_VOLCMDS <= 16, "Pattern draw code assumes <= 16 volume commands"); + int volcmd = (mc.volcmd & 0x0F); + int vol = (mc.vol & 0x7F); + + if(drawDefaultVolume) { - const int volcmd = (mc.volcmd & 0x0F); - const int vol = (mc.vol & 0x7F); + // Displaying sample default volume if there is no volume command. + const CSoundFile *pSndFile = GetDocument()->GetSoundFile(); + SAMPLEINDEX sample = mc.instr; + if(pSndFile->GetNumInstruments()) + { + if(mc.instr <= pSndFile->GetNumInstruments()) + { + sample = pSndFile->Instruments[mc.instr]->Keyboard[mc.note - NOTE_MIN]; + } else + { + sample = 0; + } + } + if(sample && sample <= pSndFile->GetNumSamples()) + { + volcmd = VOLCMD_VOLUME; + vol = pSndFile->GetSample(sample).nVolume / 4; + } + } + + if (volcmd) + { m_Dib.TextBlt(x, y, pfnt->nVolCmdWidth, COLUMN_HEIGHT, pfnt->nVolX, pfnt->nVolY+volcmd*COLUMN_HEIGHT); m_Dib.TextBlt(x+pfnt->nVolCmdWidth, y, pfnt->nVolHiWidth, COLUMN_HEIGHT, @@ -731,7 +765,8 @@ { BYTE bColSel[MAX_BASECHANNELS]; PCPATTERNFONT pfnt = GetCurrentPatternFont(); - MODCOMMAND m0, *pPattern = pSndFile->Patterns[nPattern]; + const MODCOMMAND m0 = MODCOMMAND::Empty(); + const MODCOMMAND *pPattern = pSndFile->Patterns[nPattern]; CHAR s[256]; CRect rect; int xpaint, ypaint = *pypaint; @@ -739,7 +774,6 @@ UINT bRowSel, bSpeedUp, nColumnWidth, ncols, maxcol; ncols = pSndFile->GetNumChannels(); - m0.note = m0.instr = m0.vol = m0.volcmd = m0.command = m0.param = 0; nColumnWidth = m_szCell.cx; rect.SetRect(m_szHeader.cx, rcClient.top, m_szHeader.cx+nColumnWidth, rcClient.bottom); for (UINT cmk=xofs; cmk<ncols; cmk++) @@ -855,15 +889,17 @@ xbmp = nbmp = 0; do { - DWORD dwSpeedUpMask; - MODCOMMAND *m; int x, bk_col, tx_col, col_sel, fx_col; - m = (pPattern) ? &pPattern[row*ncols+col] : &m0; - dwSpeedUpMask = 0; + const MODCOMMAND *m = (pPattern) ? &pPattern[row*ncols+col] : &m0; + + // Should empty volume commands be replaced with a volume command showing the default volume? + const bool drawDefaultVolume = (CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_SHOWDEFAULTVOLUME) && m->volcmd == VOLCMD_NONE && m->instr != 0 && m->note != NOTE_NONE && NOTE_IS_VALID(m->note); + + DWORD dwSpeedUpMask = 0; if ((bSpeedUp) && (bColSel[col] & 0x40) && (pPattern) && (row)) { - MODCOMMAND *mold = m - ncols; + const MODCOMMAND *mold = m - ncols; if (m->note == mold->note) dwSpeedUpMask |= 0x01; if ((m->instr == mold->instr) || (m_nDetailLevel < 1)) dwSpeedUpMask |= 0x02; if ( m->IsPcNote() || mold->IsPcNote() ) @@ -876,8 +912,8 @@ } else { - if (((m->volcmd == mold->volcmd) && ((!m->volcmd) || (m->vol == mold->vol))) || (m_nDetailLevel < 2)) dwSpeedUpMask |= 0x04; - if ((m->command == mold->command) || (m_nDetailLevel < 3)) dwSpeedUpMask |= (m->command) ? 0x08 : 0x18; + if ((m->volcmd == mold->volcmd && (m->volcmd == VOLCMD_NONE || m->vol == mold->vol) && !drawDefaultVolume) || (m_nDetailLevel < 2)) dwSpeedUpMask |= 0x04; + if ((m->command == mold->command) || (m_nDetailLevel < 3)) dwSpeedUpMask |= (m->command != CMD_NONE) ? 0x08 : 0x18; } if (dwSpeedUpMask == 0x1F) goto DoBlit; } @@ -958,15 +994,19 @@ { tx_col = MODCOLOR_TEXTSELECTED; bk_col = MODCOLOR_BACKSELECTED; - } else - if ((!m->IsPcNote()) && (m->volcmd) && (m->volcmd < MAX_VOLCMDS) && (CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_EFFECTHILIGHT)) + } else if (!m->IsPcNote() && (CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_EFFECTHILIGHT)) { - if(volEffectColors[m->volcmd] != 0) + if(m->volcmd != VOLCMD_NONE && m->volcmd < MAX_VOLCMDS && volEffectColors[m->volcmd] != 0) + { tx_col = volEffectColors[m->volcmd]; + } else if(drawDefaultVolume) + { + tx_col = MODCOLOR_DEFAULTVOLUME; + } } // Drawing Volume m_Dib.SetTextColor(tx_col, bk_col); - DrawVolumeCommand(xbmp+x, 0, *m); + DrawVolumeCommand(xbmp + x, 0, *m, drawDefaultVolume); } x += pfnt->nEltWidths[2]; } Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2011-10-06 12:21:52 UTC (rev 1092) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2011-10-06 15:37:37 UTC (rev 1093) @@ -157,6 +157,7 @@ MAX_MODCOLORS, // Internal color codes (not saved to color preset files) MODCOLOR_2NDHIGHLIGHT, + MODCOLOR_DEFAULTVOLUME, MAX_MODPALETTECOLORS }; @@ -193,7 +194,7 @@ #define PATTERN_AUTODELAY 0x2000000 // automatically insert delay commands in pattern when entering notes #define PATTERN_NOTEFADE 0x4000000 // alt. note fade behaviour when entering notes #define PATTERN_OVERFLOWPASTE 0x8000000 // continue paste in the next pattern instead of cutting off -//#define PATTERN_POSITIONAWARETIMER 0x10000000 // try to set the timer in the statusbar when jumping around in modules (deprecated, it generated too much load in the code due to some bugs, hence it was made optional. those bugs are now resolved, so there's no point in keeping this flag.) +#define PATTERN_SHOWDEFAULTVOLUME 0x10000000 // if there is no volume command next to note+instr, display the sample's default volume. #define PATTERN_RESETCHANNELS 0x20000000 // reset channels when looping #define PATTERN_LIVEUPDATETREE 0x40000000 // update active sample / instr icons in treeview Modified: trunk/OpenMPT/mptrack/Moptions.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moptions.cpp 2011-10-06 12:21:52 UTC (rev 1092) +++ trunk/OpenMPT/mptrack/Moptions.cpp 2011-10-06 15:37:37 UTC (rev 1093) @@ -562,6 +562,7 @@ {PATTERN_LIVEUPDATETREE,"Update sample status in tree", "If enabled, active samples and instruments will be indicated by a different icon in the treeview."}, {PATTERN_NOCLOSEDIALOG, "Disable modern close dialog", "When closing the main window, a confirmation window is shown for every unsaved document instead of one single window with a list of unsaved documents."}, {PATTERN_DBLCLICKSELECT, "Double-click to select channel", "Instead of showing the note properties, double-clicking a pattern cell selects the whole channel."}, + {PATTERN_SHOWDEFAULTVOLUME, "Show default volume commands", "If there is no volume command next to a note + instrument combination, the sample's default volume is shown."}, }; Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2011-10-06 12:21:52 UTC (rev 1092) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2011-10-06 15:37:37 UTC (rev 1093) @@ -366,8 +366,8 @@ m_dwPatternSetup &= ~0x200000; // dito if(vIniVersion < MAKE_VERSION_NUMERIC(1,20,00,07)) m_dwPatternSetup &= ~0x400000; // dito - if(vIniVersion < MptVersion::num) - m_dwPatternSetup &= ~0x10000000; // various deprecated old options + if(vIniVersion < MAKE_VERSION_NUMERIC(1,20,00,39)) + m_dwPatternSetup &= ~0x10000000; // dito m_nRowHighlightMeasures = CMainFrame::GetPrivateProfileDWord("Pattern Editor", "RowSpacing", m_nRowHighlightMeasures, iniFile); m_nRowHighlightBeats = CMainFrame::GetPrivateProfileDWord("Pattern Editor", "RowSpacing2", m_nRowHighlightBeats, iniFile); Modified: trunk/OpenMPT/mptrack/View_pat.h =================================================================== --- trunk/OpenMPT/mptrack/View_pat.h 2011-10-06 12:21:52 UTC (rev 1092) +++ trunk/OpenMPT/mptrack/View_pat.h 2011-10-06 15:37:37 UTC (rev 1093) @@ -208,7 +208,7 @@ void DrawLetter(int x, int y, char letter, int sizex=10, int ofsx=0); void DrawNote(int x, int y, UINT note, CTuning* pTuning = NULL); void DrawInstrument(int x, int y, UINT instr); - void DrawVolumeCommand(int x, int y, const MODCOMMAND mc); + void DrawVolumeCommand(int x, int y, const MODCOMMAND &mc, bool drawDefaultVolume); void DrawChannelVUMeter(HDC hdc, int x, int y, UINT nChn); void UpdateAllVUMeters(MPTNOTIFICATION *pnotify); void DrawDragSel(HDC hdc); Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2011-10-06 12:21:52 UTC (rev 1092) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2011-10-06 15:37:37 UTC (rev 1093) @@ -138,6 +138,8 @@ <CompileAs>Default</CompileAs> <ExceptionHandling>Async</ExceptionHandling> <AdditionalOptions>/O2 %(AdditionalOptions)</AdditionalOptions> + <IntrinsicFunctions>true</IntrinsicFunctions> + <FloatingPointModel>Fast</FloatingPointModel> </ClCompile> <ResourceCompile> <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-10-06 12:21:52 UTC (rev 1092) +++ trunk/OpenMPT/mptrack/version.h 2011-10-06 15:37:37 UTC (rev 1093) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 38 +#define VER_MINORMINOR 39 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-10-07 01:33:49
|
Revision: 1094 http://modplug.svn.sourceforge.net/modplug/?rev=1094&view=rev Author: saga-games Date: 2011-10-07 01:33:41 +0000 (Fri, 07 Oct 2011) Log Message: ----------- [Mod] Cleaned up tuning dialog. [Fix] Pattern Editor: Default volume display was not always updated properly when using Cut. [Imp] Song Properties: Song flags and such are now updated instantly when changing mod type. Modified Paths: -------------- trunk/OpenMPT/mptrack/TuningDialog.cpp trunk/OpenMPT/mptrack/TuningDialog.h trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/mptrack/mptrack.rc Modified: trunk/OpenMPT/mptrack/TuningDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/TuningDialog.cpp 2011-10-06 15:37:37 UTC (rev 1093) +++ trunk/OpenMPT/mptrack/TuningDialog.cpp 2011-10-07 01:33:41 UTC (rev 1094) @@ -302,8 +302,6 @@ } m_CombobTuningType.EnableWindow(enableControls); - m_EditTableSize.SetReadOnly(!enableControls); - m_EditBeginNote.SetReadOnly(!enableControls); m_EditSteps.SetReadOnly(!enableControls); m_EditRatioPeriod.SetReadOnly(!enableControls); m_EditRatio.SetReadOnly(!enableControls); @@ -323,8 +321,6 @@ if(m_pActiveTuning == NULL) //No active tuning, clearing tuning part. { m_EditName.SetWindowText(""); - m_EditTableSize.SetWindowText(""); - m_EditBeginNote.SetWindowText(""); m_EditSteps.SetWindowText(""); m_EditRatioPeriod.SetWindowText(""); m_EditRatio.SetWindowText(""); @@ -354,8 +350,6 @@ CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_STATICRATIOMAP, m_RatioMapWnd); DDX_Control(pDX, IDC_COMBO_TTYPE, m_CombobTuningType); - DDX_Control(pDX, IDC_EDIT_TABLESIZE, m_EditTableSize); - DDX_Control(pDX, IDC_EDIT_BEGINNOTE, m_EditBeginNote); DDX_Control(pDX, IDC_EDIT_STEPS, m_EditSteps); DDX_Control(pDX, IDC_EDIT_RATIOPERIOD, m_EditRatioPeriod); DDX_Control(pDX, IDC_EDIT_RATIOVALUE, m_EditRatio); Modified: trunk/OpenMPT/mptrack/TuningDialog.h =================================================================== --- trunk/OpenMPT/mptrack/TuningDialog.h 2011-10-06 15:37:37 UTC (rev 1093) +++ trunk/OpenMPT/mptrack/TuningDialog.h 2011-10-07 01:33:41 UTC (rev 1094) @@ -266,8 +266,6 @@ CComboBox m_CombobTuningType; //Tuning Edits--> - CEdit m_EditTableSize; - CEdit m_EditBeginNote; CEdit m_EditSteps; CEdit m_EditRatioPeriod; CEdit m_EditRatio; Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2011-10-06 15:37:37 UTC (rev 1093) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2011-10-07 01:33:41 UTC (rev 1094) @@ -905,25 +905,28 @@ CModDoc *pModDoc = GetDocument(); if (!pModDoc || !(IsEditingEnabled_bmsg())) return; CSoundFile *pSndFile = pModDoc->GetSoundFile(); - MODCOMMAND *p = pSndFile->Patterns[m_nPattern]; - if (!p) return; + if(pSndFile == nullptr || !pSndFile->Patterns.IsValidPat(m_nPattern)) + return; BeginWaitCursor(); - if(ITStyle && GetColTypeFromCursor(m_dwEndSel) == NOTE_COLUMN) m_dwEndSel += 1; //If selection ends to a note column, in ITStyle extending it to instrument column since the instrument data is //removed with note data. + if(ITStyle && GetColTypeFromCursor(m_dwEndSel) == NOTE_COLUMN) m_dwEndSel += 1; PrepareUndo(m_dwBeginSel, m_dwEndSel); - DWORD tmp = m_dwEndSel; - bool invalidateAllCols = false; + DWORD endCursor = m_dwEndSel; - for (UINT row = GetRowFromCursor(m_dwBeginSel); row <= GetRowFromCursor(m_dwEndSel); row++) { // for all selected rows - for (UINT i=(m_dwBeginSel & 0xFFFF); i<=(m_dwEndSel & 0xFFFF); i++) if (GetColTypeFromCursor(i) <= LAST_COLUMN) { // for all selected cols + for (ROWINDEX row = GetRowFromCursor(m_dwBeginSel); row <= GetRowFromCursor(m_dwEndSel); row++) + { + // for all selected rows + for (UINT i = (m_dwBeginSel & 0xFFFF); i <= (m_dwEndSel & 0xFFFF); i++) if (GetColTypeFromCursor(i) <= LAST_COLUMN) + { + // for all selected cols UINT chn = GetChanFromCursor(i); if ((chn >= pSndFile->m_nChannels) || (row >= pSndFile->Patterns[m_nPattern].GetNumRows())) continue; - MODCOMMAND *m = &p[row * pSndFile->m_nChannels + chn]; + MODCOMMAND *m = pSndFile->Patterns[m_nPattern].GetpModCommand(row, chn); switch(GetColTypeFromCursor(i)) { case NOTE_COLUMN: // Clear note @@ -932,7 +935,6 @@ if(m->IsPcNote()) { // Clear whole cell if clearing PC note m->Clear(); - invalidateAllCols = true; } else { @@ -956,7 +958,6 @@ if(m->IsPcNote()) { m->SetValueEffectCol(0); - invalidateAllCols = true; } } break; @@ -979,16 +980,13 @@ } //end selected columns } //end selected rows - // If selection ends on effect command column, extent invalidation area to - // effect param column as well. - if (GetColTypeFromCursor(tmp) == EFFECT_COLUMN) - tmp++; + // Expand invalidation to the whole column. Needed for: + // - Last column is the effect character (parameter needs to be invalidated, too + // - PC Notes + // - Default volume display is enabled. + endCursor += LAST_COLUMN - GetColTypeFromCursor(endCursor); - // If invalidation on all columns is wanted, extent invalidation area. - if(invalidateAllCols) - tmp += LAST_COLUMN - GetColTypeFromCursor(tmp); - - InvalidateArea(m_dwBeginSel, tmp); + InvalidateArea(m_dwBeginSel, endCursor); pModDoc->SetModified(); pModDoc->UpdateAllViews(this, HINT_PATTERNDATA | (m_nPattern << HINT_SHIFT_PAT), NULL); EndWaitCursor(); @@ -1195,7 +1193,7 @@ InvalidateRect(&m_rcDropItem, FALSE); - const bool duplicate = (nFlags & MK_SHIFT) ? true : false; + const bool duplicate = (nFlags & MK_SHIFT) != 0; const CHANNELINDEX newChannels = pModDoc->GetNumChannels() + (duplicate ? 1 : 0); vector<CHANNELINDEX> channels(newChannels, 0); CHANNELINDEX i = 0; @@ -1224,8 +1222,8 @@ { if(duplicate) { - pModDoc->UpdateAllViews(this, HINT_MODCHANNELS); - pModDoc->UpdateAllViews(this, HINT_MODTYPE); + // Number of channels changed: Update channel headers and other information. + pModDoc->UpdateAllViews(this, HINT_MODCHANNELS | HINT_MODTYPE); SetCurrentPattern(m_nPattern); } InvalidatePattern(); @@ -1233,9 +1231,11 @@ } } break; + case DRAGITEM_PATTERNHEADER: OnPatternProperties(); break; + case DRAGITEM_PLUGNAME: //rewbs.patPlugNames if (nItemNo < MAX_BASECHANNELS) TogglePluginEditor(nItemNo); @@ -1641,10 +1641,12 @@ void CViewPattern::OnSplitRecordSelect() { CModDoc *pModDoc = GetDocument(); - if (pModDoc){ + if (pModDoc) + { UINT nNumChn = pModDoc->GetNumChannels(); UINT nChn = GetChanFromCursor(m_nMenuParam); - if (nChn < nNumChn){ + if (nChn < nNumChn) + { pModDoc->Record2Channel(nChn); InvalidateChannelsHeaders(); } @@ -1731,7 +1733,7 @@ CSoundFile *pSndFile = pModDoc->GetSoundFile(); UINT nrows = GetRowFromCursor(m_dwEndSel) - GetRowFromCursor(m_dwBeginSel) + 1; DeleteRows(0, pSndFile->GetNumChannels() - 1, nrows); - m_dwEndSel = (m_dwEndSel & 0x0000FFFF) | (m_dwBeginSel & 0xFFFF0000); + m_dwEndSel = CreateCursor(GetRowFromCursor(m_dwBeginSel), GetChanFromCursor(m_dwEndSel), GetColTypeFromCursor(m_dwEndSel)); } void CViewPattern::InsertRows(UINT colmin, UINT colmax) //rewbs.customKeys: added args Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp 2011-10-06 15:37:37 UTC (rev 1093) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp 2011-10-07 01:33:41 UTC (rev 1094) @@ -70,9 +70,9 @@ m_nType = m_pSndFile->GetType(); m_nChannels = m_pSndFile->GetNumChannels(); m_dwSongFlags = m_pSndFile->m_dwSongFlags; - SetDlgItemInt(IDC_ROWSPERBEAT, m_pSndFile->m_nDefaultRowsPerBeat); - SetDlgItemInt(IDC_ROWSPERMEASURE, m_pSndFile->m_nDefaultRowsPerMeasure); + // Mod types + m_TypeBox.SetItemData(m_TypeBox.AddString("ProTracker MOD"), MOD_TYPE_MOD); m_TypeBox.SetItemData(m_TypeBox.AddString("ScreamTracker S3M"), MOD_TYPE_S3M); m_TypeBox.SetItemData(m_TypeBox.AddString("FastTracker XM"), MOD_TYPE_XM); @@ -94,6 +94,8 @@ default: m_TypeBox.SetCurSel(0); break; } + // Tempo modes + // Don't show new tempo modes for XM/IT, unless they are currently used const bool showNewTempoModes = (m_pSndFile->GetType() == MOD_TYPE_MPT || (m_pSndFile->m_dwSongFlags & SONG_ITPROJECT) != 0); @@ -112,6 +114,8 @@ } } + // Mix levels + m_PlugMixBox.SetItemData(m_PlugMixBox.AddString("OpenMPT 1.17RC3"), mixLevels_117RC3); if(m_pSndFile->m_nMixLevels == mixLevels_117RC2) // Only shown for backwards compatibility with existing tunes m_PlugMixBox.SetItemData(m_PlugMixBox.AddString("OpenMPT 1.17RC2"), mixLevels_117RC2); @@ -130,6 +134,19 @@ } } + // Misc flags + + CheckDlgButton(IDC_CHK_COMPATPLAY, m_pSndFile->GetModFlag(MSF_COMPATIBLE_PLAY)); + CheckDlgButton(IDC_CHK_MIDICCBUG, m_pSndFile->GetModFlag(MSF_MIDICC_BUGEMULATION)); + CheckDlgButton(IDC_CHK_OLDRANDOM, m_pSndFile->GetModFlag(MSF_OLDVOLSWING)); + + // Time signature information + + SetDlgItemInt(IDC_ROWSPERBEAT, m_pSndFile->m_nDefaultRowsPerBeat); + SetDlgItemInt(IDC_ROWSPERMEASURE, m_pSndFile->m_nDefaultRowsPerMeasure); + + // Version information + SetDlgItemText(IDC_TEXT_CREATEDWITH, "Created with:"); SetDlgItemText(IDC_TEXT_SAVEDWITH, "Last saved with:"); @@ -183,6 +200,8 @@ void CModTypeDlg::UpdateDialog() //------------------------------ { + const MODTYPE type = m_TypeBox.GetItemData(m_TypeBox.GetCurSel()); + UpdateChannelCBox(); m_CheckBox1.SetCheck((m_pSndFile->m_dwSongFlags & SONG_LINEARSLIDES) ? MF_CHECKED : 0); @@ -197,20 +216,20 @@ m_CheckBox6.SetCheck((m_pSndFile->m_dwSongFlags & SONG_ITPEMBEDIH) ? MF_CHECKED : 0); // -! NEW_FEATURE#0023 - m_CheckBox1.EnableWindow((m_pSndFile->m_nType & (MOD_TYPE_XM|MOD_TYPE_IT|MOD_TYPE_MPT)) ? TRUE : FALSE); - m_CheckBox2.EnableWindow((m_pSndFile->m_nType == MOD_TYPE_S3M) ? TRUE : FALSE); - m_CheckBox3.EnableWindow((m_pSndFile->m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT)) ? TRUE : FALSE); - m_CheckBox4.EnableWindow((m_pSndFile->m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT)) ? TRUE : FALSE); - m_CheckBox5.EnableWindow((m_pSndFile->m_nType & (MOD_TYPE_XM|MOD_TYPE_IT|MOD_TYPE_MPT)) ? TRUE : FALSE); - m_CheckBoxPT1x.EnableWindow((m_pSndFile->m_nType & (MOD_TYPE_MOD)) ? TRUE : FALSE); + m_CheckBox1.EnableWindow((type & (MOD_TYPE_XM|MOD_TYPE_IT|MOD_TYPE_MPT)) ? TRUE : FALSE); + m_CheckBox2.EnableWindow((type == MOD_TYPE_S3M) ? TRUE : FALSE); + m_CheckBox3.EnableWindow((type & (MOD_TYPE_IT|MOD_TYPE_MPT)) ? TRUE : FALSE); + m_CheckBox4.EnableWindow((type & (MOD_TYPE_IT|MOD_TYPE_MPT)) ? TRUE : FALSE); + m_CheckBox5.EnableWindow((type & (MOD_TYPE_XM|MOD_TYPE_IT|MOD_TYPE_MPT)) ? TRUE : FALSE); + m_CheckBoxPT1x.EnableWindow((type & (MOD_TYPE_MOD)) ? TRUE : FALSE); // -> CODE#0023 // -> DESC="IT project files (.itp)" m_CheckBox6.EnableWindow(m_TypeBox.GetCurSel() == 4 ? TRUE : FALSE); // -! NEW_FEATURE#0023 - const bool XMorITorMPT = ((m_TypeBox.GetItemData(m_TypeBox.GetCurSel()) & (MOD_TYPE_XM | MOD_TYPE_IT | MOD_TYPE_MPT)) != 0); - const bool ITorMPT = ((m_TypeBox.GetItemData(m_TypeBox.GetCurSel()) & (MOD_TYPE_IT | MOD_TYPE_MPT)) != 0); + const bool XMorITorMPT = (type & (MOD_TYPE_XM | MOD_TYPE_IT | MOD_TYPE_MPT)) != 0; + const bool ITorMPT = (type & (MOD_TYPE_IT | MOD_TYPE_MPT)) != 0; // Misc Flags if(ITorMPT) @@ -225,10 +244,6 @@ GetDlgItem(IDC_CHK_MIDICCBUG)->ShowWindow(XMorITorMPT); GetDlgItem(IDC_CHK_OLDRANDOM)->ShowWindow(ITorMPT); - CheckDlgButton(IDC_CHK_COMPATPLAY, m_pSndFile->GetModFlag(MSF_COMPATIBLE_PLAY)); - CheckDlgButton(IDC_CHK_MIDICCBUG, m_pSndFile->GetModFlag(MSF_MIDICC_BUGEMULATION)); - CheckDlgButton(IDC_CHK_OLDRANDOM, m_pSndFile->GetModFlag(MSF_OLDVOLSWING)); - // Deprecated flags are greyed out if they are not being used. GetDlgItem(IDC_CHK_MIDICCBUG)->EnableWindow(m_pSndFile->GetModFlag(MSF_MIDICC_BUGEMULATION) ? TRUE : FALSE); GetDlgItem(IDC_CHK_OLDRANDOM)->EnableWindow(m_pSndFile->GetModFlag(MSF_OLDVOLSWING) ? TRUE : FALSE); Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2011-10-06 15:37:37 UTC (rev 1093) +++ trunk/OpenMPT/mptrack/mptrack.rc 2011-10-07 01:33:41 UTC (rev 1094) @@ -2606,53 +2606,49 @@ CONTROL "Pattern Record",IDC_CHECK_PATRECORD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,114,20,65,10 END -IDD_TUNING DIALOGEX 0, 0, 512, 240 +IDD_TUNING DIALOGEX 0, 0, 512, 231 STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_THICKFRAME EXSTYLE WS_EX_CONTROLPARENT -CAPTION "Tuning properties" +CAPTION "Tuning Properties" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - DEFPUSHBUTTON "Close",IDOK,449,8,50,14 - CONTROL "",IDC_STATICRATIOMAP,"Static",SS_GRAYRECT | SS_NOTIFY | WS_TABSTOP,299,70,193,111,WS_EX_CLIENTEDGE - LTEXT "Tuning type",IDC_STATIC,109,116,46,8,SS_CENTERIMAGE - COMBOBOX IDC_COMBO_TTYPE,167,113,113,45,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Ratiotable size",IDC_STATIC,251,170,48,12,SS_CENTERIMAGE | NOT WS_VISIBLE - EDITTEXT IDC_EDIT_STEPS,167,162,66,12,ES_AUTOHSCROLL | ES_READONLY - LTEXT "Groupsize",IDC_STATIC,109,162,58,15,SS_CENTERIMAGE - LTEXT "Groupratio",IDC_STATIC,109,185,36,12,SS_CENTERIMAGE - EDITTEXT IDC_EDIT_RATIOPERIOD,167,186,66,12,ES_AUTOHSCROLL | ES_READONLY - LTEXT "Ratiotable begin note",IDC_STATIC,241,185,58,21,NOT WS_VISIBLE - EDITTEXT IDC_EDIT_BEGINNOTE,243,199,66,14,ES_AUTOHSCROLL | ES_READONLY | NOT WS_VISIBLE - EDITTEXT IDC_EDIT_TABLESIZE,245,178,66,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_VISIBLE - LTEXT "Ratio",IDC_STATIC,412,186,24,8,SS_CENTERIMAGE - EDITTEXT IDC_EDIT_RATIOVALUE,442,184,37,12,ES_AUTOHSCROLL | ES_WANTRETURN - LTEXT "Notename",IDC_STATIC,309,186,36,8,SS_CENTERIMAGE - EDITTEXT IDC_EDIT_NOTENAME,354,183,26,12,ES_AUTOHSCROLL | ES_WANTRETURN - PUSHBUTTON "Set",IDC_BUTTON_SETVALUES,389,203,23,12 - PUSHBUTTON "Import",IDC_BUTTON_IMPORT,451,26,48,13 - PUSHBUTTON "Export",IDC_BUTTON_EXPORT,451,44,48,13 - LTEXT "Multiply ",IDC_STATIC,309,204,29,12,SS_CENTERIMAGE - EDITTEXT IDC_EDIT_MISC_ACTIONS,353,202,30,13,ES_AUTOHSCROLL - LTEXT "Finetune steps",IDC_STATIC,109,207,48,12,SS_CENTERIMAGE - EDITTEXT IDC_EDIT_FINETUNESTEPS,167,207,66,12,ES_AUTOHSCROLL - CONTROL "Read Only",IDC_CHECK_READONLY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,109,74,126,12 - EDITTEXT IDC_EDIT_NAME,167,91,112,12,ES_AUTOHSCROLL | ES_READONLY - LTEXT "Name",IDC_STATIC,109,93,38,11 - GROUPBOX "Tuning",IDC_STATIC,104,63,395,168 - CONTROL "",IDC_TREE_TUNING,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_SHOWSELALWAYS | WS_BORDER | WS_TABSTOP,9,15,92,200 - GROUPBOX "Tuning collection",IDC_STATIC,104,6,342,55 - LTEXT "Name:",IDC_STATIC,111,18,45,9,SS_CENTERIMAGE - EDITTEXT IDC_EDIT_TUNINGCOLLECTION_NAME,167,16,90,12,ES_AUTOHSCROLL | ES_READONLY - LTEXT "Version",IDC_STATIC,109,32,41,9,SS_CENTERIMAGE - LTEXT "Number of tunings",IDC_STATIC,268,15,89,11,SS_CENTERIMAGE - LTEXT "Edit mask",IDC_STATIC,109,46,48,8,SS_CENTERIMAGE - EDITTEXT IDC_EDIT_TUNINGC_VERSION,168,31,90,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_VISIBLE - EDITTEXT IDC_EDIT_TUNINGC_EDITMASK,168,45,90,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_VISIBLE - EDITTEXT IDC_EDIT_TUNINGNUM,353,15,28,13,ES_AUTOHSCROLL | ES_READONLY - LTEXT "Filepath: ",IDC_STATIC,268,38,31,12,SS_CENTERIMAGE - EDITTEXT IDC_EDIT_TUNINGCOLLECTION_PATH,299,38,111,12,ES_AUTOHSCROLL | ES_READONLY - PUSHBUTTON "Save",IDC_BUTTON_TUNINGCOLLECTION_SAVE,410,38,32,12 - LTEXT "Static",IDC_TUNINGTYPE_DESC,109,134,179,20,0,WS_EX_STATICEDGE + DEFPUSHBUTTON "Close",IDOK,456,12,48,14 + PUSHBUTTON "Import",IDC_BUTTON_IMPORT,456,30,48,14 + PUSHBUTTON "Export",IDC_BUTTON_EXPORT,456,48,48,14 + CONTROL "",IDC_TREE_TUNING,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_SHOWSELALWAYS | WS_BORDER | WS_HSCROLL | WS_TABSTOP,6,6,96,222 + CONTROL "Read Only",IDC_CHECK_READONLY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,113,77,199,12 + LTEXT "Name:",IDC_STATIC,114,96,53,11 + EDITTEXT IDC_EDIT_NAME,168,96,144,12,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Tuning Type:",IDC_STATIC,114,122,46,8,SS_CENTERIMAGE + COMBOBOX IDC_COMBO_TTYPE,168,120,144,45,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "Static",IDC_TUNINGTYPE_DESC,114,138,198,20,0,WS_EX_STATICEDGE + LTEXT "Group Size:",IDC_STATIC,114,170,60,8,SS_CENTERIMAGE + EDITTEXT IDC_EDIT_STEPS,174,168,30,12,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Group Ratio:",IDC_STATIC,114,187,60,9,SS_CENTERIMAGE + EDITTEXT IDC_EDIT_RATIOPERIOD,174,186,30,12,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Finetune Steps:",IDC_STATIC,114,206,60,8,SS_CENTERIMAGE + EDITTEXT IDC_EDIT_FINETUNESTEPS,174,204,30,12,ES_AUTOHSCROLL + LTEXT "Note Name:",IDC_STATIC,210,170,39,8,SS_CENTERIMAGE + EDITTEXT IDC_EDIT_NOTENAME,252,168,30,12,ES_AUTOHSCROLL | ES_WANTRETURN + LTEXT "Ratio",IDC_STATIC,210,188,30,8,SS_CENTERIMAGE + EDITTEXT IDC_EDIT_RATIOVALUE,240,186,42,12,ES_AUTOHSCROLL | ES_WANTRETURN + LTEXT "Multiply:",IDC_STATIC,210,204,29,12,SS_CENTERIMAGE + EDITTEXT IDC_EDIT_MISC_ACTIONS,240,204,42,13,ES_AUTOHSCROLL + PUSHBUTTON "Set",IDC_BUTTON_SETVALUES,288,204,23,12 + CONTROL "",IDC_STATICRATIOMAP,"Static",SS_GRAYRECT | SS_NOTIFY | WS_TABSTOP,324,78,168,138,WS_EX_CLIENTEDGE + GROUPBOX "Tuning Editor",IDC_STATIC,108,66,395,162 + LTEXT "Name:",IDC_STATIC,114,19,35,9,SS_CENTERIMAGE + EDITTEXT IDC_EDIT_TUNINGCOLLECTION_NAME,162,18,84,12,ES_AUTOHSCROLL | ES_READONLY + LTEXT "File Path: ",IDC_STATIC,252,18,31,12,SS_CENTERIMAGE + EDITTEXT IDC_EDIT_TUNINGCOLLECTION_PATH,288,18,120,12,ES_AUTOHSCROLL | ES_READONLY + PUSHBUTTON "Save",IDC_BUTTON_TUNINGCOLLECTION_SAVE,414,18,30,12 + LTEXT "Number of tunings:",IDC_STATIC,114,36,72,11,SS_CENTERIMAGE + EDITTEXT IDC_EDIT_TUNINGNUM,186,36,60,13,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Version:",IDC_STATIC,252,37,35,9,SS_CENTERIMAGE + EDITTEXT IDC_EDIT_TUNINGC_VERSION,288,36,30,13,ES_AUTOHSCROLL | ES_READONLY | NOT WS_VISIBLE + LTEXT "Edit Mask:",IDC_STATIC,324,38,35,8,SS_CENTERIMAGE + EDITTEXT IDC_EDIT_TUNINGC_EDITMASK,366,36,78,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_VISIBLE + GROUPBOX "Tuning Collection",IDC_STATIC,108,6,342,54 END IDD_CHANNELMANAGER DIALOGEX 0, 0, 524, 231 @@ -2764,7 +2760,7 @@ VERTGUIDE, 268 VERTGUIDE, 299 VERTGUIDE, 442 - BOTTOMMARGIN, 236 + BOTTOMMARGIN, 227 END IDD_CHANNELMANAGER, DIALOG This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-10-07 19:32:19
|
Revision: 1097 http://modplug.svn.sourceforge.net/modplug/?rev=1097&view=rev Author: saga-games Date: 2011-10-07 19:32:12 +0000 (Fri, 07 Oct 2011) Log Message: ----------- [Fix] Pattern Drawing: Speed-up mask was not always handled correctly. Modified Paths: -------------- trunk/OpenMPT/mptrack/Draw_pat.cpp trunk/OpenMPT/mptrack/View_pat.h Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Draw_pat.cpp 2011-10-07 19:10:08 UTC (rev 1096) +++ trunk/OpenMPT/mptrack/Draw_pat.cpp 2011-10-07 19:32:12 UTC (rev 1097) @@ -894,12 +894,14 @@ const MODCOMMAND *m = (pPattern) ? &pPattern[row*ncols+col] : &m0; // Should empty volume commands be replaced with a volume command showing the default volume? - const bool drawDefaultVolume = (CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_SHOWDEFAULTVOLUME) && m->volcmd == VOLCMD_NONE && m->instr != 0 && m->note != NOTE_NONE && NOTE_IS_VALID(m->note); + const bool drawDefaultVolume = DrawDefaultVolume(m); DWORD dwSpeedUpMask = 0; if ((bSpeedUp) && (bColSel[col] & 0x40) && (pPattern) && (row)) { const MODCOMMAND *mold = m - ncols; + const bool drawOldDefaultVolume = DrawDefaultVolume(mold); + if (m->note == mold->note) dwSpeedUpMask |= 0x01; if ((m->instr == mold->instr) || (m_nDetailLevel < 1)) dwSpeedUpMask |= 0x02; if ( m->IsPcNote() || mold->IsPcNote() ) @@ -912,7 +914,7 @@ } else { - if ((m->volcmd == mold->volcmd && (m->volcmd == VOLCMD_NONE || m->vol == mold->vol) && !drawDefaultVolume) || (m_nDetailLevel < 2)) dwSpeedUpMask |= 0x04; + if ((m->volcmd == mold->volcmd && (m->volcmd == VOLCMD_NONE || m->vol == mold->vol) && !drawDefaultVolume && !drawOldDefaultVolume) || (m_nDetailLevel < 2)) dwSpeedUpMask |= 0x04; if ((m->command == mold->command) || (m_nDetailLevel < 3)) dwSpeedUpMask |= (m->command != CMD_NONE) ? 0x08 : 0x18; } if (dwSpeedUpMask == 0x1F) goto DoBlit; Modified: trunk/OpenMPT/mptrack/View_pat.h =================================================================== --- trunk/OpenMPT/mptrack/View_pat.h 2011-10-07 19:10:08 UTC (rev 1096) +++ trunk/OpenMPT/mptrack/View_pat.h 2011-10-07 19:32:12 UTC (rev 1097) @@ -213,6 +213,8 @@ void UpdateAllVUMeters(MPTNOTIFICATION *pnotify); void DrawDragSel(HDC hdc); void OnDrawDragSel(); + // True if default volume should be drawn for a given cell. + bool DrawDefaultVolume(const MODCOMMAND *m) const { return (CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_SHOWDEFAULTVOLUME) && m->volcmd == VOLCMD_NONE && m->instr != 0 && m->note != NOTE_NONE && NOTE_IS_VALID(m->note); } //rewbs.customKeys BOOL ExecuteCommand(CommandID command); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-10-15 23:42:26
|
Revision: 1105 http://modplug.svn.sourceforge.net/modplug/?rev=1105&view=rev Author: saga-games Date: 2011-10-15 23:42:19 +0000 (Sat, 15 Oct 2011) Log Message: ----------- [Fix] Pattern Editor: Fixed note interpolation (it was possible to interpolate between a note and f.e. note cut, but it was not possible to interpolate between a note and no note). [Mod] Plugin Window: Preset menu generation should now be a bit faster for plugins with lotsa presets (Synth1) [Imp] Sample Tuner: Added dialog where the pitch reference and target note can be specified. [Mod] OpenMPT: Version is now 1.20.00.43 Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/Autotune.cpp trunk/OpenMPT/mptrack/Autotune.h trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/mptrack/resource.h trunk/OpenMPT/mptrack/version.h Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2011-10-15 13:36:57 UTC (rev 1104) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2011-10-15 23:42:19 UTC (rev 1105) @@ -411,36 +411,48 @@ m_pPresetMenu->CreatePopupMenu(); } + const int numSubMenus = (numProgs / PRESETS_PER_GROUP) + 1; + if(numSubMenus > 1) + { + // Create sub menus if necessary + m_pPresetMenuGroup.SetSize(numSubMenus); + for(int i = 0; i < numSubMenus; i++) + { + m_pPresetMenuGroup[i] = new CMenu(); + m_pPresetMenuGroup[i]->CreatePopupMenu(); + + CString label; + label.Format("Bank %d (%d-%d)", i, 1 + i * PRESETS_PER_GROUP, 1 + min((i + 1) * PRESETS_PER_GROUP - 1, numProgs)); + m_pPresetMenu->AppendMenu(MF_POPUP, (UINT) m_pPresetMenuGroup[i]->m_hMenu, label); + } + } + + int subMenuIndex = 0; + int entryInThisMenu = 0; + int entryInThisColumn = 0; + + // If there would only be 1 submenu, we add directly to factory menu + CMenu *targetMenu = (numProgs > PRESETS_PER_GROUP) ? m_pPresetMenuGroup[subMenuIndex] : m_pPresetMenu; + for (long p = 0; p < numProgs; p++) { CString programName = m_pVstPlugin->GetFormattedProgramName(p); - // Get menu item properties - const bool checkedItem = (p == curProg); - const bool splitMenu = (p % PRESETS_PER_COLUMN == 0 && p % PRESETS_PER_GROUP != 0); - const int subMenuIndex = p / PRESETS_PER_GROUP; - - if (numProgs > PRESETS_PER_GROUP) + if(++entryInThisMenu == PRESETS_PER_GROUP) { - // If necessary, add to appropriate submenu. - if (subMenuIndex >= m_pPresetMenuGroup.GetSize()) - { - //create new submenu if required. - m_pPresetMenuGroup.SetSize(m_pPresetMenuGroup.GetSize() + 1); - m_pPresetMenuGroup[subMenuIndex] = new CMenu(); - m_pPresetMenuGroup[subMenuIndex]->CreatePopupMenu(); - - CString label; - label.Format("Bank %d (%d-%d)", subMenuIndex, 1 + subMenuIndex * PRESETS_PER_GROUP, 1 + min((subMenuIndex + 1) * PRESETS_PER_GROUP - 1, numProgs)); - m_pPresetMenu->AppendMenu(MF_POPUP, (UINT) m_pPresetMenuGroup[subMenuIndex]->m_hMenu, label); - } - m_pPresetMenuGroup[subMenuIndex]->AppendMenu(MF_STRING | (checkedItem ? MF_CHECKED : 0) | (splitMenu ? MF_MENUBARBREAK : 0), ID_PRESET_SET + p, programName); - - } else + // Advance to next preset group (sub menu) + subMenuIndex++; + targetMenu = m_pPresetMenuGroup[subMenuIndex]; + entryInThisMenu = 0; + } + UINT splitMenuFlag = 0; + if(++entryInThisColumn == PRESETS_PER_COLUMN) { - // If there would only be 1 submenu, we add directly to factory menu - m_pPresetMenu->AppendMenu(MF_STRING | (checkedItem ? MF_CHECKED : MF_UNCHECKED) | (splitMenu ? MF_MENUBARBREAK : 0), ID_PRESET_SET + p, programName); + entryInThisColumn = 0; + splitMenuFlag = MF_MENUBARBREAK; } + + targetMenu->AppendMenu(MF_STRING | (p == curProg ? MF_CHECKED : MF_UNCHECKED) | splitMenuFlag, ID_PRESET_SET + p, programName); } //Add Factory menu to main menu Modified: trunk/OpenMPT/mptrack/Autotune.cpp =================================================================== --- trunk/OpenMPT/mptrack/Autotune.cpp 2011-10-15 13:36:57 UTC (rev 1104) +++ trunk/OpenMPT/mptrack/Autotune.cpp 2011-10-15 23:42:19 UTC (rev 1105) @@ -19,25 +19,25 @@ #define MIN_SAMPLE_LENGTH 2 -double Autotune::FrequencyToNote(double freq) const -//------------------------------------------------- +double Autotune::FrequencyToNote(double freq, double pitchReference) const +//------------------------------------------------------------------------ { - return ((12.0 * (log(freq / (440.0 / 2.0)) / log(2.0))) + 57.0); + return ((12.0 * (log(freq / (pitchReference / 2.0)) / log(2.0))) + 57.0); } -double Autotune::NoteToFrequency(double note) const -//------------------------------------------------- +double Autotune::NoteToFrequency(double note, double pitchReference) const +//------------------------------------------------------------------------ { - return 440.0 * pow(2.0, (note - 69.0) / 12.0); + return pitchReference * pow(2.0, (note - 69.0) / 12.0); } // Calculate the amount of samples for autocorrelation shifting for a given note -SmpLength Autotune::NoteToShift(uint32 sampleFreq, int note) const -//------------------------------------------------------------------- +SmpLength Autotune::NoteToShift(uint32 sampleFreq, int note, double pitchReference) const +//--------------------------------------------------------------------------------------- { - const double fundamentalFrequency = NoteToFrequency((double)note / BINS_PER_NOTE); + const double fundamentalFrequency = NoteToFrequency((double)note / BINS_PER_NOTE, pitchReference); return (SmpLength)max(Util::Round((double)sampleFreq / fundamentalFrequency), 1); } @@ -134,14 +134,14 @@ bool Autotune::CanApply() const - //----------------------------- +//----------------------------- { return (sample.pSample != nullptr && sample.nLength >= MIN_SAMPLE_LENGTH); } -bool Autotune::Apply() -//-------------------- +bool Autotune::Apply(double pitchReference, int targetNote) +//--------------------------------------------------------- { if(!CanApply()) { @@ -154,7 +154,7 @@ const uint32 sampleFreq = sample.GetSampleRate(modType); // At the lowest frequency, we get the highest autocorrelation shift amount. - const SmpLength maxShift = NoteToShift(sampleFreq, autocorrStartNote); + const SmpLength maxShift = NoteToShift(sampleFreq, autocorrStartNote, pitchReference); if(!PrepareSample(maxShift)) { return false; @@ -174,7 +174,7 @@ noteBin %= historyBins; } - const SmpLength autocorrShift = NoteToShift(sampleFreq, note); + const SmpLength autocorrShift = NoteToShift(sampleFreq, note, pitchReference); uint64 autocorrSum = 0; const int8 *normalData = sampleData; @@ -207,29 +207,34 @@ // ...and find global minimum int minimumBin = 0; - //bool decrease = false; for(int i = 0; i < historyBins; i++) { const int prev = (i > 0) ? (i - 1) : (historyBins - 1); - // Are we at a minimum? - //if(interpolatedHistogram[i] > interpolatedHistogram[prev] && decrease) + // Are we at the global minimum? + if(interpolatedHistogram[prev] < interpolatedHistogram[minimumBin]) { - // Are we at the global minimum? - if(interpolatedHistogram[prev] < interpolatedHistogram[minimumBin]) - { - minimumBin = prev; - } + minimumBin = prev; } - //decrease = (interpolatedHistogram[i] < interpolatedHistogram[prev]); + } + // Center target notes around C + if(targetNote >= 6) + { + targetNote -= 12; } - // Center around C - if(minimumBin >= 6 * BINS_PER_NOTE) minimumBin -= 12 * BINS_PER_NOTE; - const double newFundamentalFreq = NoteToFrequency(69.0 + (double)minimumBin / BINS_PER_NOTE); + // Center bins around target note + minimumBin -= targetNote * BINS_PER_NOTE; + if(minimumBin >= 6 * BINS_PER_NOTE) + { + minimumBin -= 12 * BINS_PER_NOTE; + } + minimumBin += targetNote * BINS_PER_NOTE; - sample.nC5Speed = (UINT)Util::Round(sample.nC5Speed * 440.0 / newFundamentalFreq); + const double newFundamentalFreq = NoteToFrequency(static_cast<double>(69 - targetNote) + static_cast<double>(minimumBin) / BINS_PER_NOTE, pitchReference); + sample.nC5Speed = (UINT)Util::Round(sample.nC5Speed * pitchReference / newFundamentalFreq); + if((modType & (MOD_TYPE_XM | MOD_TYPE_MOD)) != 0) { CSoundFile::FrequencyToTranspose(&sample); @@ -241,3 +246,60 @@ return true; } + + +///////////////////////////////////////////////////////////// +// CAutotuneDlg + +int CAutotuneDlg::pitchReference = 440; // Pitch reference in Hz +int CAutotuneDlg::targetNote = 0; // Target note (C = 0, C# = 1, etc...) + +extern const LPCSTR szNoteNames[12]; + +void CAutotuneDlg::DoDataExchange(CDataExchange* pDX) +//--------------------------------------------------- +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CAutotuneDlg) + DDX_Control(pDX, IDC_COMBO1, m_CbnNoteBox); + //}}AFX_DATA_MAP +} + + +BOOL CAutotuneDlg::OnInitDialog() +//------------------------------- +{ + CDialog::OnInitDialog(); + + m_CbnNoteBox.ResetContent(); + for(int note = 0; note < 12; note++) + { + const int item = m_CbnNoteBox.AddString(szNoteNames[note]); + m_CbnNoteBox.SetItemData(item, note); + if(note == targetNote) + { + m_CbnNoteBox.SetCurSel(item); + } + } + + SetDlgItemInt(IDC_EDIT1, pitchReference, FALSE); + + return TRUE; +} + + +void CAutotuneDlg::OnOK() +//----------------------- +{ + CDialog::OnOK(); + + targetNote = m_CbnNoteBox.GetItemData(m_CbnNoteBox.GetCurSel()); + pitchReference = GetDlgItemInt(IDC_EDIT1); +} + + +void CAutotuneDlg::OnCancel() +//--------------------------- +{ + CDialog::OnCancel(); +} Modified: trunk/OpenMPT/mptrack/Autotune.h =================================================================== --- trunk/OpenMPT/mptrack/Autotune.h 2011-10-15 13:36:57 UTC (rev 1104) +++ trunk/OpenMPT/mptrack/Autotune.h 2011-10-15 23:42:19 UTC (rev 1105) @@ -12,6 +12,7 @@ #define AUTOTUNE_H #include "../soundlib/Snd_defs.h" +#include "resource.h" //============ class Autotune @@ -29,7 +30,7 @@ public: Autotune(MODSAMPLE &smp, MODTYPE type, SmpLength selStart, SmpLength selEnd) : sample(smp), modType(type), selectionStart(selStart), selectionEnd(selEnd) { - sampleData = 0; + sampleData = nullptr; sampleLength = 0; }; @@ -39,12 +40,12 @@ } bool CanApply() const; - bool Apply(); + bool Apply(double pitchReference, int targetNote); protected: - double FrequencyToNote(double freq) const; - double NoteToFrequency(double note) const; - SmpLength NoteToShift(uint32 sampleFreq, int note) const; + double FrequencyToNote(double freq, double pitchReference) const; + double NoteToFrequency(double note, double pitchReference) const; + SmpLength NoteToShift(uint32 sampleFreq, int note, double pitchReference) const; template <class T> void CopySamples(const T* origSample, SmpLength sampleLoopStart, SmpLength sampleLoopEnd); @@ -53,4 +54,30 @@ }; + +//================================= +class CAutotuneDlg : public CDialog +//================================= +{ +protected: + static int pitchReference; // Pitch reference (440Hz by default) + static int targetNote; // Note which the sample should be tuned to (C by default) + + CComboBox m_CbnNoteBox; + +public: + CAutotuneDlg(CWnd *parent) : CDialog(IDD_AUTOTUNE, parent) + { }; + + int GetPitchReference() const { return pitchReference; } + int GetTargetNote() const { return targetNote; } + +protected: + virtual BOOL OnInitDialog(); + virtual void OnOK(); + virtual void OnCancel(); + virtual void DoDataExchange(CDataExchange* pDX); + +}; + #endif // AUTOTUNE_H Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-10-15 13:36:57 UTC (rev 1104) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-10-15 23:42:19 UTC (rev 1105) @@ -3200,11 +3200,15 @@ Autotune at(m_pSndFile->GetSample(m_nSample), m_pSndFile->GetType(), selection.nStart, selection.nEnd); if(at.CanApply()) { - BeginWaitCursor(); - m_pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_none); - at.Apply(); - m_pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEINFO, NULL); - m_pModDoc->SetModified(); - EndWaitCursor(); + CAutotuneDlg dlg(this); + if(dlg.DoModal() == IDOK) + { + BeginWaitCursor(); + m_pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_none); + at.Apply(static_cast<double>(dlg.GetPitchReference()), dlg.GetTargetNote()); + m_pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEINFO, NULL); + m_pModDoc->SetModified(); + EndWaitCursor(); + } } } Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2011-10-15 13:36:57 UTC (rev 1104) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2011-10-15 23:42:19 UTC (rev 1105) @@ -2420,7 +2420,7 @@ bool changed = false; CArray<UINT,UINT> validChans; - if (type==EFFECT_COLUMN || type==PARAM_COLUMN) + if (type == EFFECT_COLUMN || type == PARAM_COLUMN) { CArray<UINT,UINT> moreValidChans; ListChansWhereColSelected(EFFECT_COLUMN, validChans); @@ -2464,6 +2464,14 @@ vdest = destCmd.note; vcmd = srcCmd.instr; verr = (distance * (NOTE_MAX - 1)) / NOTE_MAX; + if(srcCmd.note == NOTE_NONE) + { + vsrc = vdest; + vcmd = destCmd.note; + } else if(destCmd.note == NOTE_NONE) + { + vdest = vsrc; + } break; case VOL_COLUMN: vsrc = srcCmd.vol; @@ -2492,8 +2500,7 @@ PCinst = srcCmd.instr; if(PCinst == 0) PCinst = destCmd.instr; - } - else + } else { vsrc = srcCmd.param; vdest = destCmd.param; @@ -2524,7 +2531,7 @@ switch(type) { case NOTE_COLUMN: - if ((!pcmd->note) || (pcmd->instr == vcmd)) + if ((pcmd->note == NOTE_NONE) || (pcmd->instr == vcmd)) { int note = vsrc + ((vdest - vsrc) * i + verr) / distance; pcmd->note = (BYTE)note; @@ -2532,7 +2539,7 @@ } break; case VOL_COLUMN: - if ((!pcmd->volcmd) || (pcmd->volcmd == vcmd)) + if ((pcmd->volcmd == VOLCMD_NONE) || (pcmd->volcmd == vcmd)) { int vol = vsrc + ((vdest - vsrc) * i + verr) / distance; pcmd->vol = (BYTE)vol; @@ -2554,7 +2561,7 @@ } else { - if ((!pcmd->command) || (pcmd->command == vcmd)) + if ((pcmd->command == CMD_NONE) || (pcmd->command == vcmd)) { int val = vsrc + ((vdest - vsrc) * i + verr) / distance; pcmd->param = (BYTE)val; @@ -5581,17 +5588,24 @@ case NOTE_COLUMN: startRowCmd = startRowMC.note; endRowCmd = endRowMC.note; - result = (startRowCmd >= NOTE_MIN && endRowCmd >= NOTE_MIN); + result = (startRowCmd == endRowCmd && startRowCmd != NOTE_NONE) // Interpolate between two identical notes or Cut / Fade / etc... + || (startRowCmd != NOTE_NONE && endRowCmd == NOTE_NONE) // Fill in values from the first row + || (startRowCmd == NOTE_NONE && endRowCmd != NOTE_NONE) // Fill in values from the last row + || (NOTE_IS_VALID(startRowCmd) && NOTE_IS_VALID(endRowCmd) && !(startRowCmd == NOTE_NONE && endRowCmd == NOTE_NONE)); // Interpolate between two notes of which one may be empty break; case EFFECT_COLUMN: startRowCmd = startRowMC.command; endRowCmd = endRowMC.command; - result = (startRowCmd == endRowCmd && startRowCmd != CMD_NONE) || (startRowCmd != CMD_NONE && endRowCmd == CMD_NONE) || (startRowCmd == CMD_NONE && endRowCmd != CMD_NONE); + result = (startRowCmd == endRowCmd && startRowCmd != CMD_NONE) // Interpolate between two identical commands + || (startRowCmd != CMD_NONE && endRowCmd == CMD_NONE) // Fill in values from the first row + || (startRowCmd == CMD_NONE && endRowCmd != CMD_NONE); // Fill in values from the last row break; case VOL_COLUMN: startRowCmd = startRowMC.volcmd; endRowCmd = endRowMC.volcmd; - result = (startRowCmd == endRowCmd && startRowCmd != VOLCMD_NONE) || (startRowCmd != VOLCMD_NONE && endRowCmd == VOLCMD_NONE) || (startRowCmd == VOLCMD_NONE && endRowCmd != VOLCMD_NONE); + result = (startRowCmd == endRowCmd && startRowCmd != VOLCMD_NONE) // Interpolate between two identical commands + || (startRowCmd != VOLCMD_NONE && endRowCmd == VOLCMD_NONE) // Fill in values from the first row + || (startRowCmd == VOLCMD_NONE && endRowCmd != VOLCMD_NONE); // Fill in values from the last row break; default: result = false; Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2011-10-15 13:36:57 UTC (rev 1104) +++ trunk/OpenMPT/mptrack/mptrack.rc 2011-10-15 23:42:19 UTC (rev 1105) @@ -219,7 +219,22 @@ PUSHBUTTON "Save &None",IDC_BUTTON2,300,108,66,14 END +IDD_AUTOTUNE DIALOGEX 0, 0, 166, 82 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Sample Tuner" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + DEFPUSHBUTTON "OK",IDOK,54,60,50,14 + PUSHBUTTON "Cancel",IDCANCEL,108,60,50,14 + LTEXT "Tune sample to closest",IDC_STATIC,6,8,96,8 + COMBOBOX IDC_COMBO1,102,6,36,12,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP + LTEXT "Pitch reference (A)",IDC_STATIC,6,26,96,8 + EDITTEXT IDC_EDIT1,102,24,36,12,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "Hz",IDC_STATIC,144,26,18,8 + CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,6,48,150,1 +END + ///////////////////////////////////////////////////////////////////////////// // // DESIGNINFO @@ -315,6 +330,14 @@ TOPMARGIN, 7 BOTTOMMARGIN, 190 END + + IDD_AUTOTUNE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 159 + TOPMARGIN, 7 + BOTTOMMARGIN, 75 + END END #endif // APSTUDIO_INVOKED @@ -2546,7 +2569,7 @@ STRINGTABLE BEGIN IDC_SAMPLE_XFADE "Crossfade Loop Points\nCrossfade between loop start and loop end to create seamless sample loops." - IDC_SAMPLE_AUTOTUNE "Autotune sample to C\nTune the sample to the closest C." + IDC_SAMPLE_AUTOTUNE "Sample Tuner\nTune the sample to a given note." END #endif // English (United States) resources Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2011-10-15 13:36:57 UTC (rev 1104) +++ trunk/OpenMPT/mptrack/resource.h 2011-10-15 23:42:19 UTC (rev 1105) @@ -152,6 +152,7 @@ #define IDD_SAMPLE_XFADE 528 #define IDD_OPTIONS_UPDATE 529 #define IDD_CLOSEDOCUMENTS 530 +#define IDD_AUTOTUNE 531 #define IDC_BUTTON1 1001 #define IDC_BUTTON2 1002 #define IDC_BUTTON3 1003 @@ -1215,7 +1216,7 @@ #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 531 +#define _APS_NEXT_RESOURCE_VALUE 532 #define _APS_NEXT_COMMAND_VALUE 44474 #define _APS_NEXT_CONTROL_VALUE 2438 #define _APS_NEXT_SYMED_VALUE 901 Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-10-15 13:36:57 UTC (rev 1104) +++ trunk/OpenMPT/mptrack/version.h 2011-10-15 23:42:19 UTC (rev 1105) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 42 +#define VER_MINORMINOR 43 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-10-16 21:47:14
|
Revision: 1106 http://modplug.svn.sourceforge.net/modplug/?rev=1106&view=rev Author: saga-games Date: 2011-10-16 21:47:07 +0000 (Sun, 16 Oct 2011) Log Message: ----------- [Fix] Sample Editor: When converting between IT/MPTM and XM, the autovibrato limits were not updated. [Imp] Mod Conversion: Better IT <-> XM autovibrato conversion. Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/ModConvert.cpp Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-10-15 23:42:19 UTC (rev 1105) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-10-16 21:47:07 UTC (rev 1106) @@ -237,16 +237,6 @@ m_ComboAutoVib.AddString("Ramp Up"); m_ComboAutoVib.AddString("Ramp Down"); m_ComboAutoVib.AddString("Random"); - m_SpinVibSweep.SetRange(0, 255); - if(m_pSndFile->m_nType & MOD_TYPE_XM) - { - m_SpinVibDepth.SetRange(0, 15); - m_SpinVibRate.SetRange(0, 63); - } else - { - m_SpinVibDepth.SetRange(0, 32); - m_SpinVibRate.SetRange(0, 64); - } for (UINT i = BASENOTE_MIN; i < BASENOTE_MAX; i++) { @@ -275,7 +265,8 @@ // Pitch selection CComboBox *combo = (CComboBox *)GetDlgItem(IDC_COMBO4); - if(combo){ + if(combo) + { // Allow pitch from -12 (1 octave down) to +12 (1 octave up) for(int i = -12 ; i <= 12 ; i++){ if(i == 0) wsprintf(str,"none"); @@ -290,7 +281,8 @@ combo = (CComboBox *)GetDlgItem(IDC_COMBO5); if(combo){ // Allow quality from 4 to 128 - for(int i = 4 ; i <= 128 ; i++){ + for(int i = 4 ; i <= 128 ; i++) + { wsprintf(str,"%d",i); combo->SetItemData(combo->AddString(str), i-4); } @@ -300,7 +292,8 @@ // FFT size selection combo = (CComboBox *)GetDlgItem(IDC_COMBO6); - if(combo){ + if(combo) + { // Deduce exponent from equation : MAX_FRAME_LENGTH = 2^exponent int exponent = PowerOf2Exponent(MAX_FRAME_LENGTH); // Allow FFT size from 2^8 (256) to 2^exponent (MAX_FRAME_LENGTH) @@ -572,42 +565,51 @@ m_ComboLoopType.ResetContent(); m_ComboLoopType.AddString("Off"); m_ComboLoopType.AddString("On"); + // Sustain Loop Type m_ComboSustainType.ResetContent(); m_ComboSustainType.AddString("Off"); m_ComboSustainType.AddString("On"); + // Bidirectional Loops - if (m_pSndFile->m_nType & (MOD_TYPE_XM|MOD_TYPE_IT|MOD_TYPE_MPT)) + if (m_pSndFile->GetType() & (MOD_TYPE_XM|MOD_TYPE_IT|MOD_TYPE_MPT)) { m_ComboLoopType.AddString("Bidi"); m_ComboSustainType.AddString("Bidi"); } + // Loop Start m_SpinLoopStart.SetRange(-1, 1); m_SpinLoopStart.SetPos(0); + // Loop End m_SpinLoopEnd.SetRange(-1, 1); m_SpinLoopEnd.SetPos(0); + // Sustain Loop Start m_SpinSustainStart.SetRange(-1, 1); m_SpinSustainStart.SetPos(0); + // Sustain Loop End m_SpinSustainEnd.SetRange(-1, 1); m_SpinSustainEnd.SetPos(0); + // Sustain Loops only available in IT - b = (m_pSndFile->m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT)) ? TRUE : FALSE; + b = (m_pSndFile->GetType() & (MOD_TYPE_IT|MOD_TYPE_MPT)) ? TRUE : FALSE; m_ComboSustainType.EnableWindow(b); m_SpinSustainStart.EnableWindow(b); m_SpinSustainEnd.EnableWindow(b); m_EditSustainStart.EnableWindow(b); m_EditSustainEnd.EnableWindow(b); - // Finetune / C-4 Speed / BaseNote - b = (m_pSndFile->m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT)) ? TRUE : FALSE; + + // Finetune / C-5 Speed / BaseNote + b = (m_pSndFile->GetType() & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT)) ? TRUE : FALSE; SetDlgItemText(IDC_TEXT7, (b) ? "Freq. (Hz)" : "Finetune"); m_SpinFineTune.SetRange(-1, 1); m_EditFileName.EnableWindow(b); + // AutoVibrato - b = (m_pSndFile->m_nType & (MOD_TYPE_XM|MOD_TYPE_IT|MOD_TYPE_MPT)) ? TRUE : FALSE; + b = (m_pSndFile->GetType() & (MOD_TYPE_XM|MOD_TYPE_IT|MOD_TYPE_MPT)) ? TRUE : FALSE; m_ComboAutoVib.EnableWindow(b); m_SpinVibSweep.EnableWindow(b); m_SpinVibDepth.EnableWindow(b); @@ -615,17 +617,29 @@ m_EditVibSweep.EnableWindow(b); m_EditVibDepth.EnableWindow(b); m_EditVibRate.EnableWindow(b); + m_SpinVibSweep.SetRange(0, 255); + if(m_pSndFile->GetType() & MOD_TYPE_XM) + { + m_SpinVibDepth.SetRange(0, 15); + m_SpinVibRate.SetRange(0, 63); + } else + { + m_SpinVibDepth.SetRange(0, 32); + m_SpinVibRate.SetRange(0, 64); + } + // Global Volume - b = (m_pSndFile->m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT)) ? TRUE : FALSE; + b = (m_pSndFile->GetType() & (MOD_TYPE_IT|MOD_TYPE_MPT)) ? TRUE : FALSE; m_EditGlobalVol.EnableWindow(b); m_SpinGlobalVol.EnableWindow(b); + // Panning b = (m_pSndFile->GetType() & (MOD_TYPE_XM|MOD_TYPE_IT|MOD_TYPE_MPT)) ? TRUE : FALSE; m_CheckPanning.EnableWindow(b && !(m_pSndFile->GetType() & MOD_TYPE_XM)); m_EditPanning.EnableWindow(b); m_SpinPanning.EnableWindow(b); - b = (m_pSndFile->m_nType & MOD_TYPE_MOD) ? FALSE : TRUE; + b = (m_pSndFile->GetType() & MOD_TYPE_MOD) ? FALSE : TRUE; m_CbnBaseNote.EnableWindow(b); } // Updating Values Modified: trunk/OpenMPT/mptrack/ModConvert.cpp =================================================================== --- trunk/OpenMPT/mptrack/ModConvert.cpp 2011-10-15 23:42:19 UTC (rev 1105) +++ trunk/OpenMPT/mptrack/ModConvert.cpp 2011-10-16 21:47:07 UTC (rev 1106) @@ -321,7 +321,7 @@ } } - // All XM samples have default panning + // All XM samples have default panning, and XM's autovibrato settings are rather limited. if(newTypeIsXM) { if(!(sample.uFlags & CHN_PANNING)) @@ -329,23 +329,24 @@ sample.uFlags |= CHN_PANNING; sample.nPan = 128; } + + LimitMax(sample.nVibDepth, BYTE(15)); + LimitMax(sample.nVibRate, BYTE(63)); } + // S3M / MOD samples don't have panning. if(newTypeIsMOD || newTypeIsS3M) { sample.uFlags &= ~CHN_PANNING; } - if(oldTypeIsXM && newTypeIsIT_MPT) + if((oldTypeIsXM && newTypeIsIT_MPT) || (oldTypeIsIT_MPT && newTypeIsXM)) { - // Autovibrato settings (XM to IT, where sweep 0 means "no vibrato") - if(sample.nVibSweep == 0 && sample.nVibRate != 0 && sample.nVibDepth != 0) - sample.nVibSweep = 255; - } else if(oldTypeIsIT_MPT && newTypeIsXM) - { - // Autovibrato settings (IT to XM, where sweep 0 means "no sweep") - if(sample.nVibSweep == 0) - sample.nVibRate = sample.nVibDepth = 0; + // Autovibrato sweep setting is inverse in XM (0 = "no sweep") and IT (0 = "no vibrato") + if(sample.nVibRate != 0 && sample.nVibDepth != 0) + { + sample.nVibSweep = 255 - sample.nVibSweep; + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-10-16 21:59:41
|
Revision: 1107 http://modplug.svn.sourceforge.net/modplug/?rev=1107&view=rev Author: saga-games Date: 2011-10-16 21:59:35 +0000 (Sun, 16 Oct 2011) Log Message: ----------- [Mod] Plugin Window: Preset menu generation was kinda broken since two revisions ago. [Mod] OpenMPT: Version is now 1.20.00.44 Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/version.h Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2011-10-16 21:47:07 UTC (rev 1106) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2011-10-16 21:59:35 UTC (rev 1107) @@ -416,14 +416,14 @@ { // Create sub menus if necessary m_pPresetMenuGroup.SetSize(numSubMenus); - for(int i = 0; i < numSubMenus; i++) + for(int bank = 0, prog = 1; bank < numSubMenus; bank++, prog += PRESETS_PER_GROUP) { - m_pPresetMenuGroup[i] = new CMenu(); - m_pPresetMenuGroup[i]->CreatePopupMenu(); + m_pPresetMenuGroup[bank] = new CMenu(); + m_pPresetMenuGroup[bank]->CreatePopupMenu(); CString label; - label.Format("Bank %d (%d-%d)", i, 1 + i * PRESETS_PER_GROUP, 1 + min((i + 1) * PRESETS_PER_GROUP - 1, numProgs)); - m_pPresetMenu->AppendMenu(MF_POPUP, (UINT) m_pPresetMenuGroup[i]->m_hMenu, label); + label.Format("Bank %d (%d-%d)", bank + 1, prog, min(prog + PRESETS_PER_GROUP - 1, numProgs)); + m_pPresetMenu->AppendMenu(MF_POPUP | (bank % 32 == 0 ? MF_MENUBREAK : 0), (UINT) m_pPresetMenuGroup[bank]->m_hMenu, label); } } @@ -431,38 +431,33 @@ int entryInThisMenu = 0; int entryInThisColumn = 0; - // If there would only be 1 submenu, we add directly to factory menu + // If there would be only one sub menu, we add directly to factory menu CMenu *targetMenu = (numProgs > PRESETS_PER_GROUP) ? m_pPresetMenuGroup[subMenuIndex] : m_pPresetMenu; for (long p = 0; p < numProgs; p++) { CString programName = m_pVstPlugin->GetFormattedProgramName(p); + UINT splitMenuFlag = 0; - if(++entryInThisMenu == PRESETS_PER_GROUP) + if(entryInThisMenu++ == PRESETS_PER_GROUP) { // Advance to next preset group (sub menu) subMenuIndex++; targetMenu = m_pPresetMenuGroup[subMenuIndex]; - entryInThisMenu = 0; - } - UINT splitMenuFlag = 0; - if(++entryInThisColumn == PRESETS_PER_COLUMN) + entryInThisMenu = 1; + entryInThisColumn = 1; + } else if(entryInThisColumn++ == PRESETS_PER_COLUMN) { - entryInThisColumn = 0; + // Advance to next menu column + entryInThisColumn = 1; splitMenuFlag = MF_MENUBARBREAK; } targetMenu->AppendMenu(MF_STRING | (p == curProg ? MF_CHECKED : MF_UNCHECKED) | splitMenuFlag, ID_PRESET_SET + p, programName); } - //Add Factory menu to main menu - if (numProgs) - { - m_pMenu->InsertMenu(1, MF_BYPOSITION | MF_POPUP, (UINT) m_pPresetMenu->m_hMenu, (LPCTSTR)"&Presets"); - } else - { - m_pMenu->InsertMenu(1, MF_BYPOSITION | MF_POPUP | MF_GRAYED, (UINT) m_pPresetMenu->m_hMenu, (LPCTSTR)"&Presets"); - } + // Add Factory menu to main menu + m_pMenu->InsertMenu(1, MF_BYPOSITION | MF_POPUP | (numProgs ? 0 : MF_GRAYED), (UINT) m_pPresetMenu->m_hMenu, (LPCTSTR)"&Presets"); m_nCurProg=curProg; } Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-10-16 21:47:07 UTC (rev 1106) +++ trunk/OpenMPT/mptrack/version.h 2011-10-16 21:59:35 UTC (rev 1107) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 43 +#define VER_MINORMINOR 44 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-10-20 21:20:31
|
Revision: 1110 http://modplug.svn.sourceforge.net/modplug/?rev=1110&view=rev Author: saga-games Date: 2011-10-20 21:20:23 +0000 (Thu, 20 Oct 2011) Log Message: ----------- [Ref] Rewrote plugin parameter name retrieval to return CStrings. [Fix] VST: When automating parameters from a plugin GUI, it is first checked whether the parameter can be automated. This fixes usage of the Shift key (open MIDI Mapping dialog) in f.e. Ugo Motion and at the same time makes the Shift key work again in Synth1. [Mod] VST: Parameter indices are always displayed in decimal instead of hex and in a more consistent manner throughout the whole interface. Modified Paths: -------------- trunk/OpenMPT/mptrack/DefaultVstEditor.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/View_gen.cpp trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/Vstplug.h trunk/OpenMPT/mptrack/dlg_misc.cpp Modified: trunk/OpenMPT/mptrack/DefaultVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/DefaultVstEditor.cpp 2011-10-20 00:11:31 UTC (rev 1109) +++ trunk/OpenMPT/mptrack/DefaultVstEditor.cpp 2011-10-20 21:20:23 UTC (rev 1110) @@ -266,11 +266,7 @@ if(updateParamNames) { // Update param name - CString s; - CHAR sname[64]; - m_pVstPlugin->GetParamName(param, sname, sizeof(sname)); - s.Format("%02X: %s", paramOffset + i, sname); - controls[i]->SetParamName(s); + controls[i]->SetParamName(m_pVstPlugin->GetFormattedParamName(param)); } UpdateParamDisplay(param); @@ -482,6 +478,7 @@ SetParam(param, controls[param - paramOffset]->GetParamValueFromEdit()); } + // Called when a change occurs to the parameter slider // If the change is triggered by the user, we'll need to notify the plugin and update // the other GUI controls @@ -507,7 +504,7 @@ void CDefaultVstEditor::SetParam(PlugParamIndex param, int value) //--------------------------------------------------------------- { - if(m_pVstPlugin == nullptr) + if(m_pVstPlugin == nullptr || param >= m_pVstPlugin->GetNumParameters()) { return; } @@ -533,24 +530,15 @@ return; } - // Get the param value fromt the plug and massage it into the formats we need + // Get the actual parameter value from the plugin const int val = static_cast<int>(m_pVstPlugin->GetParameter(param) * static_cast<float>(PARAM_RESOLUTION) + 0.5f); - CString paramDisplay, paramUnits; - m_pVstPlugin->GetParamDisplay(param, paramDisplay.GetBuffer(64)); - m_pVstPlugin->GetParamLabel(param, paramUnits.GetBuffer(64)); - paramDisplay.ReleaseBuffer(); - paramUnits.ReleaseBuffer(); - paramDisplay.Trim(); - paramUnits.Trim(); - paramDisplay += " " + paramUnits; - // Update the GUI controls // Set lock to indicate that the changes to the GUI are internal - no need to notify the plug and re-update GUI. m_nControlLock++; - controls[param - paramOffset]->SetParamValue(val, paramDisplay); + controls[param - paramOffset]->SetParamValue(val, m_pVstPlugin->GetFormattedParamValue(param)); // Unset lock - done with internal GUI updates. m_nControlLock--; Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2011-10-20 00:11:31 UTC (rev 1109) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2011-10-20 21:20:23 UTC (rev 1110) @@ -2679,12 +2679,9 @@ void AddPluginParameternamesToCombobox(CComboBox& CBox, CVstPlugin& plug) //----------------------------------------------------------------------- { - char s[72], sname[64]; const PlugParamIndex nParams = plug.GetNumParameters(); for (PlugParamIndex i = 0; i < nParams; i++) { - plug.GetParamName(i, sname, sizeof(sname)); - wsprintf(s, "%02d: %s", i, sname); - CBox.SetItemData(CBox.AddString(s), i); + CBox.SetItemData(CBox.AddString(plug.GetFormattedParamName(i)), i); } } Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2011-10-20 00:11:31 UTC (rev 1109) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2011-10-20 21:20:23 UTC (rev 1110) @@ -3259,17 +3259,16 @@ case sfx_plug: { const int param = MacroToPlugParam(value); - char paramName[128] = { '\0' }; + CString paramName; if(plugin < MAX_MIXPLUGINS) { CVstPlugin *pPlug = (CVstPlugin*)m_SndFile.m_MixPlugins[plugin].pMixPlugin; if(pPlug) { - pPlug->GetParamName(param, paramName, sizeof(paramName)); - StringFixer::SetNullTerminator(paramName); + paramName = pPlug->GetParamName(param); } - if (paramName[0] == '\0') + if (paramName.IsEmpty()) { return _T("N/A"); } @@ -3842,8 +3841,8 @@ if (macroType==sfx_plug && MacroToPlugParam(macroText)==paramToUse) { CString message; - message.Format("Param %d can already be controlled with macro %X", paramToUse, checkMacro); - Reporting::Information(message, "Macro exists for this param"); + message.Format("Parameter %02d can already be controlled with macro %X.", paramToUse, checkMacro); + Reporting::Information(message, "Macro exists for this parameter"); return; } } @@ -3859,14 +3858,14 @@ } else { CString message; - message.Format("Param %d beyond controllable range.", paramToUse); - Reporting::Information(message, "Macro not assigned for this param"); + message.Format("Parameter %02d beyond controllable range. Use Parameter Control Events to automate this parameter.", paramToUse); + Reporting::Information(message, "Macro not assigned for this parameter"); return; } CString message; - message.Format("Param %d can now be controlled with macro %X", paramToUse, macroToSet); - Reporting::Information(message, "Macro assigned for this param"); + message.Format("Parameter %02d can now be controlled with macro %X.", paramToUse, macroToSet); + Reporting::Information(message, "Macro assigned for this parameter"); return; } Modified: trunk/OpenMPT/mptrack/View_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_gen.cpp 2011-10-20 00:11:31 UTC (rev 1109) +++ trunk/OpenMPT/mptrack/View_gen.cpp 2011-10-20 21:20:23 UTC (rev 1110) @@ -472,10 +472,7 @@ if(nParams) { - char sname[64]; - pVstPlugin->GetParamName(m_nCurrentParam, sname, sizeof(sname)); - wsprintf(s, "%02X: %s", m_nCurrentParam, sname); - m_CbnParam.SetItemData(m_CbnParam.AddString(s), m_nCurrentParam); + m_CbnParam.SetItemData(m_CbnParam.AddString(pVstPlugin->GetFormattedParamName(m_nCurrentParam)), m_nCurrentParam); } m_CbnParam.SetCurSel(0); @@ -970,10 +967,7 @@ if ((cursel >= 0) && (cursel < nParams)) m_nCurrentParam = cursel; if (m_nCurrentParam < nParams) { - CHAR sunits[64], sdisplay[64]; - pVstPlugin->GetParamLabel(m_nCurrentParam, sunits); - pVstPlugin->GetParamDisplay(m_nCurrentParam, sdisplay); - wsprintf(s, "Value: %s %s", sdisplay, sunits); + wsprintf(s, "Value: %s", pVstPlugin->GetFormattedParamValue(m_nCurrentParam)); SetDlgItemText(IDC_TEXT5, s); float fValue = pVstPlugin->GetParameter(m_nCurrentParam); int nValue = (int)(fValue * 100.0f + 0.5f); @@ -1535,9 +1529,7 @@ for(PlugParamIndex i = 0; i < nParams; i++) { - pVstPlugin->GetParamName(i, sname, sizeof(sname)); - wsprintf(s, "%02X: %s", i, sname); - m_CbnParam.SetItemData(m_CbnParam.AddString(s), i); + m_CbnParam.SetItemData(m_CbnParam.AddString(pVstPlugin->GetFormattedParamName(i)), i); } if (m_nCurrentParam >= nParams) m_nCurrentParam = 0; Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2011-10-20 00:11:31 UTC (rev 1109) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2011-10-20 21:20:23 UTC (rev 1110) @@ -5502,14 +5502,11 @@ HMENU paramChangeMenu = ::CreatePopupMenu(); AppendMenu(hMenu, MF_POPUP, (UINT)paramChangeMenu, "Change Plugin Parameter\t"); - char sname[64]; uint16 nThisParam = mSelStart->GetValueVolCol(); UINT nParams = plug->GetNumParameters(); for (UINT i = 0; i < nParams; i++) { - plug->GetParamName(i, sname, sizeof(sname)); - wsprintf(s, "%02d: %s", i, sname); - AppendMenu(paramChangeMenu, MF_STRING | (i == nThisParam) ? MF_CHECKED : 0, ID_CHANGE_PCNOTE_PARAM + i, s); + AppendMenu(paramChangeMenu, MF_STRING | (i == nThisParam) ? MF_CHECKED : 0, ID_CHANGE_PCNOTE_PARAM + i, plug->GetFormattedParamName(i)); } } Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2011-10-20 00:11:31 UTC (rev 1109) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2011-10-20 21:20:23 UTC (rev 1110) @@ -688,8 +688,12 @@ case audioMasterAutomate: if (effect && effect->resvd1) { - CVstPlugin *pVstPlugin = ((CVstPlugin*)effect->resvd1); - pVstPlugin->AutomateParameter(index); + CVstPlugin *pVstPlugin = reinterpret_cast<CVstPlugin *>(effect->resvd1); + if(pVstPlugin->Dispatch(effCanBeAutomated, index, nullptr, nullptr, 0.0f) != 0) + { + // This parameter can be automated. Ugo Motion constantly sends automation callback events for parameters that cannot be automated... + pVstPlugin->AutomateParameter((PlugParamIndex)index); + } } return 0; // Called when plugin asks for VST version supported by host @@ -731,7 +735,7 @@ // <value> should contain a mask indicating which fields are required case audioMasterGetTime: { - CVstPlugin* pVstPlugin = (CVstPlugin*)effect->resvd1; + CVstPlugin* pVstPlugin = reinterpret_cast<CVstPlugin *>(effect->resvd1); MemsetZero(timeInfo); timeInfo.sampleRate = CMainFrame::GetMainFrame()->GetSampleRate(); @@ -802,7 +806,7 @@ //Screw it! Let's just return the tempo at this point in time (might be a bit wrong). if (effect->resvd1) { - CSoundFile *pSndFile = ((CVstPlugin*)effect->resvd1)->GetSoundFile(); + CSoundFile *pSndFile = reinterpret_cast<CVstPlugin *>(effect->resvd1)->GetSoundFile(); if (pSndFile) { return (VstInt32)(pSndFile->GetCurrentBPM() * 10000); @@ -825,7 +829,7 @@ case audioMasterNeedIdle: if (effect && effect->resvd1) { - CVstPlugin* pVstPlugin = (CVstPlugin*)effect->resvd1; + CVstPlugin* pVstPlugin = reinterpret_cast<CVstPlugin *>(effect->resvd1); pVstPlugin->m_bNeedIdle=true; } @@ -834,18 +838,18 @@ case audioMasterSizeWindow: if (effect->resvd1) { - CVstPlugin *pVstPlugin = ((CVstPlugin*)effect->resvd1); + CVstPlugin *pVstPlugin = reinterpret_cast<CVstPlugin *>(effect->resvd1); CAbstractVstEditor *pVstEditor = pVstPlugin->GetEditor(); if (pVstEditor) { - CRect rcWnd, rcClient; - pVstEditor->GetWindowRect(rcWnd); - pVstEditor->GetClientRect(rcClient); + CRect rcWnd, rcClient; + pVstEditor->GetWindowRect(rcWnd); + pVstEditor->GetClientRect(rcClient); - rcWnd.right = rcWnd.left + (rcWnd.right-rcWnd.left) - (rcClient.right-rcClient.left) + index; - rcWnd.bottom = rcWnd.top + (rcWnd.bottom-rcWnd.top) - (rcClient.bottom-rcClient.top) + value; + rcWnd.right = rcWnd.left + (rcWnd.Width()) - (rcClient.Width()) + index; + rcWnd.bottom = rcWnd.top + (rcWnd.Height()) - (rcClient.Height()) + value; - pVstEditor->SetWindowPos(NULL, rcWnd.left, rcWnd.top, rcWnd.Width(), rcWnd.Height(), SWP_NOMOVE | SWP_NOZORDER); + pVstEditor->SetWindowPos(NULL, rcWnd.left, rcWnd.top, rcWnd.Width(), rcWnd.Height(), SWP_NOMOVE | SWP_NOZORDER); } } Log("VST plugin to host: Size Window\n"); @@ -976,7 +980,7 @@ case audioMasterUpdateDisplay: if (effect && effect->resvd1) { -// CVstPlugin *pVstPlugin = ((CVstPlugin*)effect->resvd1); +// CVstPlugin *pVstPlugin = reinterpret_cast<CVstPlugin *>(effect->resvd1); // pVstPlugin->GetModDoc()->UpdateAllViews(NULL, HINT_MIXPLUGINS, NULL); //No Need. /* CAbstractVstEditor *pVstEditor = pVstPlugin->GetEditor(); @@ -1334,7 +1338,7 @@ Dispatch(effOpen, 0, 0, NULL, 0); // VST 2.0 plugins return 2 here, VST 2.4 plugins return 2400... Great! - m_bIsVst2 = (CVstPlugin::Dispatch(effGetVstVersion, 0,0, NULL, 0) >= 2) ? true : false; + m_bIsVst2 = (CVstPlugin::Dispatch(effGetVstVersion, 0,0, NULL, 0) >= 2); if (m_bIsVst2) { // Set VST speaker in/out setup to Stereo. Required for some plugins (possibly all VST 2.4+ plugins?) @@ -1834,41 +1838,50 @@ } -void CVstPlugin::GetParamName(UINT nIndex, LPSTR pszName, UINT cbSize) -//-------------------------------------------------------------------- +// Helper function for retreiving parameter name / label / display +CString CVstPlugin::GetParamPropertyString(VstInt32 param, VstInt32 opcode) +//------------------------------------------------------------------------- { - if ((!pszName) || (!cbSize)) return; - pszName[0] = 0; - if ((m_pEffect) && (m_pEffect->numParams > 0) && (nIndex < (UINT)m_pEffect->numParams)) + CHAR s[max(kVstMaxParamStrLen, 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) { - CHAR s[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; - Dispatch(effGetParamName, nIndex, 0, s, 0); - s[min(CountOf(s) - 1, cbSize - 1)] = 0; - lstrcpyn(pszName, s, min(cbSize, sizeof(s))); + Dispatch(opcode, param, 0, s, 0); + StringFixer::SetNullTerminator(s); } + return CString(s); } -void CVstPlugin::GetParamLabel(UINT nIndex, LPSTR pszLabel) -//--------------------------------------------------------- +CString CVstPlugin::GetFormattedParamName(PlugParamIndex param) +//------------------------------------------------------------- { - pszLabel[0] = 0; - if ((m_pEffect) && (m_pEffect->numParams > 0) && (nIndex < (UINT)m_pEffect->numParams)) + const CString paramName = GetParamName(param); + CString name; + if(paramName.IsEmpty()) { - Dispatch(effGetParamLabel, nIndex, 0, pszLabel, 0); + name.Format("Parameter %02d", param); + } else + { + name.Format("%02d: %s", param, paramName); } + return name; } -void CVstPlugin::GetParamDisplay(UINT nIndex, LPSTR pszDisplay) -//------------------------------------------------------------- +// Get a parameter's current value, represented by the plugin. +CString CVstPlugin::GetFormattedParamValue(PlugParamIndex param) +//-------------------------------------------------------------- { - pszDisplay[0] = 0; - if ((m_pEffect) && (m_pEffect->numParams > 0) && (nIndex < (UINT)m_pEffect->numParams)) - { - Dispatch(effGetParamDisplay, nIndex, 0, pszDisplay, 0); - } + + CString paramDisplay = GetParamDisplay(param); + CString paramUnits = GetParamLabel(param); + paramDisplay.Trim(); + paramUnits.Trim(); + paramDisplay += " " + paramUnits; + + return paramDisplay; } @@ -2671,6 +2684,12 @@ return; } + if (m_bRecordAutomation) + { + // Record parameter change + pModDoc->RecordParamChange(GetSlot(), param); + } + CAbstractVstEditor *pVstEditor = GetEditor(); if(pVstEditor && pVstEditor->m_hWnd) @@ -2680,33 +2699,24 @@ { CMainFrame::GetMainFrame()->ThreadSafeSetModified(pModDoc); } - } - // TODO: Could be used to update general tab in real time, but causes flickers in treeview - // Better idea: add an update hint just for plugin params? - //pModDoc->UpdateAllViews(NULL, HINT_MIXPLUGINS, NULL); + // TODO: Could be used to update general tab in real time, but causes flickers in treeview + // Better idea: add an update hint just for plugin params? + //pModDoc->UpdateAllViews(NULL, HINT_MIXPLUGINS, NULL); - if (m_bRecordAutomation) - { - // Record param change - pModDoc->RecordParamChange(GetSlot(), param); - } + if (CMainFrame::GetInputHandler()->ShiftPressed()) + { + // Shift pressed -> Open MIDI mapping dialog + CMainFrame::GetInputHandler()->SetModifierMask(0); // Make sure that the dialog will open only once. - if (CMainFrame::GetInputHandler()->ShiftPressed() && pVstEditor && (pVstEditor->m_hWnd == ::GetForegroundWindow() || ::IsChild(pVstEditor->m_hWnd, ::GetForegroundWindow()))) - { - // Shift pressed -> Open MIDI mapping dialog - CMainFrame::GetInputHandler()->SetModifierMask(0); // Make sure that the dialog will open only once. + const HWND oldMIDIRecondWnd = CMainFrame::GetMainFrame()->GetMidiRecordWnd(); + CMIDIMappingDialog dlg(pVstEditor, *pModDoc->GetSoundFile()); + dlg.m_Setting.SetParamIndex(param); + dlg.m_Setting.SetPlugIndex(GetSlot() + 1); + dlg.DoModal(); + CMainFrame::GetMainFrame()->SetMidiRecordWnd(oldMIDIRecondWnd); + } - const HWND oldMIDIRecondWnd = CMainFrame::GetMainFrame()->GetMidiRecordWnd(); - CMIDIMappingDialog dlg(pVstEditor, *pModDoc->GetSoundFile()); - dlg.m_Setting.SetParamIndex(param); - dlg.m_Setting.SetPlugIndex(GetSlot() + 1); - dlg.DoModal(); - CMainFrame::GetMainFrame()->SetMidiRecordWnd(oldMIDIRecondWnd); - } - - if(pVstEditor) - { // Learn macro int macroToLearn = pVstEditor->GetLearnMacro(); if (macroToLearn > -1) @@ -2715,7 +2725,6 @@ pVstEditor->SetLearnMacro(-1); } } - } @@ -3016,7 +3025,7 @@ bool CVstPlugin::isInstrument() // ericus 18/02/2005 //----------------------------- { - if(m_pEffect) return ((m_pEffect->flags & effFlagsIsSynth) || (!m_pEffect->numInputs)) ? true : false; // rewbs.dryRatio + if(m_pEffect) return ((m_pEffect->flags & effFlagsIsSynth) || (!m_pEffect->numInputs)); // rewbs.dryRatio return false; } @@ -3024,7 +3033,7 @@ //------------------------------------- { CString s = "receiveVstMidiEvent"; - return (CVstPlugin::Dispatch(effCanDo, 0, 0, (char*)(LPCTSTR)s, 0)) ? true : false; + return (CVstPlugin::Dispatch(effCanDo, 0, 0, (char*)(LPCTSTR)s, 0) != 0); } void CVstPlugin::GetOutputPlugList(CArray<CVstPlugin*, CVstPlugin*> &list) @@ -3040,7 +3049,7 @@ UINT nOutput = m_pMixStruct->Info.dwOutputRouting & 0x7f; if (m_pSndFile && (nOutput > m_nSlot) && (nOutput < MAX_MIXPLUGINS)) { - pOutputPlug = (CVstPlugin*) m_pSndFile->m_MixPlugins[nOutput].pMixPlugin; + pOutputPlug = reinterpret_cast<CVstPlugin *>(m_pSndFile->m_MixPlugins[nOutput].pMixPlugin); } } list.Add(pOutputPlug); @@ -3059,7 +3068,7 @@ for (int nPlug=0; nPlug<MAX_MIXPLUGINS; nPlug++) { - pCandidatePlug = (CVstPlugin*) m_pSndFile->m_MixPlugins[nPlug].pMixPlugin; + pCandidatePlug = reinterpret_cast<CVstPlugin *>(m_pSndFile->m_MixPlugins[nPlug].pMixPlugin); if (pCandidatePlug) { pCandidatePlug->GetOutputPlugList(candidatePlugOutputs); @@ -4050,10 +4059,7 @@ { if(pMixPlugin) { - char s[64]; - ((CVstPlugin*)(pMixPlugin))->GetParamName(index, s, sizeof(s)); - s[sizeof(s)-1] = 0; - return CString(s); + return reinterpret_cast<CVstPlugin *>(pMixPlugin)->GetParamName(index); } else return CString(); Modified: trunk/OpenMPT/mptrack/Vstplug.h =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.h 2011-10-20 00:11:31 UTC (rev 1109) +++ trunk/OpenMPT/mptrack/Vstplug.h 2011-10-20 21:20:23 UTC (rev 1110) @@ -134,18 +134,15 @@ void GetEditorPos(int &x, int &y) const { x = m_nEditorX; y = m_nEditorY; } void SetCurrentProgram(UINT nIndex); -//rewbs.VSTCompliance: Eric's non standard preset stuff: -// -> CODE#0002 -// -> DESC="VST plugins presets" - //VOID GetProgramName(UINT nIndex, LPSTR pszName, UINT cbSize); - //BOOL SavePreset(LPCSTR lpszFileName); - //BOOL LoadPreset(LPCSTR lpszFileName); -// -! NEW_FEATURE#0002 PlugParamValue GetParameter(PlugParamIndex nIndex); void SetParameter(PlugParamIndex nIndex, PlugParamValue fValue); - void GetParamName(UINT nIndex, LPSTR pszName, UINT cbSize); - void GetParamLabel(UINT nIndex, LPSTR pszLabel); - void GetParamDisplay(UINT nIndex, LPSTR pszDisplay); + + CString GetFormattedParamName(PlugParamIndex param); + CString GetFormattedParamValue(PlugParamIndex param); + CString GetParamName(PlugParamIndex param) { return GetParamPropertyString(param, effGetParamName); }; + CString GetParamLabel(PlugParamIndex param) { return GetParamPropertyString(param, effGetParamLabel); }; + CString GetParamDisplay(PlugParamIndex param) { return GetParamPropertyString(param, effGetParamDisplay); }; + VstIntPtr Dispatch(VstInt32 opCode, VstInt32 index, VstIntPtr value, void *ptr, float opt); void ToggleEditor(); void GetPluginType(LPSTR pszType); @@ -205,20 +202,27 @@ private: short getMIDI14bitValueFromShort(short value); void MidiPitchBend(UINT nMidiCh, short pitchBendPos); + + // Helper function for retreiving parameter name / label / display + CString GetParamPropertyString(VstInt32 param, VstInt32 opcode); + #else // case: NO_VST public: PlugParamIndex GetNumParameters() {return 0;} - void GetParamName(UINT, LPSTR, UINT) {} void ToggleEditor() {} BOOL HasEditor() {return FALSE;} UINT GetNumCommands() {return 0;} void GetPluginType(LPSTR) {} PlugParamIndex GetNumPrograms() {return 0;} - bool GetProgramNameIndexed(long, long, char*) {return false;} - CString GetFormattedProgramName(VstInt32 index, bool allowFallback = false) { return ""; }; - void SetParameter(PlugParamIndex nIndex, PlugParamValue fValue) {} - void GetParamLabel(UINT, LPSTR) {} - void GetParamDisplay(UINT, LPSTR) {} + bool GetProgramNameIndexed(long, long, char*) { return false; } + CString GetFormattedProgramName(VstInt32, bool = false) { return ""; }; + void SetParameter(PlugParamIndex, PlugParamValue) {} + + CString GetFormattedParamName(PlugParamIndex) { return ""; }; + CString GetParamName(PlugParamIndex) { return ""; }; + CString GetParamLabel(PlugParamIndex) { return ""; }; + CString GetParamDisplay(PlugParamIndex) { return ""; }; + PlugParamValue GetParameter(PlugParamIndex nIndex) {return 0;} bool LoadProgram(CString) {return false;} bool SaveProgram(CString) {return false;} Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp 2011-10-20 00:11:31 UTC (rev 1109) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp 2011-10-20 21:20:23 UTC (rev 1110) @@ -1073,11 +1073,10 @@ if (!m_pSndFile) return; - CString message, plugName, paramName, line; + CString message, plugName, line; int sfx = id-ID_PLUGSELECT; int param = m_pModDoc->MacroToPlugParam(m_MidiCfg.szMidiSFXExt[sfx]); CVstPlugin *pVstPlugin; - char s[256]; message.Format("These are the parameters that can be controlled by macro SF%X:\n\n",sfx); for (UINT plug=0; plug<MAX_MIXPLUGINS; plug++) @@ -1086,11 +1085,9 @@ if (plugName != "") { pVstPlugin=(CVstPlugin*) m_pSndFile->m_MixPlugins[plug].pMixPlugin; - if (pVstPlugin && pVstPlugin->GetNumParameters()>param) + if (pVstPlugin && param <= pVstPlugin->GetNumParameters()) { - pVstPlugin->GetParamName(param, s, 256); - paramName = s; - line.Format("FX%d: %s\t Param %d (%x): %s\n", plug + 1, plugName, param, param+80, paramName); + line.Format("FX%d: %s\t %s\n", plug + 1, plugName, pVstPlugin->GetFormattedParamName(param)); message += line; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-10-21 15:35:27
|
Revision: 1114 http://modplug.svn.sourceforge.net/modplug/?rev=1114&view=rev Author: saga-games Date: 2011-10-21 15:35:19 +0000 (Fri, 21 Oct 2011) Log Message: ----------- [Mod] Improved plugin GUI resize mechanism. [Ref] Minor cleanup Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.h trunk/OpenMPT/mptrack/DefaultVstEditor.cpp trunk/OpenMPT/mptrack/DefaultVstEditor.h trunk/OpenMPT/mptrack/VSTEditor.cpp trunk/OpenMPT/mptrack/VSTEditor.h trunk/OpenMPT/mptrack/View_gen.cpp trunk/OpenMPT/mptrack/Vstplug.cpp Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.h =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.h 2011-10-21 00:25:23 UTC (rev 1113) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.h 2011-10-21 15:35:19 UTC (rev 1114) @@ -42,12 +42,16 @@ afx_msg LRESULT OnCustomKeyMsg(WPARAM, LPARAM); //rewbs.customKeys //Overridden methods: - virtual VOID OnOK()=0; - virtual VOID OnCancel()=0; - virtual BOOL OpenEditor(CWnd *parent)=0; - virtual VOID DoClose()=0; - virtual void UpdateParamDisplays()=0; - virtual afx_msg void OnClose()=0; + virtual void OnOK() = 0; + virtual void OnCancel() = 0; + virtual bool OpenEditor(CWnd *parent) = 0; + virtual void DoClose() = 0; + virtual void UpdateParamDisplays() = 0; + virtual afx_msg void OnClose() = 0; + + virtual bool IsResizable() const = 0; + virtual bool SetSize(int contentWidth, int contentHeight) = 0; + DECLARE_MESSAGE_MAP() private: Modified: trunk/OpenMPT/mptrack/DefaultVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/DefaultVstEditor.cpp 2011-10-21 00:25:23 UTC (rev 1113) +++ trunk/OpenMPT/mptrack/DefaultVstEditor.cpp 2011-10-21 15:35:19 UTC (rev 1114) @@ -389,7 +389,7 @@ } -BOOL CDefaultVstEditor::OpenEditor(CWnd *parent) +bool CDefaultVstEditor::OpenEditor(CWnd *parent) //---------------------------------------------- { Create(IDD_DEFAULTPLUGINEDITOR, parent); @@ -415,7 +415,7 @@ ShowWindow(SW_SHOW); - return TRUE; + return true; } Modified: trunk/OpenMPT/mptrack/DefaultVstEditor.h =================================================================== --- trunk/OpenMPT/mptrack/DefaultVstEditor.h 2011-10-21 00:25:23 UTC (rev 1113) +++ trunk/OpenMPT/mptrack/DefaultVstEditor.h 2011-10-21 15:35:19 UTC (rev 1114) @@ -62,10 +62,14 @@ virtual void OnOK(); virtual void OnCancel(); - BOOL OpenEditor(CWnd *parent); + bool OpenEditor(CWnd *parent); void DoClose(); afx_msg void OnClose(); + // Plugins may not request to change the GUI size, since we use our own GUI. + virtual bool IsResizable() const { return false; }; + virtual bool SetSize(int, int) { return false; }; + protected: virtual void DoDataExchange(CDataExchange* pDX); Modified: trunk/OpenMPT/mptrack/VSTEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/VSTEditor.cpp 2011-10-21 00:25:23 UTC (rev 1113) +++ trunk/OpenMPT/mptrack/VSTEditor.cpp 2011-10-21 15:35:19 UTC (rev 1114) @@ -24,24 +24,13 @@ } -BOOL COwnerVstEditor::OpenEditor(CWnd *parent) +bool COwnerVstEditor::OpenEditor(CWnd *parent) //-------------------------------------------- { Create(IDD_PLUGINEDITOR, parent); SetupMenu(); - CRect rcWnd, rcClient; - // First, get window size without menu - GetWindowRect(&rcWnd); - GetClientRect(&rcClient); - - MENUBARINFO mbi; - MemsetZero(mbi); - mbi.cbSize = sizeof(mbi); - GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi); - rcWnd.bottom -= mbi.rcBar.bottom - mbi.rcBar.top; - if(m_pVstPlugin) { // Set editor window size @@ -53,27 +42,8 @@ m_pVstPlugin->Dispatch(effEditGetRect, 0, 0, (LPRECT)&pRect, 0); if((pRect) && (pRect->right > pRect->left) && (pRect->bottom > pRect->top)) { - // Plugin provided valid window size - CRect rcContent; - rcContent.right = pRect->right - pRect->left; - rcContent.bottom = pRect->bottom - pRect->top; - - // Preliminary setup, without taking menu bar size into account, just to find out the height of the menu bar. - // With small (narrow) plugin GUIs, the menu might be two lines high... - SetWindowPos(NULL, 0, 0, - rcWnd.Width() - rcClient.Width() + rcContent.Width(), - rcWnd.Height() - rcClient.Height() + rcContent.Height(), - SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); - - GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi); - - GetWindowRect(&rcWnd); - rcWnd.bottom += mbi.rcBar.bottom - mbi.rcBar.top; - - // Now we have the real size. - SetWindowPos(NULL, 0, 0, - rcWnd.Width(), rcWnd.Height(), - SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); + // Plugin provided valid window size. + SetSize(pRect->right - pRect->left, pRect->bottom - pRect->top); } // Restore previous editor position @@ -101,29 +71,28 @@ } -VOID COwnerVstEditor::OnClose() +void COwnerVstEditor::OnClose() //----------------------------- { DoClose(); } -VOID COwnerVstEditor::OnOK() +void COwnerVstEditor::OnOK() //-------------------------- { OnClose(); } -VOID COwnerVstEditor::OnCancel() +void COwnerVstEditor::OnCancel() //------------------------------ { OnClose(); } - -VOID COwnerVstEditor::DoClose() +void COwnerVstEditor::DoClose() //----------------------------- { #ifdef VST_LOG @@ -147,11 +116,54 @@ #ifdef VST_LOG Log("Destroying window...\n"); #endif // VST_LOG - // Initially, this was called before the last Dispatch() call. - // Now it's done after that call so that energyXT's GUI still works after re-opening the VST editor. - // Let's hope that other plugins don't break... DestroyWindow(); } } + + +bool COwnerVstEditor::SetSize(int contentWidth, int contentHeight) +//---------------------------------------------------------------- +{ + if(contentWidth < 0 || contentHeight < 0) + { + return false; + } + + CRect rcWnd, rcClient; + + // Get border / menu size. + GetWindowRect(&rcWnd); + GetClientRect(&rcClient); + + MENUBARINFO mbi; + MemsetZero(mbi); + mbi.cbSize = sizeof(mbi); + GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi); + int menuHeight = mbi.rcBar.bottom - mbi.rcBar.top; + + // Preliminary setup, which might have to be adjusted for small (narrow) plugin GUIs again, + // since the menu might be two lines high... + const int windowWidth = rcWnd.Width() - rcClient.Width() + contentWidth; + const int windowHeight = rcWnd.Height() - rcClient.Height() + contentHeight; + SetWindowPos(NULL, 0, 0, + windowWidth, windowHeight, + SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); + + // Check if the height of the menu bar has changed. + GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi); + + const int menuHeightDiff = (mbi.rcBar.bottom - mbi.rcBar.top) - menuHeight; + + if(menuHeightDiff != 0) + { + // Menu height changed, resize window so that the whole content area can be viewed again. + SetWindowPos(NULL, 0, 0, + windowWidth, windowHeight + menuHeightDiff, + SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); + } + + return true; +} + + #endif // NO_VST - Modified: trunk/OpenMPT/mptrack/VSTEditor.h =================================================================== --- trunk/OpenMPT/mptrack/VSTEditor.h 2011-10-21 00:25:23 UTC (rev 1113) +++ trunk/OpenMPT/mptrack/VSTEditor.h 2011-10-21 15:35:19 UTC (rev 1114) @@ -19,17 +19,18 @@ public: COwnerVstEditor(CVstPlugin *pPlugin); virtual ~COwnerVstEditor(); - virtual VOID OnOK(); - virtual VOID OnCancel(); - afx_msg void OnLoadPreset(); - afx_msg void OnSavePreset(); - afx_msg void OnRandomizePreset(); + virtual void OnOK(); + virtual void OnCancel(); + // Plugins may request to change the GUI size. + virtual bool IsResizable() const { return true; }; + virtual bool SetSize(int contentWidth, int contentHeight); + //Overridden: - void UpdateParamDisplays() {m_pVstPlugin->Dispatch(effEditIdle, 0,0, NULL, 0); }; //we trust that the plugin GUI can update it's display with a bit of idle time. + void UpdateParamDisplays() { m_pVstPlugin->Dispatch(effEditIdle, 0,0, NULL, 0); }; //we trust that the plugin GUI can update its display with a bit of idle time. afx_msg void OnClose(); - BOOL OpenEditor(CWnd *parent); - VOID DoClose(); + bool OpenEditor(CWnd *parent); + void DoClose(); }; #endif // NO_VST Modified: trunk/OpenMPT/mptrack/View_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_gen.cpp 2011-10-21 00:25:23 UTC (rev 1113) +++ trunk/OpenMPT/mptrack/View_gen.cpp 2011-10-21 15:35:19 UTC (rev 1114) @@ -1521,8 +1521,6 @@ CVstPlugin *pVstPlugin = (pPlugin->pMixPlugin) ? (CVstPlugin *)pPlugin->pMixPlugin : nullptr; if(pVstPlugin == nullptr) return; - CHAR s[128]; - CHAR sname[64]; const PlugParamIndex nParams = pVstPlugin->GetNumParameters(); m_CbnParam.SetRedraw(FALSE); m_CbnParam.ResetContent(); Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2011-10-21 00:25:23 UTC (rev 1113) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2011-10-21 15:35:19 UTC (rev 1114) @@ -280,18 +280,18 @@ try { - hLib = LoadLibrary(pszDllPath); - //rewbs.VSTcompliance + hLib = LoadLibrary(pszDllPath); + #ifdef _DEBUG - DWORD dw = GetLastError(); - if (!hLib && dw != ERROR_MOD_NOT_FOUND) // "File not found errors" are annoying. - { - TCHAR szBuf[256]; - wsprintf(szBuf, "Warning: encountered problem when loading plugin dll. Error %d: %s", dw, (LPCTSTR)GetErrorMessage(dw)); - Reporting::Error(szBuf, "DEBUG: Error when loading plugin dll"); - } -#endif //_DEBUG - //end rewbs.VSTcompliance + DWORD dw = GetLastError(); + if (!hLib && dw != ERROR_MOD_NOT_FOUND) // "File not found errors" are annoying. + { + TCHAR szBuf[256]; + wsprintf(szBuf, "Warning: encountered problem when loading plugin dll. Error %d: %s", dw, (LPCTSTR)GetErrorMessage(dw)); + Reporting::Error(szBuf, "DEBUG: Error when loading plugin dll"); + } +#endif //_DEBUG + } catch(...) { CVstPluginManager::ReportPlugException("Exception caught in LoadLibrary (%s)", pszDllPath); @@ -363,7 +363,7 @@ CString cacheFile = theApp.GetPluginCacheFileName(); CString IDs, flagsKey; IDs.Format("%08X%08X", p->dwPluginId1, p->dwPluginId2); - flagsKey.Format("%s.Flags", IDs); + flagsKey.Format("%s.Flags", IDs); _tcsncpy(szPath, pszDllPath, CountOf(szPath) - 1); if(theApp.IsPortableMode()) @@ -479,7 +479,7 @@ if (pMixPlugin) { PVSTPLUGINLIB p = m_pVstHead; - + while (p) { if (pMixPlugin) @@ -594,7 +594,7 @@ #endif } if ((pEffect) && (pEffect->dispatcher) - && ((pEffect->magic == kEffectMagic) || (pEffect->magic == kBuzzMagic))) + && ((pEffect->magic == kEffectMagic) || (pEffect->magic == kBuzzMagic))) { bOk = TRUE; if ((pEffect->flags & effFlagsIsSynth) || (!pEffect->numInputs)) @@ -641,7 +641,7 @@ //------------------------------ { PVSTPLUGINLIB pFactory = m_pVstHead; - + while (pFactory) { CVstPlugin *p = pFactory->pPluginsList; @@ -664,7 +664,7 @@ } pFactory = pFactory->pNext; } - + } //rewbs.VSTCompliance: Added support for lots of opcodes @@ -682,35 +682,41 @@ HostCanNotDo = -1 }; + CVstPlugin *pVstPlugin = nullptr; + if(effect != nullptr) + { + pVstPlugin = reinterpret_cast<CVstPlugin *>(effect->resvd1); + } + switch(opcode) { // Called when plugin param is changed via gui - case audioMasterAutomate: - if (effect && effect->resvd1) + case audioMasterAutomate: + if (pVstPlugin != nullptr && pVstPlugin->Dispatch(effCanBeAutomated, index, nullptr, nullptr, 0.0f) != 0) { - CVstPlugin *pVstPlugin = reinterpret_cast<CVstPlugin *>(effect->resvd1); - if(pVstPlugin->Dispatch(effCanBeAutomated, index, nullptr, nullptr, 0.0f) != 0) - { - // This parameter can be automated. Ugo Motion constantly sends automation callback events for parameters that cannot be automated... - pVstPlugin->AutomateParameter((PlugParamIndex)index); - } + // This parameter can be automated. Ugo Motion constantly sends automation callback events for parameters that cannot be automated... + pVstPlugin->AutomateParameter((PlugParamIndex)index); } - return 0; + return 0; + // Called when plugin asks for VST version supported by host - case audioMasterVersion: return kVstVersion; + case audioMasterVersion: + return kVstVersion; + // Returns the unique id of a plug that's currently loading // (not sure what this is actually for - we return *effect's UID, cos Herman Seib does something similar :) // Let's see what happens...) case audioMasterCurrentId: return (effect != nullptr) ? effect->uniqueID : 0; + // Call application idle routine (this will call effEditIdle for all open editors too) case audioMasterIdle: OnIdle(); return 0; - + // Inquire if an input or output is beeing connected; index enumerates input or output counting from zero, // value is 0 for input and != 0 otherwise. note: the return value is 0 for <true> such that older versions - // will always return true. + // will always return true. case audioMasterPinConnected: //if (effect) //{ @@ -730,12 +736,14 @@ // <value> is a filter which is currently ignored - DEPRECATED in VST 2.4 // Herman Seib only processes Midi events for plugs that call this. Keep in mind. - case audioMasterWantMidi: return 1; + case audioMasterWantMidi: + return 1; + // returns const VstTimeInfo* (or 0 if not supported) // <value> should contain a mask indicating which fields are required - case audioMasterGetTime: { + case audioMasterGetTime: + { - CVstPlugin* pVstPlugin = reinterpret_cast<CVstPlugin *>(effect->resvd1); MemsetZero(timeInfo); timeInfo.sampleRate = CMainFrame::GetMainFrame()->GetSampleRate(); @@ -749,7 +757,7 @@ timeInfo.samplePos = CMainFrame::GetMainFrame()->GetTotalSampleCount(); if (timeInfo.samplePos == 0) //samplePos=0 means we just started playing { - timeInfo.flags |= kVstTransportChanged; + timeInfo.flags |= kVstTransportChanged; } } else { @@ -773,7 +781,7 @@ } } if ((value & kVstTempoValid) && pSndFile) - { + { timeInfo.tempo = pSndFile->GetCurrentBPM(); if (timeInfo.tempo) { @@ -792,105 +800,113 @@ } return ToVstPtr(&timeInfo); } + // VstEvents* in <ptr> // We don't support plugs that send VSTEvents to the host - case audioMasterProcessEvents: + case audioMasterProcessEvents: Log("VST plugin to host: Process Events\n"); break; + // DEPRECATED in VST 2.4 case audioMasterSetTime: Log("VST plugin to host: Set Time\n"); break; + // returns tempo (in bpm * 10000) at sample frame location passed in <value> - DEPRECATED in VST 2.4 case audioMasterTempoAt: //Screw it! Let's just return the tempo at this point in time (might be a bit wrong). - if (effect->resvd1) + if (pVstPlugin != nullptr) { - CSoundFile *pSndFile = reinterpret_cast<CVstPlugin *>(effect->resvd1)->GetSoundFile(); + CSoundFile *pSndFile = pVstPlugin->GetSoundFile(); if (pSndFile) { return (VstInt32)(pSndFile->GetCurrentBPM() * 10000); } } return (VstInt32)(125 * 10000); + // parameters - DEPRECATED in VST 2.4 case audioMasterGetNumAutomatableParameters: Log("VST plugin to host: Get Num Automatable Parameters\n"); 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: Log("VST plugin to host: IOchanged\n"); - break; + break; + // plug needs idle calls (outside its editor window) - DEPRECATED in VST 2.4 case audioMasterNeedIdle: - if (effect && effect->resvd1) + if (pVstPlugin != nullptr) { - CVstPlugin* pVstPlugin = reinterpret_cast<CVstPlugin *>(effect->resvd1); - pVstPlugin->m_bNeedIdle=true; + pVstPlugin->m_bNeedIdle = true; } - + return 1; + // index: width, value: height case audioMasterSizeWindow: - if (effect->resvd1) + if (pVstPlugin != nullptr) { - CVstPlugin *pVstPlugin = reinterpret_cast<CVstPlugin *>(effect->resvd1); - CAbstractVstEditor *pVstEditor = pVstPlugin->GetEditor(); - if (pVstEditor) + CAbstractVstEditor *pVstEditor = pVstPlugin->GetEditor(); + if (pVstEditor && pVstEditor->IsResizable()) { - CRect rcWnd, rcClient; - pVstEditor->GetWindowRect(rcWnd); - pVstEditor->GetClientRect(rcClient); - - rcWnd.right = rcWnd.left + (rcWnd.Width()) - (rcClient.Width()) + index; - rcWnd.bottom = rcWnd.top + (rcWnd.Height()) - (rcClient.Height()) + value; - - pVstEditor->SetWindowPos(NULL, rcWnd.left, rcWnd.top, rcWnd.Width(), rcWnd.Height(), SWP_NOMOVE | SWP_NOZORDER); + pVstEditor->SetSize(index, value); } } 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: { - VstIntPtr latency = CMainFrame::GetSettings().m_nBufferLength * (CMainFrame::GetMainFrame()->GetSampleRate()/1000L); + VstIntPtr latency = CMainFrame::GetSettings().m_nBufferLength * (CMainFrame::GetMainFrame()->GetSampleRate() / 1000L); return latency; } + // input pin in <value> (-1: first to come), returns cEffect* - DEPRECATED in VST 2.4 case audioMasterGetPreviousPlug: Log("VST plugin to host: Get Previous Plug\n"); break; + // output pin in <value> (-1: first to come), returns cEffect* - DEPRECATED in VST 2.4 case audioMasterGetNextPlug: Log("VST plugin to host: Get Next Plug\n"); 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: //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. + return 2; //Unknown. } */ - break; + 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. + // Not entirely sure what this means. We can write automation TO the plug. // Is that "read" in this context? //Log("VST plugin to host: Get Automation State\n"); return kVstAutomationRead; @@ -898,45 +914,57 @@ 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"); //return 0; return true; + case audioMasterGetVendorVersion: return s_nHostVendorVersion; - //return 7000; + //return 7000; + case audioMasterGetProductString: strcpy((char *) ptr, s_szHostProductString); //strcpy((char*)ptr,"Cubase VST"); //return 0; return true; + case audioMasterVendorSpecific: return 0; - // void* in <ptr>, format not defined yet - DEPRECATED in VST 2.4 + + // 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: @@ -953,7 +981,7 @@ if ((strcmp((char*)ptr,"sendVstEvents") == 0 || strcmp((char*)ptr,"sendVstMidiEvent") == 0 || strcmp((char*)ptr,"sendVstTimeInfo") == 0 || - strcmp((char*)ptr,"supplyIdle") == 0 || + strcmp((char*)ptr,"supplyIdle") == 0 || strcmp((char*)ptr,"sizeWindow") == 0 || strcmp((char*)ptr,"openFileSelector") == 0 || strcmp((char*)ptr,"closeFileSelector") == 0 @@ -961,29 +989,32 @@ return HostCanDo; else return HostCanNotDo; - // + case audioMasterGetLanguage: return kVstLangEnglish; + // returns platform specific ptr - DEPRECATED in VST 2.4 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(CMainFrame::GetSettings().GetDefaultDirectory(DIR_PLUGINS)); + // something has changed, update 'multi-fx' display case audioMasterUpdateDisplay: - if (effect && effect->resvd1) + if (pVstPlugin != nullptr) { -// CVstPlugin *pVstPlugin = reinterpret_cast<CVstPlugin *>(effect->resvd1); -// pVstPlugin->GetModDoc()->UpdateAllViews(NULL, HINT_MIXPLUGINS, NULL); //No Need. +// pVstPlugin->GetModDoc()->UpdateAllViews(NULL, HINT_MIXPLUGINS, NULL); //No Need. -/* CAbstractVstEditor *pVstEditor = pVstPlugin->GetEditor(); +/* CAbstractVstEditor *pVstEditor = pVstPlugin->GetEditor(); if (pVstEditor && ::IsWindow(pVstEditor->m_hWnd)) { //pVstEditor->SetupMenu(); @@ -1000,28 +1031,32 @@ case audioMasterBeginEdit: Log("VST plugin to host: Begin Edit\n"); break; - // end of automation session (when mouse up), parameter index in <index> + + // end of automation session (when mouse up), parameter index in <index> case audioMasterEndEdit: Log("VST plugin to host: End Edit\n"); break; + // open a fileselector window with VstFileSelect* in <ptr> case audioMasterOpenFileSelector: + //---from here VST 2.2 extension opcodes------------------------------------------------------ // close a fileselector operation with VstFileSelect* in <ptr>: Must be always called after an open ! case audioMasterCloseFileSelector: return VstFileSelector(opcode == audioMasterCloseFileSelector, (VstFileSelect *)ptr, effect); - + // open an editor for audio (defined by XML text in ptr) - DEPRECATED in VST 2.4 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: Log("VST plugin to host: Get Chunk File\n"); break; - + //---from here VST 2.3 extension opcodes------------------------------------------------------ // result a VstSpeakerArrangement in ret - DEPRECATED in VST 2.4 @@ -1126,7 +1161,7 @@ if(pFileSel->returnPath == nullptr || pFileSel->sizeReturnPath == 0) { - + // Provide some memory for the return path. pFileSel->sizeReturnPath = files.first_file.length() + 1; pFileSel->returnPath = new char[pFileSel->sizeReturnPath]; @@ -1212,7 +1247,7 @@ delete[] pFileSel->returnMultiplePaths[i]; } } - delete[] pFileSel->returnMultiplePaths; + delete[] pFileSel->returnMultiplePaths; } else { if(pFileSel->reserved == 1 && pFileSel->returnPath != nullptr) @@ -1291,7 +1326,7 @@ MemsetZero(dummyBuffer_); - //rewbs.dryRatio: we now initialise this in CVstPlugin::Initialize(). + //rewbs.dryRatio: we now initialise this in CVstPlugin::Initialize(). //m_pTempBuffer = (float *)((((DWORD)&m_FloatBuffer[MIXBUFFERSIZE*2])+7)&~7); m_bSongPlaying = false; //rewbs.VSTCompliance @@ -1412,7 +1447,7 @@ str.Format("Plugin has unsupported number(=%d) of outputs; plugin may malfunction.", m_pEffect->numOutputs); Reporting::Warning(str); } - + //input pointer array size must be >=2 for now - the input buffer assignment might write to non allocated mem. otherwise m_pInputs = (m_nInputs >= 2) ? new (float *[m_nInputs]) : new (float*[2]); m_pInputs[0] = m_MixState.pOutBufferL; @@ -1429,7 +1464,7 @@ for (UINT iOut=0; iOut<m_nOutputs; iOut++) { m_pTempBuffer[iOut]=(float *)((((DWORD_PTR)&m_FloatBuffer[MIXBUFFERSIZE*(2+iOut)])+7)&~7); //rewbs.dryRatio - } + } #ifdef VST_LOG Log("%s: vst ver %d.0, flags=%04X, %d programs, %d parameters\n", @@ -1502,7 +1537,7 @@ delete[] m_pOutputs; m_pOutputs = NULL; - + delete[] (char *)m_pEvList; m_pEvList = NULL; @@ -1592,7 +1627,7 @@ { if (!(m_pEffect)) return 0; - + return m_pEffect->version; } @@ -1601,14 +1636,14 @@ { if (!(m_pEffect)) return false; - + if (max>m_pEffect->numParams) max = m_pEffect->numParams; for (VstInt32 p = min; p < max; p++) param[p-min]=GetParameter(p); - return true; + return true; } @@ -1617,7 +1652,7 @@ { if (!(m_pEffect)) return false; - + if (minParam==0 && maxParam==0) { minParam=0; @@ -1632,7 +1667,7 @@ for (VstInt32 p = minParam; p < maxParam; p++) SetParameter(p, (rand() / float(RAND_MAX))); - return true; + return true; } bool CVstPlugin::SaveProgram(CString fileName) @@ -1640,7 +1675,7 @@ { if (!(m_pEffect)) return false; - + bool success; //Collect required data long ID = GetUID(); @@ -1663,20 +1698,20 @@ { //Collect required data PlugParamIndex numParams = GetNumParameters(); - float *params = new float[numParams]; + float *params = new float[numParams]; GetParams(params, 0, numParams); fxp = new Cfxp(ID, plugVersion, numParams, params); delete[] params; } - + success = fxp->Save(fileName); if (fxp) delete fxp; return success; - + } bool CVstPlugin::LoadProgram(CString fileName) @@ -1691,7 +1726,7 @@ if (m_pEffect->uniqueID != fxp.fxID) return false; - if (fxp.fxMagic == fMagic) //Load preset based fxp + if (fxp.fxMagic == fMagic) //Load preset based fxp { if (m_pEffect->numParams != fxp.numParams) return false; @@ -1699,7 +1734,7 @@ SetParameter(p, fxp.params[p]); } else if (fxp.fxMagic == chunkPresetMagic) - { + { Dispatch(effSetChunk, 1, fxp.chunkSize, (BYTE*)fxp.chunk, 0); } @@ -1770,11 +1805,11 @@ index++; CString formattedName; - if(rawname[0] < ' ') + if(rawname[0] < ' ') { formattedName.Format("%02d - Program %d", index, index); - } - else + } + else { formattedName.Format("%02d - %s", index, rawname); } @@ -1913,7 +1948,7 @@ //reset some stuff m_MixState.nVolDecayL = 0; m_MixState.nVolDecayR = 0; - Dispatch(effStopProcess, 0, 0, NULL, 0.0f); + Dispatch(effStopProcess, 0, 0, NULL, 0.0f); Dispatch(effMainsChanged, 0, 0, NULL, 0.0f); // calls plugin's suspend if (sampleRate != m_nSampleRate) { @@ -1933,7 +1968,7 @@ } -void CVstPlugin::Suspend() +void CVstPlugin::Suspend() //------------------------ { try @@ -1970,7 +2005,7 @@ (((VstMidiEvent *)(m_pEvList->events[0]))->midiData[2])&0xff); } } - + } void CVstPlugin::ClearVSTEvents() @@ -1983,7 +2018,7 @@ } } -void CVstPlugin::RecalculateGain() +void CVstPlugin::RecalculateGain() //-------------------------------- { float gain = 0.1f * (float)( m_pMixStruct ? (m_pMixStruct->Info.dwInputRouting>>16) & 0xff : 10 ); @@ -2114,8 +2149,8 @@ if ((m_pMixStruct->Info.dwInputRouting & MIXPLUG_INPUTF_WETMIX) && !isInstrument) { pOutL[i] += m_MixState.pOutBufferL[i]; - pOutR[i] += m_MixState.pOutBufferR[i]; - } + pOutR[i] += m_MixState.pOutBufferR[i]; + } } */ // Wet/Dry range expansion [0,1] -> [-1,1] update#02 @@ -2136,7 +2171,7 @@ case 0: for(UINT i = 0; i < nSamples; i++) { - //rewbs.wetratio - added the factors. [20040123] + //rewbs.wetratio - added the factors. [20040123] pOutL[i] += m_pTempBuffer[0][i]*wetRatio + m_MixState.pOutBufferL[i]*dryRatio; pOutR[i] += m_pTempBuffer[0][i]*wetRatio + m_MixState.pOutBufferR[i]*dryRatio; } @@ -2203,7 +2238,7 @@ pOutL[i] += m_MixState.pOutBufferL[i]; pOutR[i] += m_MixState.pOutBufferR[i]; } - } + } // -! BEHAVIOUR_CHANGE#0028 } @@ -2220,7 +2255,7 @@ { //rewbs.wetratio - added the factors. [20040123] - + pOutL[i] += m_pTempBuffer[0][i]*wetRatio + m_MixState.pOutBufferL[i]*dryRatio; pOutR[i] += m_pTempBuffer[1][i]*wetRatio + m_MixState.pOutBufferR[i]*dryRatio; @@ -2229,8 +2264,8 @@ if ((m_pMixStruct->Info.dwInputRouting & MIXPLUG_INPUTF_WETMIX) && !isInstrument) { pOutL[i] += m_MixState.pOutBufferL[i]; - pOutR[i] += m_MixState.pOutBufferR[i]; - } + pOutR[i] += m_MixState.pOutBufferR[i]; + } } */ // Wet/Dry range expansion [0,1] -> [-1,1] update#02 @@ -2250,7 +2285,7 @@ case 0: for(UINT i=0; i<nSamples; i++) { - //rewbs.wetratio - added the factors. [20040123] + //rewbs.wetratio - added the factors. [20040123] pOutL[i] += m_pTempBuffer[0][i]*wetRatio + m_MixState.pOutBufferL[i]*dryRatio; pOutR[i] += m_pTempBuffer[1][i]*wetRatio + m_MixState.pOutBufferR[i]*dryRatio; } @@ -2317,7 +2352,7 @@ pOutL[i] += m_MixState.pOutBufferL[i]; pOutR[i] += m_MixState.pOutBufferR[i]; } - } + } // -! BEHAVIOUR_CHANGE#0028 } @@ -2367,10 +2402,10 @@ #ifdef VST_LOG Log("Sending Midi %02X.%02X.%02X\n", pev->midiData[0]&0xff, pev->midiData[1]&0xff, pev->midiData[2]&0xff); #endif - + return true; //rewbs.instroVST } - else + else { Log("VST Event queue overflow!\n"); m_pEvList->numEvents = VSTEVENT_QUEUE_LEN-1; @@ -2388,7 +2423,7 @@ // Relies on a wait on processCalled, which will never get set // if plug is bypassed. - //if (IsBypassed()) + //if (IsBypassed()) // return; // The JUCE framework doesn't like processing while being suspended. @@ -2402,16 +2437,16 @@ { overflow=false; for (int mc=0; mc<16; mc++) //all midi chans - { + { UINT nCh = mc & 0x0f; DWORD dwMidiCode = 0x80|nCh; //command|channel|velocity PVSTINSTCH pCh = &m_MidiCh[nCh]; MidiPitchBend(mc, MIDI_PitchBend_Centre); // centre pitch bend MidiSend(0xB0|mc|(0x79<<8)); // reset all controllers - MidiSend(0xB0|mc|(0x7b<<8)); // all notes off - MidiSend(0xB0|mc|(0x78<<8)); // all sounds off - + MidiSend(0xB0|mc|(0x7b<<8)); // all notes off + MidiSend(0xB0|mc|(0x78<<8)); // all sounds off + for (UINT i=0; i<128; i++) //all notes { for (UINT c=0; c<MAX_CHANNELS; c++) @@ -2429,7 +2464,7 @@ } // let plug process events // TODO: wait for notification from audio thread that process has been called, - // rather than re-call it here + // rather than re-call it here //ResetEvent(processCalled); // Unset processCalled. //WaitForSingleObject(processCalled, 10000); // Will not return until processCalled is set again, // // i.e. until processReplacing() has been called. @@ -2446,7 +2481,7 @@ } //end rewbs.VSTiNoteHoldonStopFix -void CVstPlugin::MidiCC(UINT nMidiCh, UINT nController, UINT nParam, UINT /*trackChannel*/) +void CVstPlugin::MidiCC(UINT nMidiCh, UINT nController, UINT nParam, UINT /*trackChannel*/) //------------------------------------------------------------------------------------------ { //Error checking @@ -2466,18 +2501,18 @@ if(m_pSndFile && m_pSndFile->GetModFlag(MSF_MIDICC_BUGEMULATION)) MidiSend(nController<<16 | nParam<<8 | 0xB0|nMidiCh); - else + else MidiSend(nParam<<16 | nController<<8 | 0xB0|nMidiCh); } -short CVstPlugin::getMIDI14bitValueFromShort(short value) +short CVstPlugin::getMIDI14bitValueFromShort(short value) //------------------------------------------------------- { - //http://www.srm.com/qtma/davidsmidispec.html: - // The two bytes of the pitch bend message form a 14 bit number, 0 to 16383. - // The value 8192 (sent, LSB first, as 0x00 0x40), is centered, or "no pitch bend." - // The value 0 (0x00 0x00) means, "bend as low as possible," and, - // similarly, 16383 (0x7F 0x7F) is to "bend as high as possible." + //http://www.srm.com/qtma/davidsmidispec.html: + // The two bytes of the pitch bend message form a 14 bit number, 0 to 16383. + // The value 8192 (sent, LSB first, as 0x00 0x40), is centered, or "no pitch bend." + // The value 0 (0x00 0x00) means, "bend as low as possible," and, + // similarly, 16383 (0x7F 0x7F) is to "bend as high as possible." // The exact range of the pitch bend is specific to the synthesizer. // pre: 0 <= value <= 16383 @@ -2491,15 +2526,15 @@ } //Bend midi pitch for given midi channel using tracker param (0x00-0xFF) -void CVstPlugin::MidiPitchBend(UINT nMidiCh, int nParam, UINT /*trackChannel*/) +void CVstPlugin::MidiPitchBend(UINT nMidiCh, int nParam, UINT /*trackChannel*/) //----------------------------------------------------------------------------- { nMidiCh--; // move from 1-17 range to 0-16 range - + const int16 increment = static_cast<int16>(nParam * 0x2000/0xFF); int16 newPitchBendPos = m_nMidiPitchBendPos[nMidiCh] + increment; Limit(newPitchBendPos, int16(MIDI_PitchBend_Min), int16(MIDI_PitchBend_Max)); - + MidiPitchBend(nMidiCh, newPitchBendPos); } @@ -2524,8 +2559,8 @@ bool progChanged = (pCh->nProgram != --nMidiProg) && (nMidiProg < 0x80); //bool chanChanged = nCh != m_nPreviousMidiChan; //get vol in [0,128[ - vol = min(vol / 2, 127); - + vol = min(vol / 2, 127); + // Note: Some VSTis update bank/prog on midi channel change, others don't. // For those that don't, we do it for them. // Note 17/12/2005 - I have disabled that because it breaks Edirol Hypercanvas @@ -2538,7 +2573,7 @@ MidiSend(((wMidiBank<<16)|(0x20<<8))|(0xB0|nCh)); } // Program change - // Note: Some plugs (Edirol Orchestral) don't update on bank change only - + // Note: Some plugs (Edirol Orchestral) don't update on bank change only - // need to force it by sending prog change too. if ((nMidiProg < 0x80) && (progChanged || bankChanged /*|| chanChanged */ )) { @@ -2560,26 +2595,26 @@ pCh->uNoteOnMap[i][trackChannel]--; MidiSend(dwMidiCode|(i<<8)); } - } - + } + // "Hard core" All Sounds Off on this midi and tracker channel // This one doesn't check the note mask - just one note off per note. // Also less likely to cause a VST event buffer overflow. else if (note == NOTE_NOTECUT) // ^^ { //MidiSend(0xB0|nCh|(0x79<<8)); // reset all controllers - MidiSend(0xB0|nCh|(0x7b<<8)); // all notes off - MidiSend(0xB0|nCh|(0x78<<8)); // all sounds off + MidiSend(0xB0|nCh|(0x7b<<8)); // all notes off + MidiSend(0xB0|nCh|(0x78<<8)); // all sounds off dwMidiCode = 0x80|nCh|(vol<<16); //note off, on chan nCh; vol is note off velocity. for (UINT i=0; i<128; i++) //all notes { pCh->uNoteOnMap[i][trackChannel]=0; - MidiSend(dwMidiCode|(i<<8)); + MidiSend(dwMidiCode|(i<<8)); } - - } + } + // All "active" notes off on this midi and tracker channel // using note mask. else if (note > 0x80) // == @@ -2619,19 +2654,19 @@ // count instances of active notes. // This is to send a note off for each instance of a note, for plugs like Fabfilter. - // Problem: if a note dies out naturally and we never send a note off, this counter + // Problem: if a note dies out naturally and we never send a note off, this counter // will block at max until note off. Is this a problem? // Safe to assume we won't need more than 16 note offs max on a given note? - if (pCh->uNoteOnMap[note][trackChannel]<17) + if (pCh->uNoteOnMap[note][trackChannel]<17) pCh->uNoteOnMap[note][trackChannel]++; - - + + MidiSend(dwMidiCode|(note<<8)|(vol<<16)); } m_nPreviousMidiChan = nCh; - + } bool CVstPlugin::isPlaying(UINT note, UINT midiChn, UINT trackerChn) @@ -2650,7 +2685,7 @@ if (!(pMidiCh->uNoteOnMap[note][sourceTrackerChn])) return false; - + pMidiCh->uNoteOnMap[note][sourceTrackerChn]--; pMidiCh->uNoteOnMap[note][destTrackerChn]++; return true; @@ -2702,7 +2737,7 @@ // TODO: Could be used to update general tab in real time, but causes flickers in treeview // Better idea: add an update hint just for plugin params? - //pModDoc->UpdateAllViews(NULL, HINT_MIXPLUGINS, NULL); + //pModDoc->UpdateAllViews(NULL, HINT_MIXPLUGINS, NULL); if (CMainFrame::GetInputHandler()->ShiftPressed()) { @@ -2741,15 +2776,15 @@ && (m_pEffect->uniqueID != CCONST('S', 'y', 't', 'r'))) //special case: imageline sytrus pretends to support chunks but gives us garbage. { PVOID p = NULL; - LONG nByteSize = 0; - + LONG nByteSize = 0; + // Try to get whole bank if (m_pEffect->uniqueID != CCONST('v', 'B', 'F', '\4')) { //special case: VB ffx4 pretends to get a valid bank but gives us garbage. nByteSize = Dispatch(effGetChunk, 0,0, &p, 0); } - + if (/*(nByteSize < 8) ||*/ !p) { //If bank is less that 8 bytes, the plug must be kidding. :) (e.g.: imageline sytrus) @@ -2827,7 +2862,7 @@ { PVOID p = NULL; Dispatch(effGetChunk, 0,0, &p, 0); //init plug for chunk reception - + if ((nProgram>=0) && (nProgram < m_pEffect->numPrograms)) { // Bank: Dispatch(effSetChunk, 0, m_pMixStruct->nPluginDataSize-4, ((BYTE *)m_pMixStruct->pPluginData)+4, 0); SetCurrentProgram(nProgram); @@ -2941,7 +2976,7 @@ m_pMixStruct->Info.dwInputRouting |= MIXPLUG_INPUTF_BYPASS; else m_pMixStruct->Info.dwInputRouting &= ~MIXPLUG_INPUTF_BYPASS; - + #ifdef MODPLUG_TRACKER if (m_pModDoc) m_pModDoc->UpdateAllViews(NULL, HINT_MIXPLUGINS, NULL); @@ -2988,7 +3023,7 @@ } -PLUGINDEX CVstPlugin::FindSlot() +PLUGINDEX CVstPlugin::FindSlot() //------------------------------ { PLUGINDEX slot = 0; @@ -3002,13 +3037,13 @@ return slot; } -void CVstPlugin::SetSlot(PLUGINDEX slot) +void CVstPlugin::SetSlot(PLUGINDEX slot) //-------------------------------------- { m_nSlot = slot; } -PLUGINDEX CVstPlugin::GetSlot() +PLUGINDEX CVstPlugin::GetSlot() //----------------------------- { return m_nSlot; @@ -3036,10 +3071,10 @@ return (CVstPlugin::Dispatch(effCanDo, 0, 0, (char*)(LPCTSTR)s, 0) != 0); } -void CVstPlugin::GetOutputPlugList(CArray<CVstPlugin*, CVstPlugin*> &list) +void CVstPlugin::GetOutputPlugList(CArray<CVstPlugin*, CVstPlugin*> &list) //------------------------------------------------------------------------ { - // At the moment we know there will only be 1 output. + // At the moment we know there will only be 1 output. // Returning NULL ptr means plugin outputs directly to master. list.RemoveAll(); @@ -3057,7 +3092,7 @@ return; } -void CVstPlugin::GetInputPlugList(CArray<CVstPlugin*, CVstPlugin*> &list) +void CVstPlugin::GetInputPlugList(CArray<CVstPlugin*, CVstPlugin*> &list) //----------------------------------------------------------------------- { if(m_pSndFile == 0) return; @@ -3072,7 +3107,7 @@ if (pCandidatePlug) { pCandidatePlug->GetOutputPlugList(candidatePlugOutputs); - + for(int nOutput=0; nOutput<candidatePlugOutputs.GetSize(); nOutput++) { if (candidatePlugOutputs[nOutput] == this) @@ -3092,7 +3127,7 @@ { list.RemoveAll(); if(m_pSndFile == 0) return; - + UINT nThisMixPlug = m_nSlot+1; //m_nSlot is position in mixplug array. for (int nIns=0; nIns<MAX_INSTRUMENTS; nIns++) { @@ -3111,7 +3146,7 @@ { if(m_pSndFile == 0) return; list.RemoveAll(); - + 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++) @@ -3198,7 +3233,7 @@ virtual int GetEnvSize(int const wave, int const env) { Log("GetEnvSize\n"); return 0; } virtual bool GetEnvPoint(int const wave, int const env, int const i, word &x, word &y, int &flags) { Log("GetEnvPoint\n"); return false; } virtual CWaveLevel const *GetNearestWaveLevel(int const i, int const note) { Log("GetNearestWaveLevel(%d, %d)\n", i, note); return &m_WaveLevel; } - + // pattern editing virtual void SetNumberOfTracks(int const n) { Log("SetNumberOfTracks\n"); } virtual CPattern *CreatePattern(char const *name, int const length) { Log("CreatePattern\n"); return NULL; } @@ -3208,12 +3243,12 @@ virtual void DeletePattern(CPattern *ppat) { Log("DeletePattern\n"); } virtual int GetPatternData(CPattern *ppat, int const row, int const group, int const track, int const field) { Log("GetPatternData\n"); return 0; } virtual void SetPatternData(CPattern *ppat, int const row, int const group, int const track, int const field, int const value) { Log("SetPatternData\n"); } - + // sequence editing virtual CSequence *CreateSequence() { Log("CreateSequence\n"); return NULL; } virtual void DeleteSequence(CSequence *pseq) { Log("DeleteSequence\n"); } - // special ppat values for GetSequenceData and SetSequenceData + // special ppat values for GetSequenceData and SetSequenceData // empty = NULL // <break> = (CPattern *)1 // <mute> = (CPattern *)2 @@ -3225,7 +3260,7 @@ virtual void SetMachineInterfaceEx(CMachineInterfaceEx *pex) { Log("SetMachineInterfaceEx\n"); } // group 1=global, 2=track virtual void ControlChange__obsolete__(int group, int track, int param, int value) { Log("ControlChange__obsolete__\n"); } - + // direct calls to audiodriver, used by WaveInput and WaveOutput // shouldn't be used for anything else virtual int ADGetnumChannels(bool input) { Log("ADGetNumChannels\n"); return 2; } @@ -3454,7 +3489,7 @@ void CBuzz2Vst::SetParameter(VstInt32 index, float parameter) //----------------------------------------------------------- { - + } @@ -3507,7 +3542,7 @@ float *pinL = inputs[0], *pinR = inputs[1]; float *poutL = outputs[0], *poutR = outputs[1]; float Buffer[MIXBUFFERSIZE*2]; // Stereo interleaved - + // Re-interleave the stereo mix X86_Interleave(pinL, pinR, Buffer, sampleframes); // Process @@ -3976,7 +4011,7 @@ void CDmo2Vst::Process(float **inputs, float **outputs, long sampleframes) //------------------------------------------------------------------------ { - if ((!m_pMixBuffer) || (sampleframes <= 0)) + if ((!m_pMixBuffer) || (sampleframes <= 0)) return; #ifdef ENABLE_MMX This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-10-21 20:45:23
|
Revision: 1116 http://modplug.svn.sourceforge.net/modplug/?rev=1116&view=rev Author: saga-games Date: 2011-10-21 20:45:15 +0000 (Fri, 21 Oct 2011) Log Message: ----------- [Fix] Pattern Editor: Split keyboard settings and record groups work as intended (at least I think it was intended like this) now. If both record groups are active, the lower part of the split keyboard is recorded into record group 2, the higher part is recorded into group 1 (http://forum.openmpt.org/index.php?topic=4568.0). [Imp] Pattern Editor: When recording note offs in IT/MPTM files in sample mode, Note Cuts are inserted instead of Note Offs. [Mod] OpenMPT: Version is now 1.20.00.47 Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_pat.cpp trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/Moptions.cpp trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp trunk/OpenMPT/mptrack/PatternEditorDialogs.h trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_pat.h trunk/OpenMPT/mptrack/version.h Modified: trunk/OpenMPT/mptrack/Ctrl_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2011-10-21 17:25:25 UTC (rev 1115) +++ trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2011-10-21 20:45:15 UTC (rev 1116) @@ -280,8 +280,8 @@ m_CbnInstrument.SetRedraw(FALSE); m_CbnInstrument.ResetContent(); m_CbnInstrument.SetItemData(m_CbnInstrument.AddString(" No Instrument"), 0); - const INSTRUMENTINDEX nSplitIns = m_pModDoc->GetSplitKeyboardSettings()->splitInstrument; - const MODCOMMAND::NOTE noteSplit = 1 + m_pModDoc->GetSplitKeyboardSettings()->splitNote; + const INSTRUMENTINDEX nSplitIns = m_pModDoc->GetSplitKeyboardSettings().splitInstrument; + const MODCOMMAND::NOTE noteSplit = 1 + m_pModDoc->GetSplitKeyboardSettings().splitNote; const CString sSplitInsName = m_pModDoc->GetPatternViewInstrumentName(nSplitIns, true, false); if (m_pSndFile->GetNumInstruments()) { @@ -292,7 +292,7 @@ continue; CString sDisplayName; - if (m_pModDoc->GetSplitKeyboardSettings()->IsSplitActive()) + if (m_pModDoc->GetSplitKeyboardSettings().IsSplitActive()) { wsprintf(s, szSplitFormat, nSplitIns, GetNoteStr(noteSplit), i, (LPCTSTR)sSplitInsName, (LPCTSTR)m_pModDoc->GetPatternViewInstrumentName(i, true, false)); @@ -311,7 +311,7 @@ SAMPLEINDEX nmax = m_pSndFile->GetNumSamples(); for (SAMPLEINDEX i = 1; i <= nmax; i++) if (m_pSndFile->GetSample(i).pSample) { - if (m_pModDoc->GetSplitKeyboardSettings()->IsSplitActive() && nSplitIns < ARRAYELEMCOUNT(m_pSndFile->m_szNames)) + if (m_pModDoc->GetSplitKeyboardSettings().IsSplitActive() && nSplitIns < ARRAYELEMCOUNT(m_pSndFile->m_szNames)) wsprintf(s, szSplitFormat, nSplitIns, GetNoteStr(noteSplit), i, m_pSndFile->m_szNames[nSplitIns], m_pSndFile->m_szNames[i]); else wsprintf(s, "%02u: %s", i, m_pSndFile->m_szNames[i]); Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2011-10-21 17:25:25 UTC (rev 1115) +++ trunk/OpenMPT/mptrack/Moddoc.h 2011-10-21 20:45:15 UTC (rev 1116) @@ -269,7 +269,7 @@ CPatternUndo *GetPatternUndo() { return &m_PatternUndo; } CSampleUndo *GetSampleUndo() { return &m_SampleUndo; } - SplitKeyboardSettings *GetSplitKeyboardSettings() { return &m_SplitKeyboardSettings; } + SplitKeyboardSettings &GetSplitKeyboardSettings() { return m_SplitKeyboardSettings; } vector<FileHistory> *GetFileHistory() { return &m_FileHistory; } const vector<FileHistory> *GetFileHistory() const { return &m_FileHistory; } Modified: trunk/OpenMPT/mptrack/Moptions.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moptions.cpp 2011-10-21 17:25:25 UTC (rev 1115) +++ trunk/OpenMPT/mptrack/Moptions.cpp 2011-10-21 20:45:15 UTC (rev 1116) @@ -550,7 +550,7 @@ {PATTERN_NOEXTRALOUD, "No loud sample preview", "Disable loud playback of samples in the sample/instrument editor. Sample volume depends on the sample volume slider on the general tab when activated (if disabled, a sample volume of 256 is used)."}, {PATTERN_SHOWPREVIOUS, "Show Prev/Next patterns", "Displays grayed-out version of the previous/next patterns in the pattern editor. Does not work if \"always center active row\" is disabled."}, {PATTERN_CONTSCROLL, "Continuous scroll", "Jumps to the next pattern when moving past the end of a pattern"}, - {PATTERN_KBDNOTEOFF, "Record note off", "Record note off when a key is released on the PC keyboard (Only works in instrument mode)."}, + {PATTERN_KBDNOTEOFF, "Record note off", "Record note off when a key is released on the PC keyboard."}, {PATTERN_FOLLOWSONGOFF, "Follow song off by default", "Ensure follow song is off when opening or starting a new song."}, {PATTERN_MIDIRECORD, "MIDI record", "Enable MIDI in record by default."}, {PATTERN_OLDCTXMENUSTYLE, "Old style pattern context menu", "Check this option to hide unavailable items in the pattern editor context menu. Uncheck to grey-out unavailable items instead."}, Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2011-10-21 17:25:25 UTC (rev 1115) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2011-10-21 20:45:15 UTC (rev 1116) @@ -1452,7 +1452,7 @@ // Split Notes AppendNotesToControl(m_CbnSplitNote, m_pSndFile->GetModSpecifications().noteMin - NOTE_MIN, m_pSndFile->GetModSpecifications().noteMax - NOTE_MIN); - m_CbnSplitNote.SetCurSel(m_pOptions->splitNote - (m_pSndFile->GetModSpecifications().noteMin - NOTE_MIN)); + m_CbnSplitNote.SetCurSel(m_Settings.splitNote - (m_pSndFile->GetModSpecifications().noteMin - NOTE_MIN)); // Octave modifier for(int i = -SPLIT_OCTAVE_RANGE; i < SPLIT_OCTAVE_RANGE + 1; i++) @@ -1462,8 +1462,8 @@ m_CbnOctaveModifier.SetItemData(n, i); } - m_CbnOctaveModifier.SetCurSel(m_pOptions->octaveModifier + SPLIT_OCTAVE_RANGE); - CheckDlgButton(IDC_PATTERN_OCTAVELINK, (m_pOptions->octaveLink && m_pOptions->octaveModifier != 0) ? MF_CHECKED : MF_UNCHECKED); + m_CbnOctaveModifier.SetCurSel(m_Settings.octaveModifier + SPLIT_OCTAVE_RANGE); + CheckDlgButton(IDC_PATTERN_OCTAVELINK, (m_Settings.octaveLink && m_Settings.octaveModifier != 0) ? MF_CHECKED : MF_UNCHECKED); // Volume m_CbnSplitVolume.AddString("No Change"); @@ -1474,7 +1474,7 @@ int n = m_CbnSplitVolume.AddString(s); m_CbnSplitVolume.SetItemData(n, i); } - m_CbnSplitVolume.SetCurSel(m_pOptions->splitVolume); + m_CbnSplitVolume.SetCurSel(m_Settings.splitVolume); // Instruments m_CbnSplitInstrument.ResetContent(); @@ -1503,7 +1503,7 @@ } } } - m_CbnSplitInstrument.SetCurSel(m_pOptions->splitInstrument); + m_CbnSplitInstrument.SetCurSel(m_Settings.splitInstrument); return TRUE; } @@ -1514,11 +1514,11 @@ { CDialog::OnOK(); - m_pOptions->splitNote = static_cast<MODCOMMAND::NOTE>(m_CbnSplitNote.GetCurSel() + (m_pSndFile->GetModSpecifications().noteMin - NOTE_MIN)); - m_pOptions->octaveModifier = m_CbnOctaveModifier.GetCurSel() - SPLIT_OCTAVE_RANGE; - m_pOptions->octaveLink = (IsDlgButtonChecked(IDC_PATTERN_OCTAVELINK) == TRUE) ? true : false; - m_pOptions->splitVolume = static_cast<MODCOMMAND::VOL>(m_CbnSplitVolume.GetCurSel()); - m_pOptions->splitInstrument = static_cast<MODCOMMAND::INSTR>(m_CbnSplitInstrument.GetItemData(m_CbnSplitInstrument.GetCurSel())); + m_Settings.splitNote = static_cast<MODCOMMAND::NOTE>(m_CbnSplitNote.GetCurSel() + (m_pSndFile->GetModSpecifications().noteMin - NOTE_MIN)); + m_Settings.octaveModifier = m_CbnOctaveModifier.GetCurSel() - SPLIT_OCTAVE_RANGE; + m_Settings.octaveLink = (IsDlgButtonChecked(IDC_PATTERN_OCTAVELINK) == TRUE); + m_Settings.splitVolume = static_cast<MODCOMMAND::VOL>(m_CbnSplitVolume.GetCurSel()); + m_Settings.splitInstrument = static_cast<MODCOMMAND::INSTR>(m_CbnSplitInstrument.GetItemData(m_CbnSplitInstrument.GetCurSel())); } Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.h =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.h 2011-10-21 17:25:25 UTC (rev 1115) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.h 2011-10-21 20:45:15 UTC (rev 1116) @@ -314,12 +314,11 @@ CSoundFile *m_pSndFile; public: - SplitKeyboardSettings *m_pOptions; + SplitKeyboardSettings &m_Settings; - CSplitKeyboadSettings(CWnd *parent, CSoundFile *pSndFile, SplitKeyboardSettings *pOptions):CDialog(IDD_KEYBOARD_SPLIT, parent) + CSplitKeyboadSettings(CWnd *parent, CSoundFile *pSndFile, SplitKeyboardSettings &settings) : CDialog(IDD_KEYBOARD_SPLIT, parent), m_Settings(settings) { m_pSndFile = pSndFile; - m_pOptions = pOptions; } protected: Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2011-10-21 17:25:25 UTC (rev 1115) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2011-10-21 20:45:15 UTC (rev 1116) @@ -4201,14 +4201,14 @@ const UINT nTick = pSndFile->m_nTickCount; const PATTERNINDEX nPatPlayback = pSndFile->m_nPattern; - const bool isSplit = (pModDoc->GetSplitKeyboardSettings()->IsSplitActive()) && (note <= pModDoc->GetSplitKeyboardSettings()->splitNote); + const bool isSplit = (pModDoc->GetSplitKeyboardSettings().IsSplitActive()) && (note <= pModDoc->GetSplitKeyboardSettings().splitNote); UINT ins = 0; if (pModDoc) { if (isSplit) { - ins = pModDoc->GetSplitKeyboardSettings()->splitInstrument; - if (pModDoc->GetSplitKeyboardSettings()->octaveLink) note += 12 *pModDoc->GetSplitKeyboardSettings()->octaveModifier; + ins = pModDoc->GetSplitKeyboardSettings().splitInstrument; + if (pModDoc->GetSplitKeyboardSettings().octaveLink) note += 12 *pModDoc->GetSplitKeyboardSettings().octaveModifier; if (note > NOTE_MAX && note < NOTE_MIN_SPECIAL) note = NOTE_MAX; if (note < 0) note = 1; } @@ -4288,11 +4288,18 @@ } //Enter note off - if(pSndFile->GetModSpecifications().hasNoteOff) // === + if(pSndFile->GetModSpecifications().hasNoteOff && (pSndFile->GetNumInstruments() > 0 || !pSndFile->GetModSpecifications().hasNoteCut)) + { + // === + // Not used in sample (if module format supports ^^^ instead) pTarget->note = NOTE_KEYOFF; - else if(pSndFile->GetModSpecifications().hasNoteCut) // ^^^ + } else if(pSndFile->GetModSpecifications().hasNoteCut) + { + // ^^^ pTarget->note = NOTE_NOTECUT; - else { // we don't have anything to cut (MOD format) - use volume or ECx + } else + { + // we don't have anything to cut (MOD format) - use volume or ECx if(usePlaybackPosition && nTick) // ECx { pTarget->command = (pSndFile->TypeIsS3M_IT_MPT()) ? CMD_S3MCMDEX : CMD_MODCMDEX; @@ -4430,7 +4437,7 @@ const PATTERNINDEX nPatPlayback = pSndFile->m_nPattern; const bool bRecordEnabled = IsEditingEnabled(); - const CHANNELINDEX nChn = GetChanFromCursor(m_dwCursor); + CHANNELINDEX nChn = GetChanFromCursor(m_dwCursor); if(note < NOTE_MIN_SPECIAL) { @@ -4450,11 +4457,24 @@ return; } - const BYTE recordGroup = pModDoc->IsChannelRecord(nChn); + BYTE recordGroup = pModDoc->IsChannelRecord(nChn); const bool bIsLiveRecord = IsLiveRecord(*pMainFrm, *pModDoc, *pSndFile); const bool usePlaybackPosition = (bIsLiveRecord && (CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_AUTODELAY) && !(pSndFile->m_dwSongFlags & SONG_STEP)); - bool isSplit = false; + const bool isSplit = IsNoteSplit(note); + if((recordGroup == 1 && isSplit) || (recordGroup == 2 && !isSplit)) + { + // Record group 1 should be used for normal notes, record group 2 for split notes. + // If there are any channels assigned to the "other" record group, we switch to another channel. + const CHANNELINDEX newChannel = FindGroupRecordChannel(3 - recordGroup, true); + if(newChannel != CHANNELINDEX_INVALID) + { + // Found a free channel, switch to other record group. + nChn = newChannel; + recordGroup = 3 - recordGroup; + } + } + // -- Chord autodetection: step back if we just entered a note if (bRecordEnabled && recordGroup && !bIsLiveRecord && !MODCOMMAND::IsPcNote(note)) { @@ -4501,7 +4521,7 @@ } // -- write note and instrument data. - isSplit = HandleSplit(&newcmd, note); + HandleSplit(&newcmd, note); // Nice idea actually: Use lower section of the keyboard to play chords (but it won't work 100% correctly this way...) /*if(isSplit) @@ -4512,14 +4532,14 @@ // -- write vol data int volWrite = -1; - if (vol >= 0 && vol <= 64 && !(isSplit && pModDoc->GetSplitKeyboardSettings()->splitVolume)) //write valid volume, as long as there's no split volume override. + if (vol >= 0 && vol <= 64 && !(isSplit && pModDoc->GetSplitKeyboardSettings().splitVolume)) //write valid volume, as long as there's no split volume override. { volWrite = vol; - } else if (isSplit && pModDoc->GetSplitKeyboardSettings()->splitVolume) //cater for split volume override. + } else if (isSplit && pModDoc->GetSplitKeyboardSettings().splitVolume) //cater for split volume override. { - if (pModDoc->GetSplitKeyboardSettings()->splitVolume > 0 && pModDoc->GetSplitKeyboardSettings()->splitVolume <= 64) + if (pModDoc->GetSplitKeyboardSettings().splitVolume > 0 && pModDoc->GetSplitKeyboardSettings().splitVolume <= 64) { - volWrite = pModDoc->GetSplitKeyboardSettings()->splitVolume; + volWrite = pModDoc->GetSplitKeyboardSettings().splitVolume; } } @@ -4606,7 +4626,7 @@ // -- if recording, handle post note entry behaviour (move cursor etc..) if(bRecordEnabled) { - DWORD sel = CreateCursor(nRow) | m_dwCursor; + DWORD sel = CreateCursor(nRow, nChn, GetColTypeFromCursor(m_dwCursor)); if(bIsLiveRecord == false) { // Update only when not recording live. SetCurSel(sel, sel); @@ -4649,35 +4669,17 @@ return; } - BYTE* activeNoteMap = isSplit ? splitActiveNoteChannel : activeNoteChannel; + BYTE *activeNoteMap = isSplit ? splitActiveNoteChannel : activeNoteChannel; if (newcmd.note <= NOTE_MAX) activeNoteMap[newcmd.note] = nChn; - // Move to next channel if required if (recordGroup) { - bool channelLocked; - - CHANNELINDEX n = nChn; - for (CHANNELINDEX i = 1; i < pSndFile->GetNumChannels(); i++) + // Move to next channel in record group + nChn = FindGroupRecordChannel(recordGroup, false, nChn + 1); + if(nChn != CHANNELINDEX_INVALID) { - if (++n >= pSndFile->GetNumChannels()) n = 0; // loop around - - channelLocked = false; - for (int k = 0; k < NOTE_MAX; k++) - { - if (activeNoteChannel[k] == n || splitActiveNoteChannel[k] == n) - { - channelLocked = true; - break; - } - } - - if (pModDoc->IsChannelRecord(n) == recordGroup && !channelLocked) - { - SetCurrentColumn(CreateCursor(0, n)); - break; - } + SetCurrentColumn(CreateCursor(0, nChn)); } } } @@ -4863,6 +4865,57 @@ } +// Find a free channel for a record group, starting search from a given channel. +// If forceFreeChannel is true and all channels in the specified record group are active, some channel is picked from the specified record group. +CHANNELINDEX CViewPattern::FindGroupRecordChannel(BYTE recordGroup, bool forceFreeChannel, CHANNELINDEX startChannel) const +//------------------------------------------------------------------------------------------------------------------------- +{ + const CModDoc *pModDoc = GetDocument(); + if(pModDoc == nullptr) + { + return CHANNELINDEX_INVALID; + } + + CHANNELINDEX nChn = startChannel; + CHANNELINDEX foundChannel = CHANNELINDEX_INVALID; + + for(CHANNELINDEX i = 1; i < pModDoc->GetNumChannels(); i++, nChn++) + { + if(nChn >= pModDoc->GetNumChannels()) + { + nChn = 0; // loop around + } + + if(pModDoc->IsChannelRecord(nChn) == recordGroup) + { + // Check if any notes are playing on this channel + bool channelLocked = false; + for(size_t k = 0; k < CountOf(activeNoteChannel); k++) + { + if (activeNoteChannel[k] == nChn || splitActiveNoteChannel[k] == nChn) + { + channelLocked = true; + break; + } + } + + if (!channelLocked) + { + // Channel belongs to correct record group and no note is currently playing. + return nChn; + } + + if(forceFreeChannel) + { + // If all channels are active, we might still pick a random channel from the specified group. + foundChannel = nChn; + } + } + } + return foundChannel; +} + + void CViewPattern::OnClearField(int field, bool step, bool ITStyle) //----------------------------------------------------------------- { @@ -5019,38 +5072,46 @@ bool CViewPattern::HandleSplit(MODCOMMAND* p, int note) //----------------------------------------------------- { - CModDoc *pModDoc = GetDocument(); - CSoundFile *pSndFile; - if (pModDoc == nullptr || (pSndFile = pModDoc->GetSoundFile()) == nullptr) return false; - MODCOMMAND::INSTR ins = GetCurrentInstrument(); - bool isSplit = false; + const bool isSplit = IsNoteSplit(note); - if(pModDoc->GetSplitKeyboardSettings()->IsSplitActive()) + if(isSplit) { - if(note <= pModDoc->GetSplitKeyboardSettings()->splitNote) + CModDoc *pModDoc = GetDocument(); + CSoundFile *pSndFile; + if (pModDoc == nullptr || (pSndFile = pModDoc->GetSoundFile()) == nullptr) return false; + + if (pModDoc->GetSplitKeyboardSettings().octaveLink && note <= NOTE_MAX) { - isSplit = true; - - if (pModDoc->GetSplitKeyboardSettings()->octaveLink && note <= NOTE_MAX) - { - note += 12 * pModDoc->GetSplitKeyboardSettings()->octaveModifier; - Limit(note, pSndFile->GetModSpecifications().noteMin, pSndFile->GetModSpecifications().noteMax); - } - if (pModDoc->GetSplitKeyboardSettings()->splitInstrument) - { - ins = pModDoc->GetSplitKeyboardSettings()->splitInstrument; - } + note += 12 * pModDoc->GetSplitKeyboardSettings().octaveModifier; + Limit(note, pSndFile->GetModSpecifications().noteMin, pSndFile->GetModSpecifications().noteMax); } + if (pModDoc->GetSplitKeyboardSettings().splitInstrument) + { + ins = pModDoc->GetSplitKeyboardSettings().splitInstrument; + } } p->note = note; - if(ins) + if(ins) + { p->instr = ins; + } return isSplit; } + +bool CViewPattern::IsNoteSplit(int note) const +//-------------------------------------------- +{ + CModDoc *pModDoc = GetDocument(); + return(pModDoc != nullptr + && pModDoc->GetSplitKeyboardSettings().IsSplitActive() + && note <= pModDoc->GetSplitKeyboardSettings().splitNote); +} + + bool CViewPattern::BuildPluginCtxMenu(HMENU hMenu, UINT nChn, CSoundFile *pSndFile) const //--------------------------------------------------------------------------------------- { Modified: trunk/OpenMPT/mptrack/View_pat.h =================================================================== --- trunk/OpenMPT/mptrack/View_pat.h 2011-10-21 17:25:25 UTC (rev 1115) +++ trunk/OpenMPT/mptrack/View_pat.h 2011-10-21 20:45:15 UTC (rev 1116) @@ -358,7 +358,10 @@ private: void SetSplitKeyboardSettings(); bool HandleSplit(MODCOMMAND *p, int note); + bool IsNoteSplit(int note) const; + CHANNELINDEX FindGroupRecordChannel(BYTE recordGroup, bool forceFreeChannel, CHANNELINDEX startChannel = 0) const; + bool BuildChannelControlCtxMenu(HMENU hMenu) const; bool BuildPluginCtxMenu(HMENU hMenu, UINT nChn, CSoundFile *pSndFile) const; bool BuildRecordCtxMenu(HMENU hMenu, UINT nChn, CModDoc *pModDoc) const; Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-10-21 17:25:25 UTC (rev 1115) +++ trunk/OpenMPT/mptrack/version.h 2011-10-21 20:45:15 UTC (rev 1116) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 46 +#define VER_MINORMINOR 47 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-10-22 23:25:45
|
Revision: 1118 http://modplug.svn.sourceforge.net/modplug/?rev=1118&view=rev Author: saga-games Date: 2011-10-22 23:25:38 +0000 (Sat, 22 Oct 2011) Log Message: ----------- [Fix] Mod Conversion: Instrument fadeout is now limited properly when converting from XM to IT / MPTM. [Fix] General Tab: When enabling surround in the channel setup, panning was not reset properly for playing channels. [Imp] VST: Also checking for new VST entry point ("VSTPluginMain") when loading plugins now. [Mod] VST: Changed host response to audioMasterGetAutomationState opcode (seems more logical that way, although it doesn't seem to be documented at all what this is supposed to do)... Modified Paths: -------------- trunk/OpenMPT/mptrack/ModConvert.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Vstplug.cpp Modified: trunk/OpenMPT/mptrack/ModConvert.cpp =================================================================== --- trunk/OpenMPT/mptrack/ModConvert.cpp 2011-10-21 22:19:01 UTC (rev 1117) +++ trunk/OpenMPT/mptrack/ModConvert.cpp 2011-10-22 23:25:38 UTC (rev 1118) @@ -396,6 +396,14 @@ pIns->nGlobalVol = 64; pIns->nPan = 128; } + + // Convert XM to IT/MPTM - fix fadeout length + if(oldTypeIsXM && newTypeIsIT_MPT) + { + LimitMax(pIns->nFadeOut, 8192u); + } + + // Convert MPT to anything - remove instrument tunings, Pitch/Tempo Lock if(oldTypeIsMPT) { Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2011-10-21 22:19:01 UTC (rev 1117) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2011-10-22 23:25:38 UTC (rev 1118) @@ -1311,7 +1311,7 @@ bool CModDoc::MuteSample(SAMPLEINDEX nSample, bool bMute) //------------------------------------------------------- { - if ((nSample < 1) || (nSample > m_SndFile.m_nSamples)) return false; + if ((nSample < 1) || (nSample > m_SndFile.GetNumSamples())) return false; if (bMute) m_SndFile.GetSample(nSample).uFlags |= CHN_MUTE; else m_SndFile.GetSample(nSample).uFlags &= ~CHN_MUTE; return true; @@ -1320,7 +1320,7 @@ bool CModDoc::MuteInstrument(INSTRUMENTINDEX nInstr, bool bMute) //-------------------------------------------------------------- { - if ((nInstr < 1) || (nInstr > m_SndFile.m_nInstruments) || (!m_SndFile.Instruments[nInstr])) return false; + if ((nInstr < 1) || (nInstr > m_SndFile.GetNumInstruments()) || (!m_SndFile.Instruments[nInstr])) return false; if (bMute) m_SndFile.Instruments[nInstr]->dwFlags |= INS_MUTE; else m_SndFile.Instruments[nInstr]->dwFlags &= ~INS_MUTE; return true; @@ -1330,26 +1330,31 @@ bool CModDoc::SurroundChannel(CHANNELINDEX nChn, bool bSurround) //-------------------------------------------------------------- { - DWORD d = (bSurround) ? CHN_SURROUND : 0; + DWORD d = (bSurround ? CHN_SURROUND : 0); - if (nChn >= m_SndFile.m_nChannels) return false; - if (!(m_SndFile.m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT))) d = 0; + if (nChn >= m_SndFile.GetNumChannels()) return false; + if (!(m_SndFile.GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT))) d = 0; if (d != (m_SndFile.ChnSettings[nChn].dwFlags & CHN_SURROUND)) { - if (m_SndFile.m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT)) SetModified(); + if (m_SndFile.GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) SetModified(); if (d) { m_SndFile.ChnSettings[nChn].dwFlags |= CHN_SURROUND; m_SndFile.ChnSettings[nChn].nPan = 128; - } - else + } else { m_SndFile.ChnSettings[nChn].dwFlags &= ~CHN_SURROUND; } } - if (d) m_SndFile.Chn[nChn].dwFlags |= CHN_SURROUND; - else m_SndFile.Chn[nChn].dwFlags &= ~CHN_SURROUND; + if (d) + { + m_SndFile.Chn[nChn].dwFlags |= CHN_SURROUND; + m_SndFile.Chn[nChn].nPan = 128; + } else + { + m_SndFile.Chn[nChn].dwFlags &= ~CHN_SURROUND; + } return true; } @@ -1358,7 +1363,7 @@ //------------------------------------------------------------------- { bool bOk = false; - if ((nChn >= m_SndFile.m_nChannels) || (nVolume > 64)) return false; + if ((nChn >= m_SndFile.GetNumChannels()) || (nVolume > 64)) return false; if (m_SndFile.ChnSettings[nChn].nVolume != nVolume) { m_SndFile.ChnSettings[nChn].nVolume = nVolume; @@ -1374,7 +1379,7 @@ //-------------------------------------------------------------- { bool bOk = false; - if ((nChn >= m_SndFile.m_nChannels) || (nPan > 256)) return false; + if ((nChn >= m_SndFile.GetNumChannels()) || (nPan > 256)) return false; if (m_SndFile.ChnSettings[nChn].nPan != nPan) { m_SndFile.ChnSettings[nChn].nPan = nPan; Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2011-10-21 22:19:01 UTC (rev 1117) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2011-10-22 23:25:38 UTC (rev 1118) @@ -300,6 +300,10 @@ { BOOL bOk = FALSE; PVSTPLUGENTRY pMainProc = (PVSTPLUGENTRY)GetProcAddress(hLib, "main"); + if(pMainProc == NULL) + { + pMainProc = (PVSTPLUGENTRY)GetProcAddress(hLib, "VSTPluginMain"); + } #ifdef ENABLE_BUZZ GET_INFO pBuzzGetInfo = (GET_INFO)GetProcAddress(hLib, "GetInfo"); #endif // ENABLE_BUZZ @@ -569,6 +573,10 @@ { AEffect *pEffect = NULL; PVSTPLUGENTRY pEntryPoint = (PVSTPLUGENTRY)GetProcAddress(hLibrary, "main"); + if(pEntryPoint == NULL) + { + pEntryPoint = (PVSTPLUGENTRY)GetProcAddress(hLibrary, "VSTPluginMain"); + } #ifdef ENABLE_BUZZ GET_INFO pBuzzGetInfo = (GET_INFO)GetProcAddress(hLibrary, "GetInfo"); CREATE_MACHINE pBuzzCreateMachine = (CREATE_MACHINE)GetProcAddress(hLibrary, "CreateMachine"); @@ -827,7 +835,11 @@ // parameters - DEPRECATED in VST 2.4 case audioMasterGetNumAutomatableParameters: - Log("VST plugin to host: Get Num Automatable Parameters\n"); + //Log("VST plugin to host: Get Num Automatable Parameters\n"); + if(pVstPlugin != nullptr) + { + return pVstPlugin->GetNumParameters(); + } break; // Apparently, this one is broken in VST SDK anyway. - DEPRECATED in VST 2.4 @@ -909,7 +921,7 @@ // Not entirely sure what this means. We can write automation TO the plug. // Is that "read" in this context? //Log("VST plugin to host: Get Automation State\n"); - return kVstAutomationRead; + return kVstAutomationReadWrite; case audioMasterOfflineStart: Log("VST plugin to host: Offlinestart\n"); @@ -942,7 +954,7 @@ break; case audioMasterGetVendorString: - strcpy((char *) ptr, s_szHostVendorString); + strncpy((char *) ptr, s_szHostVendorString, 64); //strcpy((char*)ptr,"Steinberg"); //return 0; return true; @@ -952,7 +964,7 @@ //return 7000; case audioMasterGetProductString: - strcpy((char *) ptr, s_szHostProductString); + strncpy((char *) ptr, s_szHostProductString, 64); //strcpy((char*)ptr,"Cubase VST"); //return 0; return true; @@ -1602,7 +1614,7 @@ return 0; } -//rewbs.VSTcompliance: changed from BOOL to long + PlugParamIndex CVstPlugin::GetNumParameters() //------------------------------------------- { @@ -1613,7 +1625,7 @@ return 0; } -//rewbs.VSTpresets + VstInt32 CVstPlugin::GetUID() //--------------------------- { @@ -1622,6 +1634,7 @@ return m_pEffect->uniqueID; } + VstInt32 CVstPlugin::GetVersion() //------------------------------- { @@ -1631,38 +1644,36 @@ return m_pEffect->version; } + bool CVstPlugin::GetParams(float *param, VstInt32 min, VstInt32 max) //------------------------------------------------------------------ { if (!(m_pEffect)) return false; - if (max>m_pEffect->numParams) - max = m_pEffect->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; } + bool CVstPlugin::RandomizeParams(VstInt32 minParam, VstInt32 maxParam) //-------------------------------------------------------------------- { if (!(m_pEffect)) return false; - if (minParam==0 && maxParam==0) + if (minParam == 0 && maxParam == 0) { - minParam=0; - maxParam=m_pEffect->numParams; + minParam = 0; + maxParam = m_pEffect->numParams; } - else if (maxParam>m_pEffect->numParams) - { - maxParam=m_pEffect->numParams; - } + LimitMax(maxParam, m_pEffect->numParams); for (VstInt32 p = minParam; p < maxParam; p++) SetParameter(p, (rand() / float(RAND_MAX))); @@ -1670,6 +1681,7 @@ return true; } + bool CVstPlugin::SaveProgram(CString fileName) //-------------------------------------------- { @@ -1714,6 +1726,7 @@ } + bool CVstPlugin::LoadProgram(CString fileName) //-------------------------------------------- { @@ -1742,6 +1755,7 @@ } //end rewbs.VSTpresets + VstIntPtr CVstPlugin::Dispatch(VstInt32 opCode, VstInt32 index, VstIntPtr value, void *ptr, float opt) //---------------------------------------------------------------------------------------------------- { @@ -3031,18 +3045,21 @@ return slot; } + void CVstPlugin::SetSlot(PLUGINDEX slot) //-------------------------------------- { m_nSlot = slot; } + PLUGINDEX CVstPlugin::GetSlot() //----------------------------- { return m_nSlot; } + void CVstPlugin::UpdateMixStructPtr(PSNDMIXPLUGIN p) //-------------------------------------------------- { @@ -3058,13 +3075,14 @@ return false; } + bool CVstPlugin::CanRecieveMidiEvents() //------------------------------------- { - CString s = "receiveVstMidiEvent"; - return (CVstPlugin::Dispatch(effCanDo, 0, 0, (char*)(LPCTSTR)s, 0) != 0); + return (CVstPlugin::Dispatch(effCanDo, 0, nullptr, "receiveVstMidiEvent", 0.0f) != 0); } + void CVstPlugin::GetOutputPlugList(CArray<CVstPlugin*, CVstPlugin*> &list) //------------------------------------------------------------------------ { @@ -4073,15 +4091,16 @@ } +#endif // NO_VST + const char* SNDMIXPLUGIN::GetLibraryName() -//------------------------------------ +//---------------------------------------- { StringFixer::SetNullTerminator(Info.szLibraryName); - if(Info.szLibraryName[0]) return Info.szLibraryName; + if(Info.szLibraryName[0]) return Info.szLibraryName; else return 0; } -#endif // NO_VST CString SNDMIXPLUGIN::GetParamName(const UINT index) const //-------------------------------------------------------- @@ -4091,7 +4110,9 @@ return reinterpret_cast<CVstPlugin *>(pMixPlugin)->GetParamName(index); } else + { return CString(); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-10-24 20:07:52
|
Revision: 1121 http://modplug.svn.sourceforge.net/modplug/?rev=1121&view=rev Author: saga-games Date: 2011-10-24 20:07:46 +0000 (Mon, 24 Oct 2011) Log Message: ----------- [Imp] If a plugin fails to load and crashes OpenMPT, it should not be loaded the next time OpenMPT is started anymore. [Mod] OpenMPT: Version is now 1.20.00.48 Modified Paths: -------------- trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/version.h Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2011-10-23 20:34:22 UTC (rev 1120) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2011-10-24 20:07:46 UTC (rev 1121) @@ -495,7 +495,7 @@ if (!gpDLSBanks[i] || !gpDLSBanks[i]->GetFileName() || !gpDLSBanks[i]->GetFileName()[0]) continue; - _tcsncpy(szPath, gpDLSBanks[i]->GetFileName(), ARRAYELEMCOUNT(szPath) - 1); + _tcsncpy(szPath, gpDLSBanks[i]->GetFileName(), CountOf(szPath) - 1); if(theApp.IsPortableMode()) { theApp.AbsolutePathToRelative(szPath); @@ -2152,6 +2152,8 @@ CString nonFoundPlugs; + const CString failedPlugin = CMainFrame::GetPrivateProfileCString("VST Plugins", "FailedPlugin", "", m_szConfigFileName); + for (LONG iPlug=0; iPlug<nPlugins; iPlug++) { s[0] = 0; @@ -2160,7 +2162,15 @@ if (s[0]) { RelativePathToAbsolute(s); - m_pPluginManager->AddPlugin(s, TRUE, true, &nonFoundPlugs); + + if(failedPlugin.Compare(s) != 0) + { + m_pPluginManager->AddPlugin(s, TRUE, true, &nonFoundPlugs); + } else + { + const CString text = "The following plugin has previously crashed OpenMPT during initialisation and will thus not be loaded:\n\n" + failedPlugin; + Reporting::Information(text); + } } } if(nonFoundPlugs.GetLength() > 0) Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2011-10-23 20:34:22 UTC (rev 1120) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2011-10-24 20:07:46 UTC (rev 1121) @@ -278,6 +278,9 @@ HINSTANCE hLib = NULL; + // If this key contains a file name on program launch, a plugin previously crashed OpenMPT. + WritePrivateProfileString("VST Plugins", "FailedPlugin", pszDllPath, theApp.GetConfigFileName()); + try { hLib = LoadLibrary(pszDllPath); @@ -421,18 +424,19 @@ #endif // VST_LOG } - //try { - FreeLibrary(hLib); - //} catch (...) { - // CVstPluginManager::ReportPlugException("Exception in FreeLibrary(\"%s\")!\n", pszDllPath); - //} + FreeLibrary(hLib); + // Now it should be safe to assume that this plugin loaded properly. :) + WritePrivateProfileString("VST Plugins", "FailedPlugin", NULL, theApp.GetConfigFileName()); + return (bOk) ? m_pVstHead : nullptr; } else { #ifdef VST_LOG Log("LoadLibrary(%s) failed!\n", pszDllPath); #endif // VST_LOG + + WritePrivateProfileString("VST Plugins", "FailedPlugin", NULL, theApp.GetConfigFileName()); } return nullptr; } @@ -1394,7 +1398,7 @@ MemsetZero(sa); sa.numChannels = 2; sa.type = kSpeakerArrStereo; - for(int i = 0; i < ARRAYELEMCOUNT(sa.speakers); i++) + for(int i = 0; i < CountOf(sa.speakers); i++) { sa.speakers[i].azimuth = 0.0f; sa.speakers[i].elevation = 0.0f; Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-10-23 20:34:22 UTC (rev 1120) +++ trunk/OpenMPT/mptrack/version.h 2011-10-24 20:07:46 UTC (rev 1121) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 47 +#define VER_MINORMINOR 48 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-10-30 16:17:41
|
Revision: 1129 http://modplug.svn.sourceforge.net/modplug/?rev=1129&view=rev Author: saga-games Date: 2011-10-30 16:17:35 +0000 (Sun, 30 Oct 2011) Log Message: ----------- [Imp] Added "Show Settings Folder" menu item to help menu [Imp] Instrument Editor: Updated cutoff explanation Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/mptrack/resource.h Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-10-30 13:12:33 UTC (rev 1128) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-10-30 16:17:35 UTC (rev 1129) @@ -1381,22 +1381,26 @@ void CCtrlInstruments::UpdateFilterText() //--------------------------------------- { - if ((m_nInstrument) && (m_pModDoc)) + if((m_nInstrument) && (m_pModDoc)) { CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); MODINSTRUMENT *pIns = pSndFile->Instruments[m_nInstrument]; - if (pIns) + if(pIns) { CHAR s[32]; // In IT Compatible mode, it is enough to just have resonance enabled to turn on the filter. const bool resEnabled = (pIns->IsResonanceEnabled() && pIns->GetResonance() > 0 && pSndFile->IsCompatibleMode(TRK_IMPULSETRACKER)); - if ((pIns->IsCutoffEnabled() && pIns->GetCutoff() < 0x7F) || resEnabled) + if((pIns->IsCutoffEnabled() && pIns->GetCutoff() < 0x7F) || resEnabled) { const BYTE cutoff = (resEnabled && !pIns->IsCutoffEnabled()) ? 0x7F : pIns->GetCutoff(); wsprintf(s, "Z%02X (%d Hz)", cutoff, pSndFile->CutOffToFrequency(cutoff)); - } else { - wsprintf(s, "Off"); + } else if(pIns->IsCutoffEnabled()) + { + strcpy(s, "Z7F (Off)"); + } else + { + strcpy(s, "No Change"); } SetDlgItemText(IDC_FILTERTEXT, s); Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2011-10-30 13:12:33 UTC (rev 1128) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2011-10-30 16:17:35 UTC (rev 1129) @@ -105,6 +105,7 @@ ON_MESSAGE(WM_MOD_SPECIALKEY, OnSpecialKey) ON_MESSAGE(WM_MOD_KEYCOMMAND, OnCustomKeyMsg) //rewbs.customKeys ON_COMMAND(ID_INTERNETUPDATE, OnInternetUpdate) + ON_COMMAND(ID_HELP_SHOWSETTINGSFOLDER, OnShowSettingsFolder) //}}AFX_MSG_MAP ON_WM_INITMENU() ON_WM_KILLFOCUS() //rewbs.fix3116 @@ -2564,6 +2565,13 @@ } +void CMainFrame::OnShowSettingsFolder() +//------------------------------------- +{ + theApp.OpenDirectory(theApp.GetConfigPath()); +} + + HMENU CMainFrame::CreateFileMenu(const size_t nMaxCount, std::vector<CString>& vPaths, const LPCTSTR pszFolderName, const uint16 nIdRangeBegin) //--------------------------------------------------------------------------------------------------------------------------------------------- { Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2011-10-30 13:12:33 UTC (rev 1128) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2011-10-30 16:17:35 UTC (rev 1129) @@ -646,6 +646,7 @@ afx_msg void OnViewMIDIMapping(); afx_msg void OnViewEditHistory(); afx_msg void OnInternetUpdate(); + afx_msg void OnShowSettingsFolder(); //}}AFX_MSG DECLARE_MESSAGE_MAP() public: Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2011-10-30 13:12:33 UTC (rev 1128) +++ trunk/OpenMPT/mptrack/mptrack.rc 2011-10-30 16:17:35 UTC (rev 1129) @@ -1702,6 +1702,10 @@ BOTTOMMARGIN, 94 END + IDD_CONTROL_GLOBALS, DIALOG + BEGIN + END + IDD_CONTROL_COMMENTS, DIALOG BEGIN RIGHTMARGIN, 348 @@ -2116,9 +2120,10 @@ BEGIN MENUITEM "&Contents", ID_HELP_FINDER MENUITEM "&Search...", ID_HELP_SEARCH - MENUITEM "&Report a bug", ID_REPORT_BUG + MENUITEM "&Report a Bug", ID_REPORT_BUG MENUITEM SEPARATOR - MENUITEM "&Example modules", ID_EXAMPLE_MODULES + MENUITEM "&Example Modules", ID_EXAMPLE_MODULES + MENUITEM "Show Settings Folder", ID_HELP_SHOWSETTINGSFOLDER MENUITEM SEPARATOR MENUITEM "&OpenMPT Website", ID_NETLINK_MODPLUG MENUITEM "&Web Resources", ID_NETLINK_TOP_PICKS Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2011-10-30 13:12:33 UTC (rev 1128) +++ trunk/OpenMPT/mptrack/resource.h 2011-10-30 16:17:35 UTC (rev 1129) @@ -1207,9 +1207,8 @@ #define ID_FXCOMMANDS_BASE 44462 // From here: Command range [ID_FXCOMMANDS_BASE, ID_FXCOMMANDS_BASE + 10] #define ID_PLUGINEDITOR_SLIDERS_BASE 44500 -// From here: Command range [ID_PLUGINEDITOR_SLIDERS_BASE, ID_PLUGINEDITOR_SLIDERS_BASE + NUM_PLUGINEDITOR_PARAMETERS] #define ID_PLUGINEDITOR_EDIT_BASE 44550 -// From here: Command range [ID_PLUGINEDITOR_EDIT_BASE, ID_PLUGINEDITOR_EDIT_BASE + NUM_PLUGINEDITOR_PARAMETERS] +#define ID_HELP_SHOWSETTINGSFOLDER 44600 // Next default values for new objects // @@ -1217,7 +1216,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_3D_CONTROLS 1 #define _APS_NEXT_RESOURCE_VALUE 535 -#define _APS_NEXT_COMMAND_VALUE 44600 +#define _APS_NEXT_COMMAND_VALUE 44601 #define _APS_NEXT_CONTROL_VALUE 2448 #define _APS_NEXT_SYMED_VALUE 901 #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-10-31 21:27:06
|
Revision: 1130 http://modplug.svn.sourceforge.net/modplug/?rev=1130&view=rev Author: saga-games Date: 2011-10-31 21:26:59 +0000 (Mon, 31 Oct 2011) Log Message: ----------- [Mod] Changed DMO plugin processing from 16-Bit integer to 32-Bit float. All default DMO plugins seem to support this. Modified Paths: -------------- trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/resource.h Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2011-10-30 16:17:35 UTC (rev 1129) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2011-10-31 21:26:59 UTC (rev 1130) @@ -3622,8 +3622,8 @@ ULONG m_nSamplesPerSec; AEffect m_Effect; REFERENCE_TIME m_DataTime; - short int *m_pMixBuffer; - short int m_MixBuffer[MIXBUFFERSIZE*2+16]; // 16-bit Stereo interleaved + float *m_pMixBuffer; + float m_MixBuffer[MIXBUFFERSIZE * 2 + 16]; // 16-bit Stereo interleaved public: CDmo2Vst(IMediaObject *pMO, IMediaObjectInPlace *pMOIP, DWORD uid); @@ -3632,13 +3632,17 @@ VstIntPtr Dispatcher(VstInt32 opCode, VstInt32 index, VstIntPtr value, void *ptr, float opt); void SetParameter(VstInt32 index, float parameter); float GetParameter(VstInt32 index); - void Process(float **inputs, float **outputs, long sampleframes); + void Process(float * const *inputs, float **outputs, long sampleframes); public: static VstIntPtr VSTCALLBACK DmoDispatcher(AEffect *effect, VstInt32 opCode, VstInt32 index, VstIntPtr value, void *ptr, float opt); static void VSTCALLBACK DmoSetParameter(AEffect *effect, VstInt32 index, float parameter); static float VSTCALLBACK DmoGetParameter(AEffect *effect, VstInt32 index); static void VSTCALLBACK DmoProcess(AEffect *effect, float **inputs, float **outputs, VstInt32 sampleframes); + +protected: + void Interleave(const float *pinL, const float *pinR, int nsamples); + void Deinterleave(float *poutL, float *poutR, int nsamples); }; @@ -3670,7 +3674,7 @@ m_Effect.numParams = dwParamCount; } if (FAILED(m_pMediaObject->QueryInterface(IID_IMediaParams, (void **)&m_pMediaParams))) m_pMediaParams = NULL; - m_pMixBuffer = (short int *)((((int)m_MixBuffer)+15)&~15); + m_pMixBuffer = (float *)((((int)m_MixBuffer)+15)&~15); // Callbacks m_Effect.dispatcher = DmoDispatcher; m_Effect.setParameter = DmoSetParameter; @@ -3846,11 +3850,11 @@ mt.pUnk = NULL; mt.pbFormat = (LPBYTE)&wfx; mt.cbFormat = sizeof(WAVEFORMATEX); - mt.lSampleSize = 4; - wfx.wFormatTag = WAVE_FORMAT_PCM; + mt.lSampleSize = 2 * sizeof(float); + wfx.wFormatTag = WAVE_FORMAT_IEEE_FLOAT; wfx.nChannels = 2; wfx.nSamplesPerSec = m_nSamplesPerSec; - wfx.wBitsPerSample = 16; + wfx.wBitsPerSample = 32; wfx.nBlockAlign = wfx.nChannels * (wfx.wBitsPerSample >> 3); wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign; wfx.cbSize = 0; @@ -3937,141 +3941,40 @@ return 0; } -static const float _f2si = 32768.0f; -static const float _si2f = 1.0f / 32768.0f; -void X86_FloatToStereo16Mix(const float *pIn1, const float *pIn2, short int *pOut, int sampleframes) -//-------------------------------------------------------------------------------------------------- +void CDmo2Vst::Interleave(const float *pinL, const float *pinR, int nsamples) +//--------------------------------------------------------------------------- { - for (int i=0; i<sampleframes; i++) + float *pout = m_pMixBuffer; + for(int i = nsamples; i != 0; i--) { - int xl = (int)(pIn1[i] * _f2si); - int xr = (int)(pIn2[i] * _f2si); - Limit(xl, int16_min, int16_max); - Limit(xr, int16_min, int16_max); - pOut[i*2] = static_cast<int16>(xl); - pOut[i*2+1] = static_cast<int16>(xr); + *(pout++) = *(pinL++); + *(pout++) = *(pinR++); } } -void X86_Stereo16AddMixToFloat(const short int *pIn, float *pOut1, float *pOut2, int sampleframes) -//------------------------------------------------------------------------------------------------ +void CDmo2Vst::Deinterleave(float *poutL, float *poutR, int nsamples) +//------------------------------------------------------------------- { - for (int i=0; i<sampleframes; i++) + const float *pin = m_pMixBuffer; + for(int i = nsamples; i != 0; i--) { - float xl = _si2f * (float)pIn[i*2]; - float xr = _si2f * (float)pIn[i*2+1]; - pOut1[i] += xl; - pOut2[i] += xr; + *(poutL++) = *(pin++); + *(poutR++) = *(pin++); } } -#ifdef ENABLE_SSE -void SSE_FloatToStereo16Mix(const float *pIn1, const float *pIn2, short int *pOut, int sampleframes) -//-------------------------------------------------------------------------------------------------- +void CDmo2Vst::Process(float * const *inputs, float **outputs, long sampleframes) +//------------------------------------------------------------------------------- { - _asm { - mov eax, pIn1 - mov edx, pIn2 - mov ebx, pOut - mov ecx, sampleframes - movss xmm2, _f2si - xorps xmm0, xmm0 - xorps xmm1, xmm1 - shufps xmm2, xmm2, 0x00 - pxor mm0, mm0 - inc ecx - shr ecx, 1 -mainloop: - movlps xmm0, [eax] - movlps xmm1, [edx] - mulps xmm0, xmm2 - mulps xmm1, xmm2 - add ebx, 8 - cvtps2pi mm0, xmm0 // mm0 = [ x2l | x1l ] - add eax, 8 - cvtps2pi mm1, xmm1 // mm1 = [ x2r | x1r ] - add edx, 8 - packssdw mm0, mm1 // mm0 = [x2r|x1r|x2l|x1l] - pshufw mm0, mm0, 0xD8 - dec ecx - movq [ebx-8], mm0 - jnz mainloop - emms - } -} - - -void SSE_Stereo16AddMixToFloat(const short int *pIn, float *pOut1, float *pOut2, int sampleframes) -//------------------------------------------------------------------------------------------------ -{ - _asm { - mov ebx, pIn - mov eax, pOut1 - mov edx, pOut2 - mov ecx, sampleframes - movss xmm7, _si2f - inc ecx - shr ecx, 1 - shufps xmm7, xmm7, 0x00 - xorps xmm0, xmm0 - xorps xmm1, xmm1 - xorps xmm2, xmm2 -mainloop: - movq mm0, [ebx] // mm0 = [x2r|x2l|x1r|x1l] - add ebx, 8 - pxor mm1, mm1 - pxor mm2, mm2 - punpcklwd mm1, mm0 // mm1 = [x1r|0|x1l|0] - punpckhwd mm2, mm0 // mm2 = [x2r|0|x2l|0] - psrad mm1, 16 // mm1 = [x1r|x1l] - movlps xmm2, [eax] - psrad mm2, 16 // mm2 = [x2r|x2l] - cvtpi2ps xmm0, mm1 // xmm0 = [ ? | ? |x1r|x1l] - dec ecx - cvtpi2ps xmm1, mm2 // xmm1 = [ ? | ? |x2r|x2l] - movhps xmm2, [edx] // xmm2 = [y2r|y1r|y2l|y1l] - movlhps xmm0, xmm1 // xmm0 = [x2r|x2l|x1r|x1l] - shufps xmm0, xmm0, 0xD8 - lea eax, [eax+8] - mulps xmm0, xmm7 - addps xmm0, xmm2 - lea edx, [edx+8] - movlps [eax-8], xmm0 - movhps [edx-8], xmm0 - jnz mainloop - emms - } -} - -#endif - -void CDmo2Vst::Process(float **inputs, float **outputs, long sampleframes) -//------------------------------------------------------------------------ -{ if ((!m_pMixBuffer) || (sampleframes <= 0)) return; -#ifdef ENABLE_MMX -#ifdef ENABLE_SSE - if ((CSoundFile::gdwSysInfo & SYSMIX_SSE) && (CSoundFile::gdwSoundSetup & SNDMIX_ENABLEMMX)) - { - SSE_FloatToStereo16Mix(inputs[0], inputs[1], m_pMixBuffer, sampleframes); - m_pMediaProcess->Process(sampleframes*4, (LPBYTE)m_pMixBuffer, m_DataTime, DMO_INPLACE_NORMAL); - SSE_Stereo16AddMixToFloat(m_pMixBuffer, outputs[0], outputs[1], sampleframes); - } else { -#endif -#endif - X86_FloatToStereo16Mix(inputs[0], inputs[1], m_pMixBuffer, sampleframes); - m_pMediaProcess->Process(sampleframes*4, (LPBYTE)m_pMixBuffer, m_DataTime, DMO_INPLACE_NORMAL); - X86_Stereo16AddMixToFloat(m_pMixBuffer, outputs[0], outputs[1], sampleframes); -#ifdef ENABLE_MMX -#ifdef ENABLE_SSE - } -#endif -#endif + Interleave(inputs[0], inputs[1], sampleframes); + m_pMediaProcess->Process(sampleframes * 2 * sizeof(float), (LPBYTE)m_pMixBuffer, m_DataTime, DMO_INPLACE_NORMAL); + Deinterleave(outputs[0], outputs[1], sampleframes); m_DataTime += _muldiv(sampleframes, 10000000, m_nSamplesPerSec); } Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2011-10-30 16:17:35 UTC (rev 1129) +++ trunk/OpenMPT/mptrack/resource.h 2011-10-31 21:26:59 UTC (rev 1130) @@ -1207,7 +1207,9 @@ #define ID_FXCOMMANDS_BASE 44462 // From here: Command range [ID_FXCOMMANDS_BASE, ID_FXCOMMANDS_BASE + 10] #define ID_PLUGINEDITOR_SLIDERS_BASE 44500 +// From here: Command range [ID_PLUGINEDITOR_SLIDERS_BASE, ID_PLUGINEDITOR_SLIDERS_BASE + NUM_PLUGINEDITOR_PARAMETERS] #define ID_PLUGINEDITOR_EDIT_BASE 44550 +// From here: Command range [ID_PLUGINEDITOR_EDIT_BASE, ID_PLUGINEDITOR_EDIT_BASE + NUM_PLUGINEDITOR_PARAMETERS] #define ID_HELP_SHOWSETTINGSFOLDER 44600 // Next default values for new objects This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-11-06 15:05:16
|
Revision: 1133 http://modplug.svn.sourceforge.net/modplug/?rev=1133&view=rev Author: saga-games Date: 2011-11-06 15:05:09 +0000 (Sun, 06 Nov 2011) Log Message: ----------- [Fix] Instrument Editor: Envelope position display is now correct again in IT compatible mode. [Imp] Comments tab: Instrument list building is now more efficient (mostly noticeable in debug mode, but anyway...) [Mod] OpenMPT: Version is now 1.20.00.52 Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/version.h trunk/OpenMPT/mptrack/view_com.cpp Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2011-11-05 15:15:50 UTC (rev 1132) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2011-11-06 15:05:09 UTC (rev 1133) @@ -1086,7 +1086,16 @@ env = &pChn->PanEnv; } - if (env->flags & ENV_ENABLED) p->dwPos[k] = MPTNOTIFY_POSVALID | (DWORD)(env->nEnvPosition); + if (env->flags & ENV_ENABLED) + { + DWORD pos = env->nEnvPosition; + if(m_pSndFile->IsCompatibleMode(TRK_IMPULSETRACKER) && pos > 0) + { + // Impulse Tracker envelope handling (see SndMix.cpp for details) + pos--; + } + p->dwPos[k] = MPTNOTIFY_POSVALID | pos; + } } } } else Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-11-05 15:15:50 UTC (rev 1132) +++ trunk/OpenMPT/mptrack/version.h 2011-11-06 15:05:09 UTC (rev 1133) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 51 +#define VER_MINORMINOR 52 //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/view_com.cpp =================================================================== --- trunk/OpenMPT/mptrack/view_com.cpp 2011-11-05 15:15:50 UTC (rev 1132) +++ trunk/OpenMPT/mptrack/view_com.cpp 2011-11-06 15:05:09 UTC (rev 1133) @@ -8,6 +8,7 @@ #include "ChannelManagerDlg.h" #include "../common/StringFixer.h" #include "view_com.h" +#include <set> #define DETAILS_TOOLBAR_CY 28 @@ -238,9 +239,9 @@ { UINT nMax = nCount; if (nMax < pSndFile->GetNumSamples()) nMax = pSndFile->GetNumSamples(); - for (UINT iSmp=0; iSmp<nMax; iSmp++) + for (SAMPLEINDEX iSmp = 0; iSmp < nMax; iSmp++) { - if (iSmp < pSndFile->m_nSamples) + if (iSmp < pSndFile->GetNumSamples()) { UINT nCol = 0; for (UINT iCol=0; iCol<SMPLIST_COLUMNS; iCol++) @@ -271,24 +272,25 @@ } break; case SMPLIST_INSTR: - if (pSndFile->m_nInstruments) + if (pSndFile->GetNumInstruments()) { - UINT k = 0; - for (UINT i=0; i<pSndFile->m_nInstruments; i++) if (pSndFile->Instruments[i+1]) + bool first = true; + for (INSTRUMENTINDEX i = 0; i < pSndFile->GetNumInstruments(); i++) if (pSndFile->Instruments[i + 1]) { - MODINSTRUMENT *pIns = pSndFile->Instruments[i+1]; - for (UINT j=0; j<NOTE_MAX; j++) + MODINSTRUMENT *pIns = pSndFile->Instruments[i + 1]; + for (size_t j = 0; j < CountOf(pIns->Keyboard); j++) { - if ((UINT)pIns->Keyboard[j] == (iSmp+1)) + if (pIns->Keyboard[j] == (iSmp + 1)) { - if (k) strcat(s, ","); - wsprintf(stmp, "%d", i+1); + if (!first) strcat(s, ","); + first = false; + + wsprintf(stmp, "%d", i + 1); strcat(s, stmp); - k++; break; } } - if (strlen(s) > sizeof(s)-10) + if (strlen(s) > sizeof(s) - 10) { strcat(s, "..."); break; @@ -313,7 +315,7 @@ lvi.pszText = (LPTSTR)s; if ((iCol) || (iSmp < nCount)) { - BOOL bOk = TRUE; + bool bOk = true; if (iSmp < nCount) { lvi2 = lvi; @@ -321,7 +323,7 @@ lvi2.cchTextMax = sizeof(stmp); stmp[0] = 0; m_ItemList.GetItem(&lvi2); - if (!strcmp(s, stmp)) bOk = FALSE; + if (!strcmp(s, stmp)) bOk = false; } if (bOk) m_ItemList.SetItem(&lvi); } else @@ -340,7 +342,7 @@ if ((m_nCurrentListId == IDC_LIST_INSTRUMENTS) && (lHint & (HINT_MODTYPE|HINT_INSNAMES|HINT_INSTRUMENT))) { UINT nMax = nCount; - if (nMax < pSndFile->m_nInstruments) nMax = pSndFile->m_nInstruments; + if (nMax < pSndFile->GetNumInstruments()) nMax = pSndFile->GetNumInstruments(); for (UINT iIns=0; iIns<nMax; iIns++) { if (iIns < pSndFile->m_nInstruments) @@ -361,24 +363,26 @@ case INSLIST_SAMPLES: if (pIns) { - vector<bool> smpRef(MAX_SAMPLES, false); - for (UINT i=0; i<NOTE_MAX; i++) + std::set<SAMPLEINDEX> referencedSamples; + for(size_t i = 0; i < CountOf(pIns->Keyboard); i++) { - UINT n = pIns->Keyboard[i]; - if ((n) && (n < MAX_SAMPLES)) smpRef[n] = true; + referencedSamples.insert(pIns->Keyboard[i]); } - UINT k = 0; - for (UINT j=1; j<MAX_SAMPLES; j++) if (smpRef[j]) + + bool first = true; + for(std::set<SAMPLEINDEX>::iterator iter = referencedSamples.begin(); iter != referencedSamples.end(); iter++) { - if (k) strcat(s, ","); - UINT l = strlen(s); - if (l >= sizeof(s)-8) + if(!first) strcat(s, ","); + first = false; + + size_t l = strlen(s); + if(l >= sizeof(s) - 8) { strcat(s, "..."); break; } - wsprintf(s+l, "%d", j); - k++; + + wsprintf(s + l, "%d", *iter); } } break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-11-13 00:59:24
|
Revision: 1135 http://modplug.svn.sourceforge.net/modplug/?rev=1135&view=rev Author: saga-games Date: 2011-11-13 00:59:17 +0000 (Sun, 13 Nov 2011) Log Message: ----------- [Fix] Pattern names were not duplicated (http://bugs.openmpt.org/view.php?id=208) [Fix] Instrument list on comments tab had sample 0 in all sample lists. Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_pat.cpp trunk/OpenMPT/mptrack/view_com.cpp Modified: trunk/OpenMPT/mptrack/Ctrl_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2011-11-12 17:26:58 UTC (rev 1134) +++ trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2011-11-13 00:59:17 UTC (rev 1135) @@ -814,10 +814,10 @@ } +// Duplicates one or more patterns. void CCtrlPatterns::OnPatternDuplicate() //-------------------------------------- { - // duplicates one or more patterns. if (m_pModDoc) { CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); @@ -828,53 +828,64 @@ if (nInsertWhere >= pSndFile->GetModSpecifications().ordersMax) return; bool bSuccess = false; - // has this pattern been duplicated already? (for multiselect) - vector<PATTERNINDEX> pReplaceIndex; - pReplaceIndex.resize(pSndFile->Patterns.Size(), PATTERNINDEX_INVALID); + // Has this pattern been duplicated already? (for multiselect) + vector<PATTERNINDEX> patReplaceIndex(pSndFile->Patterns.Size(), PATTERNINDEX_INVALID); for(ORDERINDEX i = 0; i <= nInsertCount; i++) { PATTERNINDEX nCurPat = pSndFile->Order[selection.nOrdLo + i]; - ROWINDEX rows = 64; - if (pSndFile->Patterns.IsValidIndex(nCurPat) && pReplaceIndex[nCurPat] == PATTERNINDEX_INVALID) + if (pSndFile->Patterns.IsValidIndex(nCurPat) && patReplaceIndex[nCurPat] == PATTERNINDEX_INVALID) { - rows = pSndFile->Patterns[nCurPat].GetNumRows(); - rows = CLAMP(rows, pSndFile->GetModSpecifications().patternRowsMin, pSndFile->GetModSpecifications().patternRowsMax); + ROWINDEX rows = pSndFile->Patterns[nCurPat].GetNumRows(); + Limit(rows, pSndFile->GetModSpecifications().patternRowsMin, pSndFile->GetModSpecifications().patternRowsMax); PATTERNINDEX nNewPat = m_pModDoc->InsertPattern(nInsertWhere + i, rows); if ((nNewPat != PATTERNINDEX_INVALID) && (nNewPat < pSndFile->Patterns.Size()) && (pSndFile->Patterns[nCurPat] != nullptr)) { - // update time signature + // Update time signature and pattern name if(pSndFile->Patterns[nCurPat].GetOverrideSignature()) { pSndFile->Patterns[nNewPat].SetSignature(pSndFile->Patterns[nCurPat].GetRowsPerBeat(), pSndFile->Patterns[nCurPat].GetRowsPerMeasure()); } - // copy pattern data - MODCOMMAND *pSrc = pSndFile->Patterns[nCurPat]; - MODCOMMAND *pDest = pSndFile->Patterns[nNewPat]; - UINT n = pSndFile->Patterns[nCurPat].GetNumRows(); + pSndFile->Patterns[nNewPat].SetName(pSndFile->Patterns[nCurPat].GetName()); + + // Copy pattern data + size_t n = pSndFile->Patterns[nCurPat].GetNumRows(); if (pSndFile->Patterns[nNewPat].GetNumRows() < n) n = pSndFile->Patterns[nNewPat].GetNumRows(); - n *= pSndFile->m_nChannels; - if (n) memcpy(pDest, pSrc, n * sizeof(MODCOMMAND)); + n *= pSndFile->GetNumChannels(); + if(n) + { + memcpy(pSndFile->Patterns[nNewPat], pSndFile->Patterns[nCurPat], n * sizeof(MODCOMMAND)); + } bSuccess = true; - pReplaceIndex[nCurPat] = nNewPat; // mark as duplicated - } - else + // Mark as duplicated, so if this pattern is to be duplicated again, the same new pattern number is inserted into the order list. + patReplaceIndex[nCurPat] = nNewPat; + } else { - break; + continue; } - } - else + } else { - // invalid pattern, or it has been duplicated before (multiselect) + // Invalid pattern, or it has been duplicated before (multiselect) for (int j = pSndFile->Order.size() - 1; j > selection.nOrdLo + i + nInsertCount + 1; j--) pSndFile->Order[j] = pSndFile->Order[j - 1]; - PATTERNINDEX nNewPat; - if(nCurPat < pSndFile->Patterns.Size() && pReplaceIndex[nCurPat] != PATTERNINDEX_INVALID) - nNewPat = pReplaceIndex[nCurPat]; // take care of patterns that have been duplicated before - else - nNewPat= pSndFile->Order[selection.nOrdLo + i]; + + PATTERNINDEX nNewPat; + if(nCurPat < pSndFile->Patterns.Size() && patReplaceIndex[nCurPat] != PATTERNINDEX_INVALID) + { + // Take care of patterns that have been duplicated before + nNewPat = patReplaceIndex[nCurPat]; + } else + { + nNewPat = pSndFile->Order[selection.nOrdLo + i]; + } + if (selection.nOrdLo + i + nInsertCount + 1 < pSndFile->Order.GetLength()) + { pSndFile->Order[selection.nOrdLo + i + nInsertCount + 1] = nNewPat; + } + + bSuccess = true; + } } if(bSuccess) @@ -883,7 +894,7 @@ m_OrderList.SetCurSel(nInsertWhere); SetCurrentPattern(pSndFile->Order[min(nInsertWhere, pSndFile->Order.GetLastIndex())]); m_pModDoc->SetModified(); - m_pModDoc->UpdateAllViews(NULL, HINT_MODSEQUENCE|HINT_PATNAMES, this); + m_pModDoc->UpdateAllViews(NULL, HINT_MODSEQUENCE | HINT_PATNAMES, this); if(selection.nOrdHi != selection.nOrdLo) m_OrderList.m_nScrollPos2nd = nInsertWhere + nInsertCount; } } @@ -911,7 +922,8 @@ { CModDoc *pModDoc = GetDocument(); CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); - if ((pMainFrm) && (pModDoc)) { + if ((pMainFrm) && (pModDoc)) + { pModDoc->OnPatternPlay(); } SwitchToView(); @@ -923,7 +935,8 @@ { CModDoc *pModDoc = GetDocument(); CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); - if ((pMainFrm) && (pModDoc)) { + if ((pMainFrm) && (pModDoc)) + { pModDoc->OnPatternPlayNoLoop(); } SwitchToView(); @@ -935,7 +948,8 @@ { CModDoc *pModDoc = GetDocument(); CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); - if ((pMainFrm) && (pModDoc)) { + if ((pMainFrm) && (pModDoc)) + { pModDoc->OnPatternRestart(); } SwitchToView(); Modified: trunk/OpenMPT/mptrack/view_com.cpp =================================================================== --- trunk/OpenMPT/mptrack/view_com.cpp 2011-11-12 17:26:58 UTC (rev 1134) +++ trunk/OpenMPT/mptrack/view_com.cpp 2011-11-13 00:59:17 UTC (rev 1135) @@ -237,7 +237,7 @@ // Add Samples if ((m_nCurrentListId == IDC_LIST_SAMPLES) && (lHint & (HINT_MODTYPE|HINT_SMPNAMES|HINT_SAMPLEINFO))) { - UINT nMax = nCount; + SAMPLEINDEX nMax = static_cast<SAMPLEINDEX>(nCount); if (nMax < pSndFile->GetNumSamples()) nMax = pSndFile->GetNumSamples(); for (SAMPLEINDEX iSmp = 0; iSmp < nMax; iSmp++) { @@ -341,11 +341,11 @@ // Add Instruments if ((m_nCurrentListId == IDC_LIST_INSTRUMENTS) && (lHint & (HINT_MODTYPE|HINT_INSNAMES|HINT_INSTRUMENT))) { - UINT nMax = nCount; + INSTRUMENTINDEX nMax = static_cast<INSTRUMENTINDEX>(nCount); if (nMax < pSndFile->GetNumInstruments()) nMax = pSndFile->GetNumInstruments(); - for (UINT iIns=0; iIns<nMax; iIns++) + for (INSTRUMENTINDEX iIns = 0; iIns < nMax; iIns++) { - if (iIns < pSndFile->m_nInstruments) + if (iIns < pSndFile->GetNumInstruments()) { UINT nCol = 0; for (UINT iCol=0; iCol<INSLIST_COLUMNS; iCol++) @@ -366,7 +366,11 @@ std::set<SAMPLEINDEX> referencedSamples; for(size_t i = 0; i < CountOf(pIns->Keyboard); i++) { - referencedSamples.insert(pIns->Keyboard[i]); + // 0 isn't a sample. + if(pIns->Keyboard[i] != 0) + { + referencedSamples.insert(pIns->Keyboard[i]); + } } bool first = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-11-19 23:57:23
|
Revision: 1139 http://modplug.svn.sourceforge.net/modplug/?rev=1139&view=rev Author: saga-games Date: 2011-11-19 23:57:16 +0000 (Sat, 19 Nov 2011) Log Message: ----------- [Fix] Channel Manager: Reordering / removing channels broke some revisions ago. [Fix] Sample Editor: When loading multiple samples at once, existing samples are not overwritten anymore. Modified Paths: -------------- trunk/OpenMPT/mptrack/ChannelManagerDlg.cpp trunk/OpenMPT/mptrack/Ctrl_smp.cpp Modified: trunk/OpenMPT/mptrack/ChannelManagerDlg.cpp =================================================================== --- trunk/OpenMPT/mptrack/ChannelManagerDlg.cpp 2011-11-18 22:52:19 UTC (rev 1138) +++ trunk/OpenMPT/mptrack/ChannelManagerDlg.cpp 2011-11-19 23:57:16 UTC (rev 1139) @@ -188,7 +188,7 @@ CriticalSection cs; //Creating new order-vector for ReArrangeChannels. - vector<CHANNELINDEX> newChnOrder(nChannels); + vector<CHANNELINDEX> newChnOrder; for(CHANNELINDEX nChn = 0; nChn < nChannels; nChn++) { newChnOrder.push_back(newpat[nChn]); @@ -372,7 +372,8 @@ CModDoc *pModDoc = pMainFrm ? pMainFrm->GetActiveDoc() : NULL; CSoundFile * m_pSndFile = pModDoc ? pModDoc->GetSoundFile() : NULL; - if(pModDoc && m_pSndFile){ + if(pModDoc && m_pSndFile) + { int nbOk = 0, nbSelect = 0; @@ -450,7 +451,8 @@ CModDoc *pModDoc = pMainFrm ? pMainFrm->GetActiveDoc() : NULL; CSoundFile * m_pSndFile = pModDoc ? pModDoc->GetSoundFile() : NULL; - switch(currentTab){ + switch(currentTab) + { case 0: for(CHANNELINDEX nChn = 0; nChn < m_pSndFile->m_nChannels; nChn++) { @@ -487,7 +489,8 @@ EnterCriticalSection(&applying); - switch(currentTab){ + switch(currentTab) + { case 0: for(CHANNELINDEX nChn = 0; nChn < m_pSndFile->m_nChannels; nChn++) { @@ -531,7 +534,8 @@ int sel = TabCtrl_GetCurFocus(::GetDlgItem(m_hWnd,IDC_TAB1)); currentTab = sel; - switch(currentTab){ + switch(currentTab) + { case 0: SetDlgItemText(IDC_BUTTON5, "Solo"); SetDlgItemText(IDC_BUTTON6, "Mute"); @@ -597,7 +601,8 @@ } else ::FrameRect(hdc,&rect,CMainFrame::brushBlack); - if ((lpszText) && (lpszText[0])){ + if ((lpszText) && (lpszText[0])) + { rect.left += 13; rect.right -= 5; @@ -613,42 +618,49 @@ void CChannelManagerDlg::OnSize(UINT nType,int cx,int cy) { CWnd::OnSize(nType,cx,cy); - if(!m_hWnd || show == false) return; + if(!m_hWnd || !show) return; - CWnd * button; + CWnd *button; CRect wnd,btn; GetWindowRect(&wnd); - if((button = GetDlgItem(IDC_BUTTON1)) != 0){ + if((button = GetDlgItem(IDC_BUTTON1)) != nullptr) + { button->GetWindowRect(&btn); button->SetWindowPos(NULL, btn.left - wnd.left - 3, wnd.Height() - btn.Height() * 2 - 8, 0, 0, SWP_NOSIZE | SWP_NOZORDER); } - if((button = GetDlgItem(IDC_BUTTON2)) != 0){ + if((button = GetDlgItem(IDC_BUTTON2)) != nullptr) + { button->GetWindowRect(&btn); button->SetWindowPos(NULL, btn.left - wnd.left - 3, wnd.Height() - btn.Height() * 2 - 8, 0, 0, SWP_NOSIZE | SWP_NOZORDER); } - if((button = GetDlgItem(IDC_BUTTON3)) != 0){ + if((button = GetDlgItem(IDC_BUTTON3)) != nullptr) + { button->GetWindowRect(&btn); button->SetWindowPos(NULL, btn.left - wnd.left - 3, wnd.Height() - btn.Height() * 2 - 8, 0, 0, SWP_NOSIZE | SWP_NOZORDER); } - if((button = GetDlgItem(IDC_BUTTON4)) != 0){ + if((button = GetDlgItem(IDC_BUTTON4)) != nullptr) + { button->GetWindowRect(&btn); button->SetWindowPos(NULL, btn.left - wnd.left - 3, wnd.Height() - btn.Height() * 2 - 8, 0, 0, SWP_NOSIZE | SWP_NOZORDER); } - if((button = GetDlgItem(IDC_BUTTON5)) != 0){ + if((button = GetDlgItem(IDC_BUTTON5)) != nullptr) + { button->GetWindowRect(&btn); button->SetWindowPos(NULL, btn.left - wnd.left - 3, wnd.Height() - btn.Height() * 2 - 8, 0, 0, SWP_NOSIZE | SWP_NOZORDER); } - if((button = GetDlgItem(IDC_BUTTON6)) != 0){ + if((button = GetDlgItem(IDC_BUTTON6)) != nullptr) + { button->GetWindowRect(&btn); button->SetWindowPos(NULL, btn.left - wnd.left - 3, wnd.Height() - btn.Height() * 2 - 8, 0, 0, SWP_NOSIZE | SWP_NOZORDER); } GetClientRect(&wnd); - wnd.SetRect(wnd.left + 10, wnd.top + 38, wnd.right - 8, wnd.bottom - 30); + wnd.DeflateRect(10, 38, 8, 30); if(bkgnd) DeleteObject(bkgnd); - bkgnd = ::CreateCompatibleBitmap(::GetDC(m_hWnd),wnd.Width(),wnd.Height()); - if(!moveRect && bkgnd){ + bkgnd = ::CreateCompatibleBitmap(::GetDC(m_hWnd), wnd.Width(), wnd.Height()); + if(!moveRect && bkgnd) + { HDC bdc = ::CreateCompatibleDC(::GetDC(m_hWnd)); ::SelectObject(bdc,bkgnd); ::BitBlt(bdc,0,0,wnd.Width(),wnd.Height(),::GetDC(m_hWnd),wnd.left,wnd.top,SRCCOPY); @@ -657,7 +669,7 @@ } nChannelsOld = 0; - InvalidateRect(NULL,FALSE); + InvalidateRect(NULL, FALSE); } void CChannelManagerDlg::OnActivate(UINT nState,CWnd* pWndOther,BOOL bMinimized) @@ -689,10 +701,11 @@ ::BeginPaint(m_hWnd,&pDC); CMainFrame * pMainFrm = CMainFrame::GetMainFrame(); - CModDoc *pModDoc = pMainFrm ? pMainFrm->GetActiveDoc() : NULL; - CSoundFile * m_pSndFile = pModDoc ? pModDoc->GetSoundFile() : NULL; + CModDoc *pModDoc = pMainFrm ? pMainFrm->GetActiveDoc() : nullptr; + CSoundFile * m_pSndFile = pModDoc ? pModDoc->GetSoundFile() : nullptr; - if(!pModDoc || !m_pSndFile){ + if(!pModDoc || !m_pSndFile) + { ::EndPaint(m_hWnd,&pDC); LeaveCriticalSection(&applying); return; @@ -713,7 +726,7 @@ if(chnSizeY != CM_BT_HEIGHT) { - // resize window + // Window height is not sufficient => resize window ::EndPaint(m_hWnd,&pDC); LeaveCriticalSection(&applying); CWnd::SetWindowPos(NULL, 0, 0, btn.Width(), btn.Height() + (CM_BT_HEIGHT - chnSizeY) * nLines, SWP_NOMOVE | SWP_NOZORDER); @@ -798,17 +811,15 @@ btn.top = client.top + l * chnSizeY + 3; btn.bottom = btn.top + chnSizeY - 3; - ok = intersection.IntersectRect(&pDC.rcPaint,&client); + ok = intersection.IntersectRect(&pDC.rcPaint, &client); if(ok) DrawChannelButton(pDC.hdc, &btn, s, select[nThisChn], removed[nThisChn] ? FALSE : TRUE, DT_RIGHT | DT_VCENTER, NULL); btn.right = btn.left + chnSizeX / 7; - btn.left += 3; - btn.right -= 3; - btn.top += 3; - btn.bottom -= 3; + btn.DeflateRect(3, 3, 3, 3); - switch(currentTab){ + switch(currentTab) + { case 0: if(m_pSndFile->ChnSettings[nThisChn].dwFlags & CHN_MUTE) FillRect(pDC.hdc,&btn,red); else if(m_pSndFile->ChnSettings[nThisChn].dwFlags & CHN_SOLO) FillRect(pDC.hdc,&btn,green); @@ -832,7 +843,8 @@ break; } - if(!removed[nThisChn]){ + if(!removed[nThisChn]) + { HGDIOBJ oldpen = ::SelectObject(pDC.hdc, CMainFrame::penLightGray); ::MoveToEx(pDC.hdc, btn.right, btn.top-2, NULL); ::LineTo(pDC.hdc, btn.right, btn.bottom+1); @@ -869,7 +881,8 @@ CModDoc *pModDoc = pMainFrm ? pMainFrm->GetActiveDoc() : NULL; CSoundFile * m_pSndFile = pModDoc ? pModDoc->GetSoundFile() : NULL; - if(pModDoc && m_pSndFile){ + if(pModDoc && m_pSndFile) + { //UINT nChannels = m_pSndFile->m_nChannels; UINT nColns = CM_NB_COLS; //UINT nLines = nChannels / nColns + (nChannels % nColns ? 1 : 0); @@ -883,9 +896,11 @@ x = x / dx; y = y / dy; CHANNELINDEX n = static_cast<CHANNELINDEX>(y * nColns + x); - if(n >= 0 && n < (int)m_pSndFile->m_nChannels){ + if(n >= 0 && n < (int)m_pSndFile->m_nChannels) + { if(id) *id = n; - if(invalidate){ + if(invalidate) + { invalidate->left = client.left + x * dx; invalidate->right = invalidate->left + dx; invalidate->top = client.top + y * dy; @@ -960,7 +975,8 @@ mouseTracking = _TrackMouseEvent(&tme) != FALSE; } - if(!leftButton && !rightButton){ + if(!leftButton && !rightButton) + { mx = point.x; my = point.y; LeaveCriticalSection(&applying); @@ -981,7 +997,8 @@ CModDoc *pModDoc = pMainFrm ? pMainFrm->GetActiveDoc() : NULL; CSoundFile * m_pSndFile = pModDoc ? pModDoc->GetSoundFile() : NULL; - if(moveRect && m_pSndFile){ + if(moveRect && m_pSndFile) + { CHANNELINDEX n, i, k; CHANNELINDEX newpat[MAX_BASECHANNELS]; Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-11-18 22:52:19 UTC (rev 1138) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2011-11-19 23:57:16 UTC (rev 1139) @@ -957,6 +957,7 @@ { memcpy(m_pSndFile->GetSample(smp).pSample, m_pSndFile->GetSample(nOldSmp).pSample, m_pSndFile->GetSample(nOldSmp).GetSampleSizeInBytes()); } + m_pSndFile->AdjustSampleLoop(&m_pSndFile->GetSample(smp)); } } @@ -999,17 +1000,10 @@ for(size_t counter = 0; counter < files.filenames.size(); counter++) { - //If loading multiple samples, advancing to next sample and creating - //new one if necessary. + // If loading multiple samples, create new slots for them if(counter > 0) { - if(m_nSample >= MAX_SAMPLES-1) - break; - else - m_nSample++; - - if(m_nSample > m_pSndFile->GetNumSamples()) - OnSampleNew(); + OnSampleNew(); } if(!OpenSample(files.filenames[counter].c_str())) @@ -1051,7 +1045,7 @@ if(sPath.IsEmpty()) sPath = "untitled"; sPath += " - %sample_number% - "; - if(m_pSndFile->m_nType & (MOD_TYPE_XM|MOD_TYPE_MOD)) + if(m_pSndFile->GetType() & (MOD_TYPE_XM|MOD_TYPE_MOD)) sPath += "%sample_name%.wav"; else sPath += "%sample_filename%.wav"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2011-12-11 22:51:06
|
Revision: 1147 http://modplug.svn.sourceforge.net/modplug/?rev=1147&view=rev Author: saga-games Date: 2011-12-11 22:50:59 +0000 (Sun, 11 Dec 2011) Log Message: ----------- [Mod] Changed Mixmode RC3 default amplification settings from 64/128/128 to 128/48/48 as they were messing horribly with precision and could easily lead to distortion. [Fix] When creating a XM module, the first sample has panning enabled. Modified Paths: -------------- trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/SoundFilePlayConfig.cpp Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2011-12-10 18:53:45 UTC (rev 1146) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2011-12-11 22:50:59 UTC (rev 1147) @@ -702,16 +702,16 @@ m_SndFile.m_nMusicSpeed = m_SndFile.m_nDefaultSpeed = 6; // Set up levels - if(m_SndFile.m_nMixLevels == mixLevels_original || m_SndFile.m_nMixLevels == mixLevels_compatible) + //if(m_SndFile.m_nMixLevels == mixLevels_original || m_SndFile.m_nMixLevels == mixLevels_compatible) { m_SndFile.m_nGlobalVolume = m_SndFile.m_nDefaultGlobalVolume = MAX_GLOBAL_VOLUME; m_SndFile.m_nSamplePreAmp = m_SndFile.m_nVSTiVolume = 48; } - else + /*else { m_SndFile.m_nGlobalVolume = m_SndFile.m_nDefaultGlobalVolume = MAX_GLOBAL_VOLUME / 2; m_SndFile.m_nSamplePreAmp = m_SndFile.m_nVSTiVolume = 128; - } + }*/ for (CHANNELINDEX nChn = 0; nChn < MAX_BASECHANNELS; nChn++) { @@ -727,14 +727,12 @@ { strcpy(m_SndFile.m_szNames[1], "untitled"); m_SndFile.m_nSamples = (GetModType() == MOD_TYPE_MOD) ? 31 : 1; - if(GetModType() == MOD_TYPE_XM) - { - m_SndFile.GetSample(1).uFlags |= CHN_PANNING; - } ctrlSmp::ResetSamples(m_SndFile, ctrlSmp::SmpResetInit); - if ((!m_SndFile.m_nInstruments) && (m_SndFile.m_nType & MOD_TYPE_XM)) + InitializeSample(m_SndFile.GetSample(1)); + + if ((!m_SndFile.m_nInstruments) && (m_SndFile.GetType() & MOD_TYPE_XM)) { try { @@ -745,7 +743,7 @@ { } } - if (m_SndFile.m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT|MOD_TYPE_XM)) + if (m_SndFile.GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT | MOD_TYPE_XM)) { m_SndFile.m_dwSongFlags |= SONG_LINEARSLIDES; } Modified: trunk/OpenMPT/mptrack/SoundFilePlayConfig.cpp =================================================================== --- trunk/OpenMPT/mptrack/SoundFilePlayConfig.cpp 2011-12-10 18:53:45 UTC (rev 1146) +++ trunk/OpenMPT/mptrack/SoundFilePlayConfig.cpp 2011-12-11 22:50:59 UTC (rev 1147) @@ -2,14 +2,19 @@ #include "Sndfile.h" #include ".\soundfileplayconfig.h" -CSoundFilePlayConfig::CSoundFilePlayConfig(void) { +CSoundFilePlayConfig::CSoundFilePlayConfig() +//------------------------------------------ +{ setVSTiVolume(1.0f); } -CSoundFilePlayConfig::~CSoundFilePlayConfig(void) { +CSoundFilePlayConfig::~CSoundFilePlayConfig() +//------------------------------------------- +{ } void CSoundFilePlayConfig::SetMixLevels(int mixLevelType) +//------------------------------------------------------- { switch (mixLevelType) { @@ -91,8 +96,8 @@ setUseGlobalPreAmp(false); setForcePanningMode(forceNoSoftPanning); setDisplayDBValues(true); - setNormalSamplePreAmp(48.0); - setNormalVSTiVol(48.0); + setNormalSamplePreAmp(256.0); + setNormalVSTiVol(256.0); setNormalGlobalVol(256.0); setExtraSampleAttenuation(1); break; @@ -122,110 +127,156 @@ //getters and setters. -bool CSoundFilePlayConfig::getGlobalVolumeAppliesToMaster() { +bool CSoundFilePlayConfig::getGlobalVolumeAppliesToMaster() +//--------------------------------------------------------- +{ return m_globalVolumeAppliesToMaster; } -void CSoundFilePlayConfig::setGlobalVolumeAppliesToMaster(bool inGlobalVolumeAppliesToMaster){ +void CSoundFilePlayConfig::setGlobalVolumeAppliesToMaster(bool inGlobalVolumeAppliesToMaster) +//------------------------------------------------------------------------------------------- +{ m_globalVolumeAppliesToMaster=inGlobalVolumeAppliesToMaster; } -float CSoundFilePlayConfig::getVSTiGainFactor() { +float CSoundFilePlayConfig::getVSTiGainFactor() +//--------------------------------------------- +{ return m_VSTiVolume; } -float CSoundFilePlayConfig::getVSTiVolume() { +float CSoundFilePlayConfig::getVSTiVolume() +//----------------------------------------- +{ return m_VSTiVolume; } -void CSoundFilePlayConfig::setVSTiVolume(float inVSTiVolume) { +void CSoundFilePlayConfig::setVSTiVolume(float inVSTiVolume) +//----------------------------------------------------------- +{ m_VSTiVolume = inVSTiVolume; } -float CSoundFilePlayConfig::getVSTiAttenuation() { +float CSoundFilePlayConfig::getVSTiAttenuation() +//---------------------------------------------- +{ return m_VSTiAttenuation; } -void CSoundFilePlayConfig::setVSTiAttenuation(float inVSTiAttenuation) { +void CSoundFilePlayConfig::setVSTiAttenuation(float inVSTiAttenuation) +//--------------------------------------------------------------------- +{ m_VSTiAttenuation = inVSTiAttenuation; } -float CSoundFilePlayConfig::getIntToFloat() { +float CSoundFilePlayConfig::getIntToFloat() +//----------------------------------------- +{ return m_IntToFloat; } -void CSoundFilePlayConfig::setIntToFloat(float inIntToFloat) { - m_IntToFloat=inIntToFloat; +void CSoundFilePlayConfig::setIntToFloat(float inIntToFloat) +//----------------------------------------------------------- +{ + m_IntToFloat = inIntToFloat; } -float CSoundFilePlayConfig::getFloatToInt() { +float CSoundFilePlayConfig::getFloatToInt() +//----------------------------------------- +{ return m_FloatToInt; } -void CSoundFilePlayConfig::setFloatToInt(float inFloatToInt) { - m_FloatToInt=inFloatToInt; +void CSoundFilePlayConfig::setFloatToInt(float inFloatToInt) +//----------------------------------------------------------- +{ + m_FloatToInt = inFloatToInt; } -bool CSoundFilePlayConfig::getUseGlobalPreAmp() { +bool CSoundFilePlayConfig::getUseGlobalPreAmp() +//--------------------------------------------- +{ return m_ignorePreAmp; } -void CSoundFilePlayConfig::setUseGlobalPreAmp(bool inUseGlobalPreAmp) { - m_ignorePreAmp=inUseGlobalPreAmp; +void CSoundFilePlayConfig::setUseGlobalPreAmp(bool inUseGlobalPreAmp) +//------------------------------------------------------------------- +{ + m_ignorePreAmp = inUseGlobalPreAmp; } -forcePanningMode CSoundFilePlayConfig::getForcePanningMode() { +forcePanningMode CSoundFilePlayConfig::getForcePanningMode() +//---------------------------------------------------------- +{ return m_forceSoftPanning; } -void CSoundFilePlayConfig::setForcePanningMode(forcePanningMode inForceSoftPanning) { - m_forceSoftPanning=inForceSoftPanning; +void CSoundFilePlayConfig::setForcePanningMode(forcePanningMode inForceSoftPanning) +//--------------------------------------------------------------------------------- +{ + m_forceSoftPanning = inForceSoftPanning; } -void CSoundFilePlayConfig::setDisplayDBValues(bool in) { - m_displayDBValues=in; +void CSoundFilePlayConfig::setDisplayDBValues(bool in) +//---------------------------------------------------- +{ + m_displayDBValues = in; } -void CSoundFilePlayConfig::setNormalSamplePreAmp(double in) { - m_normalSamplePreAmp=in; +void CSoundFilePlayConfig::setNormalSamplePreAmp(double in) +//--------------------------------------------------------- +{ + m_normalSamplePreAmp = in; } -void CSoundFilePlayConfig::setNormalVSTiVol(double in) { - m_normalVSTiVol=in; +void CSoundFilePlayConfig::setNormalVSTiVol(double in) +//---------------------------------------------------- +{ + m_normalVSTiVol = in; } -void CSoundFilePlayConfig::setNormalGlobalVol(double in) { - m_normalGlobalVol=in; +void CSoundFilePlayConfig::setNormalGlobalVol(double in) +//------------------------------------------------------ +{ + m_normalGlobalVol = in; } -bool CSoundFilePlayConfig::getDisplayDBValues() { +bool CSoundFilePlayConfig::getDisplayDBValues() +//--------------------------------------------- +{ return m_displayDBValues; } -double CSoundFilePlayConfig::getNormalSamplePreAmp() { +double CSoundFilePlayConfig::getNormalSamplePreAmp() +//-------------------------------------------------- +{ return m_normalSamplePreAmp; } -double CSoundFilePlayConfig::getNormalVSTiVol() { +double CSoundFilePlayConfig::getNormalVSTiVol() +//--------------------------------------------- +{ return m_normalVSTiVol; } -double CSoundFilePlayConfig::getNormalGlobalVol() { +double CSoundFilePlayConfig::getNormalGlobalVol() +//----------------------------------------------- +{ return m_normalGlobalVol; } void CSoundFilePlayConfig::setExtraSampleAttenuation(int attn) +//------------------------------------------------------------ { m_extraAttenuation = attn; } int CSoundFilePlayConfig::getExtraSampleAttenuation() +//--------------------------------------------------- { return m_extraAttenuation; } - - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-01-02 00:14:18
|
Revision: 1151 http://modplug.svn.sourceforge.net/modplug/?rev=1151&view=rev Author: saga-games Date: 2012-01-02 00:14:12 +0000 (Mon, 02 Jan 2012) Log Message: ----------- [Imp] VST: Added support for audioMasterIOChanged Modified Paths: -------------- trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/Vstplug.h Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2012-01-01 21:52:39 UTC (rev 1150) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2012-01-02 00:14:12 UTC (rev 1151) @@ -872,7 +872,11 @@ // numInputs and/or numOutputs has changed case audioMasterIOChanged: - Log("VST plugin to host: IOchanged\n"); + if (pVstPlugin != nullptr) + { + CriticalSection cs; + return pVstPlugin->InitializeIOBuffers() ? 1 : 0; + } break; // plug needs idle calls (outside its editor window) - DEPRECATED in VST 2.4 @@ -1464,15 +1468,8 @@ } Dispatch(effMainsChanged, 0, 1, NULL, 0.0f); - m_nInputs = m_pEffect->numInputs; - m_nOutputs = m_pEffect->numOutputs; + InitializeIOBuffers(); - // Input pointer array size must be >= 2 for now - the input buffer assignment might write to non allocated mem. otherwise - mixBuffer.Initialize(max(m_nInputs, 2), m_nOutputs); - m_MixState.pOutBufferL = mixBuffer.GetInputBuffer(0); - m_MixState.pOutBufferR = mixBuffer.GetInputBuffer(1); - - #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, @@ -1496,6 +1493,21 @@ } +bool CVstPlugin::InitializeIOBuffers() +//------------------------------------ +{ + m_nInputs = m_pEffect->numInputs; + m_nOutputs = m_pEffect->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); + m_MixState.pOutBufferL = mixBuffer.GetInputBuffer(0); + m_MixState.pOutBufferR = mixBuffer.GetInputBuffer(1); + + return result; +} + + CVstPlugin::~CVstPlugin() //----------------------- { Modified: trunk/OpenMPT/mptrack/Vstplug.h =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.h 2012-01-01 21:52:39 UTC (rev 1150) +++ trunk/OpenMPT/mptrack/Vstplug.h 2012-01-02 00:14:12 UTC (rev 1151) @@ -153,6 +153,8 @@ CAbstractVstEditor* GetEditor(); //rewbs.defaultPlugGUI bool GetSpeakerArrangement(); //rewbs.VSTCompliance + bool InitializeIOBuffers(); + bool Bypass(bool bypass = true); //rewbs.defaultPlugGUI bool IsBypassed() const { return m_pMixStruct->IsBypassed(); }; //rewbs.defaultPlugGUI This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-01-03 19:06:29
|
Revision: 1157 http://modplug.svn.sourceforge.net/modplug/?rev=1157&view=rev Author: saga-games Date: 2012-01-03 19:06:22 +0000 (Tue, 03 Jan 2012) Log Message: ----------- [Imp] Instrument Editor: Added tooltip for the MIDI Channel control [Fix] Playing notes from the editor broke in some cases in the previous revision. Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Moddoc.cpp Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2012-01-03 18:26:14 UTC (rev 1156) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2012-01-03 19:06:22 UTC (rev 1157) @@ -1557,33 +1557,39 @@ { case IDC_EDIT_PITCHTEMPOLOCK: case IDC_CHECK_PITCHTEMPOLOCK: + // Pitch/Tempo lock { - const CModSpecifications& specs = m_pSndFile->GetModSpecifications(); - string str = string("Tempo range: ") + Stringify(specs.tempoMin) + string(" - ") + Stringify(specs.tempoMax); - if(str.size() >= 250) str.resize(250); - wsprintf(pszText, str.c_str()); - return TRUE; - break; + const CModSpecifications& specs = m_pSndFile->GetModSpecifications(); + string str = string("Tempo range: ") + Stringify(specs.tempoMin) + string(" - ") + Stringify(specs.tempoMax); + if(str.size() >= 250) str.resize(250); + strcpy(pszText, str.c_str()); + return TRUE; } - case IDC_EDIT7: //Fade out + + case IDC_EDIT7: + // Fade Out wsprintf(pszText, "Higher value <-> Faster fade out"); return TRUE; - break; case IDC_PLUGIN_VELOCITYSTYLE: case IDC_PLUGIN_VOLUMESTYLE: + // Plugin volume handling if(m_pSndFile->Instruments[m_nInstrument]->nMixPlug < 1) return FALSE; if(m_pSndFile->GetModFlag(MSF_MIDICC_BUGEMULATION)) { m_CbnPluginVelocityHandling.EnableWindow(FALSE); m_CbnPluginVolumeHandling.EnableWindow(FALSE); - wsprintf(pszText, "To enable, clear Plugin volume command bug emulation flag from Song Properties"); + strcpy(pszText, "To enable, clear Plugin volume command bug emulation flag from Song Properties"); return TRUE; } else return FALSE; - - break; + + case IDC_COMBO5: + // MIDI Channel + strcpy(pszText, "Mapped: MIDI channel corresponds to pattern channel modulo 16"); + return TRUE; + } } return FALSE; Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2012-01-03 18:26:14 UTC (rev 1156) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2012-01-03 19:06:22 UTC (rev 1157) @@ -924,10 +924,10 @@ CriticalSection cs; //find a channel if required - /* if (nCurrentChn == CHANNELINDEX_INVALID) + //if (nCurrentChn == CHANNELINDEX_INVALID) { nChn = FindAvailableChannel(); - } */ + } MODCHANNEL *pChn = &m_SndFile.Chn[nChn]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-01-03 23:45:04
|
Revision: 1158 http://modplug.svn.sourceforge.net/modplug/?rev=1158&view=rev Author: saga-games Date: 2012-01-03 23:44:56 +0000 (Tue, 03 Jan 2012) Log Message: ----------- [Ref] Changed parameter types of PlayNote/StopNote. [Mod] Two envelope points may not share the same tick anymore in non-compatible mode as well. Since there is no interpolation being done between two envelope points, this won't limit the sounds that can be produced using envelopes. Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/View_ins.cpp trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/View_tre.cpp Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2012-01-03 19:06:22 UTC (rev 1157) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2012-01-03 23:44:56 UTC (rev 1158) @@ -320,7 +320,7 @@ { 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; } @@ -330,7 +330,7 @@ { 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; } Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2012-01-03 19:06:22 UTC (rev 1157) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2012-01-03 23:44:56 UTC (rev 1158) @@ -738,7 +738,7 @@ //---------------------------------- { if(m_nPlayingNote >= 0) return; //no polyphony in notemap window - m_pModDoc->PlayNote(note, m_nInstrument, 0, FALSE); + m_pModDoc->PlayNote(note, m_nInstrument, 0, false); m_nPlayingNote = note; } @@ -749,7 +749,7 @@ if(note < 0) note = m_nPlayingNote; if(note < 0) return; - m_pModDoc->NoteOff(note, TRUE, m_nInstrument); + m_pModDoc->NoteOff(note, true, m_nInstrument); m_nPlayingNote = -1; } @@ -1075,7 +1075,7 @@ void CCtrlInstruments::OnDeactivatePage() //--------------------------------------- { - if (m_pModDoc) m_pModDoc->NoteOff(0, TRUE); + if (m_pModDoc) m_pModDoc->NoteOff(0, true); CChildFrame *pFrame = (CChildFrame *)GetParentFrame(); if ((pFrame) && (m_hWndView)) SendViewMessage(VIEWMSG_SAVESTATE, (LPARAM)pFrame->GetInstrumentViewState()); } @@ -1802,10 +1802,10 @@ { if (m_pModDoc->IsNotePlaying(NOTE_MIDDLEC, 0, m_nInstrument)) { - m_pModDoc->NoteOff(NOTE_MIDDLEC, TRUE, m_nInstrument); + m_pModDoc->NoteOff(NOTE_MIDDLEC, true, m_nInstrument); } else { - m_pModDoc->PlayNote(NOTE_MIDDLEC, m_nInstrument, 0, FALSE); + m_pModDoc->PlayNote(NOTE_MIDDLEC, m_nInstrument, 0, false); } } SwitchToView(); Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2012-01-03 19:06:22 UTC (rev 1157) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2012-01-03 23:44:56 UTC (rev 1158) @@ -222,7 +222,7 @@ m_SpinVolume.SetRange(0, 64); m_SpinGlobalVol.SetRange(0, 64); //rewbs.fix36944 - if (m_pSndFile->m_nType == MOD_TYPE_XM) + if (m_pSndFile->GetType() == MOD_TYPE_XM) { m_SpinPanning.SetRange(0, 255); } else @@ -411,7 +411,7 @@ { CChildFrame *pFrame = (CChildFrame *)GetParentFrame(); if ((pFrame) && (m_hWndView)) SendViewMessage(VIEWMSG_SAVESTATE, (LPARAM)pFrame->GetSampleViewState()); - if (m_pModDoc) m_pModDoc->NoteOff(0, TRUE); + if (m_pModDoc) m_pModDoc->NoteOff(0, true); } @@ -521,7 +521,7 @@ case IDC_EDIT5: case IDC_SPIN5: case IDC_COMBO_BASENOTE: - if ((m_pSndFile) && (m_pSndFile->m_nType & (MOD_TYPE_XM|MOD_TYPE_MOD)) && (m_nSample)) + if ((m_pSndFile) && (m_pSndFile->GetType() & (MOD_TYPE_XM | MOD_TYPE_MOD)) && (m_nSample)) { const MODSAMPLE &sample = m_pSndFile->GetSample(m_nSample); UINT nFreqHz = CSoundFile::TransposeToFrequency(sample.RelativeTone, sample.nFineTune); @@ -663,7 +663,7 @@ // File Name memcpy(s, sample.filename, MAX_SAMPLEFILENAME); s[21] = 0; - if (m_pSndFile->m_nType & (MOD_TYPE_MOD|MOD_TYPE_XM)) s[0] = 0; + if (m_pSndFile->GetType() & (MOD_TYPE_MOD | MOD_TYPE_XM)) s[0] = 0; SetDlgItemText(IDC_SAMPLE_FILENAME, s); // Volume SetDlgItemInt(IDC_EDIT7, sample.nVolume >> 2); @@ -672,15 +672,17 @@ // Panning CheckDlgButton(IDC_CHECK1, (sample.uFlags & CHN_PANNING) ? MF_CHECKED : MF_UNCHECKED); //rewbs.fix36944 - if (m_pSndFile->m_nType == MOD_TYPE_XM) { + if (m_pSndFile->GetType() == MOD_TYPE_XM) + { SetDlgItemInt(IDC_EDIT9, sample.nPan); //displayed panning with XM is 0-256, just like MPT's internal engine - } else { - SetDlgItemInt(IDC_EDIT9, sample.nPan>>2); //displayed panning with anything but XM is 0-64 so we divide by 4 + } else + { + SetDlgItemInt(IDC_EDIT9, sample.nPan / 4); //displayed panning with anything but XM is 0-64 so we divide by 4 } //end rewbs.fix36944 // FineTune / C-4 Speed / BaseNote int transp = 0; - if (m_pSndFile->m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT)) + if (m_pSndFile->GetType() & (MOD_TYPE_S3M | MOD_TYPE_IT | MOD_TYPE_MPT)) { wsprintf(s, "%lu", sample.nC5Speed); m_EditFineTune.SetWindowText(s); @@ -689,7 +691,7 @@ { int ftune = ((int)sample.nFineTune); // MOD finetune range -8 to 7 translates to -128 to 112 - if(m_pSndFile->m_nType & MOD_TYPE_MOD) ftune >>= 4; + if(m_pSndFile->GetType() & MOD_TYPE_MOD) ftune >>= 4; SetDlgItemInt(IDC_EDIT5, ftune); transp = (int)sample.RelativeTone; } @@ -836,7 +838,7 @@ memset(szFullFilename, 0, 32); strcpy(szFullFilename, szName); - if (m_pSndFile->m_nType & (MOD_TYPE_MOD|MOD_TYPE_XM)) + if (m_pSndFile->GetType() & (MOD_TYPE_MOD | MOD_TYPE_XM)) { // MOD/XM strcat(szFullFilename, szExt); @@ -852,7 +854,7 @@ szFullFilename[21] = 0; memcpy(sample.filename, szFullFilename, MAX_SAMPLEFILENAME); } - if ((m_pSndFile->m_nType & 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; @@ -877,7 +879,7 @@ m_pSndFile->DestroySample(m_nSample); m_pSndFile->ReadSampleFromSong(m_nSample, pSndFile, nSample); MODSAMPLE &sample = m_pSndFile->GetSample(m_nSample); - if ((m_pSndFile->m_nType & 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; @@ -966,7 +968,7 @@ { if (Reporting::Confirm("This sample is not used by any instrument. Do you want to create a new instrument using this sample?") == cnfYes) { - UINT nins = m_pModDoc->InsertInstrument(smp); + INSTRUMENTINDEX nins = m_pModDoc->InsertInstrument(smp); m_pModDoc->UpdateAllViews(NULL, (nins << HINT_SHIFT_INS) | HINT_INSTRUMENT | HINT_INSNAMES | HINT_ENVELOPE); m_pParent->InstrumentChanged(nins); } @@ -1029,7 +1031,7 @@ SwitchToView(); return; } - if (m_pSndFile->m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT)) + if (m_pSndFile->GetType() & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT)) { strncpy(szFileName, m_pSndFile->GetSample(m_nSample).filename, min(CountOf(m_pSndFile->GetSample(m_nSample).filename), CountOf(szFileName) - 1)); } else @@ -1124,10 +1126,10 @@ // if ((m_pSndFile->IsPaused()) && (m_pModDoc->IsNotePlaying(0, m_nSample, 0))) if (m_pModDoc->IsNotePlaying(0, m_nSample, 0)) { - m_pModDoc->NoteOff(0, TRUE); + m_pModDoc->NoteOff(0, true); } else { - m_pModDoc->PlayNote(NOTE_MIDDLEC, 0, m_nSample, FALSE); + m_pModDoc->PlayNote(NOTE_MIDDLEC, 0, m_nSample, false); } } SwitchToView(); @@ -1152,13 +1154,12 @@ return; iMinSample = 1; iMaxSample = m_pSndFile->m_nSamples; - } else { - SAMPLEVIEWSTATE viewstate; - memset(&viewstate, 0, sizeof(viewstate)); - SendViewMessage(VIEWMSG_SAVESTATE, (LPARAM)&viewstate); + } else + { + SELECTIONPOINTS selection = GetSelectionPoints(); - iStart = viewstate.dwBeginSel; - iEnd = viewstate.dwEndSel; + iStart = selection.nStart; + iEnd = selection.nEnd; } @@ -1180,9 +1181,10 @@ } else { //one sample: correct the boundaries, if needed - if (iEnd > sample.nLength) iEnd = sample.nLength; - if (iStart > iEnd) iStart = iEnd; - if (iStart == iEnd) { + LimitMax(iEnd, sample.nLength); + LimitMax(iStart, iEnd); + if(iStart == iEnd) + { iStart = 0; iEnd = sample.nLength; } @@ -1190,9 +1192,9 @@ m_pModDoc->GetSampleUndo().PrepareUndo(iSmp, sundo_update, iStart, iEnd); - if (sample.uFlags & CHN_STEREO) { iStart *= 2; iEnd *= 2; } + if(sample.uFlags & CHN_STEREO) { iStart *= 2; iEnd *= 2; } - if (sample.uFlags & CHN_16BIT) + if(sample.uFlags & CHN_16BIT) { int16 *p = (int16 *)sample.pSample; int max = 1; @@ -1444,9 +1446,9 @@ smplsize = sample.GetBytesPerSample(); newsmplsize = sample.GetNumChannels() * 2; // new sample is always 16-Bit pOriginal = sample.pSample; - dwNewLen = sample.nLength + (dwEnd-dwStart); + dwNewLen = sample.nLength + (dwEnd - dwStart); pNewSample = NULL; - if (dwNewLen+4 <= MAX_SAMPLE_LENGTH) pNewSample = CSoundFile::AllocateSample((dwNewLen+4)*newsmplsize); + if (dwNewLen + 4 <= MAX_SAMPLE_LENGTH) pNewSample = CSoundFile::AllocateSample((dwNewLen + 4)*newsmplsize); if (pNewSample) { m_pModDoc->GetSampleUndo().PrepareUndo(m_nSample, sundo_replace); @@ -1454,7 +1456,7 @@ const UINT nCh = sample.GetNumChannels(); for (UINT iCh=0; iCh<nCh; iCh++) { - int len = dwEnd-dwStart; + int len = dwEnd - dwStart; int maxndx = sample.nLength; if (sample.uFlags & CHN_16BIT) { @@ -1598,7 +1600,7 @@ dwNewLen = sample.nLength - dwRemove; dwEnd = dwStart+dwRemove*2; pNewSample = NULL; - if ((dwNewLen > 32) && (dwRemove)) pNewSample = CSoundFile::AllocateSample((dwNewLen+4)*smplsize); + if ((dwNewLen > 32) && (dwRemove)) pNewSample = CSoundFile::AllocateSample((dwNewLen + 4) * smplsize); if (pNewSample) { Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2012-01-03 19:06:22 UTC (rev 1157) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2012-01-03 23:44:56 UTC (rev 1158) @@ -884,8 +884,8 @@ } -UINT CModDoc::PlayNote(UINT note, UINT nins, UINT nsmp, BOOL bpause, LONG nVol, LONG loopstart, LONG loopend, CHANNELINDEX nCurrentChn, const uint32 nStartPos) //rewbs.vstiLive: added current chan param -//------------------------------------------------------------------------------------------------------------------------------------------------------------- +UINT CModDoc::PlayNote(UINT note, INSTRUMENTINDEX nins, SAMPLEINDEX nsmp, bool pause, LONG nVol, SmpLength loopStart, SmpLength loopEnd, CHANNELINDEX nCurrentChn, const SmpLength sampleOffset) //rewbs.vstiLive: added current chan param +//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- { CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); UINT nChn = GetNumChannels(); @@ -896,7 +896,7 @@ { //kill notes if required. - if ( (bpause) || (m_SndFile.IsPaused()) || pMainFrm->GetModPlaying() != this) + if ( (pause) || (m_SndFile.IsPaused()) || pMainFrm->GetModPlaying() != this) { CriticalSection cs; @@ -976,13 +976,13 @@ // Handle sample looping. // Changed line to fix http://forum.openmpt.org/index.php?topic=1700.0 //if ((loopstart + 16 < loopend) && (loopstart >= 0) && (loopend <= (LONG)pChn->nLength)) - if ((loopstart + 16 < loopend) && (loopstart >= 0) && (pChn->pModSample != nullptr)) + if ((loopStart + 16 < loopEnd) && (loopStart >= 0) && (pChn->pModSample != nullptr)) { - pChn->nPos = loopstart; + pChn->nPos = loopStart; pChn->nPosLo = 0; - pChn->nLoopStart = loopstart; - pChn->nLoopEnd = loopend; - pChn->nLength = min(UINT(loopend), pChn->pModSample->nLength); + pChn->nLoopStart = loopStart; + pChn->nLoopEnd = loopEnd; + pChn->nLength = min(UINT(loopEnd), pChn->pModSample->nLength); } // Handle extra-loud flag @@ -995,12 +995,12 @@ } // Handle custom start position - if(nStartPos != uint32_max && pChn->pModSample) + if(sampleOffset > 0 && pChn->pModSample) { - pChn->nPos = nStartPos; + pChn->nPos = sampleOffset; // If start position is after loop end, set loop end to sample end so that the sample starts // playing. - if(pChn->nLoopEnd < nStartPos) + if(pChn->nLoopEnd < sampleOffset) pChn->nLength = pChn->nLoopEnd = pChn->pModSample->nLength; } @@ -1020,7 +1020,7 @@ if ((nPlugin) && (nPlugin <= MAX_MIXPLUGINS)) { - IMixPlugin *pPlugin = m_SndFile.m_MixPlugins[nPlugin - 1].pMixPlugin; + IMixPlugin *pPlugin = m_SndFile.m_MixPlugins[nPlugin - 1].pMixPlugin; if (pPlugin) { @@ -1035,19 +1035,19 @@ { CriticalSection cs; m_SndFile.NoteChange(nChn, note); - if (bpause) m_SndFile.m_dwSongFlags |= SONG_PAUSED; + if (pause) m_SndFile.m_dwSongFlags |= SONG_PAUSED; } return nChn; } -BOOL CModDoc::NoteOff(UINT note, BOOL bFade, UINT nins, CHANNELINDEX nCurrentChn) //rewbs.vstiLive: added chan and nins -//------------------------------------------------------------------------------- +BOOL CModDoc::NoteOff(UINT note, bool fade, INSTRUMENTINDEX nins, CHANNELINDEX nCurrentChn) //rewbs.vstiLive: added chan and nins +//----------------------------------------------------------------------------------------- { CriticalSection cs; //rewbs.vstiLive - if((nins > 0) && (nins <= m_SndFile.GetNumInstruments()) && (note >= NOTE_MIN) && (note <= NOTE_MAX)) + if((nins != INSTRUMENTINDEX_INVALID) && (nins <= m_SndFile.GetNumInstruments()) && (note >= NOTE_MIN) && (note <= NOTE_MAX)) { MODINSTRUMENT *pIns = m_SndFile.Instruments[nins]; @@ -1061,7 +1061,7 @@ if ((nPlugin) && (nPlugin <= MAX_MIXPLUGINS)) { - IMixPlugin *pPlugin = m_SndFile.m_MixPlugins[nPlugin-1].pMixPlugin; + IMixPlugin *pPlugin = m_SndFile.m_MixPlugins[nPlugin - 1].pMixPlugin; if (pPlugin) { pPlugin->MidiCommand(GetPlaybackMidiChannel(pIns, nCurrentChn), pIns->nMidiProgram, pIns->wMidiBank, pIns->NoteMap[note - 1] + NOTE_KEYOFF, 0, MAX_BASECHANNELS); @@ -1071,9 +1071,9 @@ } //end rewbs.vstiLive - const DWORD mask = (bFade) ? CHN_NOTEFADE : (CHN_NOTEFADE|CHN_KEYOFF); + const DWORD mask = (fade ? CHN_NOTEFADE : (CHN_NOTEFADE | CHN_KEYOFF)); MODCHANNEL *pChn = &m_SndFile.Chn[m_SndFile.m_nChannels]; - for (UINT i=m_SndFile.m_nChannels; i<MAX_CHANNELS; i++, pChn++) if (!pChn->nMasterChn) + for (CHANNELINDEX i = m_SndFile.GetNumChannels(); i < MAX_CHANNELS; i++, pChn++) if (!pChn->nMasterChn) { // Fade all channels > m_nChannels which are playing this note. @@ -1082,7 +1082,7 @@ { m_SndFile.KeyOff(i); if (!m_SndFile.m_nInstruments) pChn->dwFlags &= ~CHN_LOOP; - if (bFade) pChn->dwFlags |= CHN_NOTEFADE; + if (fade) pChn->dwFlags |= CHN_NOTEFADE; if (note) break; } } Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2012-01-03 19:06:22 UTC (rev 1157) +++ trunk/OpenMPT/mptrack/Moddoc.h 2012-01-03 23:44:56 UTC (rev 1158) @@ -268,9 +268,10 @@ bool RemovePattern(PATTERNINDEX nPat); bool RemoveSample(SAMPLEINDEX nSmp); bool RemoveInstrument(INSTRUMENTINDEX nIns); - UINT PlayNote(UINT note, UINT nins, UINT nsmp, BOOL bpause, LONG nVol=-1, LONG loopstart=0, LONG loopend=0, CHANNELINDEX nCurrentChn = CHANNELINDEX_INVALID, const uint32 nStartPos = uint32_max); //rewbs.vstiLive: added current chan param - BOOL NoteOff(UINT note, BOOL bFade=FALSE, UINT nins=-1, CHANNELINDEX nCurrentChn = CHANNELINDEX_INVALID); //rewbs.vstiLive: add params + UINT PlayNote(UINT note, INSTRUMENTINDEX nins, SAMPLEINDEX nsmp, bool pause, LONG nVol=-1, SmpLength loopStart = 0, SmpLength loopEnd = 0, CHANNELINDEX nCurrentChn = CHANNELINDEX_INVALID, const SmpLength sampleOffset = 0); //rewbs.vstiLive: added current chan param + BOOL NoteOff(UINT note, bool fade = false, INSTRUMENTINDEX nins = INSTRUMENTINDEX_INVALID, CHANNELINDEX nCurrentChn = CHANNELINDEX_INVALID); //rewbs.vstiLive: add params + BOOL IsNotePlaying(UINT note, UINT nsmp=0, UINT nins=0); bool MuteChannel(CHANNELINDEX nChn, bool bMute); bool UpdateChannelMuteStatus(CHANNELINDEX nChn); Modified: trunk/OpenMPT/mptrack/View_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_ins.cpp 2012-01-03 19:06:22 UTC (rev 1157) +++ trunk/OpenMPT/mptrack/View_ins.cpp 2012-01-03 23:44:56 UTC (rev 1158) @@ -278,7 +278,7 @@ int maxtick = envelope->Ticks[nPoint + 1]; if (nPoint + 1 == (int)envelope->nNodes) maxtick = ENVELOPE_MAX_LENGTH; // Can't have multiple points on same tick - if(nPoint > 0 && GetDocument()->GetSoundFile()->IsCompatibleMode(TRK_IMPULSETRACKER|TRK_FASTTRACKER2) && mintick < maxtick - 1) + if(nPoint > 0 && mintick < maxtick - 1) { mintick++; if (nPoint + 1 < (int)envelope->nNodes) maxtick--; @@ -905,7 +905,8 @@ // and then BitBlt it to the destination "pDC" //check for window resize - if (m_dcMemMain.GetSafeHdc()) { + if (m_dcMemMain.GetSafeHdc()) + { m_dcMemMain.SelectObject(oldBitmap); m_dcMemMain.DeleteDC(); m_bmpMemMain.DeleteObject(); @@ -1958,7 +1959,7 @@ const size_t sizeofS = sizeof(s) / sizeof(s[0]); if (note >= 0xFE) { - pModDoc->NoteOff(0, (note == NOTE_NOTECUT) ? TRUE : FALSE, m_nInstrument); + pModDoc->NoteOff(0, (note == NOTE_NOTECUT), m_nInstrument); pMainFrm->SetInfoText(""); } else if (m_nInstrument && !m_baPlayingNote[note]) @@ -1980,7 +1981,7 @@ MODINSTRUMENT *pIns = pModDoc->GetSoundFile()->Instruments[m_nInstrument]; if ((!pIns) || (!pIns->Keyboard[note-1] && !pIns->nMixPlug)) return; m_baPlayingNote[note] = true; //rewbs.instViewNNA - m_nPlayingChannel = pModDoc->PlayNote(note, m_nInstrument, 0, FALSE); //rewbs.instViewNNA + m_nPlayingChannel = pModDoc->PlayNote(note, m_nInstrument, 0, false); //rewbs.instViewNNA s[0] = 0; if ((note) && (note <= NOTE_MAX)) { @@ -2184,11 +2185,11 @@ midiByte2 = 0; case MIDIEVENT_NOTEON: // Note On - pModDoc->NoteOff(nNote, FALSE, m_nInstrument); + pModDoc->NoteOff(nNote, false, m_nInstrument); if (midiByte2 & 0x7F) { nVol = ApplyVolumeRelatedMidiSettings(dwMidiData, midivolume); - pModDoc->PlayNote(nNote, m_nInstrument, 0, FALSE, nVol); + pModDoc->PlayNote(nNote, m_nInstrument, 0, false, nVol); } break; @@ -2302,8 +2303,8 @@ if (wParam>=kcInstrumentStartNoteStops && wParam<=kcInstrumentEndNoteStops) { int note =wParam-kcInstrumentStartNoteStops+1+pMainFrm->GetBaseOctave()*12; - m_baPlayingNote[note]=false; - pModDoc->NoteOff(note, FALSE, m_nInstrument); + m_baPlayingNote[note] = false; + pModDoc->NoteOff(note, false, m_nInstrument); return wParam; } @@ -2583,12 +2584,12 @@ return false; } // Can't move left of previous point - if((step < 0) && (pEnv->Ticks[envPoint] - pEnv->Ticks[envPoint - 1] >= -step + GetDocument()->GetSoundFile()->IsCompatibleMode(TRK_IMPULSETRACKER|TRK_FASTTRACKER2) ? 0 : 1)) + if((step < 0) && (pEnv->Ticks[envPoint] - pEnv->Ticks[envPoint - 1] <= -step)) { return false; } // Can't move right of next point - if((step > 0) && (envPoint < pEnv->nNodes - 1) && (pEnv->Ticks[envPoint + 1] - pEnv->Ticks[envPoint] >= step + GetDocument()->GetSoundFile()->IsCompatibleMode(TRK_IMPULSETRACKER|TRK_FASTTRACKER2) ? 0 : 1)) + if((step > 0) && (envPoint < pEnv->nNodes - 1) && (pEnv->Ticks[envPoint + 1] - pEnv->Ticks[envPoint] <= step)) { return false; } Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2012-01-03 19:06:22 UTC (rev 1157) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2012-01-03 23:44:56 UTC (rev 1158) @@ -4222,11 +4222,11 @@ if(bChordMode == true) { m_dwStatus &= ~PATSTATUS_CHORDPLAYING; - pModDoc->NoteOff(0, TRUE, ins, GetChanFromCursor(m_dwCursor)); // XXX this only gets one chord channel! + pModDoc->NoteOff(0, true, ins, GetChanFromCursor(m_dwCursor)); // XXX this doesn't stop VSTi notes! } else { - pModDoc->NoteOff(note, ((CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_NOTEFADE) || pSndFile->GetNumInstruments() == 0) ? TRUE : FALSE, ins, GetChanFromCursor(m_dwCursor)); + pModDoc->NoteOff(note, ((CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_NOTEFADE) || pSndFile->GetNumInstruments() == 0), ins, GetChanFromCursor(m_dwCursor)); } } @@ -4623,8 +4623,8 @@ } } } - BOOL bNotPlaying = ((pMainFrm->GetModPlaying() == pModDoc) && (pMainFrm->IsPlaying())) ? FALSE : TRUE; - pModDoc->PlayNote(newcmd.note, nPlayIns, 0, bNotPlaying, 4 * vol, 0, 0, nChn); + bool isPlaying = ((pMainFrm->GetModPlaying() == pModDoc) && (pMainFrm->IsPlaying())); + pModDoc->PlayNote(newcmd.note, nPlayIns, 0, !isPlaying, 4 * vol, 0, 0, nChn); } } @@ -4849,13 +4849,13 @@ } } } - BOOL bNotPlaying = ((pMainFrm->GetModPlaying() == pModDoc) && (pMainFrm->IsPlaying())) ? FALSE : TRUE; - pModDoc->PlayNote(p->note, nPlayIns, 0, bNotPlaying, -1, 0, 0, nChn); //rewbs.vstiLive - added extra args + bool isPlaying = ((pMainFrm->GetModPlaying() == pModDoc) && (pMainFrm->IsPlaying())); + pModDoc->PlayNote(p->note, nPlayIns, 0, !isPlaying, -1, 0, 0, nChn); //rewbs.vstiLive - added extra args for (UINT kplchrd=0; kplchrd<nPlayChord; kplchrd++) { if (chordplaylist[kplchrd]) { - pModDoc->PlayNote(chordplaylist[kplchrd], nPlayIns, 0, FALSE, -1, 0, 0, nChn); //rewbs.vstiLive - - added extra args + pModDoc->PlayNote(chordplaylist[kplchrd], nPlayIns, 0, false, -1, 0, 0, nChn); //rewbs.vstiLive - - added extra args m_dwStatus |= PATSTATUS_CHORDPLAYING; } } Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2012-01-03 19:06:22 UTC (rev 1157) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2012-01-03 23:44:56 UTC (rev 1158) @@ -2172,26 +2172,22 @@ { if (note >= NOTE_MIN_SPECIAL) { - pModDoc->NoteOff(0, (note == NOTE_NOTECUT) ? TRUE : FALSE); + pModDoc->NoteOff(0, (note == NOTE_NOTECUT)); } else { CHAR s[64]; if (m_dwStatus & SMPSTATUS_KEYDOWN) - pModDoc->NoteOff(note, TRUE); + pModDoc->NoteOff(note, true); else - pModDoc->NoteOff(0, TRUE); + pModDoc->NoteOff(0, true); DWORD loopstart = m_dwBeginSel, loopend = m_dwEndSel; if (loopend - loopstart < (UINT)(4 << m_nZoom)) loopend = loopstart = 0; // selection is too small -> no loop - if(nStartPos != uint32_max) - pModDoc->PlayNote(note, 0, m_nSample, FALSE, -1, loopstart, loopend, CHANNELINDEX_INVALID, nStartPos); - else - pModDoc->PlayNote(note, 0, m_nSample, FALSE, -1, loopstart, loopend); + pModDoc->PlayNote(note, 0, m_nSample, false, -1, loopstart, loopend, CHANNELINDEX_INVALID, nStartPos); - m_dwStatus |= SMPSTATUS_KEYDOWN; s[0] = 0; if ((note) && (note <= NOTE_MAX)) wsprintf(s, "%s%d", szNoteNames[(note-1)%12], (note-1)/12); Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2012-01-03 19:06:22 UTC (rev 1157) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2012-01-03 23:44:56 UTC (rev 1158) @@ -125,7 +125,7 @@ //------------------- { vector<ModTreeDocInfo *>::iterator iter; - for (iter = DocInfo.begin(); iter != DocInfo.end(); iter++) + for(iter = DocInfo.begin(); iter != DocInfo.end(); iter++) { delete (*iter); } @@ -1245,11 +1245,11 @@ if (!nParam) nParam = NOTE_MIDDLEC; if (nParam & 0x80) { - pModDoc->NoteOff(nParam & 0x7F, TRUE); + pModDoc->NoteOff(nParam & 0x7F, true); } else { - pModDoc->NoteOff(0, TRUE); // cut previous playing samples - pModDoc->PlayNote(nParam & 0x7F, 0, modItemID, FALSE); + pModDoc->NoteOff(0, true); // cut previous playing samples + pModDoc->PlayNote(nParam & 0x7F, 0, modItemID, false); } } return TRUE; @@ -1260,11 +1260,11 @@ if (!nParam) nParam = NOTE_MIDDLEC; if (nParam & 0x80) { - pModDoc->NoteOff(nParam, TRUE); + pModDoc->NoteOff(nParam, true); } else { - pModDoc->NoteOff(0, TRUE); - pModDoc->PlayNote(nParam, modItemID, 0, FALSE); + pModDoc->NoteOff(0, true); + pModDoc->PlayNote(nParam, modItemID, 0, false); } } return TRUE; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-02-01 19:09:46
|
Revision: 1170 http://modplug.svn.sourceforge.net/modplug/?rev=1170&view=rev Author: saga-games Date: 2012-02-01 19:09:36 +0000 (Wed, 01 Feb 2012) Log Message: ----------- [Fix] Setup dialog: Made WFIR type dropdown list non-editable. [Fix] Pattern Editor: Fixed scrollbar update after change of number of channels (http://forum.openmpt.org/index.php?topic=3705.0). Modified Paths: -------------- trunk/OpenMPT/mptrack/Draw_pat.cpp trunk/OpenMPT/mptrack/mptrack.rc Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Draw_pat.cpp 2012-01-29 01:09:04 UTC (rev 1169) +++ trunk/OpenMPT/mptrack/Draw_pat.cpp 2012-02-01 19:09:36 UTC (rev 1170) @@ -214,7 +214,7 @@ void CViewPattern::UpdateView(DWORD dwHintMask, CObject *) //-------------------------------------------------------- { - if (dwHintMask & HINT_MPTOPTIONS) + if(dwHintMask & HINT_MPTOPTIONS) { UpdateColors(); UpdateSizes(); @@ -222,25 +222,21 @@ InvalidatePattern(TRUE); return; } - if (dwHintMask & HINT_MODCHANNELS) + if(dwHintMask & HINT_MODCHANNELS) { InvalidateChannelsHeaders(); + UpdateScrollSize(); } - //if (((dwHintMask & 0xFFFFFF) == HINT_PATTERNDATA) & (m_nPattern != (dwHintMask >> HINT_SHIFT_PAT))) return; - if ( (HintFlagPart(dwHintMask) == HINT_PATTERNDATA) && (m_nPattern != (dwHintMask >> HINT_SHIFT_PAT)) ) - return; + if((HintFlagPart(dwHintMask) == HINT_PATTERNDATA) && (m_nPattern != (dwHintMask >> HINT_SHIFT_PAT))) + return; - if (dwHintMask & (HINT_MODTYPE|HINT_PATTERNDATA)) + if(dwHintMask & (HINT_MODTYPE|HINT_PATTERNDATA)) { InvalidatePattern(FALSE); } else - if (dwHintMask & HINT_PATTERNROW) + if(dwHintMask & HINT_PATTERNROW) { -// -> CODE#0008 -// -> DESC"#define to set pattern max size (number of rows) limit (now set to 1024 instead of 256)" -// InvalidateRow(dwHintMask >> 24); InvalidateRow(dwHintMask >> HINT_SHIFT_ROW); -// -! BEHAVIOUR_CHANGE#0008 } } Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2012-01-29 01:09:04 UTC (rev 1169) +++ trunk/OpenMPT/mptrack/mptrack.rc 2012-02-01 19:09:36 UTC (rev 1170) @@ -405,7 +405,7 @@ LTEXT "Resampling:",IDC_STATIC,18,182,42,8 COMBOBOX IDC_COMBO1,66,180,114,56,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "WFIR type:",IDC_STATIC,18,200,42,8 - COMBOBOX IDC_WFIRTYPE,66,198,114,64,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_WFIRTYPE,66,198,114,64,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "WFIR cutoff factor:",IDC_STATIC,18,219,63,8 EDITTEXT IDC_WFIRCUTOFF,156,216,24,14,ES_AUTOHSCROLL | ES_NUMBER LTEXT "%",IDC_STATIC,186,219,8,8 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-02-19 01:37:50
|
Revision: 1185 http://modplug.svn.sourceforge.net/modplug/?rev=1185&view=rev Author: saga-games Date: 2012-02-19 01:37:43 +0000 (Sun, 19 Feb 2012) Log Message: ----------- [Fix] Pattern Editor: Resizing a pattern didn't create an undo point. [Ref] Smaller changes. Modified Paths: -------------- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_smp.cpp Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2012-02-18 12:51:50 UTC (rev 1184) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2012-02-19 01:37:43 UTC (rev 1185) @@ -577,8 +577,9 @@ } } - UINT n = GetDlgItemInt(IDC_COMBO1, NULL, FALSE); - pSndFile->Patterns[m_nPattern].Resize(n); + const ROWINDEX newSize = (ROWINDEX)GetDlgItemInt(IDC_COMBO1, NULL, FALSE); + m_pModDoc->GetPatternUndo().PrepareUndo(m_nPattern, 0, newSize, pSndFile->Patterns[m_nPattern].GetNumChannels(), pSndFile->Patterns[m_nPattern].GetNumRows() - newSize); + pSndFile->Patterns[m_nPattern].Resize(newSize); } CDialog::OnOK(); } Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2012-02-18 12:51:50 UTC (rev 1184) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2012-02-19 01:37:43 UTC (rev 1185) @@ -28,14 +28,14 @@ FindReplaceStruct CViewPattern::m_findReplace = { - {0,0,0,0,0,0}, {0,0,0,0,0,0}, + MODCOMMAND::Empty(), MODCOMMAND::Empty(), PATSEARCH_FULLSEARCH, PATSEARCH_REPLACEALL, 0, 0, 0, 0, 0, }; -MODCOMMAND CViewPattern::m_cmdOld = {0,0,0,0,0,0}; +MODCOMMAND CViewPattern::m_cmdOld = MODCOMMAND::Empty(); IMPLEMENT_SERIAL(CViewPattern, CModScrollView, 0) @@ -1942,7 +1942,7 @@ } for (UINT nPat=nPatStart; nPat<nPatEnd; nPat++) { - LPMODCOMMAND m = pSndFile->Patterns[nPat]; + MODCOMMAND *m = pSndFile->Patterns[nPat]; DWORD len = pSndFile->GetNumChannels() * pSndFile->Patterns[nPat].GetNumRows(); if ((!m) || (!len)) continue; UINT n = 0; Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2012-02-18 12:51:50 UTC (rev 1184) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2012-02-19 01:37:43 UTC (rev 1185) @@ -327,7 +327,7 @@ //-------------------------------------------- { CModDoc *pModDoc = GetDocument(); - if ((pModDoc) && (m_nSample < MAX_SAMPLES)) + if ((pModDoc) && (m_nSample <= pModDoc->GetNumSamples())) { CSoundFile *pSndFile = pModDoc->GetSoundFile(); UINT nLen = pSndFile->GetSample(m_nSample).nLength; @@ -350,7 +350,7 @@ CModDoc *pModDoc = GetDocument(); LONG n = 0; - if ((pModDoc) && (m_nSample < MAX_SAMPLES)) + if ((pModDoc) && (m_nSample <= pModDoc->GetNumSamples())) { CSoundFile *pSndFile = pModDoc->GetSoundFile(); UINT nLen = pSndFile->GetSample(m_nSample).nLength; @@ -775,7 +775,7 @@ rect = rcClient; if ((rcClient.bottom > rcClient.top) && (rcClient.right > rcClient.left)) { - const MODSAMPLE &sample = pSndFile->GetSample((m_nSample < MAX_SAMPLES) ? m_nSample : 0); + const MODSAMPLE &sample = pSndFile->GetSample((m_nSample <= pSndFile->GetNumSamples()) ? m_nSample : 0); int ymed = (rect.top + rect.bottom) / 2; int yrange = (rect.bottom - rect.top) / 2; @@ -1289,7 +1289,7 @@ if (pMainFrm && m_dwEndSel <= m_dwBeginSel) { - if(m_nSample > 0 && m_nSample < MAX_SAMPLES && x < pSndFile->GetSample(m_nSample).nLength) + if(m_nSample > 0 && m_nSample <= pSndFile->GetNumSamples() && x < pSndFile->GetSample(m_nSample).nLength) { const DWORD xLow = (x / 0x100) % 0x100; const DWORD xHigh = x / 0x10000; @@ -2032,7 +2032,7 @@ { CModDoc *pModDoc = GetDocument(); BeginWaitCursor(); - if ((pModDoc) && (m_nSample < MAX_SAMPLES)) + if ((pModDoc) && (m_nSample <= pModDoc->GetNumSamples())) { CSoundFile *pSndFile = pModDoc->GetSoundFile(); MODSAMPLE &sample = pSndFile->GetSample(m_nSample); @@ -2070,7 +2070,7 @@ { CModDoc *pModDoc = GetDocument(); BeginWaitCursor(); - if ((pModDoc) && (m_nSample < MAX_SAMPLES)) + if ((pModDoc) && (m_nSample <= pModDoc->GetNumSamples())) { CSoundFile *pSndFile = pModDoc->GetSoundFile(); MODSAMPLE &sample = pSndFile->GetSample(m_nSample); @@ -2096,7 +2096,7 @@ { CModDoc *pModDoc = GetDocument(); //nothing loaded or invalid sample slot. - if(!pModDoc || m_nSample >= MAX_SAMPLES) return; + if(!pModDoc || m_nSample > pModDoc->GetNumSamples()) return; CSoundFile *pSndFile = pModDoc->GetSoundFile(); MODSAMPLE &sample = pSndFile->GetSample(m_nSample); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-02-19 21:21:53
|
Revision: 1188 http://modplug.svn.sourceforge.net/modplug/?rev=1188&view=rev Author: saga-games Date: 2012-02-19 21:21:46 +0000 (Sun, 19 Feb 2012) Log Message: ----------- [Fix] Previewing instruments with a valid MIDI channel but no plugin assigned crashed the tracker (probably since rev 1156). [Mod] OpenMPT: Version is now 1.20.00.70 Revision Links: -------------- http://modplug.svn.sourceforge.net/modplug/?rev=1156&view=rev Modified Paths: -------------- trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/version.h Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2012-02-19 18:09:15 UTC (rev 1187) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2012-02-19 21:21:46 UTC (rev 1188) @@ -893,9 +893,9 @@ CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); CHANNELINDEX nChn = GetNumChannels(); - if ((!pMainFrm) || (!note)) return FALSE; + if (pMainFrm == nullptr || note == NOTE_NONE) return FALSE; if (nVol > 256) nVol = 256; - if (MODCOMMAND::IsNoteOrEmpty(note)) + if (MODCOMMAND::IsNote(MODCOMMAND::NOTE(note))) { //kill notes if required. @@ -1018,8 +1018,8 @@ UINT nPlugin = 0; if (pChn->pModInstrument) nPlugin = pChn->pModInstrument->nMixPlug; // first try instrument VST - if ((!nPlugin) || (nPlugin > MAX_MIXPLUGINS) && (nCurrentChn != CHANNELINDEX_INVALID)) - nPlugin = m_SndFile.ChnSettings[nCurrentChn].nMixPlugin; // Then try Channel VST + if ((!nPlugin || nPlugin > MAX_MIXPLUGINS) && nCurrentChn != CHANNELINDEX_INVALID) + nPlugin = m_SndFile.ChnSettings[nCurrentChn].nMixPlugin; // Then try Channel VST if ((nPlugin) && (nPlugin <= MAX_MIXPLUGINS)) { Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2012-02-19 18:09:15 UTC (rev 1187) +++ trunk/OpenMPT/mptrack/version.h 2012-02-19 21:21:46 UTC (rev 1188) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 69 +#define VER_MINORMINOR 70 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2012-02-24 22:46:22
|
Revision: 1191 http://modplug.svn.sourceforge.net/modplug/?rev=1191&view=rev Author: saga-games Date: 2012-02-24 22:46:13 +0000 (Fri, 24 Feb 2012) Log Message: ----------- [Ref] Moved all the effect info stuff to a seprate file. Didn't do a lot of refactoring in that code, though (it would be necessary). Modified Paths: -------------- trunk/OpenMPT/mptrack/Draw_pat.cpp trunk/OpenMPT/mptrack/EffectVis.cpp trunk/OpenMPT/mptrack/EffectVis.h trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp trunk/OpenMPT/mptrack/PatternEditorDialogs.h trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/mptrack.vcproj trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters Added Paths: ----------- trunk/OpenMPT/mptrack/EffectInfo.cpp trunk/OpenMPT/mptrack/EffectInfo.h Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Draw_pat.cpp 2012-02-24 22:31:54 UTC (rev 1190) +++ trunk/OpenMPT/mptrack/Draw_pat.cpp 2012-02-24 22:46:13 UTC (rev 1191) @@ -9,6 +9,7 @@ #include "ChannelManagerDlg.h" #include "../soundlib/tuningbase.h" #include "../common/StringFixer.h" +#include "EffectInfo.h" #include <string> using std::string; @@ -1525,6 +1526,8 @@ if ((pMainFrm) && (pModDoc)) { CSoundFile *pSndFile = pModDoc->GetSoundFile(); + EffectInfo effectInfo(*pSndFile); + CHAR s[128]; CHANNELINDEX nChn; wsprintf(s, "Row %d, Col %d", GetCurrentRow(), GetCurrentChannel() + 1); @@ -1611,7 +1614,7 @@ } else { // "normal" volume command - if (!pModDoc->GetVolCmdInfo(pModDoc->GetIndexFromVolCmd(m->volcmd), s)) s[0] = 0; + if (!effectInfo.GetVolCmdInfo(effectInfo.GetIndexFromVolCmd(m->volcmd), s)) s[0] = 0; } break; @@ -1620,7 +1623,7 @@ // display effect command if(!m->IsPcNote()) { - if (!pModDoc->GetEffectName(s, m->command, m->param, false, nChn)) s[0] = 0; + if (!effectInfo.GetEffectName(s, m->command, m->param, false, nChn)) s[0] = 0; } break; } Added: trunk/OpenMPT/mptrack/EffectInfo.cpp =================================================================== --- trunk/OpenMPT/mptrack/EffectInfo.cpp (rev 0) +++ trunk/OpenMPT/mptrack/EffectInfo.cpp 2012-02-24 22:46:13 UTC (rev 1191) @@ -0,0 +1,962 @@ +#include "stdafx.h" +#include "EffectInfo.h" +#include "mptrack.h" +#include "..\soundlib\modcommand.h" + +extern WORD S3MFineTuneTable[16]; + +/////////////////////////////////////////////////////////////////////////// +// Effects description + +struct MPTEFFECTINFO +{ + MODCOMMAND::COMMAND effect; // CMD_XXXX + DWORD paramMask; // 0 = default + DWORD paramValue; // 0 = default + DWORD paramLimit; // Parameter Editor limit + DWORD supportedFormats; // MOD_TYPE_XXX combo + LPCSTR name; // e.g. "Tone Portamento" +}; + +#define MOD_TYPE_MODXM (MOD_TYPE_MOD | MOD_TYPE_XM) +#define MOD_TYPE_S3MIT (MOD_TYPE_S3M | MOD_TYPE_IT) +#define MOD_TYPE_S3MITMPT (MOD_TYPE_S3M | MOD_TYPE_IT | MOD_TYPE_MPT) +#define MOD_TYPE_NOMOD (MOD_TYPE_S3M | MOD_TYPE_XM | MOD_TYPE_IT | MOD_TYPE_MPT) +#define MOD_TYPE_XMIT (MOD_TYPE_XM | MOD_TYPE_IT) +#define MOD_TYPE_XMITMPT (MOD_TYPE_XM | MOD_TYPE_IT | MOD_TYPE_MPT) +#define MOD_TYPE_ITMPT (MOD_TYPE_IT | MOD_TYPE_MPT) +#define MOD_TYPE_ALL 0xFFFFFFFF + + +const MPTEFFECTINFO gFXInfo[] = +{ + {CMD_ARPEGGIO, 0,0, 0, MOD_TYPE_ALL, "Arpeggio"}, + {CMD_PORTAMENTOUP, 0,0, 0, MOD_TYPE_ALL, "Portamento Up"}, + {CMD_PORTAMENTODOWN,0,0, 0, MOD_TYPE_ALL, "Portamento Down"}, + {CMD_TONEPORTAMENTO,0,0, 0, MOD_TYPE_ALL, "Tone Portamento"}, + {CMD_VIBRATO, 0,0, 0, MOD_TYPE_ALL, "Vibrato"}, + {CMD_TONEPORTAVOL, 0,0, 0, MOD_TYPE_ALL, "Volslide+Toneporta"}, + {CMD_VIBRATOVOL, 0,0, 0, MOD_TYPE_ALL, "VolSlide+Vibrato"}, + {CMD_TREMOLO, 0,0, 0, MOD_TYPE_ALL, "Tremolo"}, + {CMD_PANNING8, 0,0, 0, MOD_TYPE_ALL, "Set Panning"}, + {CMD_OFFSET, 0,0, 0, MOD_TYPE_ALL, "Set Offset"}, + {CMD_VOLUMESLIDE, 0,0, 0, MOD_TYPE_ALL, "Volume Slide"}, + {CMD_POSITIONJUMP, 0,0, 0, MOD_TYPE_ALL, "Position Jump"}, + {CMD_VOLUME, 0,0, 0, MOD_TYPE_MODXM, "Set Volume"}, + {CMD_PATTERNBREAK, 0,0, 0, MOD_TYPE_ALL, "Pattern Break"}, + {CMD_RETRIG, 0,0, 0, MOD_TYPE_NOMOD, "Retrigger Note"}, + {CMD_SPEED, 0,0, 0, MOD_TYPE_ALL, "Set Speed"}, + {CMD_TEMPO, 0,0, 0, MOD_TYPE_ALL, "Set Tempo"}, + {CMD_TREMOR, 0,0, 0, MOD_TYPE_NOMOD, "Tremor"}, + {CMD_CHANNELVOLUME, 0,0, 0, MOD_TYPE_S3MITMPT, "Set Channel Volume"}, + {CMD_CHANNELVOLSLIDE,0,0, 0, MOD_TYPE_S3MITMPT, "Channel Volume Slide"}, + {CMD_GLOBALVOLUME, 0,0, 0, MOD_TYPE_NOMOD, "Set Global Volume"}, + {CMD_GLOBALVOLSLIDE,0,0, 0, MOD_TYPE_NOMOD, "Global Volume Slide"}, + {CMD_KEYOFF, 0,0, 0, MOD_TYPE_XM, "Key Off"}, + {CMD_FINEVIBRATO, 0,0, 0, MOD_TYPE_S3MITMPT, "Fine Vibrato"}, + {CMD_PANBRELLO, 0,0, 0, MOD_TYPE_NOMOD, "Panbrello"}, + {CMD_PANNINGSLIDE, 0,0, 0, MOD_TYPE_NOMOD, "Panning Slide"}, + {CMD_SETENVPOSITION,0,0, 0, MOD_TYPE_XM, "Envelope position"}, + {CMD_MIDI, 0,0, 0x7F, MOD_TYPE_NOMOD, "MIDI Macro"}, + {CMD_SMOOTHMIDI, 0,0, 0x7F, MOD_TYPE_XMITMPT, "Smooth MIDI Macro"}, //rewbs.smoothVST + // Extended MOD/XM effects + {CMD_MODCMDEX, 0xF0,0x10, 0, MOD_TYPE_MODXM, "Fine Porta Up"}, + {CMD_MODCMDEX, 0xF0,0x20, 0, MOD_TYPE_MODXM, "Fine Porta Down"}, + {CMD_MODCMDEX, 0xF0,0x30, 0, MOD_TYPE_MODXM, "Glissando Control"}, + {CMD_MODCMDEX, 0xF0,0x40, 0, MOD_TYPE_MODXM, "Vibrato Waveform"}, + {CMD_MODCMDEX, 0xF0,0x50, 0, MOD_TYPE_MODXM, "Set Finetune"}, + {CMD_MODCMDEX, 0xF0,0x60, 0, MOD_TYPE_MODXM, "Pattern Loop"}, + {CMD_MODCMDEX, 0xF0,0x70, 0, MOD_TYPE_MODXM, "Tremolo Waveform"}, + {CMD_MODCMDEX, 0xF0,0x80, 0, MOD_TYPE_MODXM, "Set Panning"}, + {CMD_MODCMDEX, 0xF0,0x90, 0, MOD_TYPE_MODXM, "Retrigger Note"}, + {CMD_MODCMDEX, 0xF0,0xA0, 0, MOD_TYPE_MODXM, "Fine Volslide Up"}, + {CMD_MODCMDEX, 0xF0,0xB0, 0, MOD_TYPE_MODXM, "Fine Volslide Down"}, + {CMD_MODCMDEX, 0xF0,0xC0, 0, MOD_TYPE_MODXM, "Note Cut"}, + {CMD_MODCMDEX, 0xF0,0xD0, 0, MOD_TYPE_MODXM, "Note Delay"}, + {CMD_MODCMDEX, 0xF0,0xE0, 0, MOD_TYPE_MODXM, "Pattern Delay"}, + {CMD_MODCMDEX, 0xF0,0xF0, 0, MOD_TYPE_XM, "Set Active Macro"}, + {CMD_MODCMDEX, 0xF0,0xF0, 0, MOD_TYPE_MOD, "Invert Loop"}, + // Extended S3M/IT effects + {CMD_S3MCMDEX, 0xF0,0x10, 0, MOD_TYPE_S3MITMPT, "Glissando Control"}, + {CMD_S3MCMDEX, 0xF0,0x20, 0, MOD_TYPE_S3M, "Set Finetune"}, + {CMD_S3MCMDEX, 0xF0,0x30, 0, MOD_TYPE_S3MITMPT, "Vibrato Waveform"}, + {CMD_S3MCMDEX, 0xF0,0x40, 0, MOD_TYPE_S3MITMPT, "Tremolo Waveform"}, + {CMD_S3MCMDEX, 0xF0,0x50, 0, MOD_TYPE_S3MITMPT, "Panbrello Waveform"}, + {CMD_S3MCMDEX, 0xF0,0x60, 0, MOD_TYPE_S3MITMPT, "Fine Pattern Delay"}, + {CMD_S3MCMDEX, 0xF0,0x80, 0, MOD_TYPE_S3MITMPT, "Set Panning"}, + {CMD_S3MCMDEX, 0xF0,0xA0, 0, MOD_TYPE_ITMPT, "Set High Offset"}, + {CMD_S3MCMDEX, 0xF0,0xB0, 0, MOD_TYPE_S3MITMPT, "Pattern Loop"}, + {CMD_S3MCMDEX, 0xF0,0xC0, 0, MOD_TYPE_S3MITMPT, "Note Cut"}, + {CMD_S3MCMDEX, 0xF0,0xD0, 0, MOD_TYPE_S3MITMPT, "Note Delay"}, + {CMD_S3MCMDEX, 0xF0,0xE0, 0, MOD_TYPE_S3MITMPT, "Pattern Delay"}, + {CMD_S3MCMDEX, 0xF0,0xF0, 0, MOD_TYPE_ITMPT, "Set Active Macro"}, + // MPT XM extensions and special effects + {CMD_XFINEPORTAUPDOWN,0xF0,0x10,0, MOD_TYPE_XM, "Extra Fine Porta Up"}, + {CMD_XFINEPORTAUPDOWN,0xF0,0x20,0, MOD_TYPE_XM, "Extra Fine Porta Down"}, + {CMD_XFINEPORTAUPDOWN,0xF0,0x50,0, MOD_TYPE_XM, "Panbrello Waveform"}, + {CMD_XFINEPORTAUPDOWN,0xF0,0x60,0, MOD_TYPE_XM, "Fine Pattern Delay"}, + {CMD_XFINEPORTAUPDOWN,0xF0,0x90,0, MOD_TYPE_XM, "Sound Control"}, + {CMD_XFINEPORTAUPDOWN,0xF0,0xA0,0, MOD_TYPE_XM, "Set High Offset"}, + // MPT IT extensions and special effects + {CMD_S3MCMDEX, 0xF0,0x90, 0, MOD_TYPE_S3MITMPT, "Sound Control"}, + {CMD_S3MCMDEX, 0xF0,0x70, 0, MOD_TYPE_ITMPT, "Instr. Control"}, + {CMD_DELAYCUT, 0x00,0x00, 0, MOD_TYPE_MPT, "Note Delay and Cut"}, + // -> CODE#0010 + // -> DESC="add extended parameter mechanism to pattern effects" + {CMD_XPARAM, 0x00,0x00, 0, MOD_TYPE_XMITMPT, "Parameter Extension"}, + // -! NEW_FEATURE#0010 + {CMD_NOTESLIDEUP, 0x00,0x00, 0, MOD_TYPE_NONE, "Note Slide Up"}, // .IMF effect + {CMD_NOTESLIDEDOWN, 0x00,0x00, 0, MOD_TYPE_NONE, "Note Slide Down"}, // .IMF effect +}; + + +UINT EffectInfo::GetNumEffects() const +//------------------------------------ +{ + return CountOf(gFXInfo); +} + + +bool EffectInfo::IsExtendedEffect(UINT ndx) const +//------------------------------------------------ +{ + return ((ndx < CountOf(gFXInfo)) && (gFXInfo[ndx].paramMask)); +} + + +bool EffectInfo::GetEffectName(LPSTR pszDescription, MODCOMMAND::COMMAND command, UINT param, bool bXX, CHANNELINDEX nChn) const +//------------------------------------------------------------------------------------------------------------------------------ +{ + bool bSupported; + UINT fxndx = CountOf(gFXInfo); + pszDescription[0] = 0; + for (UINT i = 0; i < CountOf(gFXInfo); i++) + { + if ((command == gFXInfo[i].effect) // Effect + && ((param & gFXInfo[i].paramMask) == gFXInfo[i].paramValue)) // Value + { + fxndx = i; + // if format is compatible, everything is fine. if not, let's still search + // for another command. this fixes searching for the EFx command, which + // does different things in MOD format. + if((sndFile.GetType() & gFXInfo[i].supportedFormats) != 0) + break; + } + } + if (fxndx == CountOf(gFXInfo)) return false; + bSupported = ((sndFile.GetType() & gFXInfo[fxndx].supportedFormats) != 0); + if (gFXInfo[fxndx].name) + { + if ((bXX) && (bSupported)) + { + strcpy(pszDescription, " xx: "); + pszDescription[0] = sndFile.GetModSpecifications().GetEffectLetter(command); + if ((gFXInfo[fxndx].paramMask & 0xF0) == 0xF0) pszDescription[1] = szHexChar[gFXInfo[fxndx].paramValue >> 4]; + if ((gFXInfo[fxndx].paramMask & 0x0F) == 0x0F) pszDescription[2] = szHexChar[gFXInfo[fxndx].paramValue & 0x0F]; + } + strcat(pszDescription, gFXInfo[fxndx].name); + //rewbs.xinfo + //Get channel specific info + if (nChn < sndFile.m_nChannels) + { + CString chanSpec = ""; + size_t macroIndex = size_t(-1); + + switch (command) + { + case CMD_MODCMDEX: + case CMD_S3MCMDEX: + if ((param & 0xF0) == 0xF0 && !(sndFile.GetType() & MOD_TYPE_MOD)) //Set Macro + { + macroIndex = (param & 0x0F); + chanSpec.Format(" to %d: ", param & 0x0F); + } + break; + + case CMD_MIDI: + case CMD_SMOOTHMIDI: + if (param < 0x80 && nChn != CHANNELINDEX_INVALID) + { + macroIndex = sndFile.Chn[nChn].nActiveMacro; + chanSpec.Format(": currently %d: ", sndFile.Chn[nChn].nActiveMacro); + } + else + { + chanSpec = " (Fixed)"; + } + break; + } + + if(macroIndex != size_t(-1)) + { + const PLUGINDEX plugin = sndFile.GetBestPlugin(nChn, PrioritiseChannel, EvenIfMuted) - 1; + chanSpec.Append(sndFile.m_MidiCfg.GetParameteredMacroName(macroIndex, plugin, sndFile)); + } + if (chanSpec != "") + { + strcat(pszDescription, chanSpec); + } + + } + //end rewbs.xinfo + } + return bSupported; +} + + +LONG EffectInfo::GetIndexFromEffect(MODCOMMAND::COMMAND command, MODCOMMAND::PARAM param) const +//--------------------------------------------------------------------------------------------- +{ + UINT ndx = CountOf(gFXInfo); + for (UINT i = 0; i < CountOf(gFXInfo); i++) + { + if ((command == gFXInfo[i].effect) // Effect + && ((param & gFXInfo[i].paramMask) == gFXInfo[i].paramValue)) // Value + { + ndx = i; + if((sndFile.GetType() & gFXInfo[i].supportedFormats) != 0) + break; // found fitting format; this is correct for sure + } + } + return ndx; +} + + +//Returns command and corrects parameter refParam if necessary +MODCOMMAND::COMMAND EffectInfo::GetEffectFromIndex(UINT ndx, int &refParam) const +//------------------------------------------------------------------------------- +{ + //if (pParam) *pParam = -1; + if (ndx >= CountOf(gFXInfo)) + { + refParam = 0; + return CMD_NONE; + } + + // Cap parameter to match FX if necessary. + if (gFXInfo[ndx].paramMask) + { + if (refParam < static_cast<int>(gFXInfo[ndx].paramValue)) + { + refParam = gFXInfo[ndx].paramValue; // for example: delay with param < D0 becomes SD0 + } else if (refParam > static_cast<int>(gFXInfo[ndx].paramValue) + 15) + { + refParam = gFXInfo[ndx].paramValue + 15; // for example: delay with param > DF becomes SDF + } + } + if (gFXInfo[ndx].paramLimit) + { + // used for Zxx macro control in parameter editor: limit to 7F max. + LimitMax(refParam, static_cast<int>(gFXInfo[ndx].paramLimit)); + } + + return gFXInfo[ndx].effect; +} + + +MODCOMMAND::COMMAND EffectInfo::GetEffectFromIndex(UINT ndx) const +//---------------------------------------------------------------- +{ + if (ndx >= CountOf(gFXInfo)) + { + return CMD_NONE; + } + + return gFXInfo[ndx].effect; +} + +UINT EffectInfo::GetEffectMaskFromIndex(UINT ndx) const +//----------------------------------------------------- +{ + if (ndx >= CountOf(gFXInfo)) + { + return 0; + } + + return gFXInfo[ndx].paramValue; + +} + +bool EffectInfo::GetEffectInfo(UINT ndx, LPSTR s, bool bXX, DWORD *prangeMin, DWORD *prangeMax) const +//--------------------------------------------------------------------------------------------------- +{ + if (s) s[0] = 0; + if (prangeMin) *prangeMin = 0; + if (prangeMax) *prangeMax = 0; + if ((ndx >= CountOf(gFXInfo)) || (!(sndFile.GetType() & gFXInfo[ndx].supportedFormats))) return FALSE; + if (s) GetEffectName(s, gFXInfo[ndx].effect, gFXInfo[ndx].paramValue, bXX); + if ((prangeMin) && (prangeMax)) + { + UINT nmin = 0, nmax = 0xFF, nType = sndFile.GetType(); + if (gFXInfo[ndx].paramMask == 0xF0) + { + nmin = gFXInfo[ndx].paramValue; + nmax = nmin | 0x0F; + } + switch(gFXInfo[ndx].effect) + { + case CMD_ARPEGGIO: + if (nType & (MOD_TYPE_MOD | MOD_TYPE_XM)) nmin = 1; + break; + case CMD_VOLUME: + case CMD_CHANNELVOLUME: + nmax = 0x40; + break; + case CMD_SPEED: + nmin = 1; + nmax = 0xFF; + if (nType & MOD_TYPE_MOD) nmax = 0x20; else + if (nType & MOD_TYPE_XM) nmax = 0x1F; + break; + case CMD_TEMPO: + nmin = 0x20; + if (nType & MOD_TYPE_MOD) nmin = 0x21; else + // -> CODE#0010 + // -> DESC="add extended parameter mechanism to pattern effects" + // if (nType & MOD_TYPE_S3MIT) nmin = 1; + if (nType & MOD_TYPE_S3MITMPT) nmin = 0; + // -! NEW_FEATURE#0010 + break; + case CMD_VOLUMESLIDE: + case CMD_TONEPORTAVOL: + case CMD_VIBRATOVOL: + case CMD_GLOBALVOLSLIDE: + case CMD_CHANNELVOLSLIDE: + case CMD_PANNINGSLIDE: + nmax = (nType & MOD_TYPE_S3MITMPT) ? 58 : 30; + break; + case CMD_PANNING8: + if (nType & (MOD_TYPE_S3M)) nmax = 0x81; + else nmax = 0xFF; + break; + case CMD_GLOBALVOLUME: + nmax = (nType & (MOD_TYPE_IT | MOD_TYPE_MPT)) ? 128 : 64; + break; + + case CMD_MODCMDEX: + // adjust waveform types for XM/MOD + if(gFXInfo[ndx].paramValue == 0x40 || gFXInfo[ndx].paramValue == 0x70) nmax = gFXInfo[ndx].paramValue | 0x07; + break; + case CMD_S3MCMDEX: + // adjust waveform types for IT/S3M + if(gFXInfo[ndx].paramValue >= 0x30 && gFXInfo[ndx].paramValue <= 0x50) nmax = gFXInfo[ndx].paramValue | (sndFile.IsCompatibleMode(TRK_IMPULSETRACKER | TRK_SCREAMTRACKER) ? 0x03 : 0x07); + break; + case CMD_PATTERNBREAK: + // no big patterns in MOD/S3M files + if(nType & (MOD_TYPE_MOD | MOD_TYPE_S3M)) + nmax = 63; + break; + } + *prangeMin = nmin; + *prangeMax = nmax; + } + return TRUE; +} + + +UINT EffectInfo::MapValueToPos(UINT ndx, UINT param) const +//-------------------------------------------------------- +{ + UINT pos; + + if (ndx >= CountOf(gFXInfo)) return 0; + pos = param; + if (gFXInfo[ndx].paramMask == 0xF0) + { + pos &= 0x0F; + pos |= gFXInfo[ndx].paramValue; + } + switch(gFXInfo[ndx].effect) + { + case CMD_VOLUMESLIDE: + case CMD_TONEPORTAVOL: + case CMD_VIBRATOVOL: + case CMD_GLOBALVOLSLIDE: + case CMD_CHANNELVOLSLIDE: + case CMD_PANNINGSLIDE: + if (sndFile.GetType() & MOD_TYPE_S3MITMPT) + { + if (!param) + pos = 29; + else if (((param & 0x0F) == 0x0F) && (param & 0xF0)) + pos = 29 + (param >> 4); + else if (((param & 0xF0) == 0xF0) && (param & 0x0F)) + pos = 29 - (param & 0x0F); + else if (param & 0x0F) + pos = 15 - (param & 0x0F); + else + pos = (param >> 4) + 44; + } else + { + if (param & 0x0F) + pos = 15 - (param & 0x0F); + else + pos = (param >> 4) + 15; + } + break; + case CMD_PANNING8: + if(sndFile.GetType() == MOD_TYPE_S3M) + { + pos = CLAMP(param, 0, 0x80); + if(param == 0xA4) + pos = 0x81; + } + break; + } + return pos; +} + + +UINT EffectInfo::MapPosToValue(UINT ndx, UINT pos) const +//------------------------------------------------------ +{ + UINT param; + + if (ndx >= CountOf(gFXInfo)) return 0; + param = pos; + if (gFXInfo[ndx].paramMask == 0xF0) param |= gFXInfo[ndx].paramValue; + switch(gFXInfo[ndx].effect) + { + case CMD_VOLUMESLIDE: + case CMD_TONEPORTAVOL: + case CMD_VIBRATOVOL: + case CMD_GLOBALVOLSLIDE: + case CMD_CHANNELVOLSLIDE: + case CMD_PANNINGSLIDE: + if (sndFile.GetType() & MOD_TYPE_S3MITMPT) + { + if (pos < 15) + param = 15 - pos; + else if (pos < 29) + param = (29 - pos) | 0xF0; + else if (pos == 29) + param = 0; + else if (pos < 44) + param = ((pos - 29) << 4) | 0x0F; + else + if (pos < 59) param = (pos - 43) << 4; + } else + { + if (pos < 15) + param = 15 - pos; + else + param = (pos - 15) << 4; + } + break; + case CMD_PANNING8: + if(sndFile.GetType() == MOD_TYPE_S3M) + param = (pos <= 0x80) ? pos : 0xA4; + break; + } + return param; +} + + +bool EffectInfo::GetEffectNameEx(LPSTR pszName, UINT ndx, UINT param) const +//------------------------------------------------------------------------- +{ + char s[64]; + char szContinueOrIgnore[16]; + + if (pszName) pszName[0] = 0; + if ((!pszName) || (ndx >= CountOf(gFXInfo)) || (!gFXInfo[ndx].name)) return false; + wsprintf(pszName, "%s: ", gFXInfo[ndx].name); + s[0] = 0; + + // for effects that don't have effect memory in MOD format. + if(sndFile.GetType() == MOD_TYPE_MOD) + strcpy(szContinueOrIgnore, "ignore"); + else + strcpy(szContinueOrIgnore, "continue"); + + std::string sPlusChar = "+", sMinusChar = "-"; + + switch(gFXInfo[ndx].effect) + { + case CMD_ARPEGGIO: + if(sndFile.GetType() == MOD_TYPE_XM) // XM also ignores this! + strcpy(szContinueOrIgnore, "ignore"); + + if (param) + wsprintf(s, "note+%d note+%d", param >> 4, param & 0x0F); + else + strcpy(s, szContinueOrIgnore); + break; + + case CMD_PORTAMENTOUP: + case CMD_PORTAMENTODOWN: + if(param) + { + char sign = (gFXInfo[ndx].effect == CMD_PORTAMENTOUP) ? '+' : '-'; + + if((sndFile.GetType() & MOD_TYPE_S3MITMPT) && ((param & 0xF0) == 0xF0)) + wsprintf(s, "fine %c%d", sign, (param & 0x0F)); + else if((sndFile.GetType() & MOD_TYPE_S3MITMPT) && ((param & 0xF0) == 0xE0)) + wsprintf(s, "extra fine %c%d", sign, (param & 0x0F)); + else + wsprintf(s, "%c%d", sign, param); + } + else + { + strcpy(s, szContinueOrIgnore); + } + break; + + case CMD_TONEPORTAMENTO: + if (param) + wsprintf(s, "speed %d", param); + else + strcpy(s, "continue"); + break; + + case CMD_VIBRATO: + case CMD_TREMOLO: + case CMD_PANBRELLO: + case CMD_FINEVIBRATO: + if (param) + wsprintf(s, "speed=%d depth=%d", param >> 4, param & 0x0F); + else + strcpy(s, "continue"); + break; + + case CMD_SPEED: + wsprintf(s, "%d ticks/row", param); + break; + + case CMD_TEMPO: + if (param < 0x10) + wsprintf(s, "-%d bpm (slower)", param & 0x0F); + else if (param < 0x20) + wsprintf(s, "+%d bpm (faster)", param & 0x0F); + else + wsprintf(s, "%d bpm", param); + break; + + case CMD_PANNING8: + wsprintf(s, "%d", param); + if(sndFile.GetType() == MOD_TYPE_S3M) + { + if(param == 0xA4) + strcpy(s, "Surround"); + } + break; + + case CMD_RETRIG: + switch(param >> 4) + { + case 0: + if(sndFile.GetType() & MOD_TYPE_XM) + strcpy(s, "continue"); + else + strcpy(s, "vol *1"); + break; + case 1: strcpy(s, "vol -1"); break; + case 2: strcpy(s, "vol -2"); break; + case 3: strcpy(s, "vol -4"); break; + case 4: strcpy(s, "vol -8"); break; + case 5: strcpy(s, "vol -16"); break; + case 6: strcpy(s, "vol *0.66"); break; + case 7: strcpy(s, "vol *0.5"); break; + case 8: strcpy(s, "vol *1"); break; + case 9: strcpy(s, "vol +1"); break; + case 10: strcpy(s, "vol +2"); break; + case 11: strcpy(s, "vol +4"); break; + case 12: strcpy(s, "vol +8"); break; + case 13: strcpy(s, "vol +16"); break; + case 14: strcpy(s, "vol *1.5"); break; + case 15: strcpy(s, "vol *2"); break; + } + char spd[10]; + wsprintf(spd, " speed %d", param & 0x0F); + strcat(s, spd); + break; + + case CMD_VOLUMESLIDE: + case CMD_TONEPORTAVOL: + case CMD_VIBRATOVOL: + case CMD_GLOBALVOLSLIDE: + case CMD_CHANNELVOLSLIDE: + case CMD_PANNINGSLIDE: + if(gFXInfo[ndx].effect == CMD_PANNINGSLIDE) + { + if(sndFile.GetType() == MOD_TYPE_XM) + { + sPlusChar = "-> "; + sMinusChar = "<- "; + } + else + { + sPlusChar = "<- "; + sMinusChar = "-> "; + } + } + + if (!param) + { + wsprintf(s, "continue"); + } else + if ((sndFile.GetType() & MOD_TYPE_S3MITMPT) && ((param & 0x0F) == 0x0F) && (param & 0xF0)) + { + wsprintf(s, "fine %s%d", sPlusChar.c_str(), param >> 4); + } else + if ((sndFile.GetType() & MOD_TYPE_S3MITMPT) && ((param & 0xF0) == 0xF0) && (param & 0x0F)) + { + wsprintf(s, "fine %s%d", sMinusChar.c_str(), param & 0x0F); + } else + if ((param & 0x0F) != param && (param & 0xF0) != param) // both nibbles are set. + { + strcpy(s, "undefined"); + } else + if (param & 0x0F) + { + wsprintf(s, "%s%d", sMinusChar.c_str(), param & 0x0F); + } else + { + wsprintf(s, "%s%d", sPlusChar.c_str(), param >> 4); + } + break; + + case CMD_PATTERNBREAK: + wsprintf(pszName, "Break to row %d", param); + break; + + case CMD_POSITIONJUMP: + wsprintf(pszName, "Jump to position %d", param); + break; + + case CMD_OFFSET: + if (param) + // -> CODE#0010 + // -> DESC="add extended parameter mechanism to pattern effects" + // wsprintf(pszName, "Set Offset to %u", param << 8); + wsprintf(pszName, "Set Offset to %u", param); + // -! NEW_FEATURE#0010 + else + strcpy(s, "continue"); + break; + + case CMD_TREMOR: + if(param) + { + BYTE ontime = (BYTE)(param >> 4), offtime = (BYTE)(param & 0x0F); + if(sndFile.m_dwSongFlags & SONG_ITOLDEFFECTS) + { + ontime++; + offtime++; + } + else + { + if(ontime == 0) ontime = 1; + if(offtime == 0) offtime = 1; + } + wsprintf(s, "ontime %d, offtime %d", ontime, offtime); + } + else + { + strcpy(s, "continue"); + } + break; + + case CMD_SETENVPOSITION: + wsprintf(s, "Tick %d", param); + break; + + case CMD_MIDI: + case CMD_SMOOTHMIDI: + if (param < 0x80) + { + wsprintf(pszName, "SFx macro: z=%02X (%d)", param, param); + } else + { + wsprintf(pszName, "Fixed Macro Z%02X", param); + } + break; + + case CMD_DELAYCUT: + wsprintf(pszName, "Note delay: %d, cut after %d ticks", (param >> 4), (param & 0x0F)); + break; + + default: + if (gFXInfo[ndx].paramMask == 0xF0) + { + // Sound control names + if (((gFXInfo[ndx].effect == CMD_XFINEPORTAUPDOWN) || (gFXInfo[ndx].effect == CMD_S3MCMDEX)) + && ((gFXInfo[ndx].paramValue & 0xF0) == 0x90) && ((param & 0xF0) == 0x90)) + { + switch(param & 0x0F) + { + case 0x00: strcpy(s, "90: Surround Off"); break; + case 0x01: strcpy(s, "91: Surround On"); break; + case 0x08: strcpy(s, "98: Reverb Off"); break; + case 0x09: strcpy(s, "99: Reverb On"); break; + case 0x0A: strcpy(s, "9A: Center surround"); break; + case 0x0B: strcpy(s, "9B: Quad surround"); break; + case 0x0C: strcpy(s, "9C: Global filters"); break; + case 0x0D: strcpy(s, "9D: Local filters"); break; + case 0x0E: strcpy(s, "9E: Play Forward"); break; + case 0x0F: strcpy(s, "9F: Play Backward"); break; + default: wsprintf(s, "%02X: undefined", param); + } + } else + if (((gFXInfo[ndx].effect == CMD_XFINEPORTAUPDOWN) || (gFXInfo[ndx].effect == CMD_S3MCMDEX)) + && ((gFXInfo[ndx].paramValue & 0xF0) == 0x70) && ((param & 0xF0) == 0x70)) + { + switch(param & 0x0F) + { + case 0x00: strcpy(s, "70: Past note cut"); break; + case 0x01: strcpy(s, "71: Past note off"); break; + case 0x02: strcpy(s, "72: Past note fade"); break; + case 0x03: strcpy(s, "73: NNA note cut"); break; + case 0x04: strcpy(s, "74: NNA continue"); break; + case 0x05: strcpy(s, "75: NNA note off"); break; + case 0x06: strcpy(s, "76: NNA note fade"); break; + case 0x07: strcpy(s, "77: Volume Env Off"); break; + case 0x08: strcpy(s, "78: Volume Env On"); break; + case 0x09: strcpy(s, "79: Pan Env Off"); break; + case 0x0A: strcpy(s, "7A: Pan Env On"); break; + case 0x0B: strcpy(s, "7B: Pitch Env Off"); break; + case 0x0C: strcpy(s, "7C: Pitch Env On"); break; + // intentional fall-through for non-MPT modules follows + case 0x0D: if(sndFile.GetType() == MOD_TYPE_MPT) { strcpy(s, "7D: Force Pitch Env"); break; } + case 0x0E: if(sndFile.GetType() == MOD_TYPE_MPT) { strcpy(s, "7E: Force Filter Env"); break; } + default: wsprintf(s, "%02X: undefined", param); break; + } + } else + { + wsprintf(s, "%d", param & 0x0F); + if(gFXInfo[ndx].effect == CMD_S3MCMDEX) + { + switch(param & 0xF0) + { + case 0x10: // glissando control + if((param & 0x0F) == 0) + strcpy(s, "smooth"); + else + strcpy(s, "semitones"); + break; + case 0x20: // set finetune + wsprintf(s, "%dHz", S3MFineTuneTable[param & 0x0F]); + break; + case 0x30: // vibrato waveform + case 0x40: // tremolo waveform + case 0x50: // panbrello waveform + if(((param & 0x0F) > 0x03) && sndFile.IsCompatibleMode(TRK_IMPULSETRACKER)) + { + strcpy(s, "ignore"); + break; + } + switch(param & 0x0F) + { + case 0x00: strcpy(s, "sine wave"); break; + case 0x01: strcpy(s, "ramp down"); break; + case 0x02: strcpy(s, "square wave"); break; + case 0x03: strcpy(s, "random"); break; + case 0x04: strcpy(s, "sine wave (cont.)"); break; + case 0x05: strcpy(s, "ramp down (cont.)"); break; + case 0x06: strcpy(s, "square wave (cont.)"); break; + case 0x07: strcpy(s, "random (cont.)"); break; + default: strcpy(s, "ignore"); break; + } + break; + + case 0x60: // fine pattern delay (ticks) + strcat(s, " ticks"); + break; + + case 0xA0: // high offset + wsprintf(s, "+ %u samples", (param & 0x0F) * 0x10000); + break; + + case 0xB0: // pattern loop + if((param & 0x0F) == 0x00) + strcpy(s, "loop start"); + else + strcat(s, " times"); + break; + case 0xC0: // note cut + case 0xD0: // note delay + //IT compatibility 22. SD0 == SD1, SC0 == SC1 + if(((param & 0x0F) == 1) || ((param & 0x0F) == 0 && (sndFile.GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)))) + strcpy(s, "1 tick"); + else + strcat(s, " ticks"); + break; + case 0xE0: // pattern delay (rows) + strcat(s, " rows"); + break; + case 0xF0: // macro + if(sndFile.GetType() != MOD_TYPE_MOD) + wsprintf(s, "SF%X", param & 0x0F); + break; + default: + break; + } + } + if(gFXInfo[ndx].effect == CMD_MODCMDEX) + { + switch(param & 0xF0) + { + case 0x30: // glissando control + if((param & 0x0F) == 0) + strcpy(s, "smooth"); + else + strcpy(s, "semitones"); + break; + case 0x40: // vibrato waveform + case 0x70: // tremolo waveform + switch(param & 0x0F) + { + case 0x00: case 0x08: strcpy(s, "sine wave"); break; + case 0x01: case 0x09: strcpy(s, "ramp down"); break; + case 0x02: case 0x0A: strcpy(s, "square wave"); break; + case 0x03: case 0x0B: strcpy(s, "square wave"); break; + + case 0x04: case 0x0C: strcpy(s, "sine wave (cont.)"); break; + case 0x05: case 0x0D: strcpy(s, "ramp down (cont.)"); break; + case 0x06: case 0x0E: strcpy(s, "square wave (cont.)"); break; + case 0x07: case 0x0F: strcpy(s, "square wave (cont.)"); break; + } + break; + case 0x50: // set finetune + { + int8 nFinetune = (param & 0x0F); + if(sndFile.GetType() & MOD_TYPE_XM) + { + // XM finetune + nFinetune = (nFinetune - 8) * 16; + } else + { + // MOD finetune + if(nFinetune > 7) nFinetune -= 16; + } + wsprintf(s, "%d", nFinetune); + } + break; + case 0x60: // pattern loop + if((param & 0x0F) == 0x00) + strcpy(s, "loop start"); + else + strcat(s, " times"); + break; + case 0x90: // retrigger + wsprintf(s, "speed %d", param & 0x0F); + break; + case 0xC0: // note cut + case 0xD0: // note delay + strcat(s, " ticks"); + break; + case 0xE0: // pattern delay (rows) + strcat(s, " rows"); + break; + case 0xF0: + if(sndFile.GetType() == MOD_TYPE_MOD) // invert loop + { + if((param & 0x0F) == 0) + strcpy(s, "Stop"); + else + wsprintf(s, "Speed %d", param & 0x0F); + } + else // macro + { + wsprintf(s, "SF%X", param & 0x0F); + } + break; + default: + break; + } + } + } + + } else + { + wsprintf(s, "%u", param); + } + } + strcat(pszName, s); + return true; +} + + +//////////////////////////////////////////////////////////////////////////////////////// +// Volume column effects description + +typedef struct MPTVOLCMDINFO +{ + MODCOMMAND::VOLCMD volCmd; // VOLCMD_XXXX + DWORD supportedFormats; // MOD_TYPE_XXX combo + LPCSTR name; // e.g. "Set Volume" +} MPTVOLCMDINFO; + +const MPTVOLCMDINFO gVolCmdInfo[] = +{ + {VOLCMD_VOLUME, MOD_TYPE_NOMOD, "Set Volume"}, + {VOLCMD_PANNING, MOD_TYPE_NOMOD, "Set Panning"}, + {VOLCMD_VOLSLIDEUP, MOD_TYPE_XMITMPT, "Volume slide up"}, + {VOLCMD_VOLSLIDEDOWN, MOD_TYPE_XMITMPT, "Volume slide down"}, + {VOLCMD_FINEVOLUP, MOD_TYPE_XMITMPT, "Fine volume up"}, + {VOLCMD_FINEVOLDOWN, MOD_TYPE_XMITMPT, "Fine volume down"}, + {VOLCMD_VIBRATOSPEED, MOD_TYPE_XM, "Vibrato speed"}, + {VOLCMD_VIBRATODEPTH, MOD_TYPE_XMITMPT, "Vibrato depth"}, + {VOLCMD_PANSLIDELEFT, MOD_TYPE_XM, "Pan slide left"}, + {VOLCMD_PANSLIDERIGHT, MOD_TYPE_XM, "Pan slide right"}, + {VOLCMD_TONEPORTAMENTO, MOD_TYPE_XMITMPT, "Tone portamento"}, + {VOLCMD_PORTAUP, MOD_TYPE_ITMPT, "Portamento up"}, + {VOLCMD_PORTADOWN, MOD_TYPE_ITMPT, "Portamento down"}, + {VOLCMD_DELAYCUT, MOD_TYPE_NONE, ""}, + {VOLCMD_OFFSET, MOD_TYPE_ITMPT, "Offset"}, //rewbs.volOff +}; + +STATIC_ASSERT(CountOf(gVolCmdInfo) == (MAX_VOLCMDS - 1)); + + +UINT EffectInfo::GetNumVolCmds() const +//------------------------------------ +{ + return CountOf(gVolCmdInfo); +} + + +LONG EffectInfo::GetIndexFromVolCmd(MODCOMMAND::VOLCMD volcmd) const +//------------------------------------------------------------------ +{ + for (UINT i = 0; i < CountOf(gVolCmdInfo); i++) + { + if (gVolCmdInfo[i].volCmd == volcmd) return i; + } + return -1; +} + + +MODCOMMAND::VOLCMD EffectInfo::GetVolCmdFromIndex(UINT ndx) const +//--------------------------------------------------------------- +{ + return (ndx < CountOf(gVolCmdInfo)) ? gVolCmdInfo[ndx].volCmd : 0; +} + + +bool EffectInfo::GetVolCmdInfo(UINT ndx, LPSTR s, DWORD *prangeMin, DWORD *prangeMax) const +//----------------------------------------------------------------------------------------- +{ + if (s) s[0] = 0; + if (prangeMin) *prangeMin = 0; + if (prangeMax) *prangeMax = 0; + if (ndx >= CountOf(gVolCmdInfo)) return false; + if (s) + { + sprintf(s, "%c: %s", sndFile.GetModSpecifications().GetVolEffectLetter(GetVolCmdFromIndex(ndx)), gVolCmdInfo[ndx].name); + } + if ((prangeMin) && (prangeMax)) + { + switch(gVolCmdInfo[ndx].volCmd) + { + case VOLCMD_VOLUME: + case VOLCMD_PANNING: + *prangeMax = 64; + break; + + default: + *prangeMax = (sndFile.GetType() & MOD_TYPE_XM) ? 15 : 9; + } + } + return (gVolCmdInfo[ndx].supportedFormats & sndFile.GetType()) != 0; +} Added: trunk/OpenMPT/mptrack/EffectInfo.h =================================================================== --- trunk/OpenMPT/mptrack/EffectInfo.h (rev 0) +++ trunk/OpenMPT/mptrack/EffectInfo.h 2012-02-24 22:46:13 UTC (rev 1191) @@ -0,0 +1,54 @@ +#pragma once +#ifndef EFFECTINFO_H +#define EFFECTINFO_H + +#include "Moddoc.h" + +//============== +class EffectInfo +//============== +{ +protected: + const CSoundFile &sndFile; + +public: + + EffectInfo(const CSoundFile &sf) : sndFile(sf) {}; + + // Effects Description + + // Get basic effect name with some additional information for some effects + bool GetEffectName(LPSTR pszDescription, MODCOMMAND::COMMAND command, UINT param, bool bXX = false, CHANNELINDEX nChn = CHANNELINDEX_INVALID) const; // bXX: Nxx: ... + // Get size of list of known effect commands + UINT GetNumEffects() const; + // Get range information, effect name, etc... from a given effect. + bool GetEffectInfo(UINT ndx, LPSTR s, bool bXX = false, DWORD *prangeMin = nullptr, DWORD *prangeMax = nullptr) const; + // Get effect index in effect list from effect command + param + LONG GetIndexFromEffect(MODCOMMAND::COMMAND command, MODCOMMAND::PARAM param) const; + // Get effect command + param from effect index + MODCOMMAND::COMMAND GetEffectFromIndex(UINT ndx, int &refParam) const; + MODCOMMAND::COMMAND GetEffectFromIndex(UINT ndx) const; + // Get parameter mask from effect (for extended effects) + UINT GetEffectMaskFromIndex(UINT ndx) const; + // Get precise effect name, also with explanation of effect parameter + bool GetEffectNameEx(LPSTR pszName, UINT ndx, UINT param) const; + // Check whether an effect is extended (with parameter nibbles) + bool IsExtendedEffect(UINT ndx) const; + // Map an effect value to slider position + UINT MapValueToPos(UINT ndx, UINT param) const; + // Map slider position to an effect value + UINT MapPosToValue(UINT ndx, UINT pos) const; + + // Volume column effects description + + // Get size of list of known volume commands + UINT GetNumVolCmds() const; + // Get effect index in effect list from volume command + LONG GetIndexFromVolCmd(MODCOMMAND::VOLCMD volcmd) const; + // Get volume command from effect index + MODCOMMAND::VOLCMD GetVolCmdFromIndex(UINT ndx) const; + // Get range information, effect name, etc... from a given effect. + bool GetVolCmdInfo(UINT ndx, LPSTR s, DWORD *prangeMin = nullptr, DWORD *prangeMax = nullptr) const; +}; + +#endif // EFFECTINFO_H \ No newline at end of file Modified: trunk/OpenMPT/mptrack/EffectVis.cpp =================================================================== --- trunk/OpenMPT/mptrack/EffectVis.cpp 2012-02-24 22:31:54 UTC (rev 1190) +++ trunk/OpenMPT/mptrack/EffectVis.cpp 2012-02-24 22:46:13 UTC (rev 1191) @@ -24,7 +24,7 @@ // EffectVis dialog IMPLEMENT_DYNAMIC(CEffectVis, CDialog) -CEffectVis::CEffectVis(CViewPattern *pViewPattern, UINT startRow, UINT endRow, UINT nchn, CModDoc* pModDoc, UINT pat) +CEffectVis::CEffectVis(CViewPattern *pViewPattern, UINT startRow, UINT endRow, UINT nchn, CModDoc* pModDoc, UINT pat) : effectInfo(*pModDoc->GetSoundFile()) { m_pViewPattern = pViewPattern; m_dwStatus = 0x00; @@ -38,7 +38,7 @@ m_nLastDrawnRow = -1; m_nLastDrawnY = -1; m_nOldPlayPos = UINT_MAX; - m_nFillEffect = m_pModDoc->GetIndexFromEffect(CMD_SMOOTHMIDI, 0); + m_nFillEffect = effectInfo.GetIndexFromEffect(CMD_SMOOTHMIDI, 0); m_nAction=kAction_OverwriteFX; m_templatePCNote.Set(NOTE_PCS, 1, 0, 0); @@ -138,7 +138,7 @@ { int param = ScreenYToFXParam(y); // Cap the parameter value as appropriate, based on effect type (e.g. Zxx gets capped to [0x00,0x7F]) - m_pModDoc->GetEffectFromIndex(m_pModDoc->GetIndexFromEffect(pcmd[offset].command, param), param); + effectInfo.GetEffectFromIndex(effectInfo.GetIndexFromEffect(pcmd[offset].command, MODCOMMAND::PARAM(param)), param); CriticalSection cs; pcmd[offset].param = static_cast<BYTE>(param); } @@ -733,7 +733,7 @@ else { paramValue = ScreenYToFXParam(point.y); - m_pModDoc->GetEffectInfo(m_pModDoc->GetIndexFromEffect(GetCommand(row), GetParam(row)), effectName, true); + effectInfo.GetEffectInfo(effectInfo.GetIndexFromEffect(GetCommand(row), MODCOMMAND::PARAM(GetParam(row))), effectName, true); } wsprintf(status, "Pat: %d\tChn: %d\tRow: %d\tVal: %02X (%03d) [%s]", @@ -792,19 +792,19 @@ // Otherwise, default to FX overwrite and // use effect of first selected row as default effect type m_nAction = kAction_OverwriteFX; - m_nFillEffect = m_pModDoc->GetIndexFromEffect(GetCommand(m_startRow), GetParam(m_startRow)); - if (m_nFillEffect<0 || m_nFillEffect>=MAX_EFFECTS) - m_nFillEffect = m_pModDoc->GetIndexFromEffect(CMD_SMOOTHMIDI, 0); + m_nFillEffect = effectInfo.GetIndexFromEffect(GetCommand(m_startRow), MODCOMMAND::PARAM(GetParam(m_startRow))); + if (m_nFillEffect < 0 || m_nFillEffect >= MAX_EFFECTS) + m_nFillEffect = effectInfo.GetIndexFromEffect(CMD_SMOOTHMIDI, 0); } CHAR s[128]; - UINT numfx = m_pModDoc->GetNumEffects(); + UINT numfx = effectInfo.GetNumEffects(); m_cmbEffectList.ResetContent(); int k; for (UINT i=0; i<numfx; i++) { - if (m_pModDoc->GetEffectInfo(i, s, true)) + if (effectInfo.GetEffectInfo(i, s, true)) { k =m_cmbEffectList.AddString(s); m_cmbEffectList.SetItemData(k, i); @@ -844,7 +844,7 @@ // Only set command if there isn't a command already at this row and it's not a PC note if (!GetCommand(row) && !IsPcNote(row)) { - SetCommand(row, m_pModDoc->GetEffectFromIndex(m_nFillEffect)); + SetCommand(row, effectInfo.GetEffectFromIndex(m_nFillEffect)); } // Always set param SetParamFromY(row, y); @@ -852,7 +852,7 @@ case kAction_OverwriteFX: // Always set command and param. Blows away any PC notes. - SetCommand(row, m_pModDoc->GetEffectFromIndex(m_nFillEffect)); + SetCommand(row, effectInfo.GetEffectFromIndex(m_nFillEffect)); SetParamFromY(row, y); break; Modified: trunk/OpenMPT/mptrack/EffectVis.h =================================================================== --- trunk/OpenMPT/mptrack/EffectVis.h 2012-02-24 22:31:54 UTC (rev 1190) +++ trunk/OpenMPT/mptrack/EffectVis.h 2012-02-24 22:46:13 UTC (rev 1191) @@ -1,5 +1,6 @@ #pragma once #include "afxwin.h" +#include "EffectInfo.h" class CViewPattern; //class CModScrollView; @@ -36,6 +37,8 @@ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //CFastBitmap m_Dib; + EffectInfo effectInfo; + CBitmap m_bGrid, m_bNodes, m_bPlayPos; CBitmap *m_pbOldGrid, *m_pbOldNodes, *m_pbOldPlayPos; CDC m_dcGrid, m_dcNodes, m_dcPlayPos; Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2012-02-24 22:31:54 UTC (rev 1190) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2012-02-24 22:46:13 UTC (rev 1191) @@ -18,8 +18,6 @@ #include "../common/StringFixer.h" #include <shlwapi.h> -extern WORD S3MFineTuneTable[16]; - #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE @@ -1817,14 +1815,13 @@ void CModDoc::OnFileCompatibilitySave() //------------------------------------- { - CHAR path[_MAX_PATH]="", drive[_MAX_DRIVE]=""; - CHAR fname[_MAX_FNAME]=""; CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); + if (!pMainFrm) return; + std::string ext, pattern, filename; - - UINT type = m_SndFile.GetType(); - if ((!pMainFrm) || (!m_SndFile.GetType())) return; + const MODTYPE type = m_SndFile.GetType(); + switch (type) { case MOD_TYPE_IT: @@ -1841,16 +1838,21 @@ } ext = m_SndFile.GetModSpecifications().fileExtension; - _splitpath(GetPathName(), drive, path, fname, NULL); - filename = drive; - filename += path; - filename += fname; - if (!strstr(fname, "compat")) - filename += ".compat."; - else - filename += "."; - filename += ext; + { + CHAR path[_MAX_PATH]="", drive[_MAX_DRIVE]=""; + CHAR fname[_MAX_FNAME]=""; + _splitpath(GetPathName(), drive, path, fname, NULL); + filename = drive; + filename += path; + filename += fname; + if (!strstr(fname, "compat")) + filename += ".compat."; + else + filename += "."; + filename += ext; + } + FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(false, ext, filename, pattern, CMainFrame::GetSettings().GetWorkingDirectory(DIR_MODS)); if(files.abort) return; @@ -1997,23 +1999,8 @@ CMainFrame::EnableLowLatencyMode(FALSE); } } -/* -void CModDoc::OnPlayerPlayFromPos(UINT pos) -//----------------------------------- -{ - CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); - if (pMainFrm) - { - pMainFrm->PauseMod(); - m_SndFile.m_dwSongFlags &= ~SONG_STEP; - m_SndFile.SetCurrentPos(pos); - pMainFrm->ResetElapsedTime(); - pMainFrm->PlayMod(this, m_hWndFollow, m_dwNotifyType); - CMainFrame::EnableLowLatencyMode(FALSE); - } -} -*/ + void CModDoc::OnEditGlobals() //--------------------------- { @@ -2183,959 +2170,6 @@ } - -/////////////////////////////////////////////////////////////////////////// -// Effects description - -typedef struct MPTEFFECTINFO -{ - MODCOMMAND::COMMAND dwEffect; // CMD_XXXX - DWORD dwParamMask; // 0 = default - DWORD dwParamValue; // 0 = default - DWORD dwFlags; // FXINFO_XXXX - DWORD dwFormats; // MOD_TYPE_XXX combo - LPCSTR pszName; // e.g. "Tone Portamento" -} MPTEFFECTINFO; - -#define MOD_TYPE_MODXM (MOD_TYPE_MOD|MOD_TYPE_XM) -#define MOD_TYPE_S3MIT (MOD_TYPE_S3M|MOD_TYPE_IT) -#define MOD_TYPE_S3MITMPT (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT) -#define MOD_TYPE_NOMOD (MOD_TYPE_S3M|MOD_TYPE_XM|MOD_TYPE_IT|MOD_TYPE_MPT) -#define MOD_TYPE_XMIT (MOD_TYPE_XM|MOD_TYPE_IT) -#define MOD_TYPE_XMITMPT (MOD_TYPE_XM|MOD_TYPE_IT|MOD_TYPE_MPT) -#define MOD_TYPE_ITMPT (MOD_TYPE_IT|MOD_TYPE_MPT) -#define MOD_TYPE_ALL 0xFFFFFFFF -#define MAX_FXINFO 70 - - -const MPTEFFECTINFO gFXInfo[] = -{ - {CMD_ARPEGGIO, 0,0, 0, MOD_TYPE_ALL, "Arpeggio"}, - {CMD_PORTAMENTOUP, 0,0, 0, MOD_TYPE_ALL, "Portamento Up"}, - {CMD_PORTAMENTODOWN,0,0, 0, MOD_TYPE_ALL, "Portamento Down"}, - {CMD_TONEPORTAMENTO,0,0, 0, MOD_TYPE_ALL, "Tone Portamento"}, - {CMD_VIBRATO, 0,0, 0, MOD_TYPE_ALL, "Vibrato"}, - {CMD_TONEPORTAVOL, 0,0, 0, MOD_TYPE_ALL, "Volslide+Toneporta"}, - {CMD_VIBRATOVOL, 0,0, 0, MOD_TYPE_ALL, "VolSlide+Vibrato"}, - {CMD_TREMOLO, 0,0, 0, MOD_TYPE_ALL, "Tremolo"}, - {CMD_PANNING8, 0,0, 0, MOD_TYPE_ALL, "Set Panning"}, - {CMD_OFFSET, 0,0, 0, MOD_TYPE_ALL, "Set Offset"}, - {CMD_VOLUMESLIDE, 0,0, 0, MOD_TYPE_ALL, "Volume Slide"}, - {CMD_POSITIONJUMP, 0,0, 0, MOD_TYPE_ALL, "Position Jump"}, - {CMD_VOLUME, 0,0, 0, MOD_TYPE_MODXM, "Set Volume"}, - {CMD_PATTERNBREAK, 0,0, 0, MOD_TYPE_ALL, "Pattern Break"}, - {CMD_RETRIG, 0,0, 0, MOD_TYPE_NOMOD, "Retrigger Note"}, - {CMD_SPEED, 0,0, 0, MOD_TYPE_ALL, "Set Speed"}, - {CMD_TEMPO, 0,0, 0, MOD_TYPE_ALL, "Set Tempo"}, - {CMD_TREMOR, 0,0, 0, MOD_TYPE_NOMOD, "Tremor"}, - {CMD_CHANNELVOLUME, 0,0, 0, MOD_TYPE_S3MITMPT, "Set Channel Volume"}, - {CMD_CHANNELVOLSLIDE,0,0, 0, MOD_TYPE_S3MITMPT, "Channel Volume Slide"}, - {CMD_GLOBALVOLUME, 0,0, 0, MOD_TYPE_NOMOD, "Set Global Volume"}, - {CMD_GLOBALVOLSLIDE,0,0, 0, MOD_TYPE_NOMOD, "Global Volume Slide"}, - {CMD_KEYOFF, 0,0, 0, MOD_TYPE_XM, "Key Off"}, - {CMD_FINEVIBRATO, 0,0, 0, MOD_TYPE_S3MITMPT, "Fine Vibrato"}, - {CMD_PANBRELLO, 0,0, 0, MOD_TYPE_NOMOD, "Panbrello"}, - {CMD_PANNINGSLIDE, 0,0, 0, MOD_TYPE_NOMOD, "Panning Slide"}, - {CMD_SETENVPOSITION,0,0, 0, MOD_TYPE_XM, "Envelope position"}, - {CMD_MIDI, 0,0, 0x7F, MOD_TYPE_NOMOD, "MIDI Macro"}, - {CMD_SMOOTHMIDI, 0,0, 0x7F, MOD_TYPE_XMITMPT, "Smooth MIDI Macro"}, //rewbs.smoothVST - // Extended MOD/XM effects - {CMD_MODCMDEX, 0xF0,0x10, 0, MOD_TYPE_MODXM, "Fine Porta Up"}, - {CMD_MODCMDEX, 0xF0,0x20, 0, MOD_TYPE_MODXM, "Fine Porta Down"}, - {CMD_MODCMDEX, 0xF0,0x30, 0, MOD_TYPE_MODXM, "Glissando Control"}, - {CMD_MODCMDEX, 0xF0,0x40, 0, MOD_TYPE_MODXM, "Vibrato Waveform"}, - {CMD_MODCMDEX, 0xF0,0x50, 0, MOD_TYPE_MODXM, "Set Finetune"}, - {CMD_MODCMDEX, 0xF0,0x60, 0, MOD_TYPE_MODXM, "Pattern Loop"}, - {CMD_MODCMDEX, 0xF0,0x70, 0, MOD_TYPE_MODXM, "Tremolo Waveform"}, - {CMD_MODCMDEX, 0xF0,0x80, 0, MOD_TYPE_MODXM, "Set Panning"}, - {CMD_MODCMDEX, 0xF0,0x90, 0, MOD_TYPE_MODXM, "Retrigger Note"}, - {CMD_MODCMDEX, 0xF0,0xA0, 0, MOD_TYPE_MODXM, "Fine Volslide Up"}, - {CMD_MODCMDEX, 0xF0,0xB0, 0, MOD_TYPE_MODXM, "Fine Volslide Down"}, - {CMD_MODCMDEX, 0xF0,0xC0, 0, MOD_TYPE_MODXM, "Note Cut"}, - {CMD_MODCMDEX, 0xF0,0xD0, 0, MOD_TYPE_MODXM, "Note Delay"}, - {CMD_MODCMDEX, 0xF0,0xE0, 0, MOD_TYPE_MODXM, "Pattern Delay"}, - {CMD_MODCMDEX, 0xF0,0xF0, 0, MOD_TYPE_XM, "Set Active Macro"}, - {CMD_MODCMDEX, 0xF0,0xF0, 0, MOD_TYPE_MOD, "Invert Loop"}, - // Extended S3M/IT effects - {CMD_S3MCMDEX, 0xF0,0x10, 0, MOD_TYPE_S3MITMPT, "Glissando Control"}, - {CMD_S3MCMDEX, 0xF0,0x20, 0, MOD_TYPE_S3M, "Set Finetune"}, - {CMD_S3MCMDEX, 0xF0,0x30, 0, MOD_TYPE_S3MITMPT, "Vibrato Waveform"}, - {CMD_S3MCMDEX, 0xF0,0x40, 0, MOD_TYPE_S3MITMPT, "Tremolo Waveform"}, - {CMD_S3MCMDEX, 0xF0,0x50, 0, MOD_TYPE_S3MITMPT, "Panbrello Waveform"}, - {CMD_S3MCMDEX, 0xF0,0x60, 0, MOD_TYPE_S3MITMPT, "Fine Pattern Delay"}, - {CMD_S3MCMDEX, 0xF0,0x80, 0, MOD_TYPE_S3MITMPT, "Set Panning"}, - {CMD_S3MCMDEX, 0xF0,0xA0, 0, MOD_TYPE_ITMPT, "Set High Offset"}, - {CMD_S3MCMDEX, 0xF0,0xB0, 0, MOD_TYPE_S3MITMPT, "Pattern Loop"}, - {CMD_S3MCMDEX, 0xF0,0xC0, 0, MOD_TYPE_S3MITMPT, "Note Cut"}, - {CMD_S3MCMDEX, 0xF0,0xD0, 0, MOD_TYPE_S3MITMPT, "Note Delay"}, - {CMD_S3MCMDEX, 0xF0,0xE0, 0, MOD_TYPE_S3MITMPT, "Pattern Delay"}, - {CMD_S3MCMDEX, 0xF0,0xF0, 0, MOD_TYPE_ITMPT, "Set Active Macro"}, - // MPT XM extensions and special effects - {CMD_XFINEPORTAUPDOWN,0xF0,0x10,0, MOD_TYPE_XM, "Extra Fine Porta Up"}, - {CMD_XFINEPORTAUPDOWN,0xF0,0x20,0, MOD_TYPE_XM, "Extra Fine Porta Down"}, - {CMD_XFINEPORTAUPDOWN,0xF0,0x50,0, MOD_TYPE_XM, "Panbrello Waveform"}, - {CMD_XFINEPORTAUPDOWN,0xF0,0x60,0, MOD_TYPE_XM, "Fine Pattern Delay"}, - {CMD_XFINEPORTAUPDOWN,0xF0,0x90,0, MOD_TYPE_XM, "Sound Control"}, - {CMD_XFINEPORTAUPDOWN,0xF0,0xA0,0, MOD_TYPE_XM, "Set High Offset"}, - // MPT IT extensions and special effects - {CMD_S3MCMDEX, 0xF0,0x90, 0, MOD_TYPE_S3MITMPT, "Sound Control"}, - {CMD_S3MCMDEX, 0xF0,0x70, 0, MOD_TYPE_ITMPT, "Instr. Control"}, - {CMD_DELAYCUT, 0x00,0x00, 0, MOD_TYPE_MPT, "Note Delay and Cut"}, -// -> CODE#0010 -// -> DESC="add extended parameter mechanism to pattern effects" - {CMD_XPARAM, 0x00,0x00, 0, MOD_TYPE_XMITMPT, "Parameter Extension"}, -// -! NEW_FEATURE#0010 - {CMD_NOTESLIDEUP, 0x00,0x00, 0, MOD_TYPE_NONE, "Note Slide Up"}, // .IMF effect - {CMD_NOTESLIDEDOWN, 0x00,0x00, 0, MOD_TYPE_NONE, "Note Slide Down"}, // .IMF effect -}; - -STATIC_ASSERT(CountOf(gFXInfo) == MAX_FXINFO); - - -UINT CModDoc::GetNumEffects() const -//--------------------------------- -{ - return MAX_FXINFO; -} - - -BOOL CModDoc::IsExtendedEffect(UINT ndx) const -//-------------------------------------------- -{ - return ((ndx < MAX_FXINFO) && (gFXInfo[ndx].dwParamMask)); -} - - -bool CModDoc::GetEffectName(LPSTR pszDescription, MODCOMMAND::COMMAND command, UINT param, bool bXX, CHANNELINDEX nChn) //rewbs.xinfo: added chan arg -//--------------------------------------------------------------------------------------------------------------------- -{ - bool bSupported; - UINT fxndx = MAX_FXINFO; - pszDescription[0] = 0; - for (UINT i = 0; i < MAX_FXINFO; i++) - { - if ((command == gFXInfo[i].dwEffect) // Effect - && ((param & gFXInfo[i].dwParamMask) == gFXInfo[i].dwParamValue)) // Value - { - fxndx = i; - // if format is compatible, everything is fine. if not, let's still search - // for another command. this fixes searching for the EFx command, which - // does different things in MOD format. - if((m_SndFile.GetType() & gFXInfo[i].dwFormats) != 0) - break; - } - } - if (fxndx == MAX_FXINFO) return false; - bSupported = ((m_SndFile.GetType() & gFXInfo[fxndx].dwFormats) != 0); - if (gFXInfo[fxndx].pszName) - { - if ((bXX) && (bSupported)) - { - strcpy(pszDescription, " xx: "); - pszDescription[0] = m_SndFile.GetModSpecifications().GetEffectLetter(command); - if ((gFXInfo[fxndx].dwParamMask & 0xF0) == 0xF0) pszDescription[1] = szHexChar[gFXInfo[fxndx].dwParamValue >> 4]; - if ((gFXInfo[fxndx].dwParamMask & 0x0F) == 0x0F) pszDescription[2] = szHexChar[gFXInfo[fxndx].dwParamValue & 0x0F]; - } - strcat(pszDescription, gFXInfo[fxndx].pszName); - //rewbs.xinfo - //Get channel specific info - if (nChn < m_SndFile.m_nChannels) - { - CString chanSpec = ""; - size_t macroIndex = size_t(-1); - - switch (command) - { - case CMD_MODCMDEX: - case CMD_S3MCMDEX: - if ((param & 0xF0) == 0xF0 && !(m_SndFile.GetType() & MOD_TYPE_MOD)) //Set Macro - { - macroIndex = (param & 0x0F); - chanSpec.Format(" to %d: ", param & 0x0F); - } - break; - - case CMD_MIDI: - case CMD_SMOOTHMIDI: - if (param < 0x80 && nChn != CHANNELINDEX_INVALID) - { - macroIndex = m_SndFile.Chn[nChn].nActiveMacro; - chanSpec.Format(": currently %d: ", m_SndFile.Chn[nChn].nActiveMacro); - } - else - { - chanSpec = " (Fixed)"; - } - break; - } - - if(macroIndex != size_t(-1)) - { - const PLUGINDEX plugin = m_SndFile.GetBestPlugin(nChn, PrioritiseChannel, EvenIfMuted) - 1; - chanSpec.Append(m_SndFile.m_MidiCfg.GetParameteredMacroName(macroIndex, plugin, *(this->GetSoundFile()))); - } - if (chanSpec != "") - { - strcat(pszDescription, chanSpec); - } - - } - //end rewbs.xinfo - } - return bSupported; -} - - -LONG CModDoc::GetIndexFromEffect(UINT command, UINT param) -//-------------------------------------------------------- -{ - UINT ndx = MAX_FXINFO; - for (UINT i = 0; i < MAX_FXINFO; i++) - { - if ((command == gFXInfo[i].dwEffect) // Effect - && ((param & gFXInfo[i].dwParamMask) == gFXInfo[i].dwParamValue)) // Value - { - ndx = i; - if((m_SndFile.m_nType & gFXInfo[i].dwFormats) != 0) - break; // found fitting format; this is correct for sure - } - } - return ndx; -} - - -//Returns command and corrects parameter refParam if necessary -MODCOMMAND::COMMAND CModDoc::GetEffectFromIndex(UINT ndx, int &refParam) -//---------------------------------------------------------------------- -{ - //if (pParam) *pParam = -1; - if (ndx >= MAX_FXINFO) - { - refParam = 0; - return CMD_NONE; - } - - //Cap parameter to match FX if necessary. - if (gFXInfo[ndx].dwParamMask) - { - if (refParam < static_cast<int>(gFXInfo[ndx].dwParamValue)) - { - refParam = gFXInfo[ndx].dwParamValue; // for example: delay with param < D0 becomes SD0 - } else if (refParam > static_cast<int>(gFXInfo[ndx].dwParamValue) + 15) - { - refParam = gFXInfo[ndx].dwParamValue + 15; // for example: delay with param > DF becomes SDF - } - } - if (gFXInfo[ndx].dwFlags) - { - if (refParam > static_cast<int>(gFXInfo[ndx].dwFlags)) - { - refParam = gFXInfo[ndx].dwFlags; //used for Zxx macro control: limit to 7F max. - } - } - - return gFXInfo[ndx].dwEffect; -} - - -MODCOMMAND::COMMAND CModDoc::GetEffectFromIndex(UINT ndx) -//------------------------------------------------------- -{ - if (ndx >= MAX_FXINFO) - { - return CMD_NONE; - } - - return gFXInfo[ndx].dwEffect; -} - -UINT CModDoc::GetEffectMaskFromIndex(UINT ndx) -//-------------------------------------------- -{ - if (ndx >= MAX_FXINFO) - { - return 0; - } - - return gFXInfo[ndx].dwParamValue; - -} - -bool CModDoc::GetEffectInfo(UINT ndx, LPSTR s, bool bXX, DWORD *prangeMin, DWORD *prangeMax) -//------------------------------------------------------------------------------------------ -{ - if (s) s[0] = 0; - if (prangeMin) *prangeMin = 0; - if (prangeMax) *prangeMax = 0; - if ((ndx >= MAX_FXINFO) || (!(m_SndFile.m_nType & gFXInfo[ndx].dwFormats))) return FALSE; - if (s) GetEffectName(s, gFXInfo[ndx].dwEffect, gFXInfo[ndx].dwParamValue, bXX); - if ((prangeMin) && (prangeMax)) - { - UINT nmin = 0, nmax = 0xFF, nType = m_SndFile.m_nType; - if (gFXInfo[ndx].dwParamMask == 0xF0) - { - nmin = gFXInfo[ndx].dwParamValue; - nmax = nmin | 0x0F; - } - switch(gFXInfo[ndx].dwEffect) - { - case CMD_ARPEGGIO: - if (nType & (MOD_TYPE_MOD|MOD_TYPE_XM)) nmin = 1; - break; - case CMD_VOLUME: - case CMD_CHANNELVOLUME: - nmax = 0x40; - break; - case CMD_SPEED: - nmin = 1; - nmax = 0xFF; - if (nType & MOD_TYPE_MOD) nmax = 0x20; else - if (nType & MOD_TYPE_XM) nmax = 0x1F; - break; - case CMD_TEMPO: - nmin = 0x20; - if (nType & MOD_TYPE_MOD) nmin = 0x21; else -// -> CODE#0010 -// -> DESC="add extended parameter mechanism to pattern effects" -// if (nType & MOD_TYPE_S3MIT) nmin = 1; - if (nType & MOD_TYPE_S3MITMPT) nmin = 0; -// -! NEW_FEATURE#0010 - break; - case CMD_VOLUMESLIDE: - case CMD_TONEPORTAVOL: - case CMD_VIBRATOVOL: - case CMD_GLOBALVOLSLIDE: - case CMD_CHANNELVOLSLIDE: - case CMD_PANNINGSLIDE: - nmax = (nType & MOD_TYPE_S3MITMPT) ? 58 : 30; - break; - case CMD_PANNING8: - if (nType & (MOD_TYPE_S3M)) nmax = 0x81; - else nmax = 0xFF; - break; - case CMD_GLOBALVOLUME: - nmax = (nType & (MOD_TYPE_IT|MOD_TYPE_MPT)) ? 128 : 64; - break; - - case CMD_MODCMDEX: - // adjust waveform types for XM/MOD - if(gFXInfo[ndx].dwParamValue == 0x40 || gFXInfo[ndx].dwParamValue == 0x70) nmax = gFXInfo[ndx].dwParamValue | 0x07; - break; - case CMD_S3MCMDEX: - // adjust waveform types for IT/S3M - if(gFXInfo[ndx].dwParamValue >= 0x30 && gFXInfo[ndx].dwParamValue <= 0x50) nmax = gFXInfo[ndx].dwParamValue | (m_SndFile.IsCompatibleMode(TRK_IMPULSETRACKER | TRK_SCREAMTRACKER) ? 0x03 : 0x07); - break; - case CMD_PATTERNBREAK: - // no big patterns in MOD/S3M files - if(nType & (MOD_TYPE_MOD|MOD_TYPE_S3M)) - nmax = 63; - break; - } - *prangeMin = nmin; - *prangeMax = nmax; - } - return TRUE; -} - - -UINT CModDoc::MapValueToPos(UINT ndx, UINT param) -//----------------------------------------------- -{ - UINT pos; - - if (ndx >= MAX_FXINFO) return 0; - pos = param; - if (gFXInfo[ndx].dwParamMask == 0xF0) - { - pos &= 0x0F; - pos |= gFXInfo[ndx].dwParamValue; - } - switch(gFXInfo[ndx].dwEffect) - { - case CMD_VOLUMESLIDE: - case CMD_TONEPORTAVOL: - case CMD_VIBRATOVOL: - case CMD_GLOBALVOLSLIDE: - case CMD_CHANNELVOLSLIDE: - case CMD_PANNINGSLIDE: - if (m_SndFile.GetType() & MOD_TYPE_S3MITMPT) - { - if (!param) pos = 29; else - if (((param & 0x0F) == 0x0F) && (param & 0xF0)) - pos = 29 + (param >> 4); else - if (((param & 0xF0) == 0xF0) && (param & 0x0F)) - pos = 29 - (param & 0x0F); else - if (param & 0x0F) - pos = 15 - (param & 0x0F); - else - pos = (param >> 4) + 44; - } else - { - if (param & 0x0F) pos = 15 - (param & 0x0F); - else pos = (param >> 4) + 15; - } - break; - case CMD_PANNING8: - if(m_SndFile.GetType() == MOD_TYPE_S3M) - { - pos = CLAMP(param, 0, 0x80); - if(param == 0xA4) - pos = 0x81; - } - break; - } - return pos; -} - - -UINT CModDoc::MapPosToValue(UINT ndx, UINT pos) -//--------------------------------------------- -{ - UINT param; - - if (ndx >= MAX_FXINFO) return 0; - param = pos; - if (gFXInfo[ndx].dwParamMask == 0xF0) param |= gFXInfo[ndx].dwParamValue; - switch(gFXInfo[ndx].dwEffect) - { - case CMD_VOLUMESLIDE: - case CMD_TONEPORTAVOL: - case CMD_VIBRATOVOL: - case CMD_GLOBALVOLSLIDE: - case CMD_CHANNELVOLSLIDE: - case CMD_PANNINGSLIDE: - if (m_SndFile.GetType() & MOD_TYPE_S3MITMPT) - { - if (pos < 15) param = 15-pos; else - if (pos < 29) param = (29-pos) | 0xF0; else - if (pos == 29) param = 0; else - if (pos < 44) param = ((pos - 29) << 4) | 0x0F; else - if (pos < 59) param = (pos-43) << 4; - } else - { - if (pos < 15) param = 15 - pos; else - param = (pos - 15) << 4; - } - break; - case CMD_PANNING8: - if(m_SndFile.GetType() == MOD_TYPE_S3M) - param = (pos <= 0x80) ? pos : 0xA4; - break; - } - return param; -} - - -bool CModDoc::GetEffectNameEx(LPSTR pszName, UINT ndx, UINT param) -//---------------------------------------------------------------- -{ - char s[64]; - char szContinueOrIgnore[16]; - - if (pszName) pszName[0] = 0; - if ((!pszName) || (ndx >= MAX_FXINFO) || (!gFXInfo[ndx].pszName)) return false; - wsprintf(pszName, "%s: ", gFXInfo[ndx].pszName); - s[0] = 0; - - // for effects that don't have effect memory in MOD format. - if(m_SndFile.GetType() == MOD_TYPE_MOD) - strcpy(szContinueOrIgnore, "ignore"); - else - strcpy(szContinueOrIgnore, "continue"); - - std::string sPlusChar = "+", sMinusChar = "-"; - - switch(gFXInfo[ndx].dwEffect) - { - case CMD_ARPEGGIO: - if(m_SndFile.GetType() == MOD_TYPE_XM) // XM also ignores this! - strcpy(szContinueOrIgnore, "ignore"); - - if (param) - wsprintf(s, "note+%d note+%d", param >> 4, param & 0x0F); - else - strcpy(s, szContinueOrIgnore); - break; - - case CMD_PORTAMENTOUP: - case CMD_PORTAMENTODOWN: - if(param) - { - char sign[2]; - strcpy(sign, (gFXInfo[ndx].dwEffect == CMD_PORTAMENTOUP) ? "+" : "-"); - if((m_SndFile.GetType() & MOD_TYPE_S3MITMPT) && ((param & 0xF0) == 0xF0)) - wsprintf(s, "fine %s%d", sign, (param & 0x0F)); - else if((m_SndFile.GetType() & MOD_TYPE_S3MITMPT) && ((param & 0xF0) == 0xE0)) - wsprintf(s, "extra fine %s%d", sign, (param & 0x0F)); - else - wsprintf(s, "%s%d", sign, param); - } - else - { - strcpy(s, szContinueOrIgnore); - } - break; - - case CMD_TONEPORTAMENTO: - if (param) - wsprintf(s, "speed %d", param); - else - strcpy(s, "continue"); - break; - - case CMD_VIBRATO: - case CMD_TREMOLO: - case CMD_PANBRELLO: - case CMD_FINEVIBRATO: - if (param) - wsprintf(s, "speed=%d depth=%d", param >> 4, param & 0x0F); - else - strcpy(s, "continue"); - break; - - case CMD_SPEED: - wsprintf(s, "%d ticks/row", param); - break; - - case CMD_TEMPO: - if (param < 0x10) - wsprintf(s, "-%d bpm (slower)", param & 0x0F); - else if (param < 0x20) - wsprintf(s, "+%d bpm (faster)", param & 0x0F); - else - wsprintf(s, "%d bpm", param); - break; - - case CMD_PANNING8: - wsprintf(s, "%d", param); - if(m_SndFile.GetType() == MOD_TYPE_S3M) - { - if(param == 0xA4) - strcpy(s, "Surround"); - } - break; - - case CMD_RETRIG: - switch(param >> 4) - { - case 0: - if(m_SndFile.GetType() & MOD_TYPE_XM) - strcpy(s, "continue"); - else - strcpy(s, "vol *1"); - break; - case 1: strcpy(s, "vol -1"); break; - case 2: strcpy(s, "vol -2"); break; - case 3: strcpy(s, "vol -4"); break; - case 4: strcpy(s, "vol -8"); break; - case 5: strcpy(s, "vol -16"); break; - case 6: strcpy(s, "vol *0.66"); break; - case 7: strcpy(s, "vol *0.5"); break; - case 8: strcpy(s, "vol *1"); break; - case 9: strcpy(s, "vol +1"); break; - case 10: strcpy(s, "vol +2"); break; - case 11: strcpy(s, "vol +4"); break; - case 12: strcpy(s, "vol +8"); break; - case 13: strcpy(s, "vol +16"); break; - case 14: strcpy(s, "vol *1.5"); break; - case 15: strcpy(s, "vol *2"); break; - } - char spd[10]; - wsprintf(spd, " speed %d", param & 0x0F); - strcat(s, spd); - break; - - case CMD_VOLUMESLIDE: - case CMD_TONEPORTAVOL: - case CMD_VIBRATOVOL: - case CMD_GLOBALVOLSLIDE: - case CMD_CHANNELVOLSLIDE: - case CMD_PANNINGSLIDE: - if(gFXInfo[ndx].dwEffect == CMD_PANNINGSLIDE) - { - if(m_SndFile.GetType() == MOD_TYPE_XM) - { - sPlusChar = "-> "; - sMinusChar = "<- "; - } - else - { - sPlusChar = "<- "; - sMinusChar = "-> "; - } - } - - if (!param) - { - wsprintf(s, "continue"); - } else - if ((m_SndFile.GetType() & MOD_TYPE_S3MITMPT) && ((param & 0x0F) == 0x0F) && (param & 0xF0)) - { - wsprintf(s, "fine %s%d", sPlusChar.c_str(), param >> 4); - } else - if ((m_SndFile.GetType() & MOD_TYPE_S3MITMPT) && ((param & 0xF0) == 0xF0) && (param & 0x0F)) - { - wsprintf(s, "fine %s%d", sMinusChar.c_str(), param & 0x0F); - } else - if ((param & 0x0F) != param && (param & 0xF0) != param) // both nibbles are set. - { - strcpy(s, "undefined"); - } else - if (param & 0x0F) - { - wsprintf(s, "%s%d", sMinusChar.c_str(), ... [truncated message content] |
From: <sag...@us...> - 2012-03-07 23:21:41
|
Revision: 1208 http://modplug.svn.sourceforge.net/modplug/?rev=1208&view=rev Author: saga-games Date: 2012-03-07 23:21:34 +0000 (Wed, 07 Mar 2012) Log Message: ----------- [Fix] Revision 1204 broke pattern display update of instrument replacement / PC Event parameter selection (http://bugs.openmpt.org/view.php?id=231). [Fix] Revision 1024 also broke Shrink Selection (http://bugs.openmpt.org/view.php?id=230). [Imp] Pattern Editor: Follow Song isn't turned off anymore when using Find&Replace and the currently edited song isn't actually playing (http://bugs.openmpt.org/view.php?id=229). [Imp] Pattern Editor: Find&Replace also sets the correct order in the order list now - doesn't work across multiple sequences, though (http://bugs.openmpt.org/view.php?id=152). Revision Links: -------------- http://modplug.svn.sourceforge.net/modplug/?rev=1204&view=rev http://modplug.svn.sourceforge.net/modplug/?rev=1024&view=rev Modified Paths: -------------- trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_pat.h Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2012-03-07 19:31:57 UTC (rev 1207) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2012-03-07 23:21:34 UTC (rev 1208) @@ -898,7 +898,7 @@ const ROWINDEX offset = row - startSel.GetRow(); const ROWINDEX srcRow = startSel.GetRow() + (offset * 2); - for(CHANNELINDEX chn = startSel.GetChannel(); chn <= startSel.GetChannel(); chn++) + for(CHANNELINDEX chn = startSel.GetChannel(); chn <= endSel.GetChannel(); chn++) { for(int i = PatternCursor::firstColumn; i <= PatternCursor::lastColumn; i++) { @@ -2135,11 +2135,20 @@ const bool updatePos = ((m_findReplace.dwReplaceFlags & (PATSEARCH_REPLACEALL | PATSEARCH_REPLACE)) != (PATSEARCH_REPLACEALL | PATSEARCH_REPLACE)); nFound++; - if (updatePos) + if(updatePos) { - // turn off "follow song" - m_dwStatus &= ~psFollowSong; - SendCtrlMessage(CTRLMSG_PAT_FOLLOWSONG, 0); + if(IsLiveRecord()) + { + // turn off "follow song" + m_dwStatus &= ~psFollowSong; + SendCtrlMessage(CTRLMSG_PAT_FOLLOWSONG, 0); + } + // This doesn't find the order if it's in another sequence :( + ORDERINDEX matchingOrder = pSndFile->Order.FindOrder(pat, static_cast<ORDERINDEX>(SendCtrlMessage(CTRLMSG_GETCURRENTORDER))); + if(matchingOrder != ORDERINDEX_INVALID) + { + SendCtrlMessage(CTRLMSG_SETCURRENTORDER, matchingOrder); + } // go to place of finding SetCurrentPattern(pat); } @@ -3438,10 +3447,9 @@ //Work out where to put the new data const CHANNELINDEX nChn = GetCurrentChannel(); - const bool bUsePlaybackPosition = IsLiveRecord(*pModDoc, *pSndFile); ROWINDEX nRow = GetCurrentRow(); PATTERNINDEX nPattern = m_nPattern; - if(bUsePlaybackPosition == true) + if(IsLiveRecord()) SetEditPos(*pSndFile, nRow, nPattern, pSndFile->m_nRow, pSndFile->m_nPattern); ModCommand *pRow = pSndFile->Patterns[nPattern].GetpModCommand(nRow, nChn); @@ -3593,12 +3601,13 @@ // Write parameter control commands if needed. if (paramValue != uint8_max && IsEditingEnabled() && pSndFile->GetType() == MOD_TYPE_MPT) { - const bool bLiveRecord = IsLiveRecord(*pModDoc, *pSndFile); - ModCommandPos editpos = GetEditPos(*pSndFile, bLiveRecord); + const bool liveRecord = IsLiveRecord(); + + ModCommandPos editpos = GetEditPos(*pSndFile, liveRecord); ModCommand* p = GetModCommand(*pSndFile, editpos); pModDoc->GetPatternUndo().PrepareUndo(editpos.nPat, editpos.nChn, editpos.nRow, 1, 1); p->Set(NOTE_PCS, mappedIndex, static_cast<uint16>(paramIndex), static_cast<uint16>((paramValue * ModCommand::maxColumnValue)/127)); - if(bLiveRecord == false) + if(!liveRecord) InvalidateRow(editpos.nRow); pMainFrm->ThreadSafeSetModified(pModDoc); } @@ -3643,9 +3652,11 @@ // Don't write this if command was already written by MIDI mapping. if((paramValue == uint8_max || pSndFile->GetType() != MOD_TYPE_MPT) && IsEditingEnabled() && (CMainFrame::GetSettings().m_dwMidiSetup & MIDISETUP_MIDIMACROCONTROL)) { - const bool bLiveRecord = IsLiveRecord(*pModDoc, *pSndFile); - ModCommandPos editpos = GetEditPos(*pSndFile, bLiveRecord); + const bool liveRecord = IsLiveRecord(); + + ModCommandPos editpos = GetEditPos(*pSndFile, liveRecord); ModCommand* p = GetModCommand(*pSndFile, editpos); + if(p->command == CMD_NONE || p->command == CMD_SMOOTHMIDI || p->command == CMD_MIDI) { // Write command only if there's no existing command or already a midi macro command. pModDoc->GetPatternUndo().PrepareUndo(editpos.nPat, editpos.nChn, editpos.nRow, 1, 1); @@ -3654,7 +3665,7 @@ pMainFrm->ThreadSafeSetModified(pModDoc); // Update GUI only if not recording live. - if(bLiveRecord == false) + if(!liveRecord) InvalidateRow(editpos.nRow); } } @@ -4289,21 +4300,13 @@ } } - if (IsEditingEnabled_bmsg()) - { - SetSelToCursor(); + SetSelToCursor(); - if(oldcmd != *pTarget) - { - SetModified(false); - InvalidateCell(m_Cursor); - UpdateIndicator(); - } - } - else + if(oldcmd != *pTarget) { - // recording disabled - *pTarget = oldcmd; + SetModified(false); + InvalidateCell(m_Cursor); + UpdateIndicator(); } } @@ -4432,17 +4435,20 @@ const bool isSplit = (pModDoc->GetSplitKeyboardSettings().IsSplitActive()) && (note <= pModDoc->GetSplitKeyboardSettings().splitNote); UINT ins = 0; - if (pModDoc) + if(pModDoc) { - if (isSplit) + if(isSplit) { ins = pModDoc->GetSplitKeyboardSettings().splitInstrument; if (pModDoc->GetSplitKeyboardSettings().octaveLink) note += 12 *pModDoc->GetSplitKeyboardSettings().octaveModifier; if (note > NOTE_MAX && note < NOTE_MIN_SPECIAL) note = NOTE_MAX; if (note < 0) note = NOTE_MIN; } - if (!ins) ins = GetCurrentInstrument(); - if (!ins) ins = m_nFoundInstrument; + if(!ins) + ins = GetCurrentInstrument(); + if(!ins) + ins = m_nFoundInstrument; + if(bChordMode == true) { m_dwStatus &= ~psChordPlaying; @@ -4462,7 +4468,7 @@ if (!pModDoc || !pMainFrm || !(IsEditingEnabled())) return; - const bool bIsLiveRecord = IsLiveRecord(*pMainFrm, *pModDoc, *pSndFile); + const bool liveRecord = IsLiveRecord(); const CHANNELINDEX nChnCursor = GetCurrentChannel(); @@ -4478,7 +4484,7 @@ } // -- write sdx if playing live - const bool usePlaybackPosition = (!bChordMode) && (bIsLiveRecord && (CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_AUTODELAY)); + const bool usePlaybackPosition = (!bChordMode) && (liveRecord && (CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_AUTODELAY)); //Work out where to put the note off ROWINDEX nRow = GetCurrentRow(); @@ -4495,7 +4501,7 @@ //if there's a note in the current location and the song is playing and following, //the user probably just tapped the key - let's try the next row down. nRow++; - if (pTarget->note==note && bIsLiveRecord && pSndFile->Patterns[nPat].IsValidRow(nRow)) + if (pTarget->note==note && liveRecord && pSndFile->Patterns[nPat].IsValidRow(nRow)) { pTarget = pSndFile->Patterns[nPat].GetpModCommand(nRow, nChn); if (pTarget->note || (!bChordMode && (pTarget->instr || pTarget->volcmd)) ) @@ -4548,7 +4554,7 @@ pModDoc->SetModified(); // Update only if not recording live. - if(bIsLiveRecord == false) + if(!liveRecord) { PatternCursor sel(nRow, nChn); InvalidateCell(sel); @@ -4564,7 +4570,7 @@ void CViewPattern::TempEnterOctave(int val) //----------------------------------------- { - CSoundFile *pSndFile = GetSoundFile(); + const CSoundFile *pSndFile = GetSoundFile(); if(pSndFile == nullptr) { return; @@ -4572,11 +4578,10 @@ PrepareUndo(m_Selection); - ModCommand* pTarget = pSndFile->Patterns[m_nPattern].GetpModCommand(GetCurrentRow(), GetCurrentChannel()); - ModCommand oldcmd = *pTarget; // This is the command we are about to overwrite - if (oldcmd.note) + const ModCommand &target = *pSndFile->Patterns[m_nPattern].GetpModCommand(GetCurrentRow(), GetCurrentChannel()); + if(target.IsNote()) { - TempEnterNote(((oldcmd.note - 1) % 12) + val * 12 + 1); + TempEnterNote(((target.note - 1) % 12) + val * 12 + 1); } } @@ -4673,8 +4678,8 @@ } BYTE recordGroup = pModDoc->IsChannelRecord(nChn); - const bool bIsLiveRecord = IsLiveRecord(*pMainFrm, *pModDoc, *pSndFile); - const bool usePlaybackPosition = (bIsLiveRecord && (CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_AUTODELAY) && !(pSndFile->m_dwSongFlags & SONG_STEP)); + const bool liveRecord = IsLiveRecord(); + const bool usePlaybackPosition = (liveRecord && (CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_AUTODELAY) && !(pSndFile->m_dwSongFlags & SONG_STEP)); const bool isSplit = IsNoteSplit(note); if(pModDoc->GetSplitKeyboardSettings().IsSplitActive() @@ -4692,7 +4697,7 @@ } // -- Chord autodetection: step back if we just entered a note - if (recordEnabled && recordGroup && !bIsLiveRecord && !ModCommand::IsPcNote(note)) + if (recordEnabled && recordGroup && !liveRecord && !ModCommand::IsPcNote(note)) { if (m_nSpacing > 0 && m_nSpacing <= MAX_SPACING) { @@ -4801,7 +4806,7 @@ // -- play note if (((CMainFrame::GetSettings().m_dwPatternSetup & (PATTERN_PLAYNEWNOTE|PATTERN_PLAYEDITROW)) || !recordEnabled) && !newcmd.IsPcNote()) { - const bool playWholeRow = ((CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_PLAYEDITROW) && !bIsLiveRecord); + const bool playWholeRow = ((CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_PLAYEDITROW) && !liveRecord); if (playWholeRow) { // play the whole row in "step mode" @@ -4840,7 +4845,7 @@ if(recordEnabled) { PatternCursor sel(nRow, nChn, m_Cursor.GetColumnType()); - if(bIsLiveRecord == false) + if(liveRecord == false) { // Update only when not recording live. SetCurSel(sel); @@ -4849,7 +4854,7 @@ if(modified) // Has it really changed? { pModDoc->SetModified(); - if(bIsLiveRecord == false) + if(liveRecord == false) { // Update only when not recording live. InvalidateCell(sel); @@ -4858,7 +4863,7 @@ } // Set new cursor position (row spacing) - if (!bIsLiveRecord) + if (!liveRecord) { if((m_nSpacing > 0) && (m_nSpacing <= MAX_SPACING)) { @@ -4881,7 +4886,7 @@ // Nothing to do here anymore. return; } - + BYTE *activeNoteMap = isSplit ? splitActiveNoteChannel : activeNoteChannel; if (newcmd.note <= NOTE_MAX) activeNoteMap[newcmd.note] = nChn; @@ -4931,8 +4936,8 @@ ModCommand* p = &newrow[nChn]; - const bool bIsLiveRecord = IsLiveRecord(*pMainFrm, *pModDoc, *pSndFile); - const bool bRecordEnabled = IsEditingEnabled(); + const bool liveRecord = IsLiveRecord(); + const bool recordEnabled = IsEditingEnabled(); // -- establish note data HandleSplit(p, note); @@ -4970,7 +4975,7 @@ recordGroup = currentRecordGroup; //record group found UINT n = ((nchordnote-1)/12) * 12 + pChords[nchord].notes[nchno]; - if(bRecordEnabled) + if(recordEnabled) { if ((nchordch != nChn) && recordGroup && (currentRecordGroup == recordGroup) && (n <= NOTE_MAX)) { @@ -4998,7 +5003,7 @@ // -- write notedata - if(bRecordEnabled) + if(recordEnabled) { SetSelToCursor(); @@ -5016,15 +5021,15 @@ // -- play note - if ((CMainFrame::GetSettings().m_dwPatternSetup & (PATTERN_PLAYNEWNOTE|PATTERN_PLAYEDITROW)) || (!bRecordEnabled)) + if ((CMainFrame::GetSettings().m_dwPatternSetup & (PATTERN_PLAYNEWNOTE|PATTERN_PLAYEDITROW)) || (!recordEnabled)) { - const bool playWholeRow = ((CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_PLAYEDITROW) && !bIsLiveRecord); + const bool playWholeRow = ((CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_PLAYEDITROW) && !liveRecord); if (playWholeRow) { // play the whole row in "step mode" PatternStep(false); } - if (!playWholeRow || !bRecordEnabled) + if (!playWholeRow || !recordEnabled) { // NOTE: This code is *also* used for the PATTERN_PLAYEDITROW edit mode because of some unforseeable race conditions when modifying pattern data. // We have to use this code when editing is disabled or else we will get some stupid hazards, because we would first have to write the new note @@ -5066,7 +5071,7 @@ // Set new cursor position (row spacing) - only when not recording live - if (bRecordEnabled && !bIsLiveRecord) + if (recordEnabled && !liveRecord) { if ((m_nSpacing > 0) && (m_nSpacing <= MAX_SPACING)) SetCurrentRow(GetCurrentRow() + m_nSpacing); @@ -5283,6 +5288,7 @@ if (bModified) { SetModified(); + InvalidatePattern(); } } @@ -6164,6 +6170,7 @@ if (modified) { SetModified(); + InvalidatePattern(); } EndWaitCursor(); } Modified: trunk/OpenMPT/mptrack/View_pat.h =================================================================== --- trunk/OpenMPT/mptrack/View_pat.h 2012-03-07 19:31:57 UTC (rev 1207) +++ trunk/OpenMPT/mptrack/View_pat.h 2012-03-07 23:21:34 UTC (rev 1208) @@ -429,16 +429,16 @@ void Interpolate(PatternCursor::Columns type); // Return true if recording live (i.e. editing while following playback). - // rSndFile must be the CSoundFile object of given rModDoc. - bool IsLiveRecord(const CModDoc &rModDoc, const CSoundFile &rSndFile) const + bool IsLiveRecord() const { - return IsLiveRecord(*CMainFrame::GetMainFrame(), rModDoc, rSndFile); + CMainFrame *mainFrm = CMainFrame::GetMainFrame(); + if(mainFrm == nullptr || GetDocument() == nullptr || GetSoundFile() == nullptr) + { + return false; + } + // (following song) && (following in correct document) && (playback is on) + return (m_dwStatus & psFollowSong) && mainFrm->GetFollowSong(GetDocument()) == m_hWnd && !GetSoundFile()->IsPaused(); }; - bool IsLiveRecord(const CMainFrame &rMainFrm, const CModDoc &rModDoc, const CSoundFile &rSndFile) const - { - // (following song) && (following in correct document) && (playback is on) - return ((m_dwStatus & psFollowSong) && (rMainFrm.GetFollowSong(&rModDoc) == m_hWnd) && !(rSndFile.IsPaused())); - }; // If given edit positions are valid, sets them to iRow and iPat. // If not valid, set edit cursor position. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |