From: <sag...@us...> - 2012-05-29 13:51:18
|
Revision: 1289 http://modplug.svn.sourceforge.net/modplug/?rev=1289&view=rev Author: saga-games Date: 2012-05-29 13:51:08 +0000 (Tue, 29 May 2012) Log Message: ----------- [Fix] WAV loading: Some bugs in loop import. [Imp] Sample Editor: If zooming the current selection is impossible, the zoom context menu item is greyed out. [Imp] VST: If supported by the plugin, effGetParameterProperties is used to retrieve parameter names. [Ref] Smaller changes. [Mod] OpenMPT: Version is now 1.20.01.05 Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/AbstractVstEditor.h trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/View_smp.h trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/version.h trunk/OpenMPT/soundlib/MIDIEvents.cpp trunk/OpenMPT/soundlib/MIDIEvents.h trunk/OpenMPT/soundlib/SampleFormatConverters.h trunk/OpenMPT/soundlib/WAVTools.cpp Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2012-05-28 23:15:59 UTC (rev 1288) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2012-05-29 13:51:08 UTC (rev 1289) @@ -247,7 +247,7 @@ //end rewbs.defaultPlugGUI BOOL CAbstractVstEditor::PreTranslateMessage(MSG* pMsg) -//---------------------------------------------------- +//----------------------------------------------------- { if (pMsg) { @@ -273,7 +273,7 @@ } // Don't forward key repeats if plug does not listen for keypresses - // (avoids system beeps on note hold) + // (avoids system beeps on note hold) if (kT == kKeyEventRepeat) { return true; @@ -285,7 +285,7 @@ } -void CAbstractVstEditor::SetTitle() +void CAbstractVstEditor::SetTitle() //--------------------------------- { if (m_pVstPlugin && m_pVstPlugin->m_pMixStruct) @@ -355,7 +355,7 @@ m_nInstrument = GetBestInstrumentCandidate(); //only show messagebox if plug is able to process notes. - if(m_nInstrument < 0) + if(m_nInstrument == INSTRUMENTINDEX_INVALID) { if(m_pVstPlugin->CanRecieveMidiEvents()) { @@ -512,16 +512,15 @@ CArray<UINT, UINT> inputInstruments; m_pVstPlugin->GetInputInstrumentList(inputInstruments); - bool checked; - for (int nIns=0; nIns<inputInstruments.GetSize(); nIns++) + for(int nIns = 0; nIns<inputInstruments.GetSize(); nIns++) { - checked=false; + bool checked = false; if (nIns==0 && (inputPlugs.GetSize() || inputChannels.GetSize())) { m_pInputMenu->AppendMenu(MF_SEPARATOR); } name.Format("Ins%02d: %s", inputInstruments[nIns], (LPCTSTR)pSndFile->GetInstrumentName(inputInstruments[nIns])); - if (inputInstruments[nIns] == (UINT)m_nInstrument) checked=true; + if (inputInstruments[nIns] == (UINT)m_nInstrument) checked = true; m_pInputMenu->AppendMenu(MF_STRING|(checked?MF_CHECKED:0), ID_SELECTINST+inputInstruments[nIns], name); } @@ -673,21 +672,21 @@ } -bool CAbstractVstEditor::CheckInstrument(int instrument) -//------------------------------------------------------ +bool CAbstractVstEditor::CheckInstrument(INSTRUMENTINDEX ins) +//----------------------------------------------------------- { CSoundFile* pSndFile = m_pVstPlugin->GetSoundFile(); - if (instrument >= 0 && instrument<MAX_INSTRUMENTS && pSndFile->Instruments[instrument]) + if(ins != INSTRUMENTINDEX_INVALID && ins < MAX_INSTRUMENTS && pSndFile->Instruments[ins] != nullptr) { - return (pSndFile->Instruments[instrument]->nMixPlug) == (m_pVstPlugin->m_nSlot + 1); + return (pSndFile->Instruments[ins]->nMixPlug) == (m_pVstPlugin->m_nSlot + 1); } return false; } -int CAbstractVstEditor::GetBestInstrumentCandidate() -//-------------------------------------------------- +INSTRUMENTINDEX CAbstractVstEditor::GetBestInstrumentCandidate() +//-------------------------------------------------------------- { //First try current instrument: /* CModDoc* pModDoc = m_pVstPlugin->GetModDoc(); @@ -699,20 +698,20 @@ //Then just take the first instrument that points to this plug.. CArray<UINT, UINT> plugInstrumentList; m_pVstPlugin->GetInputInstrumentList(plugInstrumentList); - if (plugInstrumentList.GetSize()) + if(plugInstrumentList.GetSize()) { - return plugInstrumentList[0]; + return static_cast<INSTRUMENTINDEX>(plugInstrumentList[0]); } //No instrument in the entire track points to this plug. - return -1; + return INSTRUMENTINDEX_INVALID; } void CAbstractVstEditor::OnSetInputInstrument(UINT nID) //----------------------------------------------------- { - m_nInstrument = (nID - ID_SELECTINST); + m_nInstrument = static_cast<INSTRUMENTINDEX>(nID - ID_SELECTINST); } Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.h =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.h 2012-05-28 23:15:59 UTC (rev 1288) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.h 2012-05-29 13:51:08 UTC (rev 1289) @@ -77,10 +77,10 @@ void UpdateOutputMenu(); void UpdateMacroMenu(); void UpdateOptionsMenu(); - int GetBestInstrumentCandidate(); - bool CheckInstrument(int instrument); + INSTRUMENTINDEX GetBestInstrumentCandidate(); + bool CheckInstrument(INSTRUMENTINDEX ins); bool ValidateCurrentInstrument(); - int m_nInstrument; + INSTRUMENTINDEX m_nInstrument; int m_nLearnMacro; void OnToggleEditor(UINT nID); Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2012-05-28 23:15:59 UTC (rev 1288) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2012-05-29 13:51:08 UTC (rev 1289) @@ -1489,9 +1489,9 @@ { if (m_dwEndSel >= m_dwBeginSel + 4) { - ::AppendMenu(hMenu, MF_STRING, ID_SAMPLE_ZOOMONSEL, "Zoom"); + ::AppendMenu(hMenu, MF_STRING | (CanZoomSelection() ? 0 : MF_GRAYED), ID_SAMPLE_ZOOMONSEL, "Zoom"); ::AppendMenu(hMenu, MF_STRING, ID_SAMPLE_SETLOOP, "Set As Loop"); - if (pSndFile->m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT)) + if (pSndFile->GetType() & (MOD_TYPE_IT|MOD_TYPE_MPT)) ::AppendMenu(hMenu, MF_STRING, ID_SAMPLE_SETSUSTAINLOOP, "Set As Sustain Loop"); ::AppendMenu(hMenu, MF_SEPARATOR, 0, ""); } else @@ -1502,21 +1502,22 @@ { //Set loop points wsprintf(s, "Set Loop Start to:\t%d", dwPos); - ::AppendMenu(hMenu, MF_STRING|((dwPos+4<=sample.nLoopEnd)?0:MF_GRAYED), - ID_SAMPLE_SETLOOPSTART, s); + ::AppendMenu(hMenu, MF_STRING | (dwPos + 4 <= sample.nLoopEnd ? 0 : MF_GRAYED), + ID_SAMPLE_SETLOOPSTART, s); wsprintf(s, "Set Loop End to:\t%d", dwPos); - ::AppendMenu(hMenu, MF_STRING|((dwPos>=sample.nLoopStart+4)?0:MF_GRAYED), - ID_SAMPLE_SETLOOPEND, s); + ::AppendMenu(hMenu, MF_STRING | (dwPos >= sample.nLoopStart + 4 ? 0 : MF_GRAYED), + ID_SAMPLE_SETLOOPEND, s); - if (pSndFile->m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT)) { + if (pSndFile->GetType() & (MOD_TYPE_IT|MOD_TYPE_MPT)) + { //Set sustain loop points ::AppendMenu(hMenu, MF_SEPARATOR, 0, ""); wsprintf(s, "Set Sustain Start to:\t%d", dwPos); - ::AppendMenu(hMenu, MF_STRING|((dwPos+4<=sample.nSustainEnd)?0:MF_GRAYED), - ID_SAMPLE_SETSUSTAINSTART, s); + ::AppendMenu(hMenu, MF_STRING | (dwPos + 4 <= sample.nSustainEnd ? 0 : MF_GRAYED), + ID_SAMPLE_SETSUSTAINSTART, s); wsprintf(s, "Set Sustain End to:\t%d", dwPos); - ::AppendMenu(hMenu, MF_STRING|((dwPos>=sample.nSustainStart+4)?0:MF_GRAYED), - ID_SAMPLE_SETSUSTAINEND, s); + ::AppendMenu(hMenu, MF_STRING | (dwPos >= sample.nSustainStart + 4 ? 0 : MF_GRAYED), + ID_SAMPLE_SETSUSTAINEND, s); } ::AppendMenu(hMenu, MF_SEPARATOR, 0, ""); m_dwMenuParam = dwPos; @@ -2363,15 +2364,28 @@ } +UINT CViewSample::GetSelectionZoomLevel() const +//--------------------------------------------- +{ + UINT zoom = 0; + while(((static_cast<UINT>(m_rcClient.right) << zoom) < m_dwEndSel - m_dwBeginSel) && (zoom < MAX_ZOOM - 1)) + { + zoom++; + } + if(zoom++ < MAX_ZOOM) + return zoom; + else + return 0; +} + + void CViewSample::OnZoomOnSel() //----------------------------- { if ((m_dwEndSel > m_dwBeginSel) && (m_rcClient.right > 0)) { - DWORD dwZoom = 0; - - while ((((DWORD)m_rcClient.right << dwZoom) < (m_dwEndSel - m_dwBeginSel)) && (dwZoom < (MAX_ZOOM-1))) dwZoom++; - if (dwZoom < (MAX_ZOOM-1)) dwZoom++; else dwZoom = 0; + DWORD dwZoom = GetSelectionZoomLevel(); + SendCtrlMessage(CTRLMSG_SMP_SETZOOM, dwZoom); if (dwZoom) { @@ -2575,9 +2589,12 @@ if (!pSndFile) return 0; const BYTE nNote = midibyte1 + NOTE_MIN; - int nVol = midibyte2; - BYTE event = MIDIEvents::GetTypeFromEvent(dwMidiData); - if ((event == MIDIEvents::evNoteOn) && !nVol) event = MIDIEvents::evNoteOff; //Convert event to note-off if req'd + int nVol = midibyte2; + MIDIEvents::EventType event = MIDIEvents::GetTypeFromEvent(dwMidiData); + if(event == MIDIEvents::evNoteOn && !nVol) + { + event = MIDIEvents::evNoteOff; //Convert event to note-off if req'd + } // Handle MIDI messages assigned to shortcuts CInputHandler *ih = CMainFrame::GetMainFrame()->GetInputHandler(); @@ -2709,7 +2726,7 @@ // return value is N. If zoom is bigger than the biggest zoom, returns MIN_ZOOM + 1 and // if smaller than the smallest zoom, returns value >= MAX_ZOOM + 1. UINT CViewSample::GetAutoZoomLevel(const ModSample& smp) -//----------------------------------------------------- +//------------------------------------------------------ { m_rcClient.NormalizeRect(); if (m_rcClient.Width() == 0 || smp.nLength <= 0) Modified: trunk/OpenMPT/mptrack/View_smp.h =================================================================== --- trunk/OpenMPT/mptrack/View_smp.h 2012-05-28 23:15:59 UTC (rev 1288) +++ trunk/OpenMPT/mptrack/View_smp.h 2012-05-29 13:51:08 UTC (rev 1289) @@ -60,22 +60,26 @@ // Sets sample data on sample draw. template<class T, class uT> - void SetSampleData(void* pSample, const CPoint& point, const DWORD old); + void SetSampleData(void *pSample, const CPoint &point, const DWORD old); // Sets initial draw point on sample draw. template<class T, class uT> - void SetInitialDrawPoint(void* pSample, const CPoint& point); + void SetInitialDrawPoint(void *pSample, const CPoint &point); // Returns sample value corresponding given point in the sample view. template<class T, class uT> - T GetSampleValueFromPoint(const CPoint& point); + T GetSampleValueFromPoint(const CPoint &point); // Returns auto-zoom level compared to other zoom levels. // If auto-zoom gives bigger zoom than zoom level N but smaller than zoom level N-1, // return value is N. If zoom is bigger than the biggest zoom, returns MIN_ZOOM + 1 and // if smaller than the smallest zoom, returns value >= MAX_ZOOM + 1. - UINT GetAutoZoomLevel(const ModSample& smp); + UINT GetAutoZoomLevel(const ModSample &smp); + // Calculate zoom level based on the current selection + UINT GetSelectionZoomLevel() const; + bool CanZoomSelection() const { return GetSelectionZoomLevel() != 0; } + UINT ScrollPosToSamplePos() const {return ScrollPosToSamplePos(m_nZoom);} UINT ScrollPosToSamplePos(UINT nZoom) const {return (nZoom > 0) ? (m_nScrollPos << (nZoom - 1)) : 0;} Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2012-05-28 23:15:59 UTC (rev 1288) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2012-05-29 13:51:08 UTC (rev 1289) @@ -1850,7 +1850,19 @@ CString CVstPlugin::GetFormattedParamName(PlugParamIndex param) //------------------------------------------------------------- { - const CString paramName = GetParamName(param); + static VstParameterProperties properties; + + CString paramName; + + if(Dispatch(effGetParameterProperties, param, nullptr, &properties, 0.0f) == 1) + { + StringFixer::SetNullTerminator(properties.label); + paramName = properties.label; + } else + { + paramName = GetParamName(param); + } + CString name; if(paramName.IsEmpty()) { Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2012-05-28 23:15:59 UTC (rev 1288) +++ trunk/OpenMPT/mptrack/version.h 2012-05-29 13:51:08 UTC (rev 1289) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 01 -#define VER_MINORMINOR 04 +#define VER_MINORMINOR 05 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of Modified: trunk/OpenMPT/soundlib/MIDIEvents.cpp =================================================================== --- trunk/OpenMPT/soundlib/MIDIEvents.cpp 2012-05-28 23:15:59 UTC (rev 1288) +++ trunk/OpenMPT/soundlib/MIDIEvents.cpp 2012-05-29 13:51:08 UTC (rev 1289) @@ -1,6 +1,6 @@ /* - * MIDI.cpp - * -------- + * MIDIEvents.cpp + * -------------- * Purpose: MIDI event handling, event lists, ... * Notes : (currently none) * Authors: OpenMPT Devs @@ -26,7 +26,7 @@ uint32 BuildCCEvent(MidiCC midiCC, uint8 midiChannel, uint8 param) //---------------------------------------------------------------- { - return BuildEvent(evControllerChange, midiChannel, midiCC, param); + return BuildEvent(evControllerChange, midiChannel, static_cast<uint8>(midiCC), param); } @@ -34,7 +34,7 @@ uint32 BuildPitchBendEvent(uint8 midiChannel, uint16 bendAmount) //-------------------------------------------------------------- { - return BuildEvent(evPitchBend, midiChannel, (bendAmount & 0x7F), (bendAmount >> 7)); + return BuildEvent(evPitchBend, midiChannel, static_cast<uint8>(bendAmount & 0x7F), static_cast<uint8>(bendAmount >> 7)); } @@ -66,7 +66,7 @@ uint8 BuildSystemEvent(SystemEvent eventType) //------------------------------------------- { - return (evSystem << 4) | eventType; + return static_cast<uint8>((evSystem << 4) | eventType); } Modified: trunk/OpenMPT/soundlib/MIDIEvents.h =================================================================== --- trunk/OpenMPT/soundlib/MIDIEvents.h 2012-05-28 23:15:59 UTC (rev 1288) +++ trunk/OpenMPT/soundlib/MIDIEvents.h 2012-05-29 13:51:08 UTC (rev 1289) @@ -1,6 +1,6 @@ /* - * MIDI.h - * ------ + * MIDIEvents.h + * ------------ * Purpose: MIDI event handling, event lists, ... * Notes : (currently none) * Authors: OpenMPT Devs Modified: trunk/OpenMPT/soundlib/SampleFormatConverters.h =================================================================== --- trunk/OpenMPT/soundlib/SampleFormatConverters.h 2012-05-28 23:15:59 UTC (rev 1288) +++ trunk/OpenMPT/soundlib/SampleFormatConverters.h 2012-05-29 13:51:08 UTC (rev 1289) @@ -430,5 +430,5 @@ } } - return numSamples * sizeof(SampleConversion::input_t) * sample.GetNumChannels(); + return numSamples * inSize; } Modified: trunk/OpenMPT/soundlib/WAVTools.cpp =================================================================== --- trunk/OpenMPT/soundlib/WAVTools.cpp 2012-05-28 23:15:59 UTC (rev 1288) +++ trunk/OpenMPT/soundlib/WAVTools.cpp 2012-05-29 13:51:08 UTC (rev 1289) @@ -131,7 +131,7 @@ // Read software name const bool isOldMPT = infoChunk.GetChunk(RIFFChunk::idISFT).ReadMagic("Modplug Tracker"); - sample.uFlags &= ~(CHN_LOOP | CHN_SUSTAINLOOP); + sample.uFlags &= ~(CHN_LOOP | CHN_PINGPONGLOOP | CHN_SUSTAINLOOP | CHN_PINGPONGSUSTAIN); // Convert loops if(!sampleLoops.empty()) @@ -139,7 +139,7 @@ size_t normalLoopIndex = 0; if(sampleLoops.size() > 1) { - sampleLoops[0].ApplyToSample(sample.nSustainStart, sample.nSustainStart, sample.nLength, sample.uFlags, CHN_SUSTAINLOOP, CHN_PINGPONGSUSTAIN, isOldMPT); + sampleLoops[0].ApplyToSample(sample.nSustainStart, sample.nSustainEnd, sample.nLength, sample.uFlags, CHN_SUSTAINLOOP, CHN_PINGPONGSUSTAIN, isOldMPT); normalLoopIndex = 1; } sampleLoops[normalLoopIndex].ApplyToSample(sample.nLoopStart, sample.nLoopEnd, sample.nLength, sample.uFlags, CHN_LOOP, CHN_PINGPONGLOOP, isOldMPT); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |