From: <sag...@us...> - 2010-07-04 14:41:45
|
Revision: 635 http://modplug.svn.sourceforge.net/modplug/?rev=635&view=rev Author: saga-games Date: 2010-07-04 14:41:38 +0000 (Sun, 04 Jul 2010) Log Message: ----------- [Imp] Instrument Editor / XM Saver: For XM, allow fadeout values up to 32767 again, as FT2 can actually handle them (and other apps like Milky support them as well) [New] Sample Editor: It's not also possible to create sample selections using shift+click. [Ref] A bit of refactoring Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/soundlib/Load_xm.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2010-07-01 21:47:33 UTC (rev 634) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2010-07-04 14:41:38 UTC (rev 635) @@ -183,13 +183,14 @@ if ((pIns) && (nPos >= 0) && (nPos < NOTE_MAX) && (pIns->NoteMap[nPos])) { UINT n = pIns->NoteMap[nPos]; - if (n == NOTE_KEYOFF) strcpy(s, "==="); else - if (n == NOTE_NOTECUT) strcpy(s, "^^^"); else - if (n <= NOTE_MAX) + if(n < NOTE_MIN_SPECIAL) { string temp = pSndFile->GetNoteName(n, m_nInstrument); temp.resize(4); wsprintf(s, "%s", temp.c_str()); + } else + { + strcpy(s, szSpecialNoteNames[pIns->NoteMap[n] - NOTE_MIN_SPECIAL]); } } FillRect(hdc, &rect, (bHighLight) ? CMainFrame::brushHighLight : CMainFrame::brushWindow); @@ -658,7 +659,7 @@ case VK_TAB: return true; case VK_RETURN: - if (m_pModDoc) + if (m_pModDoc && m_pModDoc->GetSoundFile()) { MODINSTRUMENT *pIns = m_pModDoc->GetSoundFile()->Instruments[m_nInstrument]; if(pIns) @@ -680,20 +681,24 @@ return false; } + void CNoteMapWnd::PlayNote(int note) +//---------------------------------- { - if (m_nPlayingNote >=0) return; //no polyphony in notemap window + if(m_nPlayingNote >= 0) return; //no polyphony in notemap window m_pModDoc->PlayNote(note, m_nInstrument, 0, FALSE); - m_nPlayingNote=note; + m_nPlayingNote = note; } + void CNoteMapWnd::StopNote(int note = -1) +//---------------------------------- { - if (note<0) note = m_nPlayingNote; - if (note<0) return; + if(note < 0) note = m_nPlayingNote; + if(note < 0) return; m_pModDoc->NoteOff(note, TRUE, m_nInstrument); - m_nPlayingNote=-1; + m_nPlayingNote = -1; } //end rewbs.customKeys @@ -872,7 +877,8 @@ m_SpinMidiBK.SetRange(0, 128); // Midi Channel //rewbs.instroVSTi: we no longer combine midi chan and FX in same cbbox - for (UINT ich=0; ich<17; ich++) { + for (UINT ich=0; ich<17; ich++) + { UINT n = 0; s[0] = 0; if (!ich) { strcpy(s, "None"); n=0; } @@ -1115,7 +1121,7 @@ m_SpinFadeOut.EnableWindow(bITandXM); if(m_pSndFile->m_nType & MOD_TYPE_XM) - m_SpinFadeOut.SetRange(0, 4095); + m_SpinFadeOut.SetRange(0, 32767); else m_SpinFadeOut.SetRange(0, 8192); @@ -1768,9 +1774,9 @@ if ((!IsLocked()) && (pIns)) { int nVol = GetDlgItemInt(IDC_EDIT7); - if (nVol < 0) nVol = 0; - if (nVol > 16384) nVol = 16384; - if (nVol != (int)pIns->nFadeOut) + nVol = CLAMP(nVol, 0, 32767); + + if(nVol != (int)pIns->nFadeOut) { pIns->nFadeOut = nVol; m_pModDoc->SetModified(); Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2010-07-01 21:47:33 UTC (rev 634) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2010-07-04 14:41:38 UTC (rev 635) @@ -1340,35 +1340,45 @@ if ((m_dwStatus & SMPSTATUS_MOUSEDRAG) || (!pModDoc)) return; pSndFile = pModDoc->GetSoundFile(); len = pSndFile->Samples[m_nSample].nLength; - if (len) + if (!len) + return; + + m_dwStatus |= SMPSTATUS_MOUSEDRAG; + SetFocus(); + SetCapture(); + bool oldsel = (m_dwBeginSel != m_dwEndSel) ? true : false; + + // shift + click = update selection + if(CMainFrame::GetInputHandler()->ShiftPressed()) { - m_dwStatus |= SMPSTATUS_MOUSEDRAG; - SetFocus(); - SetCapture(); - BOOL oldsel = (m_dwBeginSel != m_dwEndSel) ? TRUE : FALSE; + oldsel = true; + m_dwEndDrag = ScreenToSample(point.x); + SetCurSel(m_dwBeginDrag, m_dwEndDrag); + } else + { m_dwBeginDrag = ScreenToSample(point.x); if (m_dwBeginDrag >= len) m_dwBeginDrag = len-1; m_dwEndDrag = m_dwBeginDrag; - if (oldsel) SetCurSel(m_dwBeginDrag, m_dwEndDrag); - // set initial point for sample drawing - if (m_bDrawingEnabled) - { - pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_replace); - if(pSndFile->Samples[m_nSample].GetElementarySampleSize() == 2) - SetInitialDrawPoint<int16, uint16>(pSndFile->Samples[m_nSample].pSample, point); - else if(pSndFile->Samples[m_nSample].GetElementarySampleSize() == 1) - SetInitialDrawPoint<int8, uint8>(pSndFile->Samples[m_nSample].pSample, point); + } + if (oldsel) SetCurSel(m_dwBeginDrag, m_dwEndDrag); + // set initial point for sample drawing + if (m_bDrawingEnabled) + { + pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_replace); + if(pSndFile->Samples[m_nSample].GetElementarySampleSize() == 2) + SetInitialDrawPoint<int16, uint16>(pSndFile->Samples[m_nSample].pSample, point); + else if(pSndFile->Samples[m_nSample].GetElementarySampleSize() == 1) + SetInitialDrawPoint<int8, uint8>(pSndFile->Samples[m_nSample].pSample, point); - InvalidateSample(); - pModDoc->SetModified(); - } - else - { - // ctrl + click = play from cursor pos - if(CMainFrame::GetInputHandler()->CtrlPressed()) - PlayNote(NOTE_MIDDLEC, ScreenToSample(point.x)); - } + InvalidateSample(); + pModDoc->SetModified(); } + else + { + // ctrl + click = play from cursor pos + if(CMainFrame::GetInputHandler()->CtrlPressed()) + PlayNote(NOTE_MIDDLEC, ScreenToSample(point.x)); + } } @@ -1822,6 +1832,7 @@ if (pSmp->uFlags & (CHN_LOOP|CHN_SUSTAINLOOP)) { WAVESAMPLERINFO *psmpl = (WAVESAMPLERINFO *)psh; + MemsetZero(psmpl->wsiLoops); if (pSmp->uFlags & CHN_SUSTAINLOOP) { psmpl->wsiHdr.dwSampleLoops = 2; Modified: trunk/OpenMPT/soundlib/Load_xm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_xm.cpp 2010-07-01 21:47:33 UTC (rev 634) +++ trunk/OpenMPT/soundlib/Load_xm.cpp 2010-07-04 14:41:38 UTC (rev 635) @@ -956,7 +956,7 @@ { memcpy(xmih.name, pIns->name, 22); xmih.type = pIns->nMidiProgram; - xmsh.volfade = LittleEndianW(min(pIns->nFadeOut, 0xFFF)); // FFF is maximum in FT2 + xmsh.volfade = LittleEndianW(min(pIns->nFadeOut, 0x7FFF)); // FFF is maximum in the FT2 GUI, but it can also accept other values. MilkyTracker just allows 0...4095 and 32767 ("cut") xmsh.vnum = (BYTE)pIns->VolEnv.nNodes; xmsh.pnum = (BYTE)pIns->PanEnv.nNodes; if (xmsh.vnum > 12) xmsh.vnum = 12; Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2010-07-01 21:47:33 UTC (rev 634) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2010-07-04 14:41:38 UTC (rev 635) @@ -3038,17 +3038,16 @@ return 0; } -string CSoundFile::GetNoteName(const CTuning::NOTEINDEXTYPE& note, const int inst) const +string CSoundFile::GetNoteName(const CTuning::NOTEINDEXTYPE& note, const INSTRUMENTINDEX inst) const //---------------------------------------------------------------------------------- { - if(inst >= MAX_INSTRUMENTS || inst < -1 || note < 1 || note > NOTE_MAX) return "BUG"; - if(inst == -1) - return szDefaultNoteNames[note-1]; - - if(m_nType == MOD_TYPE_MPT && Instruments[inst] && Instruments[inst]->pTuning) - return Instruments[inst]->pTuning->GetNoteName(note-NOTE_MIDDLEC); + if((inst >= MAX_INSTRUMENTS && inst != INSTRUMENTINDEX_INVALID) || note < 1 || note > NOTE_MAX) return "BUG"; + + // For MPTM instruments with custom tuning, find the appropriate note name. Else, use default note names. + if(inst != INSTRUMENTINDEX_INVALID && m_nType == MOD_TYPE_MPT && Instruments[inst] && Instruments[inst]->pTuning) + return Instruments[inst]->pTuning->GetNoteName(note - NOTE_MIDDLEC); else - return szDefaultNoteNames[note-1]; + return szDefaultNoteNames[note - 1]; } Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2010-07-01 21:47:33 UTC (rev 634) +++ trunk/OpenMPT/soundlib/Sndfile.h 2010-07-04 14:41:38 UTC (rev 635) @@ -99,8 +99,8 @@ INSTRUMENTENVELOPE PanEnv; INSTRUMENTENVELOPE PitchEnv; - BYTE NoteMap[128]; - WORD Keyboard[128]; + BYTE NoteMap[128]; // Note mapping, f.e. C-5 => D-5 + WORD Keyboard[128]; // Sample mapping, f.e. C-5 => Sample 1 BYTE nNNA; BYTE nDCT; @@ -495,7 +495,7 @@ static CTuningCollection& GetLocalTunings() {return *s_pTuningsSharedLocal;} CTuningCollection& GetTuneSpecificTunings() {return *m_pTuningsTuneSpecific;} - std::string GetNoteName(const int16&, const int inst = -1) const; + std::string GetNoteName(const int16&, const INSTRUMENTINDEX inst = INSTRUMENTINDEX_INVALID) const; private: CTuningCollection* m_pTuningsTuneSpecific; static CTuningCollection* s_pTuningsSharedBuiltIn; @@ -724,13 +724,13 @@ void SaveExtendedInstrumentProperties(MODINSTRUMENT *instruments[], UINT nInstruments, FILE* f); void SaveExtendedSongProperties(FILE* f); void LoadExtendedSongProperties(const MODTYPE modtype, LPCBYTE ptr, const LPCBYTE startpos, const size_t seachlimit, bool* pInterpretMptMade = nullptr); +#endif // MODPLUG_NO_FILESAVE // Reads extended instrument properties(XM/IT/MPTM). // If no errors occur and song extension tag is found, returns pointer to the beginning // of the tag, else returns NULL. LPCBYTE LoadExtendedInstrumentProperties(const LPCBYTE pStart, const LPCBYTE pEnd, bool* pInterpretMptMade = nullptr); -#endif // MODPLUG_NO_FILESAVE // MOD Convert function MODTYPE GetBestSaveFormat() const; MODTYPE GetSaveFormats() const; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |