You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
(1) |
Apr
(1) |
May
|
Jun
(1) |
Jul
|
Aug
(10) |
Sep
|
Oct
|
Nov
|
Dec
(3) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(1) |
Feb
(2) |
Mar
(3) |
Apr
(2) |
May
(10) |
Jun
(2) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
(3) |
Dec
|
2008 |
Jan
(6) |
Feb
(4) |
Mar
(5) |
Apr
(2) |
May
(1) |
Jun
(1) |
Jul
(4) |
Aug
(6) |
Sep
(2) |
Oct
(9) |
Nov
(1) |
Dec
(4) |
2009 |
Jan
(9) |
Feb
(2) |
Mar
(2) |
Apr
(2) |
May
(6) |
Jun
(18) |
Jul
(33) |
Aug
(39) |
Sep
(33) |
Oct
(24) |
Nov
(23) |
Dec
(22) |
2010 |
Jan
(29) |
Feb
(32) |
Mar
(51) |
Apr
(17) |
May
(31) |
Jun
(21) |
Jul
(32) |
Aug
(28) |
Sep
(35) |
Oct
(27) |
Nov
(11) |
Dec
(13) |
2011 |
Jan
(14) |
Feb
(13) |
Mar
(27) |
Apr
(27) |
May
(28) |
Jun
(20) |
Jul
(43) |
Aug
(52) |
Sep
(66) |
Oct
(61) |
Nov
(11) |
Dec
(8) |
2012 |
Jan
(20) |
Feb
(30) |
Mar
(38) |
Apr
(21) |
May
(33) |
Jun
(21) |
Jul
(25) |
Aug
(9) |
Sep
(24) |
Oct
(42) |
Nov
(27) |
Dec
(41) |
2013 |
Jan
(20) |
Feb
(35) |
Mar
(156) |
Apr
(298) |
May
(258) |
Jun
(201) |
Jul
(105) |
Aug
(60) |
Sep
(193) |
Oct
(245) |
Nov
(280) |
Dec
(194) |
2014 |
Jan
(63) |
Feb
(202) |
Mar
(200) |
Apr
(23) |
May
(53) |
Jun
(105) |
Jul
(18) |
Aug
(26) |
Sep
(110) |
Oct
(187) |
Nov
(97) |
Dec
(74) |
2015 |
Jan
(45) |
Feb
(55) |
Mar
(116) |
Apr
(116) |
May
(193) |
Jun
(164) |
Jul
(50) |
Aug
(111) |
Sep
(98) |
Oct
(71) |
Nov
(103) |
Dec
(63) |
2016 |
Jan
(33) |
Feb
(101) |
Mar
(182) |
Apr
(139) |
May
(140) |
Jun
(103) |
Jul
(165) |
Aug
(286) |
Sep
(208) |
Oct
(127) |
Nov
(97) |
Dec
(54) |
2017 |
Jan
(64) |
Feb
(335) |
Mar
(202) |
Apr
(212) |
May
(139) |
Jun
(127) |
Jul
(294) |
Aug
(154) |
Sep
(170) |
Oct
(152) |
Nov
(156) |
Dec
(62) |
2018 |
Jan
(168) |
Feb
(237) |
Mar
(196) |
Apr
(174) |
May
(174) |
Jun
(161) |
Jul
(127) |
Aug
(88) |
Sep
(149) |
Oct
(66) |
Nov
(52) |
Dec
(135) |
2019 |
Jan
(146) |
Feb
(126) |
Mar
(104) |
Apr
(58) |
May
(60) |
Jun
(28) |
Jul
(197) |
Aug
(129) |
Sep
(141) |
Oct
(148) |
Nov
(63) |
Dec
(100) |
2020 |
Jan
(74) |
Feb
(37) |
Mar
(59) |
Apr
(154) |
May
(194) |
Jun
(133) |
Jul
(313) |
Aug
(197) |
Sep
(49) |
Oct
(162) |
Nov
(143) |
Dec
(57) |
2021 |
Jan
(120) |
Feb
(107) |
Mar
(314) |
Apr
(157) |
May
(524) |
Jun
(169) |
Jul
(72) |
Aug
(133) |
Sep
(135) |
Oct
(146) |
Nov
(198) |
Dec
(325) |
2022 |
Jan
(409) |
Feb
(249) |
Mar
(138) |
Apr
(95) |
May
(102) |
Jun
(221) |
Jul
(66) |
Aug
(120) |
Sep
(192) |
Oct
(131) |
Nov
(53) |
Dec
(171) |
2023 |
Jan
(357) |
Feb
(82) |
Mar
(168) |
Apr
(218) |
May
(196) |
Jun
(86) |
Jul
(115) |
Aug
(49) |
Sep
(190) |
Oct
(102) |
Nov
(45) |
Dec
(76) |
2024 |
Jan
(86) |
Feb
(50) |
Mar
(324) |
Apr
(209) |
May
(197) |
Jun
(232) |
Jul
(194) |
Aug
(247) |
Sep
(219) |
Oct
(266) |
Nov
(328) |
Dec
(304) |
2025 |
Jan
(191) |
Feb
(115) |
Mar
(137) |
Apr
(32) |
May
(126) |
Jun
(403) |
Jul
(120) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <sv...@op...> - 2024-12-21 19:54:48
|
Author: sagamusix Date: Sat Dec 21 20:54:42 2024 New Revision: 22596 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22596 Log: Merged revision(s) 22595 from trunk/OpenMPT: [Fix] Avoid NNA channel starvation because of sample-based instruments that have a MIDI channel assigned. Channel starvation can still happen if a VST plugin or the MIDI I/O plugin is associated with the instrument. Other built-in plugins won't have this issue (https://bugs.openmpt.org/view.php?id=1848). ........ Modified: branches/OpenMPT-1.31/ (props changed) branches/OpenMPT-1.31/soundlib/Snd_fx.cpp Modified: branches/OpenMPT-1.31/soundlib/Snd_fx.cpp ============================================================================== --- branches/OpenMPT-1.31/soundlib/Snd_fx.cpp Sat Dec 21 20:52:32 2024 (r22595) +++ branches/OpenMPT-1.31/soundlib/Snd_fx.cpp Sat Dec 21 20:54:42 2024 (r22596) @@ -2132,19 +2132,22 @@ for(CHANNELINDEX i = m_nChannels; i < MAX_CHANNELS; i++) { const ModChannel &c = m_PlayState.Chn[i]; - // No sample and no plugin playing - if(!c.nLength && !c.HasMIDIOutput()) + // Sample playing? + if(c.nLength) + continue; + // Can a plugin potentially be playing? + if(!c.HasMIDIOutput()) return i; - // Plugin channel with already released note - if(!c.nLength && c.dwFlags[CHN_KEYOFF | CHN_NOTEFADE]) + // Has the plugin note already been released? (note: lastMidiNoteWithoutArp is set from within IMixPlugin, so this implies that there is a valid plugin assignment) + if(c.dwFlags[CHN_KEYOFF | CHN_NOTEFADE] || c.lastMidiNoteWithoutArp == NOTE_NONE) return i; // Stopped OPL channel if(c.dwFlags[CHN_ADLIB] && (!m_opl || !m_opl->IsActive(i))) return i; } - uint32 vol = 0x800000; - if(nChn < MAX_CHANNELS) + int32 vol = 0x800100; + if(nChn < m_PlayState.Chn.size()) { const ModChannel &srcChn = m_PlayState.Chn[nChn]; if(!srcChn.nFadeOutVol && srcChn.nLength) @@ -2163,7 +2166,8 @@ // Use a combination of real volume [14 bit] (which includes volume envelopes, but also potentially global volume) and note volume [9 bit]. // Rationale: We need volume envelopes in case e.g. all NNA channels are playing at full volume but are looping on a 0-volume envelope node. // But if global volume is not applied to master and the global volume temporarily drops to 0, we would kill arbitrary channels. Hence, add the note volume as well. - uint32 v = (c.nRealVolume << 9) | c.nVolume; + int32 v = (c.nRealVolume << 9) | c.nVolume; + // Less priority to looped samples if(c.dwFlags[CHN_LOOP]) v /= 2; if((v < vol) || ((v == vol) && (c.VolEnv.nEnvPosition > envpos))) |
From: <sv...@op...> - 2024-12-21 19:52:44
|
Author: sagamusix Date: Sat Dec 21 20:52:32 2024 New Revision: 22595 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22595 Log: [Fix] Avoid NNA channel starvation because of sample-based instruments that have a MIDI channel assigned. Channel starvation can still happen if a VST plugin or the MIDI I/O plugin is associated with the instrument. Other built-in plugins won't have this issue (https://bugs.openmpt.org/view.php?id=1848). Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp ============================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp Sat Dec 21 20:26:11 2024 (r22594) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp Sat Dec 21 20:52:32 2024 (r22595) @@ -2233,16 +2233,19 @@ for(CHANNELINDEX i = GetNumChannels(); i < m_PlayState.Chn.size(); i++) { const ModChannel &c = m_PlayState.Chn[i]; - // No sample and no plugin playing - if(!c.nLength && !c.HasMIDIOutput()) + // Sample playing? + if(c.nLength) + continue; + // Can a plugin potentially be playing? + if(!c.HasMIDIOutput()) return i; - // Plugin channel with already released note - if(!c.nLength && c.dwFlags[CHN_KEYOFF | CHN_NOTEFADE]) + // Has the plugin note already been released? (note: lastMidiNoteWithoutArp is set from within IMixPlugin, so this implies that there is a valid plugin assignment) + if(c.dwFlags[CHN_KEYOFF | CHN_NOTEFADE] || c.lastMidiNoteWithoutArp == NOTE_NONE) return i; } - uint32 vol = 0x800000; - if(nChn < MAX_CHANNELS) + int32 vol = 0x800100; + if(nChn < m_PlayState.Chn.size()) { const ModChannel &srcChn = m_PlayState.Chn[nChn]; if(!srcChn.nFadeOutVol && srcChn.nLength) @@ -2264,7 +2267,8 @@ // Use a combination of real volume [14 bit] (which includes volume envelopes, but also potentially global volume) and note volume [9 bit]. // Rationale: We need volume envelopes in case e.g. all NNA channels are playing at full volume but are looping on a 0-volume envelope node. // But if global volume is not applied to master and the global volume temporarily drops to 0, we would kill arbitrary channels. Hence, add the note volume as well. - uint32 v = (c.nRealVolume << 9) | c.nVolume; + int32 v = (c.nRealVolume << 9) | c.nVolume; + // Less priority to looped samples if(c.dwFlags[CHN_LOOP]) v /= 2; if((v < vol) || ((v == vol) && (c.VolEnv.nEnvPosition > envpos))) |
From: <sv...@op...> - 2024-12-21 19:26:18
|
Author: sagamusix Date: Sat Dec 21 20:26:11 2024 New Revision: 22594 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22594 Log: Merged revision(s) 22591-22593 from trunk/OpenMPT: [Imp] MO3: Import dummy command W (XM). ........ [Imp] Pressing Ctrl while moving loop points or clicking loop start/end spin buttons now moves the loop, keeping the loop length constant. ........ [Ref] Remove unused variable. ........ Modified: branches/OpenMPT-1.31/ (props changed) branches/OpenMPT-1.31/mptrack/Ctrl_smp.cpp branches/OpenMPT-1.31/mptrack/View_smp.cpp branches/OpenMPT-1.31/soundlib/Load_mo3.cpp branches/OpenMPT-1.31/soundlib/ModSample.h branches/OpenMPT-1.31/soundlib/modsmp_ctrl.cpp branches/OpenMPT-1.31/tracklib/SampleEdit.cpp branches/OpenMPT-1.31/tracklib/SampleEdit.h Modified: branches/OpenMPT-1.31/mptrack/Ctrl_smp.cpp ============================================================================== --- branches/OpenMPT-1.31/mptrack/Ctrl_smp.cpp Sat Dec 21 17:35:48 2024 (r22593) +++ branches/OpenMPT-1.31/mptrack/Ctrl_smp.cpp Sat Dec 21 20:26:11 2024 (r22594) @@ -2938,99 +2938,29 @@ } -#define SMPLOOP_ACCURACY 7 // 5% -#define BIDILOOP_ACCURACY 2 // 5% - - -bool MPT_LoopCheck(int sstart0, int sstart1, int send0, int send1) -{ - int dse0 = send0 - sstart0; - if ((dse0 < -SMPLOOP_ACCURACY) || (dse0 > SMPLOOP_ACCURACY)) return false; - int dse1 = send1 - sstart1; - if ((dse1 < -SMPLOOP_ACCURACY) || (dse1 > SMPLOOP_ACCURACY)) return false; - int dstart = sstart1 - sstart0; - int dend = send1 - send0; - if (!dstart) dstart = dend >> 7; - if (!dend) dend = dstart >> 7; - if ((dstart ^ dend) < 0) return false; - int delta = dend - dstart; - return ((delta > -SMPLOOP_ACCURACY) && (delta < SMPLOOP_ACCURACY)); -} - - -bool MPT_BidiEndCheck(int spos0, int spos1, int spos2) -{ - int delta0 = spos1 - spos0; - int delta1 = spos2 - spos1; - int delta2 = spos2 - spos0; - if (!delta0) delta0 = delta1 >> 7; - if (!delta1) delta1 = delta0 >> 7; - if ((delta1 ^ delta0) < 0) return false; - return ((delta0 >= -1) && (delta0 <= 0) && (delta1 >= -1) && (delta1 <= 0) && (delta2 >= -1) && (delta2 <= 0)); -} - - -bool MPT_BidiStartCheck(int spos0, int spos1, int spos2) -{ - int delta1 = spos1 - spos0; - int delta0 = spos2 - spos1; - int delta2 = spos2 - spos0; - if (!delta0) delta0 = delta1 >> 7; - if (!delta1) delta1 = delta0 >> 7; - if ((delta1 ^ delta0) < 0) return false; - return ((delta0 >= -1) && (delta0 <= 0) && (delta1 > -1) && (delta1 <= 0) && (delta2 >= -1) && (delta2 <= 0)); -} - - - void CCtrlSamples::OnVScroll(UINT nCode, UINT, CScrollBar *scrollBar) { - TCHAR s[256]; + TCHAR s[32]; if(IsLocked()) return; ModSample &sample = m_sndFile.GetSample(m_nSample); - const uint8 *pSample = mpt::byte_cast<const uint8 *>(sample.sampleb()); - const uint32 inc = sample.GetBytesPerSample(); - SmpLength i; - int pos; + const bool moveLoop = CMainFrame::GetInputHandler()->CtrlPressed(); bool redraw = false; static CScrollBar *lastScrollbar = nullptr; LockControls(); - if ((!sample.nLength) || (!pSample)) goto NoSample; - if (sample.uFlags[CHN_16BIT]) - { - pSample++; - } // Loop Start - if ((pos = m_SpinLoopStart.GetPos32()) != 0 && sample.nLoopEnd > 0) + if(int pos = m_SpinLoopStart.GetPos32(); pos != 0 && sample.nLoopEnd > 0 && sample.HasSampleData()) { - bool bOk = false; - const uint8 *p = pSample + sample.nLoopStart * inc; - int find0 = (int)pSample[sample.nLoopEnd*inc-inc]; - int find1 = (int)pSample[sample.nLoopEnd*inc]; - // Find Next LoopStart Point - if (pos > 0) - { - for (i = sample.nLoopStart + 1; i + 16 < sample.nLoopEnd; i++) - { - p += inc; - bOk = sample.uFlags[CHN_PINGPONGLOOP] ? MPT_BidiStartCheck(p[0], p[inc], p[inc*2]) : MPT_LoopCheck(find0, find1, p[0], p[inc]); - if (bOk) break; - } - } else - // Find Prev LoopStart Point + if(SmpLength i = SampleEdit::FindLoopStart(sample, false, pos > 0, moveLoop); i < sample.nLength) { - for (i = sample.nLoopStart; i; ) + if(!m_startedEdit && lastScrollbar != scrollBar) + PrepareUndo(moveLoop ? "Move Loop" : "Set Loop Start"); + if(moveLoop) { - i--; - p -= inc; - bOk = sample.uFlags[CHN_PINGPONGLOOP] ? MPT_BidiStartCheck(p[0], p[inc], p[inc*2]) : MPT_LoopCheck(find0, find1, p[0], p[inc]); - if (bOk) break; + sample.nLoopEnd = i + (sample.nLoopEnd - sample.nLoopStart); + wsprintf(s, _T("%u"), sample.nLoopEnd); + m_EditLoopEnd.SetWindowText(s); } - } - if (bOk) - { - if(!m_startedEdit && lastScrollbar != scrollBar) PrepareUndo("Set Loop Start"); sample.nLoopStart = i; wsprintf(s, _T("%u"), sample.nLoopStart); m_EditLoopStart.SetWindowText(s); @@ -3040,34 +2970,18 @@ m_SpinLoopStart.SetPos(0); } // Loop End - if ((pos = m_SpinLoopEnd.GetPos32()) != 0) + if(int pos = m_SpinLoopEnd.GetPos32(); pos != 0 && sample.HasSampleData()) { - bool bOk = false; - const uint8 *p = pSample + sample.nLoopEnd * inc; - int find0 = (int)pSample[sample.nLoopStart*inc]; - int find1 = (int)pSample[sample.nLoopStart*inc+inc]; - // Find Next LoopEnd Point - if (pos > 0) - { - for (i = sample.nLoopEnd + 1; i <= sample.nLength; i++, p += inc) - { - bOk = sample.uFlags[CHN_PINGPONGLOOP] ? MPT_BidiEndCheck(p[0], p[inc], p[inc*2]) : MPT_LoopCheck(find0, find1, p[0], p[inc]); - if (bOk) break; - } - } else - // Find Prev LoopEnd Point + if(SmpLength i = SampleEdit::FindLoopEnd(sample, false, pos > 0, moveLoop); i > 0) { - for (i = sample.nLoopEnd; i > sample.nLoopStart + 16; ) + if(!m_startedEdit && lastScrollbar != scrollBar) + PrepareUndo(moveLoop ? "Move Loop" : "Set Loop End"); + if(moveLoop) { - i--; - p -= inc; - bOk = sample.uFlags[CHN_PINGPONGLOOP] ? MPT_BidiEndCheck(p[0], p[inc], p[inc*2]) : MPT_LoopCheck(find0, find1, p[0], p[inc]); - if (bOk) break; + sample.nLoopStart = i - (sample.nLoopEnd - sample.nLoopStart); + wsprintf(s, _T("%u"), sample.nLoopStart); + m_EditLoopStart.SetWindowText(s); } - } - if (bOk) - { - if(!m_startedEdit && lastScrollbar != scrollBar) PrepareUndo("Set Loop End"); sample.nLoopEnd = i; wsprintf(s, _T("%u"), sample.nLoopEnd); m_EditLoopEnd.SetWindowText(s); @@ -3077,35 +2991,18 @@ m_SpinLoopEnd.SetPos(0); } // Sustain Loop Start - if ((pos = m_SpinSustainStart.GetPos32()) != 0 && sample.nSustainEnd > 0) + if(int pos = m_SpinSustainStart.GetPos32(); pos != 0 && sample.nSustainEnd > 0 && sample.HasSampleData()) { - bool bOk = false; - const uint8 *p = pSample + sample.nSustainStart * inc; - int find0 = (int)pSample[sample.nSustainEnd*inc-inc]; - int find1 = (int)pSample[sample.nSustainEnd*inc]; - // Find Next Sustain LoopStart Point - if (pos > 0) - { - for (i = sample.nSustainStart + 1; i + 16 < sample.nSustainEnd; i++) - { - p += inc; - bOk = sample.uFlags[CHN_PINGPONGSUSTAIN] ? MPT_BidiStartCheck(p[0], p[inc], p[inc*2]) : MPT_LoopCheck(find0, find1, p[0], p[inc]); - if (bOk) break; - } - } else - // Find Prev Sustain LoopStart Point + if(SmpLength i = SampleEdit::FindLoopStart(sample, true, pos > 0, moveLoop); i < sample.nLength) { - for (i = sample.nSustainStart; i; ) + if(!m_startedEdit && lastScrollbar != scrollBar) + PrepareUndo(moveLoop ? "Move Sustain Loop" : "Set Sustain Loop Start"); + if(moveLoop) { - i--; - p -= inc; - bOk = sample.uFlags[CHN_PINGPONGSUSTAIN] ? MPT_BidiStartCheck(p[0], p[inc], p[inc*2]) : MPT_LoopCheck(find0, find1, p[0], p[inc]); - if (bOk) break; + sample.nSustainEnd = i + (sample.nSustainEnd - sample.nSustainStart); + wsprintf(s, _T("%u"), sample.nSustainEnd); + m_EditSustainEnd.SetWindowText(s); } - } - if (bOk) - { - if(!m_startedEdit && lastScrollbar != scrollBar) PrepareUndo("Set Sustain Loop Start"); sample.nSustainStart = i; wsprintf(s, _T("%u"), sample.nSustainStart); m_EditSustainStart.SetWindowText(s); @@ -3115,34 +3012,18 @@ m_SpinSustainStart.SetPos(0); } // Sustain Loop End - if ((pos = m_SpinSustainEnd.GetPos32()) != 0) + if(int pos = m_SpinSustainEnd.GetPos32(); pos != 0 && sample.HasSampleData()) { - bool bOk = false; - const uint8 *p = pSample + sample.nSustainEnd * inc; - int find0 = (int)pSample[sample.nSustainStart*inc]; - int find1 = (int)pSample[sample.nSustainStart*inc+inc]; - // Find Next LoopEnd Point - if (pos > 0) - { - for (i = sample.nSustainEnd + 1; i + 1 < sample.nLength; i++, p += inc) - { - bOk = sample.uFlags[CHN_PINGPONGSUSTAIN] ? MPT_BidiEndCheck(p[0], p[inc], p[inc*2]) : MPT_LoopCheck(find0, find1, p[0], p[inc]); - if (bOk) break; - } - } else - // Find Prev LoopEnd Point + if(SmpLength i = SampleEdit::FindLoopEnd(sample, true, pos > 0, moveLoop); i > 0) { - for (i = sample.nSustainEnd; i > sample.nSustainStart + 16; ) + if(!m_startedEdit && lastScrollbar != scrollBar) + PrepareUndo(moveLoop ? "Move Sustain Loop" : "Set Sustain Loop End"); + if(moveLoop) { - i--; - p -= inc; - bOk = sample.uFlags[CHN_PINGPONGSUSTAIN] ? MPT_BidiEndCheck(p[0], p[inc], p[inc*2]) : MPT_LoopCheck(find0, find1, p[0], p[inc]); - if (bOk) break; + sample.nSustainStart = i - (sample.nSustainEnd - sample.nSustainStart); + wsprintf(s, _T("%u"), sample.nSustainStart); + m_EditSustainStart.SetWindowText(s); } - } - if (bOk) - { - if(!m_startedEdit && lastScrollbar != scrollBar) PrepareUndo("Set Sustain Loop End"); sample.nSustainEnd = i; wsprintf(s, _T("%u"), sample.nSustainEnd); m_EditSustainEnd.SetWindowText(s); @@ -3151,9 +3032,8 @@ } m_SpinSustainEnd.SetPos(0); } -NoSample: // FineTune / C-5 Speed - if ((pos = m_SpinFineTune.GetPos32()) != 0) + if(int pos = m_SpinFineTune.GetPos32(); pos != 0) { if(!m_startedEdit && lastScrollbar != scrollBar) PrepareUndo("Finetune"); @@ -3366,8 +3246,7 @@ CSampleXFadeDlg dlg(this, sample); if(dlg.DoModal() == IDOK) { - const SmpLength loopStart = dlg.m_useSustainLoop ? sample.nSustainStart: sample.nLoopStart; - const SmpLength loopEnd = dlg.m_useSustainLoop ? sample.nSustainEnd: sample.nLoopEnd; + const auto [loopStart, loopEnd] = dlg.m_useSustainLoop ? sample.GetSustainLoop() : sample.GetLoop(); const SmpLength maxSamples = std::min({ sample.nLength, loopStart, loopEnd / 2 }); SmpLength fadeSamples = dlg.PercentToSamples(dlg.m_fadeLength); LimitMax(fadeSamples, maxSamples); Modified: branches/OpenMPT-1.31/mptrack/View_smp.cpp ============================================================================== --- branches/OpenMPT-1.31/mptrack/View_smp.cpp Sat Dec 21 17:35:48 2024 (r22593) +++ branches/OpenMPT-1.31/mptrack/View_smp.cpp Sat Dec 21 20:26:11 2024 (r22594) @@ -1857,9 +1857,11 @@ m_startDragValue = ScreenToSample(point.x); } + const bool moveLoop = (flags & MK_CONTROL); bool update = false; SmpLength *updateLoopPoint = nullptr; const char *updateLoopDesc = nullptr; + SmpLength loopLength = 0; switch(m_dragItem) { case HitTestItem::SelectionStart: @@ -1872,28 +1874,50 @@ } break; case HitTestItem::LoopStart: - if(x < sample.nLoopEnd) + if(moveLoop) + { + updateLoopPoint = &sample.nLoopStart; + updateLoopDesc = "Move Loop"; + loopLength = sample.nLoopEnd - sample.nLoopStart; + } else if(x < sample.nLoopEnd) { updateLoopPoint = &sample.nLoopStart; updateLoopDesc = "Set Loop Start"; } break; case HitTestItem::LoopEnd: - if(x > sample.nLoopStart) + if(moveLoop) + { + updateLoopPoint = &sample.nLoopStart; + updateLoopDesc = "Move Loop"; + loopLength = sample.nLoopEnd - sample.nLoopStart; + x = (x > loopLength) ? x - loopLength : 0; + } else if(x > sample.nLoopStart) { updateLoopPoint = &sample.nLoopEnd; updateLoopDesc = "Set Loop End"; } break; case HitTestItem::SustainStart: - if(x < sample.nSustainEnd) + if(moveLoop) + { + updateLoopPoint = &sample.nSustainStart; + updateLoopDesc = "Move Sustain Loop"; + loopLength = sample.nSustainEnd - sample.nSustainStart; + } else if(x < sample.nSustainEnd) { updateLoopPoint = &sample.nSustainStart; updateLoopDesc = "Set Sustain Start"; } break; case HitTestItem::SustainEnd: - if(x > sample.nSustainStart) + if(moveLoop) + { + updateLoopPoint = &sample.nSustainStart; + updateLoopDesc = "Move Loop"; + loopLength = sample.nSustainEnd - sample.nSustainStart; + x = (x > loopLength) ? x - loopLength : 0; + } else if(x > sample.nSustainStart) { updateLoopPoint = &sample.nSustainEnd; updateLoopDesc = "Set Sustain End"; @@ -1909,6 +1933,9 @@ break; } + if(loopLength) + LimitMax(x, sample.nLength - loopLength); + if(updateLoopPoint && updateLoopDesc && *updateLoopPoint != x) { if(!m_dragPreparedUndo) @@ -1916,6 +1943,10 @@ m_dragPreparedUndo = true; update = true; *updateLoopPoint = x; + if(loopLength && updateLoopPoint == &sample.nLoopStart) + sample.nLoopEnd = sample.nLoopStart + loopLength; + else if(loopLength && updateLoopPoint == &sample.nSustainStart) + sample.nSustainEnd = sample.nSustainStart + loopLength; sample.PrecomputeLoops(sndFile, true); SetModified(SampleHint().Info(), true, false); } @@ -2050,7 +2081,7 @@ } else { // ctrl + click = play from cursor pos - if(flags & MK_CONTROL) + if((flags & MK_CONTROL) && point.y >= m_timelineHeight) PlayNote(NOTE_MIDDLEC, ScreenToSample(point.x)); } } Modified: branches/OpenMPT-1.31/soundlib/Load_mo3.cpp ============================================================================== --- branches/OpenMPT-1.31/soundlib/Load_mo3.cpp Sat Dec 21 17:35:48 2024 (r22593) +++ branches/OpenMPT-1.31/soundlib/Load_mo3.cpp Sat Dec 21 20:26:11 2024 (r22594) @@ -1016,7 +1016,7 @@ CMD_PORTAMENTOUP, CMD_TREMOR, CMD_RETRIG, CMD_FINEVIBRATO, CMD_CHANNELVOLUME, CMD_CHANNELVOLSLIDE, CMD_PANNINGSLIDE, CMD_S3MCMDEX, CMD_TEMPO, CMD_GLOBALVOLSLIDE, CMD_PANBRELLO, CMD_MIDI, - CMD_NONE,/*FineVolSld*/ CMD_NONE,/*PortaDown*/ CMD_NONE, /*PortaUp*/ CMD_NONE, + CMD_NONE,/*FineVolSld*/ CMD_NONE,/*PortaDown*/ CMD_NONE, /*PortaUp*/ CMD_DUMMY, CMD_NONE,/*ITVolCol*/ CMD_XPARAM, CMD_SMOOTHMIDI, CMD_DELAYCUT, CMD_FINETUNE, CMD_FINETUNE_SMOOTH, }; Modified: branches/OpenMPT-1.31/soundlib/ModSample.h ============================================================================== --- branches/OpenMPT-1.31/soundlib/ModSample.h Sat Dec 21 17:35:48 2024 (r22593) +++ branches/OpenMPT-1.31/soundlib/ModSample.h Sat Dec 21 20:26:11 2024 (r22594) @@ -144,6 +144,10 @@ void SetLoop(SmpLength start, SmpLength end, bool enable, bool pingpong, CSoundFile &sndFile); // Set sustain loop points and update loop wrap-around buffer void SetSustainLoop(SmpLength start, SmpLength end, bool enable, bool pingpong, CSoundFile &sndFile); + // Retrieve the normal loop points + std::pair<SmpLength, SmpLength> GetLoop() const noexcept { return std::make_pair(nLoopStart, nLoopEnd); } + // Retrieve the sustain loop points + std::pair<SmpLength, SmpLength> GetSustainLoop() const noexcept { return std::make_pair(nSustainStart, nSustainEnd); } // Update loop wrap-around buffer void PrecomputeLoops(CSoundFile &sndFile, bool updateChannels = true); Modified: branches/OpenMPT-1.31/soundlib/modsmp_ctrl.cpp ============================================================================== --- branches/OpenMPT-1.31/soundlib/modsmp_ctrl.cpp Sat Dec 21 17:35:48 2024 (r22593) +++ branches/OpenMPT-1.31/soundlib/modsmp_ctrl.cpp Sat Dec 21 20:26:11 2024 (r22594) @@ -177,8 +177,7 @@ bool XFadeSample(ModSample &smp, SmpLength fadeLength, int fadeLaw, bool afterloopFade, bool useSustainLoop, CSoundFile &sndFile) { if(!smp.HasSampleData()) return false; - const SmpLength loopStart = useSustainLoop ? smp.nSustainStart : smp.nLoopStart; - const SmpLength loopEnd = useSustainLoop ? smp.nSustainEnd : smp.nLoopEnd; + const auto [loopStart, loopEnd] = useSustainLoop ? smp.GetSustainLoop() : smp.GetLoop(); if(loopEnd <= loopStart || loopEnd > smp.nLength) return false; if(loopStart < fadeLength) return false; Modified: branches/OpenMPT-1.31/tracklib/SampleEdit.cpp ============================================================================== --- branches/OpenMPT-1.31/tracklib/SampleEdit.cpp Sat Dec 21 17:35:48 2024 (r22593) +++ branches/OpenMPT-1.31/tracklib/SampleEdit.cpp Sat Dec 21 20:26:11 2024 (r22594) @@ -796,8 +796,7 @@ || (!smp.HasPingPongSustainLoop() && sustainLoop)) return false; - const SmpLength loopStart = sustainLoop ? smp.nSustainStart : smp.nLoopStart; - const SmpLength loopEnd = sustainLoop ? smp.nSustainEnd : smp.nLoopEnd; + const auto [loopStart, loopEnd] = sustainLoop ? smp.GetSustainLoop(): smp.GetLoop(); const SmpLength oldLoopLength = loopEnd - loopStart; const SmpLength oldLength = smp.nLength; @@ -1056,6 +1055,184 @@ return newSelEnd; } + +static constexpr int SMPLOOP_ACCURACY = 7; // 5% + +static bool LoopCheck(int sstart0, int sstart1, int send0, int send1) +{ + int dse0 = send0 - sstart0; + if((dse0 < -SMPLOOP_ACCURACY) || (dse0 > SMPLOOP_ACCURACY)) + return false; + int dse1 = send1 - sstart1; + if((dse1 < -SMPLOOP_ACCURACY) || (dse1 > SMPLOOP_ACCURACY)) + return false; + int dstart = sstart1 - sstart0; + int dend = send1 - send0; + if(!dstart) + dstart = dend >> 7; + if(!dend) + dend = dstart >> 7; + if((dstart ^ dend) < 0) + return false; + int delta = dend - dstart; + return ((delta > -SMPLOOP_ACCURACY) && (delta < SMPLOOP_ACCURACY)); +} + + +static bool BidiEndCheck(int spos0, int spos1, int spos2) +{ + int delta0 = spos1 - spos0; + int delta1 = spos2 - spos1; + int delta2 = spos2 - spos0; + if(!delta0) + delta0 = delta1 >> 7; + if(!delta1) + delta1 = delta0 >> 7; + if((delta1 ^ delta0) < 0) + return false; + return ((delta0 >= -1) && (delta0 <= 0) && (delta1 >= -1) && (delta1 <= 0) && (delta2 >= -1) && (delta2 <= 0)); +} + + +static bool BidiStartCheck(int spos0, int spos1, int spos2) +{ + int delta1 = spos1 - spos0; + int delta0 = spos2 - spos1; + int delta2 = spos2 - spos0; + if(!delta0) + delta0 = delta1 >> 7; + if(!delta1) + delta1 = delta0 >> 7; + if((delta1 ^ delta0) < 0) + return false; + return ((delta0 >= -1) && (delta0 <= 0) && (delta1 > -1) && (delta1 <= 0) && (delta2 >= -1) && (delta2 <= 0)); +} + + +SmpLength FindLoopStart(const ModSample &sample, bool sustainLoop, bool goForward, bool moveLoop) +{ + const uint8 *pSample = mpt::byte_cast<const uint8 *>(sample.sampleb()); + if(sample.uFlags[CHN_16BIT] && mpt::endian_is_little()) + pSample++; + const uint32 inc = sample.GetBytesPerSample(); + const auto [loopStart, loopEnd] = sustainLoop ? sample.GetSustainLoop() : sample.GetLoop(); + const SmpLength loopLength = loopEnd - loopStart; + const bool pingpong = sample.uFlags[sustainLoop ? CHN_PINGPONGSUSTAIN : CHN_PINGPONGLOOP]; + + const uint8 *p = pSample + loopStart * inc; + int find0 = static_cast<int>(pSample[loopEnd * inc - inc]); + int find1 = static_cast<int>(pSample[loopEnd * inc]); + if(goForward) + { + // Find Next LoopStart Point + const SmpLength searchEnd = moveLoop ? sample.nLength - loopLength : (std::max(loopEnd, SmpLength(16)) - 16); + for(SmpLength i = sample.nLoopStart + 1; i <= searchEnd; i++) + { + p += inc; + if(pingpong) + { + if(BidiStartCheck(p[0], p[inc], p[inc * 2])) + return i; + } else + { + if(moveLoop) + { + find0 = static_cast<int>(pSample[(i + loopLength - 1) * inc]); + find1 = static_cast<int>(pSample[(i + loopLength) * inc]); + } + if(LoopCheck(find0, find1, p[0], p[inc])) + return i; + } + } + } else + { + // Find Prev LoopStart Point + for(SmpLength i = sample.nLoopStart; i;) + { + i--; + p -= inc; + if(pingpong) + { + if(BidiStartCheck(p[0], p[inc], p[inc * 2])) + return i; + } else + { + if(moveLoop) + { + find0 = static_cast<int>(pSample[(i + loopLength - 1) * inc]); + find1 = static_cast<int>(pSample[(i + loopLength) * inc]); + } + if(LoopCheck(find0, find1, p[0], p[inc])) + return i; + } + } + } + return sample.nLength; +} + + +SmpLength FindLoopEnd(const ModSample &sample, bool sustainLoop, bool goForward, bool moveLoop) +{ + const uint8 *pSample = mpt::byte_cast<const uint8 *>(sample.sampleb()); + if(sample.uFlags[CHN_16BIT] && mpt::endian_is_little()) + pSample++; + const uint32 inc = sample.GetBytesPerSample(); + const auto [loopStart, loopEnd] = sustainLoop ? sample.GetSustainLoop() : sample.GetLoop(); + const SmpLength loopLength = loopEnd - loopStart; + const bool pingpong = sample.uFlags[sustainLoop ? CHN_PINGPONGSUSTAIN : CHN_PINGPONGLOOP]; + + const uint8 *p = pSample + loopEnd * inc; + int find0 = static_cast<int>(pSample[loopStart * inc]); + int find1 = static_cast<int>(pSample[loopStart * inc + inc]); + if(goForward) + { + // Find Next LoopEnd Point + for(SmpLength i = loopEnd + 1; i <= sample.nLength; i++) + { + p += inc; + if(pingpong) + { + if(BidiEndCheck(p[0], p[inc], p[inc * 2])) + return i; + } else + { + if(moveLoop) + { + find0 = static_cast<int>(pSample[(i - loopLength) * inc]); + find1 = static_cast<int>(pSample[(i - loopLength + 1) * inc]); + } + if(LoopCheck(find0, find1, p[0], p[inc])) + return i; + } + } + } else + { + // Find Prev LoopEnd Point + const SmpLength searchEnd = moveLoop ? loopLength : (loopStart + 16); + for(SmpLength i = loopEnd; i > searchEnd;) + { + i--; + p -= inc; + if(pingpong) + { + if(BidiEndCheck(p[0], p[inc], p[inc * 2])) + return i; + } else + { + if(moveLoop) + { + find0 = static_cast<int>(pSample[(i - loopLength) * inc]); + find1 = static_cast<int>(pSample[(i - loopLength + 1) * inc]); + } + if(LoopCheck(find0, find1, p[0], p[inc])) + return i; + } + } + } + return 0; +} + + } // namespace SampleEdit OPENMPT_NAMESPACE_END Modified: branches/OpenMPT-1.31/tracklib/SampleEdit.h ============================================================================== --- branches/OpenMPT-1.31/tracklib/SampleEdit.h Sat Dec 21 17:35:48 2024 (r22593) +++ branches/OpenMPT-1.31/tracklib/SampleEdit.h Sat Dec 21 20:26:11 2024 (r22594) @@ -98,6 +98,15 @@ // Returns end point of resampled data, or 0 on failure. SmpLength Resample(ModSample &smp, SmpLength start, SmpLength end, uint32 newRate, ResamplingMode mode, CSoundFile &sndFile, bool updatePatternCommands, const std::function<void()> &prepareSampleUndoFunc, const std::function<void()> &preparePatternUndoFunc); +// Find a suitable loop start going either forward or backward from the current loop start. +// If moveLoop is true, the calculations are done assuming that the loop length stays the same (i.e. the loop end is moved by the same amount). +// Returns a valid loop start less than the sample length if it was successful. +SmpLength FindLoopStart(const ModSample &sample, bool sustainLoop, bool goForward, bool moveLoop); +// Find a suitable loop end going either forward or backward from the current loop end. +// If moveLoop is true, the calculations are done assuming that the loop length stays the same (i.e. the loop start is moved by the same amount). +// Returns a valid loop end greater than 0 if it was successful. +SmpLength FindLoopEnd(const ModSample &sample, bool sustainLoop, bool goForward, bool moveLoop); + } // namespace SampleEdit OPENMPT_NAMESPACE_END |
From: <sv...@op...> - 2024-12-21 16:35:55
|
Author: sagamusix Date: Sat Dec 21 17:35:48 2024 New Revision: 22593 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22593 Log: [Ref] Remove unused variable. Modified: trunk/OpenMPT/tracklib/SampleEdit.cpp Modified: trunk/OpenMPT/tracklib/SampleEdit.cpp ============================================================================== --- trunk/OpenMPT/tracklib/SampleEdit.cpp Sat Dec 21 14:27:47 2024 (r22592) +++ trunk/OpenMPT/tracklib/SampleEdit.cpp Sat Dec 21 17:35:48 2024 (r22593) @@ -1106,8 +1106,6 @@ static constexpr int SMPLOOP_ACCURACY = 7; // 5% -static constexpr int BIDILOOP_ACCURACY = 2; // 5% - static bool LoopCheck(int sstart0, int sstart1, int send0, int send1) { |
From: <sv...@op...> - 2024-12-21 13:28:00
|
Author: sagamusix Date: Sat Dec 21 14:27:47 2024 New Revision: 22592 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22592 Log: [Imp] Pressing Ctrl while moving loop points or clicking loop start/end spin buttons now moves the loop, keeping the loop length constant. Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/soundlib/ModSample.h trunk/OpenMPT/soundlib/modsmp_ctrl.cpp trunk/OpenMPT/tracklib/SampleEdit.cpp trunk/OpenMPT/tracklib/SampleEdit.h Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp ============================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp Fri Dec 20 21:16:23 2024 (r22591) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp Sat Dec 21 14:27:47 2024 (r22592) @@ -2508,99 +2508,29 @@ } -#define SMPLOOP_ACCURACY 7 // 5% -#define BIDILOOP_ACCURACY 2 // 5% - - -bool MPT_LoopCheck(int sstart0, int sstart1, int send0, int send1) -{ - int dse0 = send0 - sstart0; - if ((dse0 < -SMPLOOP_ACCURACY) || (dse0 > SMPLOOP_ACCURACY)) return false; - int dse1 = send1 - sstart1; - if ((dse1 < -SMPLOOP_ACCURACY) || (dse1 > SMPLOOP_ACCURACY)) return false; - int dstart = sstart1 - sstart0; - int dend = send1 - send0; - if (!dstart) dstart = dend >> 7; - if (!dend) dend = dstart >> 7; - if ((dstart ^ dend) < 0) return false; - int delta = dend - dstart; - return ((delta > -SMPLOOP_ACCURACY) && (delta < SMPLOOP_ACCURACY)); -} - - -bool MPT_BidiEndCheck(int spos0, int spos1, int spos2) -{ - int delta0 = spos1 - spos0; - int delta1 = spos2 - spos1; - int delta2 = spos2 - spos0; - if (!delta0) delta0 = delta1 >> 7; - if (!delta1) delta1 = delta0 >> 7; - if ((delta1 ^ delta0) < 0) return false; - return ((delta0 >= -1) && (delta0 <= 0) && (delta1 >= -1) && (delta1 <= 0) && (delta2 >= -1) && (delta2 <= 0)); -} - - -bool MPT_BidiStartCheck(int spos0, int spos1, int spos2) -{ - int delta1 = spos1 - spos0; - int delta0 = spos2 - spos1; - int delta2 = spos2 - spos0; - if (!delta0) delta0 = delta1 >> 7; - if (!delta1) delta1 = delta0 >> 7; - if ((delta1 ^ delta0) < 0) return false; - return ((delta0 >= -1) && (delta0 <= 0) && (delta1 > -1) && (delta1 <= 0) && (delta2 >= -1) && (delta2 <= 0)); -} - - - void CCtrlSamples::OnVScroll(UINT nCode, UINT, CScrollBar *scrollBar) { - TCHAR s[256]; + TCHAR s[32]; if(IsLocked()) return; ModSample &sample = m_sndFile.GetSample(m_nSample); - const uint8 *pSample = mpt::byte_cast<const uint8 *>(sample.sampleb()); - const uint32 inc = sample.GetBytesPerSample(); - SmpLength i; - int pos; + const bool moveLoop = CMainFrame::GetInputHandler()->CtrlPressed(); bool redraw = false; static CScrollBar *lastScrollbar = nullptr; LockControls(); - if ((!sample.nLength) || (!pSample)) goto NoSample; - if (sample.uFlags[CHN_16BIT]) - { - pSample++; - } // Loop Start - if ((pos = m_SpinLoopStart.GetPos32()) != 0 && sample.nLoopEnd > 0) + if(int pos = m_SpinLoopStart.GetPos32(); pos != 0 && sample.nLoopEnd > 0 && sample.HasSampleData()) { - bool bOk = false; - const uint8 *p = pSample + sample.nLoopStart * inc; - int find0 = (int)pSample[sample.nLoopEnd*inc-inc]; - int find1 = (int)pSample[sample.nLoopEnd*inc]; - // Find Next LoopStart Point - if (pos > 0) - { - for (i = sample.nLoopStart + 1; i + 16 < sample.nLoopEnd; i++) - { - p += inc; - bOk = sample.uFlags[CHN_PINGPONGLOOP] ? MPT_BidiStartCheck(p[0], p[inc], p[inc*2]) : MPT_LoopCheck(find0, find1, p[0], p[inc]); - if (bOk) break; - } - } else - // Find Prev LoopStart Point + if(SmpLength i = SampleEdit::FindLoopStart(sample, false, pos > 0, moveLoop); i < sample.nLength) { - for (i = sample.nLoopStart; i; ) + if(!m_startedEdit && lastScrollbar != scrollBar) + PrepareUndo(moveLoop ? "Move Loop" : "Set Loop Start"); + if(moveLoop) { - i--; - p -= inc; - bOk = sample.uFlags[CHN_PINGPONGLOOP] ? MPT_BidiStartCheck(p[0], p[inc], p[inc*2]) : MPT_LoopCheck(find0, find1, p[0], p[inc]); - if (bOk) break; + sample.nLoopEnd = i + (sample.nLoopEnd - sample.nLoopStart); + wsprintf(s, _T("%u"), sample.nLoopEnd); + m_EditLoopEnd.SetWindowText(s); } - } - if (bOk) - { - if(!m_startedEdit && lastScrollbar != scrollBar) PrepareUndo("Set Loop Start"); sample.nLoopStart = i; wsprintf(s, _T("%u"), sample.nLoopStart); m_EditLoopStart.SetWindowText(s); @@ -2610,34 +2540,18 @@ m_SpinLoopStart.SetPos(0); } // Loop End - if ((pos = m_SpinLoopEnd.GetPos32()) != 0) + if(int pos = m_SpinLoopEnd.GetPos32(); pos != 0 && sample.HasSampleData()) { - bool bOk = false; - const uint8 *p = pSample + sample.nLoopEnd * inc; - int find0 = (int)pSample[sample.nLoopStart*inc]; - int find1 = (int)pSample[sample.nLoopStart*inc+inc]; - // Find Next LoopEnd Point - if (pos > 0) - { - for (i = sample.nLoopEnd + 1; i <= sample.nLength; i++, p += inc) - { - bOk = sample.uFlags[CHN_PINGPONGLOOP] ? MPT_BidiEndCheck(p[0], p[inc], p[inc*2]) : MPT_LoopCheck(find0, find1, p[0], p[inc]); - if (bOk) break; - } - } else - // Find Prev LoopEnd Point + if(SmpLength i = SampleEdit::FindLoopEnd(sample, false, pos > 0, moveLoop); i > 0) { - for (i = sample.nLoopEnd; i > sample.nLoopStart + 16; ) + if(!m_startedEdit && lastScrollbar != scrollBar) + PrepareUndo(moveLoop ? "Move Loop" : "Set Loop End"); + if(moveLoop) { - i--; - p -= inc; - bOk = sample.uFlags[CHN_PINGPONGLOOP] ? MPT_BidiEndCheck(p[0], p[inc], p[inc*2]) : MPT_LoopCheck(find0, find1, p[0], p[inc]); - if (bOk) break; + sample.nLoopStart = i - (sample.nLoopEnd - sample.nLoopStart); + wsprintf(s, _T("%u"), sample.nLoopStart); + m_EditLoopStart.SetWindowText(s); } - } - if (bOk) - { - if(!m_startedEdit && lastScrollbar != scrollBar) PrepareUndo("Set Loop End"); sample.nLoopEnd = i; wsprintf(s, _T("%u"), sample.nLoopEnd); m_EditLoopEnd.SetWindowText(s); @@ -2647,35 +2561,18 @@ m_SpinLoopEnd.SetPos(0); } // Sustain Loop Start - if ((pos = m_SpinSustainStart.GetPos32()) != 0 && sample.nSustainEnd > 0) + if(int pos = m_SpinSustainStart.GetPos32(); pos != 0 && sample.nSustainEnd > 0 && sample.HasSampleData()) { - bool bOk = false; - const uint8 *p = pSample + sample.nSustainStart * inc; - int find0 = (int)pSample[sample.nSustainEnd*inc-inc]; - int find1 = (int)pSample[sample.nSustainEnd*inc]; - // Find Next Sustain LoopStart Point - if (pos > 0) - { - for (i = sample.nSustainStart + 1; i + 16 < sample.nSustainEnd; i++) - { - p += inc; - bOk = sample.uFlags[CHN_PINGPONGSUSTAIN] ? MPT_BidiStartCheck(p[0], p[inc], p[inc*2]) : MPT_LoopCheck(find0, find1, p[0], p[inc]); - if (bOk) break; - } - } else - // Find Prev Sustain LoopStart Point + if(SmpLength i = SampleEdit::FindLoopStart(sample, true, pos > 0, moveLoop); i < sample.nLength) { - for (i = sample.nSustainStart; i; ) + if(!m_startedEdit && lastScrollbar != scrollBar) + PrepareUndo(moveLoop ? "Move Sustain Loop" : "Set Sustain Loop Start"); + if(moveLoop) { - i--; - p -= inc; - bOk = sample.uFlags[CHN_PINGPONGSUSTAIN] ? MPT_BidiStartCheck(p[0], p[inc], p[inc*2]) : MPT_LoopCheck(find0, find1, p[0], p[inc]); - if (bOk) break; + sample.nSustainEnd = i + (sample.nSustainEnd - sample.nSustainStart); + wsprintf(s, _T("%u"), sample.nSustainEnd); + m_EditSustainEnd.SetWindowText(s); } - } - if (bOk) - { - if(!m_startedEdit && lastScrollbar != scrollBar) PrepareUndo("Set Sustain Loop Start"); sample.nSustainStart = i; wsprintf(s, _T("%u"), sample.nSustainStart); m_EditSustainStart.SetWindowText(s); @@ -2685,34 +2582,18 @@ m_SpinSustainStart.SetPos(0); } // Sustain Loop End - if ((pos = m_SpinSustainEnd.GetPos32()) != 0) + if(int pos = m_SpinSustainEnd.GetPos32(); pos != 0 && sample.HasSampleData()) { - bool bOk = false; - const uint8 *p = pSample + sample.nSustainEnd * inc; - int find0 = (int)pSample[sample.nSustainStart*inc]; - int find1 = (int)pSample[sample.nSustainStart*inc+inc]; - // Find Next LoopEnd Point - if (pos > 0) - { - for (i = sample.nSustainEnd + 1; i + 1 < sample.nLength; i++, p += inc) - { - bOk = sample.uFlags[CHN_PINGPONGSUSTAIN] ? MPT_BidiEndCheck(p[0], p[inc], p[inc*2]) : MPT_LoopCheck(find0, find1, p[0], p[inc]); - if (bOk) break; - } - } else - // Find Prev LoopEnd Point + if(SmpLength i = SampleEdit::FindLoopEnd(sample, true, pos > 0, moveLoop); i > 0) { - for (i = sample.nSustainEnd; i > sample.nSustainStart + 16; ) + if(!m_startedEdit && lastScrollbar != scrollBar) + PrepareUndo(moveLoop ? "Move Sustain Loop" : "Set Sustain Loop End"); + if(moveLoop) { - i--; - p -= inc; - bOk = sample.uFlags[CHN_PINGPONGSUSTAIN] ? MPT_BidiEndCheck(p[0], p[inc], p[inc*2]) : MPT_LoopCheck(find0, find1, p[0], p[inc]); - if (bOk) break; + sample.nSustainStart = i - (sample.nSustainEnd - sample.nSustainStart); + wsprintf(s, _T("%u"), sample.nSustainStart); + m_EditSustainStart.SetWindowText(s); } - } - if (bOk) - { - if(!m_startedEdit && lastScrollbar != scrollBar) PrepareUndo("Set Sustain Loop End"); sample.nSustainEnd = i; wsprintf(s, _T("%u"), sample.nSustainEnd); m_EditSustainEnd.SetWindowText(s); @@ -2721,9 +2602,8 @@ } m_SpinSustainEnd.SetPos(0); } -NoSample: // FineTune / C-5 Speed - if ((pos = m_SpinFineTune.GetPos32()) != 0) + if(int pos = m_SpinFineTune.GetPos32(); pos != 0) { if(!m_startedEdit && lastScrollbar != scrollBar) PrepareUndo("Finetune"); @@ -2930,8 +2810,7 @@ CSampleXFadeDlg dlg(this, sample); if(dlg.DoModal() == IDOK) { - const SmpLength loopStart = dlg.m_useSustainLoop ? sample.nSustainStart: sample.nLoopStart; - const SmpLength loopEnd = dlg.m_useSustainLoop ? sample.nSustainEnd: sample.nLoopEnd; + const auto [loopStart, loopEnd] = dlg.m_useSustainLoop ? sample.GetSustainLoop() : sample.GetLoop(); const SmpLength maxSamples = std::min({ sample.nLength, loopStart, loopEnd / 2 }); SmpLength fadeSamples = dlg.PercentToSamples(dlg.m_fadeLength); LimitMax(fadeSamples, maxSamples); Modified: trunk/OpenMPT/mptrack/View_smp.cpp ============================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp Fri Dec 20 21:16:23 2024 (r22591) +++ trunk/OpenMPT/mptrack/View_smp.cpp Sat Dec 21 14:27:47 2024 (r22592) @@ -1848,9 +1848,11 @@ m_startDragValue = ScreenToSample(point.x); } + const bool moveLoop = (flags & MK_CONTROL); bool update = false; SmpLength *updateLoopPoint = nullptr; const char *updateLoopDesc = nullptr; + SmpLength loopLength = 0; switch(m_dragItem) { case HitTestItem::SelectionStart: @@ -1863,28 +1865,50 @@ } break; case HitTestItem::LoopStart: - if(x < sample.nLoopEnd) + if(moveLoop) + { + updateLoopPoint = &sample.nLoopStart; + updateLoopDesc = "Move Loop"; + loopLength = sample.nLoopEnd - sample.nLoopStart; + } else if(x < sample.nLoopEnd) { updateLoopPoint = &sample.nLoopStart; updateLoopDesc = "Set Loop Start"; } break; case HitTestItem::LoopEnd: - if(x > sample.nLoopStart) + if(moveLoop) + { + updateLoopPoint = &sample.nLoopStart; + updateLoopDesc = "Move Loop"; + loopLength = sample.nLoopEnd - sample.nLoopStart; + x = (x > loopLength) ? x - loopLength : 0; + } else if(x > sample.nLoopStart) { updateLoopPoint = &sample.nLoopEnd; updateLoopDesc = "Set Loop End"; } break; case HitTestItem::SustainStart: - if(x < sample.nSustainEnd) + if(moveLoop) + { + updateLoopPoint = &sample.nSustainStart; + updateLoopDesc = "Move Sustain Loop"; + loopLength = sample.nSustainEnd - sample.nSustainStart; + } else if(x < sample.nSustainEnd) { updateLoopPoint = &sample.nSustainStart; updateLoopDesc = "Set Sustain Start"; } break; case HitTestItem::SustainEnd: - if(x > sample.nSustainStart) + if(moveLoop) + { + updateLoopPoint = &sample.nSustainStart; + updateLoopDesc = "Move Loop"; + loopLength = sample.nSustainEnd - sample.nSustainStart; + x = (x > loopLength) ? x - loopLength : 0; + } else if(x > sample.nSustainStart) { updateLoopPoint = &sample.nSustainEnd; updateLoopDesc = "Set Sustain End"; @@ -1900,6 +1924,9 @@ break; } + if(loopLength) + LimitMax(x, sample.nLength - loopLength); + if(updateLoopPoint && updateLoopDesc && *updateLoopPoint != x) { if(!m_dragPreparedUndo) @@ -1907,6 +1934,10 @@ m_dragPreparedUndo = true; update = true; *updateLoopPoint = x; + if(loopLength && updateLoopPoint == &sample.nLoopStart) + sample.nLoopEnd = sample.nLoopStart + loopLength; + else if(loopLength && updateLoopPoint == &sample.nSustainStart) + sample.nSustainEnd = sample.nSustainStart + loopLength; sample.PrecomputeLoops(sndFile, true); SetModified(SampleHint().Info(), true, false); } @@ -2041,7 +2072,7 @@ } else { // ctrl + click = play from cursor pos - if(flags & MK_CONTROL) + if((flags & MK_CONTROL) && point.y >= m_timelineHeight) PlayNote(NOTE_MIDDLEC, ScreenToSample(point.x)); } } Modified: trunk/OpenMPT/soundlib/ModSample.h ============================================================================== --- trunk/OpenMPT/soundlib/ModSample.h Fri Dec 20 21:16:23 2024 (r22591) +++ trunk/OpenMPT/soundlib/ModSample.h Sat Dec 21 14:27:47 2024 (r22592) @@ -148,6 +148,10 @@ void SetLoop(SmpLength start, SmpLength end, bool enable, bool pingpong, CSoundFile &sndFile); // Set sustain loop points and update loop wrap-around buffer void SetSustainLoop(SmpLength start, SmpLength end, bool enable, bool pingpong, CSoundFile &sndFile); + // Retrieve the normal loop points + std::pair<SmpLength, SmpLength> GetLoop() const noexcept { return std::make_pair(nLoopStart, nLoopEnd); } + // Retrieve the sustain loop points + std::pair<SmpLength, SmpLength> GetSustainLoop() const noexcept { return std::make_pair(nSustainStart, nSustainEnd); } // Update loop wrap-around buffer void PrecomputeLoops(CSoundFile &sndFile, bool updateChannels = true); Modified: trunk/OpenMPT/soundlib/modsmp_ctrl.cpp ============================================================================== --- trunk/OpenMPT/soundlib/modsmp_ctrl.cpp Fri Dec 20 21:16:23 2024 (r22591) +++ trunk/OpenMPT/soundlib/modsmp_ctrl.cpp Sat Dec 21 14:27:47 2024 (r22592) @@ -105,8 +105,7 @@ bool XFadeSample(ModSample &smp, SmpLength fadeLength, int fadeLaw, bool afterloopFade, bool useSustainLoop, CSoundFile &sndFile) { if(!smp.HasSampleData()) return false; - const SmpLength loopStart = useSustainLoop ? smp.nSustainStart : smp.nLoopStart; - const SmpLength loopEnd = useSustainLoop ? smp.nSustainEnd : smp.nLoopEnd; + const auto [loopStart, loopEnd] = useSustainLoop ? smp.GetSustainLoop() : smp.GetLoop(); if(loopEnd <= loopStart || loopEnd > smp.nLength) return false; if(loopStart < fadeLength) return false; Modified: trunk/OpenMPT/tracklib/SampleEdit.cpp ============================================================================== --- trunk/OpenMPT/tracklib/SampleEdit.cpp Fri Dec 20 21:16:23 2024 (r22591) +++ trunk/OpenMPT/tracklib/SampleEdit.cpp Sat Dec 21 14:27:47 2024 (r22592) @@ -805,8 +805,7 @@ || (!smp.HasPingPongSustainLoop() && sustainLoop)) return false; - const SmpLength loopStart = sustainLoop ? smp.nSustainStart : smp.nLoopStart; - const SmpLength loopEnd = sustainLoop ? smp.nSustainEnd : smp.nLoopEnd; + const auto [loopStart, loopEnd] = sustainLoop ? smp.GetSustainLoop(): smp.GetLoop(); const SmpLength oldLoopLength = loopEnd - loopStart; const SmpLength oldLength = smp.nLength; @@ -1105,6 +1104,186 @@ return newSelEnd; } + +static constexpr int SMPLOOP_ACCURACY = 7; // 5% +static constexpr int BIDILOOP_ACCURACY = 2; // 5% + + +static bool LoopCheck(int sstart0, int sstart1, int send0, int send1) +{ + int dse0 = send0 - sstart0; + if((dse0 < -SMPLOOP_ACCURACY) || (dse0 > SMPLOOP_ACCURACY)) + return false; + int dse1 = send1 - sstart1; + if((dse1 < -SMPLOOP_ACCURACY) || (dse1 > SMPLOOP_ACCURACY)) + return false; + int dstart = sstart1 - sstart0; + int dend = send1 - send0; + if(!dstart) + dstart = dend >> 7; + if(!dend) + dend = dstart >> 7; + if((dstart ^ dend) < 0) + return false; + int delta = dend - dstart; + return ((delta > -SMPLOOP_ACCURACY) && (delta < SMPLOOP_ACCURACY)); +} + + +static bool BidiEndCheck(int spos0, int spos1, int spos2) +{ + int delta0 = spos1 - spos0; + int delta1 = spos2 - spos1; + int delta2 = spos2 - spos0; + if(!delta0) + delta0 = delta1 >> 7; + if(!delta1) + delta1 = delta0 >> 7; + if((delta1 ^ delta0) < 0) + return false; + return ((delta0 >= -1) && (delta0 <= 0) && (delta1 >= -1) && (delta1 <= 0) && (delta2 >= -1) && (delta2 <= 0)); +} + + +static bool BidiStartCheck(int spos0, int spos1, int spos2) +{ + int delta1 = spos1 - spos0; + int delta0 = spos2 - spos1; + int delta2 = spos2 - spos0; + if(!delta0) + delta0 = delta1 >> 7; + if(!delta1) + delta1 = delta0 >> 7; + if((delta1 ^ delta0) < 0) + return false; + return ((delta0 >= -1) && (delta0 <= 0) && (delta1 > -1) && (delta1 <= 0) && (delta2 >= -1) && (delta2 <= 0)); +} + + +SmpLength FindLoopStart(const ModSample &sample, bool sustainLoop, bool goForward, bool moveLoop) +{ + const uint8 *pSample = mpt::byte_cast<const uint8 *>(sample.sampleb()); + if(sample.uFlags[CHN_16BIT] && mpt::endian_is_little()) + pSample++; + const uint32 inc = sample.GetBytesPerSample(); + const auto [loopStart, loopEnd] = sustainLoop ? sample.GetSustainLoop() : sample.GetLoop(); + const SmpLength loopLength = loopEnd - loopStart; + const bool pingpong = sample.uFlags[sustainLoop ? CHN_PINGPONGSUSTAIN : CHN_PINGPONGLOOP]; + + const uint8 *p = pSample + loopStart * inc; + int find0 = static_cast<int>(pSample[loopEnd * inc - inc]); + int find1 = static_cast<int>(pSample[loopEnd * inc]); + if(goForward) + { + // Find Next LoopStart Point + const SmpLength searchEnd = moveLoop ? sample.nLength - loopLength : (std::max(loopEnd, SmpLength(16)) - 16); + for(SmpLength i = sample.nLoopStart + 1; i <= searchEnd; i++) + { + p += inc; + if(pingpong) + { + if(BidiStartCheck(p[0], p[inc], p[inc * 2])) + return i; + } else + { + if(moveLoop) + { + find0 = static_cast<int>(pSample[(i + loopLength - 1) * inc]); + find1 = static_cast<int>(pSample[(i + loopLength) * inc]); + } + if(LoopCheck(find0, find1, p[0], p[inc])) + return i; + } + } + } else + { + // Find Prev LoopStart Point + for(SmpLength i = sample.nLoopStart; i;) + { + i--; + p -= inc; + if(pingpong) + { + if(BidiStartCheck(p[0], p[inc], p[inc * 2])) + return i; + } else + { + if(moveLoop) + { + find0 = static_cast<int>(pSample[(i + loopLength - 1) * inc]); + find1 = static_cast<int>(pSample[(i + loopLength) * inc]); + } + if(LoopCheck(find0, find1, p[0], p[inc])) + return i; + } + } + } + return sample.nLength; +} + + +SmpLength FindLoopEnd(const ModSample &sample, bool sustainLoop, bool goForward, bool moveLoop) +{ + const uint8 *pSample = mpt::byte_cast<const uint8 *>(sample.sampleb()); + if(sample.uFlags[CHN_16BIT] && mpt::endian_is_little()) + pSample++; + const uint32 inc = sample.GetBytesPerSample(); + const auto [loopStart, loopEnd] = sustainLoop ? sample.GetSustainLoop() : sample.GetLoop(); + const SmpLength loopLength = loopEnd - loopStart; + const bool pingpong = sample.uFlags[sustainLoop ? CHN_PINGPONGSUSTAIN : CHN_PINGPONGLOOP]; + + const uint8 *p = pSample + loopEnd * inc; + int find0 = static_cast<int>(pSample[loopStart * inc]); + int find1 = static_cast<int>(pSample[loopStart * inc + inc]); + if(goForward) + { + // Find Next LoopEnd Point + for(SmpLength i = loopEnd + 1; i <= sample.nLength; i++) + { + p += inc; + if(pingpong) + { + if(BidiEndCheck(p[0], p[inc], p[inc * 2])) + return i; + } else + { + if(moveLoop) + { + find0 = static_cast<int>(pSample[(i - loopLength) * inc]); + find1 = static_cast<int>(pSample[(i - loopLength + 1) * inc]); + } + if(LoopCheck(find0, find1, p[0], p[inc])) + return i; + } + } + } else + { + // Find Prev LoopEnd Point + const SmpLength searchEnd = moveLoop ? loopLength : (loopStart + 16); + for(SmpLength i = loopEnd; i > searchEnd;) + { + i--; + p -= inc; + if(pingpong) + { + if(BidiEndCheck(p[0], p[inc], p[inc * 2])) + return i; + } else + { + if(moveLoop) + { + find0 = static_cast<int>(pSample[(i - loopLength) * inc]); + find1 = static_cast<int>(pSample[(i - loopLength + 1) * inc]); + } + if(LoopCheck(find0, find1, p[0], p[inc])) + return i; + } + } + } + return 0; +} + + } // namespace SampleEdit OPENMPT_NAMESPACE_END Modified: trunk/OpenMPT/tracklib/SampleEdit.h ============================================================================== --- trunk/OpenMPT/tracklib/SampleEdit.h Fri Dec 20 21:16:23 2024 (r22591) +++ trunk/OpenMPT/tracklib/SampleEdit.h Sat Dec 21 14:27:47 2024 (r22592) @@ -98,6 +98,15 @@ // Returns end point of resampled data, or 0 on failure. SmpLength Resample(ModSample &smp, SmpLength start, SmpLength end, uint32 newRate, ResamplingMode mode, CSoundFile &sndFile, bool updatePatternCommands, bool updatePatternNotes, const std::function<void()> &prepareSampleUndoFunc, const std::function<void()> &preparePatternUndoFunc); +// Find a suitable loop start going either forward or backward from the current loop start. +// If moveLoop is true, the calculations are done assuming that the loop length stays the same (i.e. the loop end is moved by the same amount). +// Returns a valid loop start less than the sample length if it was successful. +SmpLength FindLoopStart(const ModSample &sample, bool sustainLoop, bool goForward, bool moveLoop); +// Find a suitable loop end going either forward or backward from the current loop end. +// If moveLoop is true, the calculations are done assuming that the loop length stays the same (i.e. the loop start is moved by the same amount). +// Returns a valid loop end greater than 0 if it was successful. +SmpLength FindLoopEnd(const ModSample &sample, bool sustainLoop, bool goForward, bool moveLoop); + } // namespace SampleEdit OPENMPT_NAMESPACE_END |
From: <sv...@op...> - 2024-12-20 20:16:31
|
Author: sagamusix Date: Fri Dec 20 21:16:23 2024 New Revision: 22591 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22591 Log: [Imp] MO3: Import dummy command W (XM). Modified: trunk/OpenMPT/soundlib/Load_mo3.cpp Modified: trunk/OpenMPT/soundlib/Load_mo3.cpp ============================================================================== --- trunk/OpenMPT/soundlib/Load_mo3.cpp Fri Dec 20 18:00:03 2024 (r22590) +++ trunk/OpenMPT/soundlib/Load_mo3.cpp Fri Dec 20 21:16:23 2024 (r22591) @@ -1078,7 +1078,7 @@ CMD_PORTAMENTOUP, CMD_TREMOR, CMD_RETRIG, CMD_FINEVIBRATO, CMD_CHANNELVOLUME, CMD_CHANNELVOLSLIDE, CMD_PANNINGSLIDE, CMD_S3MCMDEX, CMD_TEMPO, CMD_GLOBALVOLSLIDE, CMD_PANBRELLO, CMD_MIDI, - CMD_NONE,/*FineVolSld*/ CMD_NONE,/*PortaDown*/ CMD_NONE, /*PortaUp*/ CMD_NONE, + CMD_NONE,/*FineVolSld*/ CMD_NONE,/*PortaDown*/ CMD_NONE, /*PortaUp*/ CMD_DUMMY, CMD_NONE,/*ITVolCol*/ CMD_XPARAM, CMD_SMOOTHMIDI, CMD_DELAYCUT, CMD_FINETUNE, CMD_FINETUNE_SMOOTH, }; |
From: <sv...@op...> - 2024-12-20 17:00:11
|
Author: sagamusix Date: Fri Dec 20 18:00:03 2024 New Revision: 22590 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22590 Log: [Fix] Fix formatting of volume-column volume slide up command parameters (patch by cs127, https://github.com/OpenMPT/openmpt/pull/31). Modified: trunk/OpenMPT/mptrack/EffectInfo.cpp Modified: trunk/OpenMPT/mptrack/EffectInfo.cpp ============================================================================== --- trunk/OpenMPT/mptrack/EffectInfo.cpp Fri Dec 20 13:42:28 2024 (r22589) +++ trunk/OpenMPT/mptrack/EffectInfo.cpp Fri Dec 20 18:00:03 2024 (r22590) @@ -1050,7 +1050,7 @@ case VOLCMD_FINEVOLDOWN: if(m.vol > 0 || sndFile.GetType() == MOD_TYPE_XM) { - *s = (m.volcmd == VOLCMD_VOLSLIDEUP || m.volcmd == VOLCMD_FINEVOLUP) ? _T('+') : _T('-') + *s = ((m.volcmd == VOLCMD_VOLSLIDEUP || m.volcmd == VOLCMD_FINEVOLUP) ? _T('+') : _T('-')) + volume; } else { |
From: <sv...@op...> - 2024-12-20 12:42:39
|
Author: manx Date: Fri Dec 20 13:42:28 2024 New Revision: 22589 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22589 Log: [Ref] mpt/string/buffer.hpp: Make mpt::charbuf more constexpr-friendly. Modified: trunk/OpenMPT/src/mpt/string/buffer.hpp Modified: trunk/OpenMPT/src/mpt/string/buffer.hpp ============================================================================== --- trunk/OpenMPT/src/mpt/string/buffer.hpp Fri Dec 20 13:32:43 2024 (r22588) +++ trunk/OpenMPT/src/mpt/string/buffer.hpp Fri Dec 20 13:42:28 2024 (r22589) @@ -6,7 +6,6 @@ #include "mpt/base/detect.hpp" -#include "mpt/base/macros.hpp" #include "mpt/base/namespace.hpp" #include "mpt/base/saturate_cast.hpp" #include "mpt/detect/mfc.hpp" @@ -308,11 +307,13 @@ } public: - Tchar buf[len]; + Tchar buf[len]{}; public: - MPT_CONSTEXPR20_FUN charbuf() { - std::fill(std::begin(buf), std::end(buf), char_constants<Tchar>::null); + constexpr charbuf() { + for (std::size_t i = 0; i < len; ++i) { + buf[i] = char_constants<Tchar>::null; + } } constexpr charbuf(const charbuf &) = default; constexpr charbuf(charbuf &&) = default; |
From: <sv...@op...> - 2024-12-20 12:32:55
|
Author: manx Date: Fri Dec 20 13:32:43 2024 New Revision: 22588 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22588 Log: [Ref] mpt/base/array.hpp: Add constexpr-friendly mpt::generate_array(). Modified: trunk/OpenMPT/src/mpt/base/array.hpp Modified: trunk/OpenMPT/src/mpt/base/array.hpp ============================================================================== --- trunk/OpenMPT/src/mpt/base/array.hpp Fri Dec 20 13:15:31 2024 (r22587) +++ trunk/OpenMPT/src/mpt/base/array.hpp Fri Dec 20 13:32:43 2024 (r22588) @@ -74,6 +74,16 @@ } +template <typename T, std::size_t N, typename Fgen> +constexpr std::array<T, N> generate_array(Fgen generator) { + std::array<T, N> result{}; + for (std::size_t i = 0; i < N; ++i) { + result[i] = generator(i); + } + return result; +} + + } // namespace MPT_INLINE_NS } // namespace mpt |
From: <sv...@op...> - 2024-12-20 12:15:47
|
Author: manx Date: Fri Dec 20 13:15:31 2024 New Revision: 22587 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22587 Log: [Ref] mpt/base/macros.hpp: Add MPT_CONSTEXPR23_FUN and MPT_CONSTEXPR23_VAR. Modified: trunk/OpenMPT/src/mpt/base/macros.hpp Modified: trunk/OpenMPT/src/mpt/base/macros.hpp ============================================================================== --- trunk/OpenMPT/src/mpt/base/macros.hpp Fri Dec 20 13:09:16 2024 (r22586) +++ trunk/OpenMPT/src/mpt/base/macros.hpp Fri Dec 20 13:15:31 2024 (r22587) @@ -30,14 +30,25 @@ // constexpr + #define MPT_CONSTEXPRINLINE constexpr MPT_FORCEINLINE -#if MPT_CXX_AT_LEAST(20) + +#if MPT_CXX_AT_LEAST(23) +#define MPT_CONSTEXPR20_FUN constexpr MPT_FORCEINLINE +#define MPT_CONSTEXPR20_VAR constexpr +#define MPT_CONSTEXPR23_FUN constexpr MPT_FORCEINLINE +#define MPT_CONSTEXPR23_VAR constexpr +#elif MPT_CXX_AT_LEAST(20) #define MPT_CONSTEXPR20_FUN constexpr MPT_FORCEINLINE #define MPT_CONSTEXPR20_VAR constexpr -#else // !C++20 +#define MPT_CONSTEXPR23_FUN MPT_FORCEINLINE +#define MPT_CONSTEXPR23_VAR const +#else // C++ #define MPT_CONSTEXPR20_FUN MPT_FORCEINLINE #define MPT_CONSTEXPR20_VAR const -#endif // C++20 +#define MPT_CONSTEXPR23_FUN MPT_FORCEINLINE +#define MPT_CONSTEXPR23_VAR const +#endif // C++ |
From: <sv...@op...> - 2024-12-20 12:09:40
|
Author: manx Date: Fri Dec 20 13:09:16 2024 New Revision: 22586 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22586 Log: [Fix] mpt/string/buffer.hpp: Add missing include. Modified: trunk/OpenMPT/src/mpt/string/buffer.hpp Modified: trunk/OpenMPT/src/mpt/string/buffer.hpp ============================================================================== --- trunk/OpenMPT/src/mpt/string/buffer.hpp Fri Dec 20 09:23:41 2024 (r22585) +++ trunk/OpenMPT/src/mpt/string/buffer.hpp Fri Dec 20 13:09:16 2024 (r22586) @@ -6,6 +6,7 @@ #include "mpt/base/detect.hpp" +#include "mpt/base/macros.hpp" #include "mpt/base/namespace.hpp" #include "mpt/base/saturate_cast.hpp" #include "mpt/detect/mfc.hpp" |
From: <sv...@op...> - 2024-12-20 08:23:53
|
Author: sagamusix Date: Fri Dec 20 09:23:41 2024 New Revision: 22585 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22585 Log: [Fix] Remove more constexpr. Android won't have it. Modified: trunk/OpenMPT/soundlib/ModInstrument.h Modified: trunk/OpenMPT/soundlib/ModInstrument.h ============================================================================== --- trunk/OpenMPT/soundlib/ModInstrument.h Thu Dec 19 22:59:15 2024 (r22584) +++ trunk/OpenMPT/soundlib/ModInstrument.h Fri Dec 20 09:23:41 2024 (r22585) @@ -135,13 +135,13 @@ } // Assign all notes to a given sample. - MPT_CONSTEXPR20_FUN void AssignSample(SAMPLEINDEX sample) + void AssignSample(SAMPLEINDEX sample) { Keyboard.fill(sample); } // Reset note mapping (i.e. every note is mapped to itself) - MPT_CONSTEXPR20_FUN void ResetNoteMap() + void ResetNoteMap() { std::iota(NoteMap.begin(), NoteMap.end(), static_cast<uint8>(NOTE_MIN)); } |
From: <sv...@op...> - 2024-12-19 21:59:26
|
Author: sagamusix Date: Thu Dec 19 22:59:15 2024 New Revision: 22584 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22584 Log: [Fix] Remove constexpr ModInstrument constructor again for now. clang builds aren't happy. Modified: trunk/OpenMPT/soundlib/ModInstrument.h Modified: trunk/OpenMPT/soundlib/ModInstrument.h ============================================================================== --- trunk/OpenMPT/soundlib/ModInstrument.h Thu Dec 19 21:40:05 2024 (r22583) +++ trunk/OpenMPT/soundlib/ModInstrument.h Thu Dec 19 22:59:15 2024 (r22584) @@ -128,7 +128,7 @@ // WHEN adding new members here, ALSO update InstrumentExtensions.cpp // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - MPT_CONSTEXPR20_FUN explicit ModInstrument(SAMPLEINDEX sample = 0) + explicit ModInstrument(SAMPLEINDEX sample = 0) { AssignSample(sample); ResetNoteMap(); |
From: <sv...@op...> - 2024-12-19 20:40:12
|
Author: sagamusix Date: Thu Dec 19 21:40:05 2024 New Revision: 22583 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22583 Log: [Imp] Improve MPTM read/write tests to include a test tuning and long envelopes with differing sizes. Modified: trunk/OpenMPT/test/test.cpp trunk/OpenMPT/test/test.mptm Modified: trunk/OpenMPT/test/test.cpp ============================================================================== --- trunk/OpenMPT/test/test.cpp Thu Dec 19 21:16:11 2024 (r22582) +++ trunk/OpenMPT/test/test.cpp Thu Dec 19 21:40:05 2024 (r22583) @@ -3144,7 +3144,10 @@ VERIFY_EQUAL_NONCONT(pIns->wMidiBank, 2); VERIFY_EQUAL_NONCONT(pIns->midiPWD, -1); - VERIFY_EQUAL_NONCONT(pIns->pTuning, nullptr); + if(ins == 1) + VERIFY_EQUAL_NONCONT(pIns->pTuning, nullptr); + else + VERIFY_EQUAL_NONCONT(pIns->pTuning->GetName(), UL_("Test Tuning")); VERIFY_EQUAL_NONCONT(pIns->pitchToTempoLock, TEMPO(130, 2000)); @@ -3163,13 +3166,20 @@ VERIFY_EQUAL_NONCONT(pIns->VolEnv[2].tick, 96); VERIFY_EQUAL_NONCONT(pIns->VolEnv[2].value, 0); - VERIFY_EQUAL_NONCONT(pIns->PanEnv.dwFlags, ENV_LOOP); - VERIFY_EQUAL_NONCONT(pIns->PanEnv.size(), 76); - VERIFY_EQUAL_NONCONT(pIns->PanEnv.nLoopStart, 22); + VERIFY_EQUAL_NONCONT(pIns->PanEnv.dwFlags, ENV_LOOP | ENV_SUSTAIN); + VERIFY_EQUAL_NONCONT(pIns->PanEnv.size(), (ins == 1) ? 74u : 76u); + VERIFY_EQUAL_NONCONT(pIns->PanEnv.nLoopStart, 26); VERIFY_EQUAL_NONCONT(pIns->PanEnv.nLoopEnd, 29); + VERIFY_EQUAL_NONCONT(pIns->PanEnv.nSustainStart, 27); + VERIFY_EQUAL_NONCONT(pIns->PanEnv.nSustainEnd, 28); VERIFY_EQUAL_NONCONT(pIns->PanEnv.nReleaseNode, ENV_RELEASE_NODE_UNSET); - VERIFY_EQUAL_NONCONT(pIns->PanEnv[75].tick, 427); - VERIFY_EQUAL_NONCONT(pIns->PanEnv[75].value, 27); + VERIFY_EQUAL_NONCONT(pIns->PanEnv[73].tick, 417); + VERIFY_EQUAL_NONCONT(pIns->PanEnv[73].value, 23); + if(ins == 2) + { + VERIFY_EQUAL_NONCONT(pIns->PanEnv[75].tick, 427); + VERIFY_EQUAL_NONCONT(pIns->PanEnv[75].value, 27); + } VERIFY_EQUAL_NONCONT(pIns->PitchEnv.dwFlags, ENV_ENABLED | ENV_CARRY | ENV_SUSTAIN | ENV_FILTER); VERIFY_EQUAL_NONCONT(pIns->PitchEnv.size(), 3); Modified: trunk/OpenMPT/test/test.mptm ============================================================================== Binary file (source and/or target). No diff available. |
From: <sv...@op...> - 2024-12-19 20:16:23
|
Author: sagamusix Date: Thu Dec 19 21:16:11 2024 New Revision: 22582 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22582 Log: [Fix] Write the correct amount of padding when some envelopes are longer than 25 points. Modified: trunk/OpenMPT/soundlib/InstrumentExtensions.cpp Modified: trunk/OpenMPT/soundlib/InstrumentExtensions.cpp ============================================================================== --- trunk/OpenMPT/soundlib/InstrumentExtensions.cpp Thu Dec 19 21:11:37 2024 (r22581) +++ trunk/OpenMPT/soundlib/InstrumentExtensions.cpp Thu Dec 19 21:16:11 2024 (r22582) @@ -245,7 +245,7 @@ mpt::IO::WriteIntLE(file, static_cast<uint8>(env[i].value)); } // Not every instrument's envelope will be the same length. fill up with zeros. - uint16le padding{}; + uint8 padding{}; for(uint32 i = maxNodes; i < nodes; ++i) { mpt::IO::Write(file, padding); |
From: <sv...@op...> - 2024-12-19 20:11:49
|
Author: sagamusix Date: Thu Dec 19 21:11:37 2024 New Revision: 22581 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22581 Log: [Ref] Use IsPropertyNeeded for pitch/tempo lock. Modified: trunk/OpenMPT/soundlib/InstrumentExtensions.cpp Modified: trunk/OpenMPT/soundlib/InstrumentExtensions.cpp ============================================================================== --- trunk/OpenMPT/soundlib/InstrumentExtensions.cpp Thu Dec 19 21:03:22 2024 (r22580) +++ trunk/OpenMPT/soundlib/InstrumentExtensions.cpp Thu Dec 19 21:11:37 2024 (r22581) @@ -196,7 +196,7 @@ struct PropertyWriterEnvelopeBase { PropertyWriterEnvelopeBase(uint32 nodes, EnvelopeType type) : nodes{nodes}, type{type} {} - static bool IsPropertyNeeded(const ModInstrument&) noexcept + static bool IsPropertyNeeded(const ModInstrument &) noexcept { return true; } @@ -255,7 +255,7 @@ struct PropertyWriterPitchTempoLock { - static bool IsPropertyNeeded(const ModInstrument &ins) noexcept { return DEFAULT_INSTRUMENT.pitchToTempoLock != ins.pitchToTempoLock; } + static constexpr auto IsPropertyNeeded = IsPropertyNonDefault<&ModInstrument::pitchToTempoLock>; static constexpr uint16 Size() noexcept { return sizeof(uint16le); } PropertyWriterPitchTempoLock(bool intPart) : m_intPart{intPart} {} void Write(std::ostream &file, const ModInstrument &ins) |
From: <sv...@op...> - 2024-12-19 20:03:28
|
Author: sagamusix Date: Thu Dec 19 21:03:22 2024 New Revision: 22580 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22580 Log: [Ref] Make ModInstrument constexpr-constructable. This will allow an instrument extension writer implementation without a global constant ModInstrument object once C++17 support is dropped. Modified: trunk/OpenMPT/soundlib/ModInstrument.cpp trunk/OpenMPT/soundlib/ModInstrument.h trunk/OpenMPT/src/mpt/string/buffer.hpp Modified: trunk/OpenMPT/soundlib/ModInstrument.cpp ============================================================================== --- trunk/OpenMPT/soundlib/ModInstrument.cpp Thu Dec 19 19:40:32 2024 (r22579) +++ trunk/OpenMPT/soundlib/ModInstrument.cpp Thu Dec 19 21:03:22 2024 (r22580) @@ -152,18 +152,6 @@ } -ModInstrument::ModInstrument(SAMPLEINDEX sample) -{ - SetCutoff(0, false); - SetResonance(0, false); - - pitchToTempoLock.Set(0); - - AssignSample(sample); - ResetNoteMap(); -} - - // Translate instrument properties between two given formats. void ModInstrument::Convert(MODTYPE fromType, MODTYPE toType) { Modified: trunk/OpenMPT/soundlib/ModInstrument.h ============================================================================== --- trunk/OpenMPT/soundlib/ModInstrument.h Thu Dec 19 19:40:32 2024 (r22579) +++ trunk/OpenMPT/soundlib/ModInstrument.h Thu Dec 19 21:03:22 2024 (r22580) @@ -35,8 +35,8 @@ tick_t tick = 0; // Envelope node position (x axis) value_t value = 0; // Envelope node value (y axis) - EnvelopeNode() { } - EnvelopeNode(tick_t tick, value_t value) : tick(tick), value(value) { } + constexpr EnvelopeNode() = default; + constexpr EnvelopeNode(tick_t tick, value_t value) : tick{tick}, value{value} { } bool operator== (const EnvelopeNode &other) const { return tick == other.tick && value == other.value; } }; @@ -128,16 +128,20 @@ // WHEN adding new members here, ALSO update InstrumentExtensions.cpp // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - explicit ModInstrument(SAMPLEINDEX sample = 0); + MPT_CONSTEXPR20_FUN explicit ModInstrument(SAMPLEINDEX sample = 0) + { + AssignSample(sample); + ResetNoteMap(); + } // Assign all notes to a given sample. - void AssignSample(SAMPLEINDEX sample) + MPT_CONSTEXPR20_FUN void AssignSample(SAMPLEINDEX sample) { Keyboard.fill(sample); } // Reset note mapping (i.e. every note is mapped to itself) - void ResetNoteMap() + MPT_CONSTEXPR20_FUN void ResetNoteMap() { std::iota(NoteMap.begin(), NoteMap.end(), static_cast<uint8>(NOTE_MIN)); } @@ -149,23 +153,23 @@ // Transpose entire note mapping by given number of semitones void Transpose(int8 amount); - bool IsCutoffEnabled() const { return (nIFC & 0x80) != 0; } - bool IsResonanceEnabled() const { return (nIFR & 0x80) != 0; } - uint8 GetCutoff() const { return (nIFC & 0x7F); } - uint8 GetResonance() const { return (nIFR & 0x7F); } - void SetCutoff(uint8 cutoff, bool enable) { nIFC = std::min(cutoff, uint8(0x7F)) | (enable ? 0x80 : 0x00); } - void SetResonance(uint8 resonance, bool enable) { nIFR = std::min(resonance, uint8(0x7F)) | (enable ? 0x80 : 0x00); } + MPT_CONSTEXPRINLINE bool IsCutoffEnabled() const { return (nIFC & 0x80) != 0; } + MPT_CONSTEXPRINLINE bool IsResonanceEnabled() const { return (nIFR & 0x80) != 0; } + MPT_CONSTEXPRINLINE uint8 GetCutoff() const { return (nIFC & 0x7F); } + MPT_CONSTEXPRINLINE uint8 GetResonance() const { return (nIFR & 0x7F); } + MPT_CONSTEXPRINLINE void SetCutoff(uint8 cutoff, bool enable) { nIFC = std::min(cutoff, uint8(0x7F)) | (enable ? 0x80 : 0x00); } + MPT_CONSTEXPRINLINE void SetResonance(uint8 resonance, bool enable) { nIFR = std::min(resonance, uint8(0x7F)) | (enable ? 0x80 : 0x00); } - bool HasValidMIDIChannel() const { return (nMidiChannel >= 1 && nMidiChannel <= 17); } + MPT_CONSTEXPRINLINE bool HasValidMIDIChannel() const { return (nMidiChannel >= 1 && nMidiChannel <= 17); } uint8 GetMIDIChannel(const ModChannel &channel, CHANNELINDEX chn) const; - void SetTuning(CTuning *pT) + MPT_CONSTEXPRINLINE void SetTuning(CTuning *pT) { pTuning = pT; } // Get a reference to a specific envelope of this instrument - const InstrumentEnvelope &GetEnvelope(EnvelopeType envType) const + MPT_CONSTEXPRINLINE const InstrumentEnvelope &GetEnvelope(EnvelopeType envType) const { switch(envType) { Modified: trunk/OpenMPT/src/mpt/string/buffer.hpp ============================================================================== --- trunk/OpenMPT/src/mpt/string/buffer.hpp Thu Dec 19 19:40:32 2024 (r22579) +++ trunk/OpenMPT/src/mpt/string/buffer.hpp Thu Dec 19 21:03:22 2024 (r22580) @@ -310,13 +310,13 @@ Tchar buf[len]; public: - charbuf() { + MPT_CONSTEXPR20_FUN charbuf() { std::fill(std::begin(buf), std::end(buf), char_constants<Tchar>::null); } - charbuf(const charbuf &) = default; - charbuf(charbuf &&) = default; - charbuf & operator=(const charbuf &) = default; - charbuf & operator=(charbuf &&) = default; + constexpr charbuf(const charbuf &) = default; + constexpr charbuf(charbuf &&) = default; + constexpr charbuf & operator=(const charbuf &) = default; + constexpr charbuf & operator=(charbuf &&) = default; const Tchar & operator[](std::size_t i) const { return buf[i]; } |
From: <sv...@op...> - 2024-12-19 18:40:44
|
Author: sagamusix Date: Thu Dec 19 19:40:32 2024 New Revision: 22579 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22579 Log: [Fix] Silence another warning. Modified: trunk/OpenMPT/soundlib/InstrumentExtensions.cpp Modified: trunk/OpenMPT/soundlib/InstrumentExtensions.cpp ============================================================================== --- trunk/OpenMPT/soundlib/InstrumentExtensions.cpp Thu Dec 19 19:31:32 2024 (r22578) +++ trunk/OpenMPT/soundlib/InstrumentExtensions.cpp Thu Dec 19 19:40:32 2024 (r22579) @@ -140,6 +140,7 @@ { #if MPT_COMPILER_CLANG #pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wglobal-constructors" #pragma clang diagnostic ignored "-Wexit-time-destructors" #endif // MPT_COMPILER_CLANG const ModInstrument DEFAULT_INSTRUMENT; |
From: <sv...@op...> - 2024-12-19 18:31:44
|
Author: sagamusix Date: Thu Dec 19 19:31:32 2024 New Revision: 22578 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22578 Log: [Ref] Go back to using a single default instrument instance. This generates much better code that doesn't instantiate and destroy potentially hundreds of ModInstruments while saving instrument extensions. Modified: trunk/OpenMPT/soundlib/InstrumentExtensions.cpp Modified: trunk/OpenMPT/soundlib/InstrumentExtensions.cpp ============================================================================== --- trunk/OpenMPT/soundlib/InstrumentExtensions.cpp Thu Dec 19 19:11:15 2024 (r22577) +++ trunk/OpenMPT/soundlib/InstrumentExtensions.cpp Thu Dec 19 19:31:32 2024 (r22578) @@ -136,8 +136,20 @@ #ifndef MODPLUG_NO_FILESAVE +namespace +{ +#if MPT_COMPILER_CLANG +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wexit-time-destructors" +#endif // MPT_COMPILER_CLANG + const ModInstrument DEFAULT_INSTRUMENT; +#if MPT_COMPILER_CLANG +#pragma clang diagnostic pop +#endif // MPT_COMPILER_CLANG +} // namespace + template <auto Member> -constexpr bool IsPropertyNonDefault(const ModInstrument &ins) { return ModInstrument{}.*Member != ins.*Member; } +constexpr bool IsPropertyNonDefault(const ModInstrument &ins) { return DEFAULT_INSTRUMENT.*Member != ins.*Member; } template <auto Member> constexpr uint16 PropertySize() noexcept { return sizeof(ModInstrument{}.*Member); } @@ -174,7 +186,7 @@ struct PropertyWriterReleaseNode { - bool IsPropertyNeeded(const ModInstrument &ins) const noexcept { return ModInstrument{}.GetEnvelope(type).nReleaseNode != ins.GetEnvelope(type).nReleaseNode; } + bool IsPropertyNeeded(const ModInstrument &ins) const noexcept { return DEFAULT_INSTRUMENT.GetEnvelope(type).nReleaseNode != ins.GetEnvelope(type).nReleaseNode; } static constexpr uint16 Size() noexcept { return sizeof(InstrumentEnvelope{}.nReleaseNode); } void Write(std::ostream &file, const ModInstrument &ins) const { mpt::IO::WriteIntLE(file, ins.GetEnvelope(type).nReleaseNode); } const EnvelopeType type; @@ -242,7 +254,7 @@ struct PropertyWriterPitchTempoLock { - static bool IsPropertyNeeded(const ModInstrument &ins) noexcept { return ModInstrument{}.pitchToTempoLock != ins.pitchToTempoLock; } + static bool IsPropertyNeeded(const ModInstrument &ins) noexcept { return DEFAULT_INSTRUMENT.pitchToTempoLock != ins.pitchToTempoLock; } static constexpr uint16 Size() noexcept { return sizeof(uint16le); } PropertyWriterPitchTempoLock(bool intPart) : m_intPart{intPart} {} void Write(std::ostream &file, const ModInstrument &ins) @@ -269,10 +281,9 @@ return; mpt::IO::WriteIntLE<uint32>(f, code); mpt::IO::WriteIntLE<uint16>(f, property.Size()); - ModInstrument defaultInstr{}; for(const ModInstrument *ins : instruments) { - property.Write(f, ins ? *ins : defaultInstr); + property.Write(f, ins ? *ins : DEFAULT_INSTRUMENT); } } |
From: <sv...@op...> - 2024-12-19 18:11:27
|
Author: sagamusix Date: Thu Dec 19 19:11:15 2024 New Revision: 22577 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22577 Log: [Ref] Remove CSoundFile::GetDefaultTuning. Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/ModInstrument.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/test/test.cpp Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp ============================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp Thu Dec 19 19:03:17 2024 (r22576) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp Thu Dec 19 19:11:15 2024 (r22577) @@ -2965,7 +2965,7 @@ Reporting::Notification(MPT_CFORMAT("Tuning {} was not found. Setting to default tuning.")(mpt::ToCString(m_sndFile.Instruments[m_nInstrument]->pTuning->GetName()))); CriticalSection cs; - pIns->SetTuning(m_sndFile.GetDefaultTuning()); + pIns->SetTuning(nullptr); m_modDoc.SetModified(); } Modified: trunk/OpenMPT/soundlib/Load_it.cpp ============================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp Thu Dec 19 19:03:17 2024 (r22576) +++ trunk/OpenMPT/soundlib/Load_it.cpp Thu Dec 19 19:11:15 2024 (r22577) @@ -262,13 +262,13 @@ #endif // MODPLUG_TRACKER } - csf.Instruments[i]->pTuning = csf.GetDefaultTuning(); + csf.Instruments[i]->pTuning = nullptr; } else { //This 'else' happens probably only in case of corrupted file. if(csf.Instruments[i]) - csf.Instruments[i]->pTuning = csf.GetDefaultTuning(); + csf.Instruments[i]->pTuning = nullptr; } } Modified: trunk/OpenMPT/soundlib/ModInstrument.cpp ============================================================================== --- trunk/OpenMPT/soundlib/ModInstrument.cpp Thu Dec 19 19:03:17 2024 (r22576) +++ trunk/OpenMPT/soundlib/ModInstrument.cpp Thu Dec 19 19:11:15 2024 (r22577) @@ -159,8 +159,6 @@ pitchToTempoLock.Set(0); - pTuning = CSoundFile::GetDefaultTuning(); - AssignSample(sample); ResetNoteMap(); } Modified: trunk/OpenMPT/soundlib/Sndfile.h ============================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h Thu Dec 19 19:03:17 2024 (r22576) +++ trunk/OpenMPT/soundlib/Sndfile.h Thu Dec 19 19:11:15 2024 (r22577) @@ -409,7 +409,6 @@ //Tuning--> public: static std::unique_ptr<CTuning> CreateTuning12TET(const mpt::ustring &name); - static CTuning *GetDefaultTuning() {return nullptr;} CTuningCollection& GetTuneSpecificTunings() {return *m_pTuningsTuneSpecific;} mpt::ustring GetNoteName(const ModCommand::NOTE note, const INSTRUMENTINDEX inst, const NoteName *noteNames = nullptr) const; Modified: trunk/OpenMPT/test/test.cpp ============================================================================== --- trunk/OpenMPT/test/test.cpp Thu Dec 19 19:03:17 2024 (r22576) +++ trunk/OpenMPT/test/test.cpp Thu Dec 19 19:11:15 2024 (r22577) @@ -2823,7 +2823,7 @@ VERIFY_EQUAL_NONCONT(pIns->wMidiBank, 2); VERIFY_EQUAL_NONCONT(pIns->midiPWD, 8); - VERIFY_EQUAL_NONCONT(pIns->pTuning, sndFile.GetDefaultTuning()); + VERIFY_EQUAL_NONCONT(pIns->pTuning, nullptr); VERIFY_EQUAL_NONCONT(pIns->pitchToTempoLock, TEMPO(0, 0)); @@ -3144,7 +3144,7 @@ VERIFY_EQUAL_NONCONT(pIns->wMidiBank, 2); VERIFY_EQUAL_NONCONT(pIns->midiPWD, -1); - VERIFY_EQUAL_NONCONT(pIns->pTuning, sndFile.GetDefaultTuning()); + VERIFY_EQUAL_NONCONT(pIns->pTuning, nullptr); VERIFY_EQUAL_NONCONT(pIns->pitchToTempoLock, TEMPO(130, 2000)); |
From: <sv...@op...> - 2024-12-19 18:03:31
|
Author: sagamusix Date: Thu Dec 19 19:03:17 2024 New Revision: 22576 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22576 Log: [Fix] Instrument Extensions: Condition when to always write pitch wheel depth was inverted. Modified: trunk/OpenMPT/soundlib/InstrumentExtensions.cpp Modified: trunk/OpenMPT/soundlib/InstrumentExtensions.cpp ============================================================================== --- trunk/OpenMPT/soundlib/InstrumentExtensions.cpp Thu Dec 19 10:18:34 2024 (r22575) +++ trunk/OpenMPT/soundlib/InstrumentExtensions.cpp Thu Dec 19 19:03:17 2024 (r22576) @@ -301,7 +301,7 @@ WriteProperty(f, MagicBE("FO.."), instruments, PropertyWriterInt<&ModInstrument::nFadeOut>{[](const ModInstrument &ins) { return (ins.nFadeOut % 32u) || ins.nFadeOut > 8192; }}); // XM instrument headers already have support for this // Note: For ITI we always want to write this property, hence the allInstruments check - int32 prevPWD = allInstruments ? int32_max : int32_min; + int32 prevPWD = allInstruments ? int32_min : int32_max; WriteProperty(f, MagicBE("MPWD"), instruments, PropertyWriterInt<&ModInstrument::midiPWD, std::function<bool(const ModInstrument &)>>{[&prevPWD](const ModInstrument& ins) { if((prevPWD != int32_min && ins.midiPWD != prevPWD) || (ins.midiPWD < 0)) |
From: <sv...@op...> - 2024-12-19 09:18:41
|
Author: manx Date: Thu Dec 19 10:18:34 2024 New Revision: 22575 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22575 Log: [Fix] Do not use rvalue reference for sink parameter with default argument. Modified: trunk/OpenMPT/soundlib/InstrumentExtensions.cpp Modified: trunk/OpenMPT/soundlib/InstrumentExtensions.cpp ============================================================================== --- trunk/OpenMPT/soundlib/InstrumentExtensions.cpp Thu Dec 19 10:13:39 2024 (r22574) +++ trunk/OpenMPT/soundlib/InstrumentExtensions.cpp Thu Dec 19 10:18:34 2024 (r22575) @@ -148,7 +148,7 @@ PropertyNeededFunc IsPropertyNeeded; static constexpr auto Size = PropertySizeFunc; - PropertyWriterBase(PropertyNeededFunc &&propertyNeededFunc = IsPropertyNonDefault<Member>) + PropertyWriterBase(PropertyNeededFunc propertyNeededFunc = IsPropertyNonDefault<Member>) : IsPropertyNeeded{std::move(propertyNeededFunc)} { } }; |
From: <sv...@op...> - 2024-12-19 09:13:51
|
Author: manx Date: Thu Dec 19 10:13:39 2024 New Revision: 22574 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22574 Log: [Fix] Remove superfluous semicolon. Modified: trunk/OpenMPT/soundlib/InstrumentExtensions.cpp Modified: trunk/OpenMPT/soundlib/InstrumentExtensions.cpp ============================================================================== --- trunk/OpenMPT/soundlib/InstrumentExtensions.cpp Thu Dec 19 10:11:38 2024 (r22573) +++ trunk/OpenMPT/soundlib/InstrumentExtensions.cpp Thu Dec 19 10:13:39 2024 (r22574) @@ -182,7 +182,7 @@ struct PropertyWriterEnvelopeBase { - PropertyWriterEnvelopeBase(uint32 nodes, EnvelopeType type) : nodes{nodes}, type{type} {}; + PropertyWriterEnvelopeBase(uint32 nodes, EnvelopeType type) : nodes{nodes}, type{type} {} static bool IsPropertyNeeded(const ModInstrument&) noexcept { return true; |
From: <sv...@op...> - 2024-12-19 09:11:51
|
Author: manx Date: Thu Dec 19 10:11:38 2024 New Revision: 22573 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22573 Log: [Fix] Compile fix. Modified: trunk/OpenMPT/soundlib/InstrumentExtensions.cpp Modified: trunk/OpenMPT/soundlib/InstrumentExtensions.cpp ============================================================================== --- trunk/OpenMPT/soundlib/InstrumentExtensions.cpp Wed Dec 18 23:57:29 2024 (r22572) +++ trunk/OpenMPT/soundlib/InstrumentExtensions.cpp Thu Dec 19 10:11:38 2024 (r22573) @@ -183,7 +183,7 @@ struct PropertyWriterEnvelopeBase { PropertyWriterEnvelopeBase(uint32 nodes, EnvelopeType type) : nodes{nodes}, type{type} {}; - static constexpr bool IsPropertyNeeded(const ModInstrument&) noexcept + static bool IsPropertyNeeded(const ModInstrument&) noexcept { return true; } @@ -242,7 +242,7 @@ struct PropertyWriterPitchTempoLock { - static constexpr bool IsPropertyNeeded(const ModInstrument &ins) noexcept { return ModInstrument{}.pitchToTempoLock != ins.pitchToTempoLock; } + static bool IsPropertyNeeded(const ModInstrument &ins) noexcept { return ModInstrument{}.pitchToTempoLock != ins.pitchToTempoLock; } static constexpr uint16 Size() noexcept { return sizeof(uint16le); } PropertyWriterPitchTempoLock(bool intPart) : m_intPart{intPart} {} void Write(std::ostream &file, const ModInstrument &ins) |
From: <sv...@op...> - 2024-12-18 22:57:41
|
Author: sagamusix Date: Wed Dec 18 23:57:29 2024 New Revision: 22572 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22572 Log: [Ref] Avoid clang warnings. Modified: trunk/OpenMPT/soundlib/InstrumentExtensions.cpp Modified: trunk/OpenMPT/soundlib/InstrumentExtensions.cpp ============================================================================== --- trunk/OpenMPT/soundlib/InstrumentExtensions.cpp Wed Dec 18 23:42:09 2024 (r22571) +++ trunk/OpenMPT/soundlib/InstrumentExtensions.cpp Wed Dec 18 23:57:29 2024 (r22572) @@ -136,13 +136,8 @@ #ifndef MODPLUG_NO_FILESAVE -namespace -{ - const ModInstrument DEFAULT_INSTRUMENT; -} - template <auto Member> -constexpr bool IsPropertyNonDefault(const ModInstrument &ins) { return DEFAULT_INSTRUMENT.*Member != ins.*Member; } +constexpr bool IsPropertyNonDefault(const ModInstrument &ins) { return ModInstrument{}.*Member != ins.*Member; } template <auto Member> constexpr uint16 PropertySize() noexcept { return sizeof(ModInstrument{}.*Member); } @@ -179,7 +174,7 @@ struct PropertyWriterReleaseNode { - bool IsPropertyNeeded(const ModInstrument &ins) const noexcept { return DEFAULT_INSTRUMENT.GetEnvelope(type).nReleaseNode != ins.GetEnvelope(type).nReleaseNode; } + bool IsPropertyNeeded(const ModInstrument &ins) const noexcept { return ModInstrument{}.GetEnvelope(type).nReleaseNode != ins.GetEnvelope(type).nReleaseNode; } static constexpr uint16 Size() noexcept { return sizeof(InstrumentEnvelope{}.nReleaseNode); } void Write(std::ostream &file, const ModInstrument &ins) const { mpt::IO::WriteIntLE(file, ins.GetEnvelope(type).nReleaseNode); } const EnvelopeType type; @@ -187,19 +182,25 @@ struct PropertyWriterEnvelopeBase { - static constexpr bool IsPropertyNeeded(const ModInstrument &) noexcept { return true; } + PropertyWriterEnvelopeBase(uint32 nodes, EnvelopeType type) : nodes{nodes}, type{type} {}; + static constexpr bool IsPropertyNeeded(const ModInstrument&) noexcept + { + return true; + } const uint32 nodes; const EnvelopeType type; }; struct PropertyWriterEnvelopeSize : PropertyWriterEnvelopeBase { + using PropertyWriterEnvelopeBase::PropertyWriterEnvelopeBase; static constexpr uint16 Size() noexcept { return sizeof(uint32le); } void Write(std::ostream &file, const ModInstrument &ins) const { mpt::IO::WriteIntLE<uint32>(file, ins.GetEnvelope(type).size()); } }; struct PropertyWriterEnvelopeTicks : PropertyWriterEnvelopeBase { + using PropertyWriterEnvelopeBase::PropertyWriterEnvelopeBase; uint16 Size() const noexcept { return static_cast<uint16>(sizeof(uint16le) * nodes); } void Write(std::ostream &file, const ModInstrument &ins) const { @@ -220,6 +221,7 @@ struct PropertyWriterEnvelopeValues : PropertyWriterEnvelopeBase { + using PropertyWriterEnvelopeBase::PropertyWriterEnvelopeBase; uint16 Size() const noexcept { return static_cast<uint16>(sizeof(uint8) * nodes); } void Write(std::ostream &file, const ModInstrument &ins) const { @@ -240,7 +242,7 @@ struct PropertyWriterPitchTempoLock { - static constexpr bool IsPropertyNeeded(const ModInstrument &ins) noexcept { return DEFAULT_INSTRUMENT.pitchToTempoLock != ins.pitchToTempoLock; } + static constexpr bool IsPropertyNeeded(const ModInstrument &ins) noexcept { return ModInstrument{}.pitchToTempoLock != ins.pitchToTempoLock; } static constexpr uint16 Size() noexcept { return sizeof(uint16le); } PropertyWriterPitchTempoLock(bool intPart) : m_intPart{intPart} {} void Write(std::ostream &file, const ModInstrument &ins) @@ -267,9 +269,10 @@ return; mpt::IO::WriteIntLE<uint32>(f, code); mpt::IO::WriteIntLE<uint16>(f, property.Size()); + ModInstrument defaultInstr{}; for(const ModInstrument *ins : instruments) { - property.Write(f, ins ? *ins : DEFAULT_INSTRUMENT); + property.Write(f, ins ? *ins : defaultInstr); } } |