|
From: <rel...@us...> - 2008-10-13 17:28:29
|
Revision: 230
http://modplug.svn.sourceforge.net/modplug/?rev=230&view=rev
Author: relabsoluness
Date: 2008-10-13 17:28:21 +0000 (Mon, 13 Oct 2008)
Log Message:
-----------
(Patch from Jojo)
/ Sample editing: If possible, use loop points as trim limits if there's no selection chosen.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/View_smp.cpp
Modified: trunk/OpenMPT/mptrack/View_smp.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_smp.cpp 2008-10-13 15:53:01 UTC (rev 229)
+++ trunk/OpenMPT/mptrack/View_smp.cpp 2008-10-13 17:28:21 UTC (rev 230)
@@ -1322,14 +1322,32 @@
m_dwMenuParam = dwPos;
}
}
+
if (m_dwBeginSel >= m_dwEndSel)
{
if (pins->uFlags & CHN_16BIT) ::AppendMenu(hMenu, MF_STRING, ID_SAMPLE_8BITCONVERT, "Convert to 8-bit");
if (pins->uFlags & CHN_STEREO) ::AppendMenu(hMenu, MF_STRING, ID_SAMPLE_MONOCONVERT, "Convert to mono");
}
+
+ // "Trim" menu item is responding differently if there's no selection,
+ // but a loop present: "trim around loop point"! (jojo in topic 2258)
+ std::string sTrimMenuText = "Trim";
+ bool bIsGrayed = (m_dwEndSel<=m_dwBeginSel);
+
+ if ((m_dwBeginSel == m_dwEndSel) && (pins->nLoopStart < pins->nLoopEnd))
+ {
+ // no selection => use loop points
+ sTrimMenuText += " around loop points";
+ bIsGrayed = false;
+ }
- ::AppendMenu(hMenu, MF_STRING|(m_dwEndSel>m_dwBeginSel)?0:MF_GRAYED,
- ID_SAMPLE_TRIM, "Trim\t" + ih->GetKeyTextFromCommand(kcSampleTrim));
+ sTrimMenuText += "\t" + ih->GetKeyTextFromCommand(kcSampleTrim);
+
+ // change by jojo: "trim" menu item is also available
+ // if there's no selection, but loop points
+ //::AppendMenu(hMenu, MF_STRING|(m_dwEndSel>m_dwBeginSel)?0:MF_GRAYED,
+ // ID_SAMPLE_TRIM, "Trim\t" + ih->GetKeyTextFromCommand(kcSampleTrim));
+ ::AppendMenu(hMenu, MF_STRING|(bIsGrayed)?MF_GRAYED:0, ID_SAMPLE_TRIM, sTrimMenuText.c_str());
::AppendMenu(hMenu, MF_STRING, ID_EDIT_CUT, "Cut\t" + ih->GetKeyTextFromCommand(kcEditCut));
::AppendMenu(hMenu, MF_STRING, ID_EDIT_COPY, "Copy\t" + ih->GetKeyTextFromCommand(kcEditCopy));
}
@@ -1825,51 +1843,60 @@
//------------------------------
{
CModDoc *pModDoc = GetDocument();
+ //nothing loaded or invalid sample slot.
+ if(!pModDoc || m_nSample >= MAX_SAMPLES) return;
+
+ CSoundFile *pSndFile = pModDoc->GetSoundFile();
+ MODINSTRUMENT *pins = &pSndFile->Ins[m_nSample];
+
+ if(m_dwBeginSel == m_dwEndSel) {
+ // trim around loop points if there's no selection (suggested by jojo in topic 2258)
+ m_dwBeginSel = pins->nLoopStart;
+ m_dwEndSel = pins->nLoopEnd;
+ }
+
+ if (m_dwBeginSel >= m_dwEndSel) return; // invalid selection
+
BeginWaitCursor();
- if ((pModDoc) && (m_nSample < MAX_SAMPLES) && (m_dwBeginSel < m_dwEndSel))
+ UINT nStart = m_dwBeginSel;
+ UINT nEnd = m_dwEndSel - m_dwBeginSel;
+
+ if ((pins->pSample) && (nStart+nEnd <= pins->nLength) && (nEnd >= 16))
{
- CSoundFile *pSndFile = pModDoc->GetSoundFile();
- MODINSTRUMENT *pins = &pSndFile->Ins[m_nSample];
- UINT nStart = m_dwBeginSel;
- UINT nEnd = m_dwEndSel - m_dwBeginSel;
-
- if ((pins->pSample) && (nStart+nEnd <= pins->nLength) && (nEnd >= 16))
+ BEGIN_CRITICAL();
{
- BEGIN_CRITICAL();
+ UINT bend = nEnd, bstart = nStart;
+ if (pins->uFlags & CHN_16BIT) { bend <<= 1; bstart <<= 1; }
+ if (pins->uFlags & CHN_STEREO) { bend <<= 1; bstart <<= 1; }
+ signed char *p = (signed char *)pins->pSample;
+ for (UINT i=0; i<bend; i++)
{
- UINT bend = nEnd, bstart = nStart;
- if (pins->uFlags & CHN_16BIT) { bend <<= 1; bstart <<= 1; }
- if (pins->uFlags & CHN_STEREO) { bend <<= 1; bstart <<= 1; }
- signed char *p = (signed char *)pins->pSample;
- for (UINT i=0; i<bend; i++)
- {
- p[i] = p[i+bstart];
- }
+ p[i] = p[i+bstart];
}
- if (pins->nLoopStart >= nStart) pins->nLoopStart -= nStart;
- if (pins->nLoopEnd >= nStart) pins->nLoopEnd -= nStart;
- if (pins->nSustainStart >= nStart) pins->nSustainStart -= nStart;
- if (pins->nSustainEnd >= nStart) pins->nSustainEnd -= nStart;
- if (pins->nLoopEnd > nEnd) pins->nLoopEnd = nEnd;
- if (pins->nSustainEnd > nEnd) pins->nSustainEnd = nEnd;
- if (pins->nLoopStart >= pins->nLoopEnd)
- {
- pins->nLoopStart = pins->nLoopEnd = 0;
- pins->uFlags &= ~(CHN_LOOP|CHN_PINGPONGLOOP);
- }
- if (pins->nSustainStart >= pins->nSustainEnd)
- {
- pins->nSustainStart = pins->nSustainEnd = 0;
- pins->uFlags &= ~(CHN_SUSTAINLOOP|CHN_PINGPONGSUSTAIN);
- }
- pins->nLength = nEnd;
- END_CRITICAL();
- pModDoc->SetModified();
- pModDoc->AdjustEndOfSample(m_nSample);
- SetCurSel(0, 0);
- // 05/01/05 : ericus replaced "m_nSample << 24" by "m_nSample << 20" : 4000 samples -> 12bits [see Moddoc.h]
- pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEDATA | HINT_SAMPLEINFO, NULL);
}
+ if (pins->nLoopStart >= nStart) pins->nLoopStart -= nStart;
+ if (pins->nLoopEnd >= nStart) pins->nLoopEnd -= nStart;
+ if (pins->nSustainStart >= nStart) pins->nSustainStart -= nStart;
+ if (pins->nSustainEnd >= nStart) pins->nSustainEnd -= nStart;
+ if (pins->nLoopEnd > nEnd) pins->nLoopEnd = nEnd;
+ if (pins->nSustainEnd > nEnd) pins->nSustainEnd = nEnd;
+ if (pins->nLoopStart >= pins->nLoopEnd)
+ {
+ pins->nLoopStart = pins->nLoopEnd = 0;
+ pins->uFlags &= ~(CHN_LOOP|CHN_PINGPONGLOOP);
+ }
+ if (pins->nSustainStart >= pins->nSustainEnd)
+ {
+ pins->nSustainStart = pins->nSustainEnd = 0;
+ pins->uFlags &= ~(CHN_SUSTAINLOOP|CHN_PINGPONGSUSTAIN);
+ }
+ pins->nLength = nEnd;
+ END_CRITICAL();
+ pModDoc->SetModified();
+ pModDoc->AdjustEndOfSample(m_nSample);
+ SetCurSel(0, 0);
+ // 05/01/05 : ericus replaced "m_nSample << 24" by "m_nSample << 20" : 4000 samples -> 12bits [see Moddoc.h]
+ pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEDATA | HINT_SAMPLEINFO, NULL);
}
EndWaitCursor();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-09-13 17:21:50
|
Revision: 710
http://modplug.svn.sourceforge.net/modplug/?rev=710&view=rev
Author: saga-games
Date: 2010-09-13 17:21:44 +0000 (Mon, 13 Sep 2010)
Log Message:
-----------
[Fix] Sample Editor: When cutting samples with a loop, the loop end point was not always moved correctly if the cut part started in the loop.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/View_smp.cpp
Modified: trunk/OpenMPT/mptrack/View_smp.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_smp.cpp 2010-09-13 15:53:16 UTC (rev 709)
+++ trunk/OpenMPT/mptrack/View_smp.cpp 2010-09-13 17:21:44 UTC (rev 710)
@@ -1743,12 +1743,12 @@
pSmp->nLoopStart = m_dwBeginSel;
pSmp->nLoopEnd -= m_dwEndSel - m_dwBeginSel;
}
- else if(m_dwBeginSel > pSmp->nLoopStart && m_dwEndSel < pSmp->nLoopEnd)
+ else if(m_dwBeginSel >= pSmp->nLoopStart && m_dwEndSel < pSmp->nLoopEnd)
{
// cut part is in the loop
pSmp->nLoopEnd -= m_dwEndSel - m_dwBeginSel;
}
- else if(m_dwBeginSel > pSmp->nLoopStart && m_dwBeginSel < pSmp->nLoopEnd && m_dwEndSel > pSmp->nLoopEnd)
+ else if(m_dwBeginSel >= pSmp->nLoopStart && m_dwBeginSel < pSmp->nLoopEnd && m_dwEndSel > pSmp->nLoopEnd)
{
// cut part is partly before loop end
pSmp->nLoopEnd = m_dwBeginSel;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2013-04-27 13:22:54
|
Revision: 1978
http://sourceforge.net/p/modplug/code/1978
Author: saga-games
Date: 2013-04-27 13:22:44 +0000 (Sat, 27 Apr 2013)
Log Message:
-----------
[Fix] Sample editor: Split stereo sample didn't update sample list in pattern editor (http://bugs.openmpt.org/bug_update_page.php?bug_id=382)
Modified Paths:
--------------
trunk/OpenMPT/mptrack/View_smp.cpp
Modified: trunk/OpenMPT/mptrack/View_smp.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_smp.cpp 2013-04-26 22:13:07 UTC (rev 1977)
+++ trunk/OpenMPT/mptrack/View_smp.cpp 2013-04-27 13:22:44 UTC (rev 1978)
@@ -2134,7 +2134,7 @@
}
}
pModDoc->SetModified();
- pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEDATA | HINT_SAMPLEINFO, NULL);
+ pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEDATA | HINT_SAMPLEINFO | HINT_SMPNAMES | HINT_INSNAMES, NULL);
} else
{
pModDoc->GetSampleUndo().RemoveLastUndoStep(m_nSample);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2013-05-20 17:10:18
|
Revision: 2150
http://sourceforge.net/p/modplug/code/2150
Author: saga-games
Date: 2013-05-20 17:10:12 +0000 (Mon, 20 May 2013)
Log Message:
-----------
[Fix] Compile error.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/View_smp.cpp
Modified: trunk/OpenMPT/mptrack/View_smp.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_smp.cpp 2013-05-20 16:39:22 UTC (rev 2149)
+++ trunk/OpenMPT/mptrack/View_smp.cpp 2013-05-20 17:10:12 UTC (rev 2150)
@@ -2246,7 +2246,7 @@
CSoundFile &sndFile = pModDoc->GetrSoundFile();
ModSample &sample = sndFile.GetSample(m_nSample);
- uint32 freq = sndFile.GetFreqFromPeriod(pSndFile->GetPeriodFromNote(note + (pSndFile->GetType() == MOD_TYPE_XM ? sample.RelativeTone : 0), sample.nFineTune, sample.nC5Speed), sample.nC5Speed, 0);
+ uint32 freq = sndFile.GetFreqFromPeriod(sndFile.GetPeriodFromNote(note + (sndFile.GetType() == MOD_TYPE_XM ? sample.RelativeTone : 0), sample.nFineTune, sample.nC5Speed), sample.nC5Speed, 0);
CHAR s[32];
wsprintf(s, "%s (%d.%d Hz)", szDefaultNoteNames[note - 1], freq >> FREQ_FRACBITS, Util::muldiv(freq & ((1 << FREQ_FRACBITS) - 1), 100, 1 << FREQ_FRACBITS));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-02-22 22:16:32
|
Revision: 3754
http://sourceforge.net/p/modplug/code/3754
Author: saga-games
Date: 2014-02-22 22:16:25 +0000 (Sat, 22 Feb 2014)
Log Message:
-----------
[Fix] More little SSE fixes (mono samples)
Modified Paths:
--------------
trunk/OpenMPT/mptrack/View_smp.cpp
Modified: trunk/OpenMPT/mptrack/View_smp.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_smp.cpp 2014-02-22 21:49:40 UTC (rev 3753)
+++ trunk/OpenMPT/mptrack/View_smp.cpp 2014-02-22 22:16:25 UTC (rev 3754)
@@ -611,8 +611,8 @@
if(channels < 2)
{
// Mono
- minVal2 = _mm_sra_pi32(minVal2, _mm_cvtsi32_si64(16));
- maxVal2 = _mm_sra_pi32(maxVal2, _mm_cvtsi32_si64(16));
+ minVal2 = _mm_sra_pi32(minVal, _mm_cvtsi32_si64(16));
+ maxVal2 = _mm_sra_pi32(maxVal, _mm_cvtsi32_si64(16));
minVal = _mm_min_pi16(minVal, minVal2);
maxVal = _mm_max_pi16(maxVal, maxVal2);
}
@@ -680,16 +680,16 @@
minVal = _mm_min_pu8(minVal, minVal2);
maxVal = _mm_max_pu8(maxVal, maxVal2);
- minVal2 = _mm_srl_pi32(minVal2, _mm_cvtsi32_si64(16));
- maxVal2 = _mm_srl_pi32(maxVal2, _mm_cvtsi32_si64(16));
+ minVal2 = _mm_srl_pi32(minVal, _mm_cvtsi32_si64(16));
+ maxVal2 = _mm_srl_pi32(maxVal, _mm_cvtsi32_si64(16));
minVal = _mm_min_pu8(minVal, minVal2);
maxVal = _mm_max_pu8(maxVal, maxVal2);
if(channels < 2)
{
// Mono
- minVal2 = _mm_srl_pi32(minVal2, _mm_cvtsi32_si64(8));
- maxVal2 = _mm_srl_pi32(maxVal2, _mm_cvtsi32_si64(8));
+ minVal2 = _mm_srl_pi32(minVal, _mm_cvtsi32_si64(8));
+ maxVal2 = _mm_srl_pi32(maxVal, _mm_cvtsi32_si64(8));
minVal = _mm_min_pu8(minVal, minVal2);
maxVal = _mm_max_pu8(maxVal, maxVal2);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2015-06-29 14:59:29
|
Revision: 5384
http://sourceforge.net/p/modplug/code/5384
Author: saga-games
Date: 2015-06-29 14:59:24 +0000 (Mon, 29 Jun 2015)
Log Message:
-----------
[Imp] Don't reset sample draw status when modifying a sample, except when it was deleted.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/View_smp.cpp
Modified: trunk/OpenMPT/mptrack/View_smp.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_smp.cpp 2015-06-29 12:59:38 UTC (rev 5383)
+++ trunk/OpenMPT/mptrack/View_smp.cpp 2015-06-29 14:59:24 UTC (rev 5384)
@@ -15,11 +15,11 @@
#include "InputHandler.h"
#include "Childfrm.h"
#include "Moddoc.h"
-#include "globals.h"
-#include "ctrl_smp.h"
+#include "Globals.h"
+#include "Ctrl_smp.h"
#include "Dlsbank.h"
-#include "channelManagerDlg.h"
-#include "view_smp.h"
+#include "ChannelManagerDlg.h"
+#include "View_smp.h"
#include "../soundlib/MIDIEvents.h"
#include "SampleEditorDialogs.h"
#include "../soundlib/WAVTools.h"
@@ -543,12 +543,14 @@
UpdateNcButtonState();
InvalidateSample();
}
-
- // sample drawing
if(hintType[HINT_SAMPLEINFO])
{
- m_dwStatus.reset(SMPSTATUS_DRAWING);
- UpdateNcButtonState();
+ if(!GetDocument()->GetrSoundFile().GetSample(m_nSample).HasSampleData())
+ {
+ // Disable sample drawing if we cannot actually draw anymore.
+ m_dwStatus.reset(SMPSTATUS_DRAWING);
+ UpdateNcButtonState();
+ }
}
}
@@ -1043,8 +1045,7 @@
//--------------------------------
{
CRect rcClient = m_rcClient, rect, rc;
- CModDoc *pModDoc = GetDocument();
- HGDIOBJ oldpen;
+ const CModDoc *pModDoc = GetDocument();
const SmpLength nSmpScrollPos = ScrollPosToSamplePos();
@@ -1061,7 +1062,7 @@
offScreenDC.SelectObject(offScreenBitmap);
}
- oldpen = offScreenDC.SelectObject(CMainFrame::penBlack);
+ const HGDIOBJ oldpen = offScreenDC.SelectObject(CMainFrame::penBlack);
rect = rcClient;
if ((rcClient.bottom > rcClient.top) && (rcClient.right > rcClient.left))
{
@@ -1411,11 +1412,9 @@
//-------------------------------------
{
CModDoc *pModDoc = GetDocument();
- CSoundFile *pSndFile;
CDC *pDC = NULL;
if (!pModDoc) return;
- pSndFile = pModDoc->GetSoundFile();
for (UINT i=0; i<SMP_LEFTBAR_BUTTONS; i++) if (cLeftBarButtons[i] != ID_SEPARATOR)
{
DWORD dwStyle = 0;
@@ -1430,7 +1429,7 @@
{
case ID_SAMPLE_DRAW:
if(m_dwStatus[SMPSTATUS_DRAWING]) dwStyle |= NCBTNS_CHECKED;
- if(m_nSample > pSndFile->GetNumSamples())
+ if(m_nSample > pModDoc->GetNumSamples())
{
dwStyle |= NCBTNS_DISABLED;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2011-08-25 21:22:34
|
Revision: 1001
http://modplug.svn.sourceforge.net/modplug/?rev=1001&view=rev
Author: saga-games
Date: 2011-08-25 21:22:28 +0000 (Thu, 25 Aug 2011)
Log Message:
-----------
[Mod] Loops are now automatically enabled when setting loop points in the sample editor
Modified Paths:
--------------
trunk/OpenMPT/mptrack/View_smp.cpp
Modified: trunk/OpenMPT/mptrack/View_smp.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_smp.cpp 2011-08-25 21:11:13 UTC (rev 1000)
+++ trunk/OpenMPT/mptrack/View_smp.cpp 2011-08-25 21:22:28 UTC (rev 1001)
@@ -2380,13 +2380,9 @@
{
pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_none);
pSmp->nLoopStart = m_dwMenuParam;
+ pSmp->uFlags |= CHN_LOOP;
pModDoc->SetModified();
- if(pSmp->uFlags & CHN_LOOP)
- {
- /* only update sample buffer if the loop is actually enabled
- (resets sound without any reason otherwise) - http://forum.openmpt.org/index.php?topic=1874.0 */
- pModDoc->AdjustEndOfSample(m_nSample);
- }
+ pModDoc->AdjustEndOfSample(m_nSample);
pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEINFO | HINT_SAMPLEDATA, NULL);
}
}
@@ -2405,13 +2401,9 @@
{
pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_none);
pSmp->nLoopEnd = m_dwMenuParam;
+ pSmp->uFlags |= CHN_LOOP;
pModDoc->SetModified();
- if(pSmp->uFlags & CHN_LOOP)
- {
- /* only update sample buffer if the loop is actually enabled
- (resets sound without any reason otherwise) - http://forum.openmpt.org/index.php?topic=1874.0 */
- pModDoc->AdjustEndOfSample(m_nSample);
- }
+ pModDoc->AdjustEndOfSample(m_nSample);
pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEINFO | HINT_SAMPLEDATA, NULL);
}
}
@@ -2430,6 +2422,7 @@
{
pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_none);
pSmp->nSustainStart = m_dwMenuParam;
+ pSmp->uFlags |= CHN_SUSTAINLOOP;
pModDoc->SetModified();
pModDoc->AdjustEndOfSample(m_nSample);
pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEINFO | HINT_SAMPLEDATA, NULL);
@@ -2450,6 +2443,7 @@
{
pModDoc->GetSampleUndo()->PrepareUndo(m_nSample, sundo_none);
pSmp->nSustainEnd = m_dwMenuParam;
+ pSmp->uFlags |= CHN_SUSTAINLOOP;
pModDoc->SetModified();
pModDoc->AdjustEndOfSample(m_nSample);
pModDoc->UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEINFO | HINT_SAMPLEDATA, NULL);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2012-11-19 21:42:48
|
Revision: 1433
http://modplug.svn.sourceforge.net/modplug/?rev=1433&view=rev
Author: saga-games
Date: 2012-11-19 21:42:41 +0000 (Mon, 19 Nov 2012)
Log Message:
-----------
[Imp] Sample Editor: When triggering a note, the note frequency is displayed next to the note name in the status bar.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/View_smp.cpp
Modified: trunk/OpenMPT/mptrack/View_smp.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_smp.cpp 2012-11-17 17:28:39 UTC (rev 1432)
+++ trunk/OpenMPT/mptrack/View_smp.cpp 2012-11-19 21:42:41 UTC (rev 1433)
@@ -1525,7 +1525,7 @@
}
}
- if (m_dwBeginSel >= m_dwEndSel)
+ if(m_dwBeginSel >= m_dwEndSel)
{
if (sample.uFlags & CHN_16BIT) ::AppendMenu(hMenu, MF_STRING, ID_SAMPLE_8BITCONVERT, "Convert to 8-bit");
if (sample.uFlags & CHN_STEREO) ::AppendMenu(hMenu, MF_STRING, ID_SAMPLE_MONOCONVERT, "Convert to mono");
@@ -2068,11 +2068,11 @@
{
CModDoc *pModDoc = GetDocument();
BeginWaitCursor();
- if ((pModDoc) && (m_nSample <= pModDoc->GetNumSamples()))
+ if(pModDoc != nullptr && (m_nSample <= pModDoc->GetNumSamples()))
{
CSoundFile *pSndFile = pModDoc->GetSoundFile();
ModSample &sample = pSndFile->GetSample(m_nSample);
- if ((sample.uFlags & CHN_STEREO) && (sample.pSample) && (sample.nLength))
+ if(sample.GetNumChannels() > 1&& sample.pSample != nullptr && sample.nLength != 0)
{
pModDoc->GetSampleUndo().PrepareUndo(m_nSample, sundo_replace);
if(ctrlSmp::ConvertToMono(sample, pSndFile))
@@ -2188,7 +2188,14 @@
m_dwStatus |= SMPSTATUS_KEYDOWN;
s[0] = 0;
- if ((note) && (note <= NOTE_MAX)) wsprintf(s, "%s%d", szNoteNames[(note-1)%12], (note-1)/12);
+ if(ModCommand::IsNote(note))
+ {
+ CSoundFile *pSndFile = pModDoc->GetSoundFile();
+ ModSample &sample = pSndFile->GetSample(m_nSample);
+ uint32 freq = pSndFile->GetFreqFromPeriod(pSndFile->GetPeriodFromNote(note + sample.RelativeTone, sample.nFineTune, sample.nC5Speed), sample.nC5Speed, 0);
+
+ wsprintf(s, "%s%d (%d Hz)", szNoteNames[(note - 1) % 12], (note - 1) / 12, freq);
+ }
pMainFrm->SetInfoText(s);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2012-11-23 17:26:32
|
Revision: 1439
http://modplug.svn.sourceforge.net/modplug/?rev=1439&view=rev
Author: saga-games
Date: 2012-11-23 17:26:20 +0000 (Fri, 23 Nov 2012)
Log Message:
-----------
[Imp] Newly added shortcuts are now also displayed in sample editor context menu.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/View_smp.cpp
Modified: trunk/OpenMPT/mptrack/View_smp.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_smp.cpp 2012-11-23 17:21:54 UTC (rev 1438)
+++ trunk/OpenMPT/mptrack/View_smp.cpp 2012-11-23 17:26:20 UTC (rev 1439)
@@ -1530,14 +1530,14 @@
if(m_dwBeginSel >= m_dwEndSel)
{
- if(sample.GetElementarySampleSize() > 1) ::AppendMenu(hMenu, MF_STRING, ID_SAMPLE_8BITCONVERT, "Convert to &8-bit");
+ if(sample.GetElementarySampleSize() > 1) ::AppendMenu(hMenu, MF_STRING, ID_SAMPLE_8BITCONVERT, "Convert to &8-bit\t" + ih->GetKeyTextFromCommand(kcSample8Bit));
if(sample.GetNumChannels() > 1)
{
HMENU hMonoMenu = ::CreatePopupMenu();
- ::AppendMenu(hMonoMenu, MF_STRING, ID_SAMPLE_MONOCONVERT, "&Mix Channels");
- ::AppendMenu(hMonoMenu, MF_STRING, ID_SAMPLE_MONOCONVERT_LEFT, "&Left Channel");
- ::AppendMenu(hMonoMenu, MF_STRING, ID_SAMPLE_MONOCONVERT_RIGHT, "&Right Channel");
- ::AppendMenu(hMonoMenu, MF_STRING, ID_SAMPLE_MONOCONVERT_SPLIT, "&Split Sample");
+ ::AppendMenu(hMonoMenu, MF_STRING, ID_SAMPLE_MONOCONVERT, "&Mix Channels\t" + ih->GetKeyTextFromCommand(kcSampleMonoMix));
+ ::AppendMenu(hMonoMenu, MF_STRING, ID_SAMPLE_MONOCONVERT_LEFT, "&Left Channel\t" + ih->GetKeyTextFromCommand(kcSampleMonoLeft));
+ ::AppendMenu(hMonoMenu, MF_STRING, ID_SAMPLE_MONOCONVERT_RIGHT, "&Right Channel\t" + ih->GetKeyTextFromCommand(kcSampleMonoRight));
+ ::AppendMenu(hMonoMenu, MF_STRING, ID_SAMPLE_MONOCONVERT_SPLIT, "&Split Sample\t" + ih->GetKeyTextFromCommand(kcSampleMonoSplit));
::AppendMenu(hMenu, MF_POPUP, reinterpret_cast<UINT_PTR>(hMonoMenu), "Convert to &Mono");
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2013-11-29 21:39:19
|
Revision: 3335
http://sourceforge.net/p/modplug/code/3335
Author: saga-games
Date: 2013-11-29 21:39:12 +0000 (Fri, 29 Nov 2013)
Log Message:
-----------
[Fix] Sample view: Drawing sample lines while playing sample and changing selection points broke in previous revision. Sample is now always drawn completely off-screen.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/View_smp.cpp
Modified: trunk/OpenMPT/mptrack/View_smp.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_smp.cpp 2013-11-29 20:37:19 UTC (rev 3334)
+++ trunk/OpenMPT/mptrack/View_smp.cpp 2013-11-29 21:39:12 UTC (rev 3335)
@@ -798,7 +798,15 @@
UINT nSmpScrollPos = ScrollPosToSamplePos();
if ((!pModDoc) || (!pDC)) return;
- hdc = pDC->m_hDC;
+
+ // Create off-screen image
+ DeleteObject(offScreenBitmap);
+ DeleteDC(offScreenDC);
+ offScreenDC = CreateCompatibleDC(pDC->m_hDC);
+ offScreenBitmap = CreateCompatibleBitmap(pDC->m_hDC, m_rcClient.Width(), m_rcClient.Height());
+ SelectObject(offScreenDC, offScreenBitmap);
+
+ hdc = offScreenDC;
oldpen = ::SelectObject(hdc, CMainFrame::penBlack);
pSndFile = pModDoc->GetSoundFile();
rect = rcClient;
@@ -881,13 +889,12 @@
}
// Drawing Sample Data
::SelectObject(hdc, CMainFrame::penSample);
- int smplsize = (sample.uFlags & CHN_16BIT) ? 2 : 1;
- if (sample.uFlags & CHN_STEREO) smplsize *= 2;
+ int smplsize = sample.GetBytesPerSample();
if ((m_nZoom == 1) || ((!m_nZoom) && (sample.nLength <= (UINT)rect.right)))
{
int len = sample.nLength - nSmpScrollPos;
signed char *psample = ((signed char *)sample.pSample) + nSmpScrollPos * smplsize;
- if (sample.uFlags & CHN_STEREO)
+ if (sample.uFlags[CHN_STEREO])
{
DrawSampleData1(hdc, ymed-yrange/2, rect.right, yrange, len, sample.uFlags, psample);
DrawSampleData1(hdc, ymed+yrange/2, rect.right, yrange, len, sample.uFlags, psample+smplsize/2);
@@ -905,7 +912,7 @@
len -= nSmpScrollPos;
}
signed char *psample = ((signed char *)sample.pSample) + xscroll * smplsize;
- if (sample.uFlags & CHN_STEREO)
+ if (sample.uFlags[CHN_STEREO])
{
DrawSampleData2(hdc, ymed-yrange/2, rect.right, yrange, len, sample.uFlags, psample);
DrawSampleData2(hdc, ymed+yrange/2, rect.right, yrange, len, sample.uFlags, psample+smplsize/2);
@@ -917,16 +924,8 @@
}
}
- // Create off-screen image
- DeleteObject(offScreenBitmap);
- DeleteDC(offScreenDC);
- offScreenDC = CreateCompatibleDC(pDC->m_hDC);
- offScreenBitmap = CreateCompatibleBitmap(pDC->m_hDC, m_rcClient.Width(), m_rcClient.Height());
- SelectObject(offScreenDC, offScreenBitmap);
- BitBlt(offScreenDC, m_rcClient.left, m_rcClient.top, m_rcClient.Width(), m_rcClient.Height(), pDC->m_hDC, 0, 0, SRCCOPY);
-
DrawPositionMarks();
- BitBlt(hdc, m_rcClient.left, m_rcClient.top, m_rcClient.Width(), m_rcClient.Height(), offScreenDC, 0, 0, SRCCOPY);
+ BitBlt(pDC->m_hDC, m_rcClient.left, m_rcClient.top, m_rcClient.Width(), m_rcClient.Height(), offScreenDC, 0, 0, SRCCOPY);
if (oldpen) ::SelectObject(hdc, oldpen);
@@ -1853,12 +1852,12 @@
if(sample.nLoopEnd == 0)
{
- sample.uFlags &= ~(CHN_LOOP | CHN_PINGPONGLOOP);
+ sample.uFlags.reset(CHN_LOOP | CHN_PINGPONGLOOP);
}
if(sample.nSustainEnd == 0)
{
- sample.uFlags &= ~(CHN_SUSTAINLOOP | CHN_PINGPONGSUSTAIN);
+ sample.uFlags.reset(CHN_SUSTAINLOOP | CHN_PINGPONGSUSTAIN);
}
}
SetCurSel(0, 0);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-02-10 23:10:18
|
Revision: 3696
http://sourceforge.net/p/modplug/code/3696
Author: saga-games
Date: 2014-02-10 23:10:12 +0000 (Mon, 10 Feb 2014)
Log Message:
-----------
[Fix] Missing space in sample editor context menu
Modified Paths:
--------------
trunk/OpenMPT/mptrack/View_smp.cpp
Modified: trunk/OpenMPT/mptrack/View_smp.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_smp.cpp 2014-02-10 23:01:57 UTC (rev 3695)
+++ trunk/OpenMPT/mptrack/View_smp.cpp 2014-02-10 23:10:12 UTC (rev 3696)
@@ -1603,8 +1603,8 @@
::AppendMenu(hMenu, MF_STRING, ID_EDIT_COPY, "&Copy\t" + ih->GetKeyTextFromCommand(kcEditCopy));
}
::AppendMenu(hMenu, MF_STRING | (IsClipboardFormatAvailable(CF_WAVE) ? 0 : MF_GRAYED), ID_EDIT_PASTE, "&Paste\t" + ih->GetKeyTextFromCommand(kcEditPaste));
- ::AppendMenu(hMenu, MF_STRING | (pModDoc->GetSampleUndo().CanUndo(m_nSample) ? 0 : MF_GRAYED), ID_EDIT_UNDO, "&Undo" + CString(pModDoc->GetSampleUndo().GetUndoName(m_nSample)) + "\t" + ih->GetKeyTextFromCommand(kcEditUndo));
- ::AppendMenu(hMenu, MF_STRING | (pModDoc->GetSampleUndo().CanRedo(m_nSample) ? 0 : MF_GRAYED), ID_EDIT_REDO, "&Redo" + CString(pModDoc->GetSampleUndo().GetRedoName(m_nSample)) + "\t" + ih->GetKeyTextFromCommand(kcEditRedo));
+ ::AppendMenu(hMenu, MF_STRING | (pModDoc->GetSampleUndo().CanUndo(m_nSample) ? 0 : MF_GRAYED), ID_EDIT_UNDO, "&Undo " + CString(pModDoc->GetSampleUndo().GetUndoName(m_nSample)) + "\t" + ih->GetKeyTextFromCommand(kcEditUndo));
+ ::AppendMenu(hMenu, MF_STRING | (pModDoc->GetSampleUndo().CanRedo(m_nSample) ? 0 : MF_GRAYED), ID_EDIT_REDO, "&Redo " + CString(pModDoc->GetSampleUndo().GetRedoName(m_nSample)) + "\t" + ih->GetKeyTextFromCommand(kcEditRedo));
ClientToScreen(&pt);
::TrackPopupMenu(hMenu, TPM_LEFTALIGN|TPM_RIGHTBUTTON, pt.x, pt.y, 0, m_hWnd, NULL);
::DestroyMenu(hMenu);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-02-16 18:23:53
|
Revision: 3725
http://sourceforge.net/p/modplug/code/3725
Author: saga-games
Date: 2014-02-16 18:23:42 +0000 (Sun, 16 Feb 2014)
Log Message:
-----------
[Imp] Sample tab: Sample grid is now visualised using dashed lines.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/View_smp.cpp
Modified: trunk/OpenMPT/mptrack/View_smp.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_smp.cpp 2014-02-16 17:39:12 UTC (rev 3724)
+++ trunk/OpenMPT/mptrack/View_smp.cpp 2014-02-16 18:23:42 UTC (rev 3725)
@@ -154,7 +154,7 @@
if (pMainFrm)
{
pMainFrm->SetInfoText("");
- pMainFrm->SetXInfoText(""); //rewbs.xinfo
+ pMainFrm->SetXInfoText("");
}
UpdateScrollSize();
}
@@ -657,7 +657,7 @@
signed char *psample = (signed char *)pSampleData;
//int y0 = 0, xmax, posincr, posfrac, poshi;
int32 y0 = 0, xmax, poshi;
- uint64 posincr, posfrac;
+ uint64 posincr, posfrac; // Increments have 16-bit fractional part
if (len <= 0) return;
smplsize = (uFlags & CHN_16BIT) ? 2 : 1;
@@ -768,13 +768,15 @@
{
CRect rcClient = m_rcClient, rect, rc;
CModDoc *pModDoc = GetDocument();
- CSoundFile *pSndFile;
HGDIOBJ oldpen;
UINT nSmpScrollPos = ScrollPosToSamplePos();
if ((!pModDoc) || (!pDC)) return;
+ const CSoundFile &sndFile = pModDoc->GetrSoundFile();
+ const ModSample &sample = sndFile.GetSample((m_nSample <= sndFile.GetNumSamples()) ? m_nSample : 0);
+
// Create off-screen image
if(offScreenDC == nullptr)
{
@@ -785,11 +787,9 @@
offScreenDC = offScreenDC;
oldpen = ::SelectObject(offScreenDC, CMainFrame::penBlack);
- pSndFile = pModDoc->GetSoundFile();
rect = rcClient;
if ((rcClient.bottom > rcClient.top) && (rcClient.right > rcClient.left))
{
- const ModSample &sample = pSndFile->GetSample((m_nSample <= pSndFile->GetNumSamples()) ? m_nSample : 0);
int ymed = (rect.top + rect.bottom) / 2;
int yrange = (rect.bottom - rect.top) / 2;
@@ -901,19 +901,29 @@
}
}
+ if(m_nGridSegments)
+ {
+ // Draw sample grid
+ ::SelectObject(offScreenDC, CMainFrame::penHalfDarkGray);
+ for(int i = 0; i < m_nGridSegments; i++)
+ {
+ int screenPos = SampleToScreen(sample.nLength * i / m_nGridSegments);
+ ::MoveToEx(offScreenDC, screenPos, rect.top, nullptr);
+ ::LineTo(offScreenDC, screenPos, rect.bottom);
+ }
+ }
+
DrawPositionMarks();
+
BitBlt(pDC->m_hDC, m_rcClient.left, m_rcClient.top, m_rcClient.Width(), m_rcClient.Height(), offScreenDC, 0, 0, SRCCOPY);
if (oldpen) ::SelectObject(offScreenDC, oldpen);
-// -> CODE#0015
-// -> DESC="channels management dlg"
- CMainFrame * pMainFrm = CMainFrame::GetMainFrame();
- BOOL activeDoc = pMainFrm ? pMainFrm->GetActiveDoc() == GetDocument() : FALSE;
+ CMainFrame *pMainFrm = CMainFrame::GetMainFrame();
+ bool activeDoc = pMainFrm ? pMainFrm->GetActiveDoc() == GetDocument() : false;
if(activeDoc && CChannelManagerDlg::sharedInstance(FALSE) && CChannelManagerDlg::sharedInstance()->IsDisplayed())
CChannelManagerDlg::sharedInstance()->SetDocument((void*)this);
-// -! NEW_FEATURE#0015
}
@@ -1164,7 +1174,7 @@
void CViewSample::OnSize(UINT nType, int cx, int cy)
//--------------------------------------------------
{
- CScrollView::OnSize(nType, cx, cy);
+ CModScrollView::OnSize(nType, cx, cy);
DeleteObject(offScreenBitmap);
DeleteDC(offScreenDC);
@@ -2520,7 +2530,7 @@
{
CriticalSection cs;
- UINT nStart = (dlg.m_nEditOption == addsilence_at_end) ? sample.nLength : 0;
+ SmpLength nStart = (dlg.m_nEditOption == addsilence_at_end) ? sample.nLength : 0;
pModDoc->GetSampleUndo().PrepareUndo(m_nSample, sundo_insert, "Add Silence", nStart, nStart + dlg.m_nSamples);
ctrlSmp::InsertSilence(sample, dlg.m_nSamples, nStart, sndFile);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-02-22 21:15:44
|
Revision: 3752
http://sourceforge.net/p/modplug/code/3752
Author: saga-games
Date: 2014-02-22 21:15:25 +0000 (Sat, 22 Feb 2014)
Log Message:
-----------
[Fix] Translate min/max finder in sample drawing code to SSE intrinsics and make it actually 100% equivalent to the non-optimized version (the "add ebx, edx" loop counter should always have incremented by 8 bytes instead of the actual sample size, which made some samples look weird, to say the least)
Modified Paths:
--------------
trunk/OpenMPT/mptrack/View_smp.cpp
Modified: trunk/OpenMPT/mptrack/View_smp.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_smp.cpp 2014-02-22 17:49:24 UTC (rev 3751)
+++ trunk/OpenMPT/mptrack/View_smp.cpp 2014-02-22 21:15:25 UTC (rev 3752)
@@ -571,142 +571,148 @@
#if defined(ENABLE_X86_AMD) || defined(ENABLE_SSE)
-static void amdmmxext_or_sse_findminmax16(const void *p, int scanlen, int smplsize, int *smin, int *smax)
+#include <mmintrin.h>
+
+// AMD MMX/SSE implementation for min/max finder, packs 4*int16 in a 64-bit MMX register.
+// scanlen = How many samples to process on this channel
+static void amdmmxext_or_sse_findminmax16(const void *p, int scanlen, int channels, int &smin, int &smax)
//-------------------------------------------------------------------------------------------------------
{
- _asm {
- mov ebx, p
- mov ecx, scanlen
- mov edx, smplsize
- mov esi, smin
- mov edi, smax
- movd mm0, [esi] // mm0 = min
- movd mm1, [edi] // mm1 = max
- shr ecx, 2
- or ecx, ecx
- punpcklwd mm0, mm0
- punpcklwd mm1, mm1
- punpckldq mm0, mm0
- punpckldq mm1, mm1
- jz done4x
-mainloop4x:
- movq mm2, [ebx]
- add ebx, edx
- dec ecx
- pminsw mm0, mm2
- pmaxsw mm1, mm2
- jnz mainloop4x
- movq mm2, mm0
- movq mm3, mm1
- punpckhdq mm2, mm2
- punpckhdq mm3, mm3
- cmp edx, 2
- pminsw mm0, mm2
- pmaxsw mm1, mm3
- jg done4x
- psrad mm2, 16
- psrad mm3, 16
- pminsw mm0, mm2
- pmaxsw mm1, mm3
-done4x:
- mov ecx, scanlen
- and ecx, 3
- or ecx, ecx
- jz done1x
-mainloop1x:
- movzx eax, word ptr [ebx]
- add ebx, edx
- movd mm2, eax
- dec ecx
- pminsw mm0, mm2
- pmaxsw mm1, mm2
- jnz mainloop1x
-done1x:
- movd eax, mm0
- movd edx, mm1
- movsx eax, ax
- movsx edx, dx
- mov [esi], eax
- mov [edi], edx
- emms
+ scanlen *= channels;
+
+ __m64 minVal = _mm_cvtsi32_si64(smin);
+ __m64 maxVal = _mm_cvtsi32_si64(smax);
+
+ // Put minimum / maximum in 4 packed int16 values
+ minVal = _mm_unpacklo_pi16(minVal, minVal);
+ maxVal = _mm_unpacklo_pi16(maxVal, maxVal);
+ minVal = _mm_unpacklo_pi32(minVal, minVal);
+ maxVal = _mm_unpacklo_pi32(maxVal, maxVal);
+
+ int scanlen4 = scanlen / 4;
+ if(scanlen4)
+ {
+ const __m64 *v = static_cast<const __m64 *>(p);
+ p = static_cast<const uint64 *>(p) + scanlen4;
+
+ while(scanlen4--)
+ {
+ __m64 curVals = *(v++);
+ minVal = _mm_min_pi16(minVal, curVals);
+ maxVal = _mm_max_pi16(maxVal, curVals);
+ }
+
+ __m64 minVal2 = _mm_unpackhi_pi32(minVal, minVal);
+ __m64 maxVal2 = _mm_unpackhi_pi32(maxVal, maxVal);
+
+ minVal = _mm_min_pi16(minVal, minVal2);
+ maxVal = _mm_max_pi16(maxVal, maxVal2);
+
+ if(channels < 2)
+ {
+ // Mono
+ minVal2 = _mm_sra_pi32(minVal2, _mm_cvtsi32_si64(16));
+ maxVal2 = _mm_sra_pi32(maxVal2, _mm_cvtsi32_si64(16));
+ minVal = _mm_min_pi16(minVal, minVal2);
+ maxVal = _mm_max_pi16(maxVal, maxVal2);
+ }
+
+ ASSERT(p == v);
}
+
+ const int8 *p8 = static_cast<const int8 *>(p);
+ while(scanlen & 3)
+ {
+ scanlen -= channels;
+ __m64 curVals = _mm_cvtsi32_si64(*reinterpret_cast<const int16 *>(p8));
+ p8 += channels;
+ minVal = _mm_min_pi16(minVal, curVals);
+ maxVal = _mm_max_pi16(maxVal, curVals);
+ }
+
+ smin = static_cast<int16>(_mm_cvtsi64_si32(minVal));
+ smax = static_cast<int16>(_mm_cvtsi64_si32(maxVal));
+
+ _mm_empty();
}
-static void amdmmxext_or_sse_findminmax8(const void *p, int scanlen, int smplsize, int *smin, int *smax)
+// AMD MMX/SSE implementation for min/max finder, packs 8*int8 in a 64-bit MMX register.
+// scanlen = How many samples to process on this channel
+static void amdmmxext_or_sse_findminmax8(const void *p, int scanlen, int channels, int &smin, int &smax)
//------------------------------------------------------------------------------------------------------
{
- _asm {
- mov ebx, p
- mov ecx, scanlen
- mov edx, smplsize
- mov esi, smin
- mov edi, smax
- movd mm0, [esi] // mm0 = min
- movd mm1, [edi] // mm1 = max
- shr ecx, 3
- mov eax, 0x80808080
- movd mm7, eax
- punpckldq mm7, mm7
- or ecx, ecx
- punpcklbw mm0, mm0
- punpcklbw mm1, mm1
- punpcklwd mm0, mm0
- punpcklwd mm1, mm1
- punpckldq mm0, mm0
- punpckldq mm1, mm1
- pxor mm0, mm7
- pxor mm1, mm7
- jz done8x
-mainloop8x:
- movq mm2, [ebx]
- add ebx, edx
- dec ecx
- pxor mm2, mm7
- pminub mm0, mm2
- pmaxub mm1, mm2
- jnz mainloop8x
- movq mm2, mm0
- movq mm3, mm1
- punpckhdq mm2, mm2
- punpckhdq mm3, mm3
- pminub mm0, mm2
- pmaxub mm1, mm3
- cmp edx, 1
- psrld mm2, 16
- psrld mm3, 16
- pminub mm0, mm2
- pmaxub mm1, mm3
- jg done8x
- psrld mm2, 8
- psrld mm3, 8
- pminub mm0, mm2
- pmaxub mm1, mm3
-done8x:
- mov ecx, scanlen
- and ecx, 7
- or ecx, ecx
- jz done1x
-mainloop1x:
- movzx eax, byte ptr [ebx]
- add ebx, edx
- movd mm2, eax
- dec ecx
- pxor mm2, mm7
- pminub mm0, mm2
- pmaxub mm1, mm2
- jnz mainloop1x
-done1x:
- pxor mm0, mm7
- pxor mm1, mm7
- movd eax, mm0
- movd edx, mm1
- movsx eax, al
- movsx edx, dl
- mov [esi], eax
- mov [edi], edx
- emms
+ scanlen *= channels;
+
+ __m64 minVal = _mm_cvtsi32_si64(smin);
+ __m64 maxVal = _mm_cvtsi32_si64(smax);
+
+ // For signed <-> unsigned conversion
+ __m64 xorVal = _mm_cvtsi32_si64(0x80808080);
+ xorVal = _mm_unpacklo_pi32(xorVal, xorVal);
+
+ // Put minimum / maximum in 8 packed uint8 values
+ minVal = _mm_unpacklo_pi8(minVal, minVal);
+ maxVal = _mm_unpacklo_pi8(maxVal, maxVal);
+ minVal = _mm_unpacklo_pi16(minVal, minVal);
+ maxVal = _mm_unpacklo_pi16(maxVal, maxVal);
+ minVal = _mm_unpacklo_pi32(minVal, minVal);
+ maxVal = _mm_unpacklo_pi32(maxVal, maxVal);
+ minVal = _mm_xor_si64(minVal, xorVal);
+ maxVal = _mm_xor_si64(maxVal, xorVal);
+
+ int scanlen8 = scanlen / 8;
+ if(scanlen8)
+ {
+ const __m64 *v = static_cast<const __m64 *>(p);
+ p = static_cast<const uint64 *>(p) + scanlen8;
+
+ while(scanlen8--)
+ {
+ __m64 curVals = _mm_xor_si64(*(v++), xorVal);
+ minVal = _mm_min_pu8(minVal, curVals);
+ maxVal = _mm_max_pu8(maxVal, curVals);
+ }
+
+ __m64 minVal2 = _mm_unpackhi_pi32(minVal, minVal);
+ __m64 maxVal2 = _mm_unpackhi_pi32(maxVal, maxVal);
+
+ minVal = _mm_min_pu8(minVal, minVal2);
+ maxVal = _mm_max_pu8(maxVal, maxVal2);
+
+ minVal2 = _mm_srl_pi32(minVal2, _mm_cvtsi32_si64(16));
+ maxVal2 = _mm_srl_pi32(maxVal2, _mm_cvtsi32_si64(16));
+ minVal = _mm_min_pu8(minVal, minVal2);
+ maxVal = _mm_max_pu8(maxVal, maxVal2);
+
+ if(channels < 2)
+ {
+ // Mono
+ minVal2 = _mm_srl_pi32(minVal2, _mm_cvtsi32_si64(8));
+ maxVal2 = _mm_srl_pi32(maxVal2, _mm_cvtsi32_si64(8));
+ minVal = _mm_min_pu8(minVal, minVal2);
+ maxVal = _mm_max_pu8(maxVal, maxVal2);
+ }
+
+ ASSERT(p == v);
}
+
+ const int8 *p8 = static_cast<const int8 *>(p);
+ while(scanlen & 7)
+ {
+ scanlen -= channels;
+ __m64 curVals = _mm_xor_si64(_mm_cvtsi32_si64(*p8), xorVal);
+ p8 += channels;
+ minVal = _mm_min_pu8(minVal, curVals);
+ maxVal = _mm_max_pu8(maxVal, curVals);
+ }
+
+ minVal = _mm_xor_si64(minVal, xorVal);
+ maxVal = _mm_xor_si64(maxVal, xorVal);
+ smin = static_cast<int8>(_mm_cvtsi64_si32(minVal));
+ smax = static_cast<int8>(_mm_cvtsi64_si32(maxVal));
+
+ _mm_empty();
}
#endif
@@ -715,7 +721,7 @@
void CViewSample::DrawSampleData2(HDC hdc, int ymed, int cx, int cy, SmpLength len, int uFlags, const void *pSampleData)
//----------------------------------------------------------------------------------------------------------------------
{
- int smplsize, oldsmin, oldsmax;
+ int oldsmin, oldsmax;
int yrange = cy/2;
const int8 *psample = static_cast<const int8 *>(pSampleData);
int32 y0 = 0, xmax;
@@ -723,8 +729,9 @@
uint64 posincr, posfrac; // Increments have 16-bit fractional part
if (len <= 0) return;
- smplsize = (uFlags & CHN_16BIT) ? 2 : 1;
- if (uFlags & CHN_STEREO) smplsize *= 2;
+ const int numChannels = (uFlags & CHN_STEREO) ? 2 : 1;
+ const int smplsize = ((uFlags & CHN_16BIT) ? 2 : 1) * numChannels;
+
if (uFlags & CHN_16BIT)
{
y0 = YCVT(*((const int16 *)(psample-smplsize)), 15);
@@ -767,7 +774,7 @@
#if defined(ENABLE_X86_AMD) || defined(ENABLE_SSE)
if(GetProcSupport() & (PROCSUPPORT_AMD_MMXEXT|PROCSUPPORT_SSE))
{
- amdmmxext_or_sse_findminmax16(p, scanlen, smplsize, &smin, &smax);
+ amdmmxext_or_sse_findminmax16(p, scanlen, numChannels, smin, smax);
} else
#endif
{
@@ -776,7 +783,7 @@
int s = *p;
if (s < smin) smin = s;
if (s > smax) smax = s;
- p = (signed short *)(((signed char *)p) + smplsize);
+ p += numChannels;
}
}
smin = YCVT(smin,15);
@@ -790,7 +797,7 @@
#if defined(ENABLE_X86_AMD) || defined(ENABLE_SSE)
if(GetProcSupport() & (PROCSUPPORT_AMD_MMXEXT|PROCSUPPORT_SSE))
{
- amdmmxext_or_sse_findminmax8(p, scanlen, smplsize, &smin, &smax);
+ amdmmxext_or_sse_findminmax8(p, scanlen, numChannels, smin, smax);
} else
#endif
{
@@ -800,7 +807,7 @@
int s = *p;
if (s < smin) smin = s;
if (s > smax) smax = s;
- p += smplsize;
+ p += numChannels;
}
}
smin = YCVT(smin,7);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-02-22 21:49:50
|
Revision: 3753
http://sourceforge.net/p/modplug/code/3753
Author: saga-games
Date: 2014-02-22 21:49:40 +0000 (Sat, 22 Feb 2014)
Log Message:
-----------
[Fix] Minor fix to SSE sample display code (not relevant in many cases)
Modified Paths:
--------------
trunk/OpenMPT/mptrack/View_smp.cpp
Modified: trunk/OpenMPT/mptrack/View_smp.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_smp.cpp 2014-02-22 21:15:25 UTC (rev 3752)
+++ trunk/OpenMPT/mptrack/View_smp.cpp 2014-02-22 21:49:40 UTC (rev 3753)
@@ -620,12 +620,12 @@
ASSERT(p == v);
}
- const int8 *p8 = static_cast<const int8 *>(p);
+ const int16 *p16 = static_cast<const int16 *>(p);
while(scanlen & 3)
{
scanlen -= channels;
- __m64 curVals = _mm_cvtsi32_si64(*reinterpret_cast<const int16 *>(p8));
- p8 += channels;
+ __m64 curVals = _mm_cvtsi32_si64(*p16);
+ p16 += channels;
minVal = _mm_min_pi16(minVal, curVals);
maxVal = _mm_max_pi16(maxVal, curVals);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-03-29 19:02:39
|
Revision: 3997
http://sourceforge.net/p/modplug/code/3997
Author: saga-games
Date: 2014-03-29 19:02:30 +0000 (Sat, 29 Mar 2014)
Log Message:
-----------
[Fix] Sample editor: Turns out that min8/max8 instructions are only available as unsigned instructions in SSE2... (http://bugs.openmpt.org/view.php?id=496)
Modified Paths:
--------------
trunk/OpenMPT/mptrack/View_smp.cpp
Modified: trunk/OpenMPT/mptrack/View_smp.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_smp.cpp 2014-03-29 18:28:18 UTC (rev 3996)
+++ trunk/OpenMPT/mptrack/View_smp.cpp 2014-03-29 19:02:30 UTC (rev 3997)
@@ -589,8 +589,8 @@
// AMD MMX/SSE implementation for min/max finder, packs 4*int16 in a 64-bit MMX register.
// scanlen = How many samples to process on this channel
-static void amdmmxext_or_sse_findminmax16(const void *p, int scanlen, int channels, int &smin, int &smax)
-//-------------------------------------------------------------------------------------------------------
+static void amdmmxext_or_sse_findminmax16(const void *p, SmpLength scanlen, int channels, int &smin, int &smax)
+//-------------------------------------------------------------------------------------------------------------
{
scanlen *= channels;
__m64 minVal = _mm_cvtsi32_si64(smin);
@@ -602,7 +602,7 @@
minVal = _mm_unpacklo_pi32(minVal, minVal);
maxVal = _mm_unpacklo_pi32(maxVal, maxVal);
- int scanlen4 = scanlen / 4;
+ SmpLength scanlen4 = scanlen / 4;
if(scanlen4)
{
const __m64 *v = static_cast<const __m64 *>(p);
@@ -653,8 +653,8 @@
// AMD MMX/SSE implementation for min/max finder, packs 8*int8 in a 64-bit MMX register.
// scanlen = How many samples to process on this channel
-static void amdmmxext_or_sse_findminmax8(const void *p, int scanlen, int channels, int &smin, int &smax)
-//------------------------------------------------------------------------------------------------------
+static void amdmmxext_or_sse_findminmax8(const void *p, SmpLength scanlen, int channels, int &smin, int &smax)
+//------------------------------------------------------------------------------------------------------------
{
scanlen *= channels;
@@ -675,7 +675,7 @@
minVal = _mm_xor_si64(minVal, xorVal);
maxVal = _mm_xor_si64(maxVal, xorVal);
- int scanlen8 = scanlen / 8;
+ SmpLength scanlen8 = scanlen / 8;
if(scanlen8)
{
const __m64 *v = static_cast<const __m64 *>(p);
@@ -738,8 +738,8 @@
// SSE2 implementation for min/max finder, packs 8*int16 in a 128-bit XMM register.
// scanlen = How many samples to process on this channel
-static void sse2_findminmax16(const void *p, int scanlen, int channels, int &smin, int &smax)
-//-------------------------------------------------------------------------------------------
+static void sse2_findminmax16(const void *p, SmpLength scanlen, int channels, int &smin, int &smax)
+//-------------------------------------------------------------------------------------------------
{
scanlen *= channels;
@@ -747,7 +747,7 @@
__m128i minVal = _mm_set1_epi16(static_cast<int16>(smin));
__m128i maxVal = _mm_set1_epi16(static_cast<int16>(smax));
- int scanlen8 = scanlen / 8;
+ SmpLength scanlen8 = scanlen / 8;
if(scanlen8)
{
const __m128i *v = static_cast<const __m128i *>(p);
@@ -801,16 +801,19 @@
// SSE2 implementation for min/max finder, packs 16*int8 in a 128-bit XMM register.
// scanlen = How many samples to process on this channel
-static void sse2_findminmax8(const void *p, int scanlen, int channels, int &smin, int &smax)
-//------------------------------------------------------------------------------------------
+static void sse2_findminmax8(const void *p, SmpLength scanlen, int channels, int &smin, int &smax)
+//------------------------------------------------------------------------------------------------
{
scanlen *= channels;
- // Put minimum / maximum in 8 packed int16 values
- __m128i minVal = _mm_set1_epi8(static_cast<int8>(smin));
- __m128i maxVal = _mm_set1_epi8(static_cast<int8>(smax));
+ // Put minimum / maximum in 16 packed int8 values
+ __m128i minVal = _mm_set1_epi8(static_cast<int8>(smin ^ 0x80u));
+ __m128i maxVal = _mm_set1_epi8(static_cast<int8>(smax ^ 0x80u));
- int scanlen16 = scanlen / 16;
+ // For signed <-> unsigned conversion (_mm_min_epi8/_mm_max_epi8 is SSE4)
+ __m128i xorVal = _mm_set1_epi8(0x80u);
+
+ SmpLength scanlen16 = scanlen / 16;
if(scanlen16)
{
const __m128i *v = static_cast<const __m128i *>(p);
@@ -819,38 +822,39 @@
while(scanlen16--)
{
__m128i curVals = _mm_loadu_si128(v++);
- minVal = _mm_min_epi8(minVal, curVals);
- maxVal = _mm_max_epi8(maxVal, curVals);
+ curVals = _mm_xor_si128(curVals, xorVal);
+ minVal = _mm_min_epu8(minVal, curVals);
+ maxVal = _mm_max_epu8(maxVal, curVals);
}
// Now we have 16 minima and maxima each, in case of stereo they are interleaved L/R values.
// Move the upper 8 values to the lower half and compute the minima/maxima of that.
__m128i minVal2 = _mm_unpackhi_epi64(minVal, minVal);
__m128i maxVal2 = _mm_unpackhi_epi64(maxVal, maxVal);
- minVal = _mm_min_epi8(minVal, minVal2);
- maxVal = _mm_max_epi8(maxVal, maxVal2);
+ minVal = _mm_min_epu8(minVal, minVal2);
+ maxVal = _mm_max_epu8(maxVal, maxVal2);
// Now we have 8 minima and maxima each, in case of stereo they are interleaved L/R values.
// Move the upper 4 values to the lower half and compute the minima/maxima of that.
minVal2 = _mm_shuffle_epi32(minVal, _MM_SHUFFLE(1, 1, 1, 1));
maxVal2 = _mm_shuffle_epi32(maxVal, _MM_SHUFFLE(1, 1, 1, 1));
- minVal = _mm_min_epi8(minVal, minVal2);
- maxVal = _mm_max_epi8(maxVal, maxVal2);
+ minVal = _mm_min_epu8(minVal, minVal2);
+ maxVal = _mm_max_epu8(maxVal, maxVal2);
// Now we have 4 minima and maxima each, in case of stereo they are interleaved L/R values.
// Move the upper 2 values to the lower half and compute the minima/maxima of that.
minVal2 = _mm_srai_epi32(minVal, 16);
maxVal2 = _mm_srai_epi32(maxVal, 16);
- minVal = _mm_min_epi8(minVal, minVal2);
- maxVal = _mm_max_epi8(maxVal, maxVal2);
+ minVal = _mm_min_epu8(minVal, minVal2);
+ maxVal = _mm_max_epu8(maxVal, maxVal2);
if(channels < 2)
{
// Mono: Compute the minima/maxima of the both remaining values
minVal2 = _mm_srai_epi16(minVal, 8);
maxVal2 = _mm_srai_epi16(maxVal, 8);
- minVal = _mm_min_epi8(minVal, minVal2);
- maxVal = _mm_max_epi8(maxVal, maxVal2);
+ minVal = _mm_min_epu8(minVal, minVal2);
+ maxVal = _mm_max_epu8(maxVal, maxVal2);
}
}
@@ -858,14 +862,14 @@
while(scanlen & 15)
{
scanlen -= channels;
- __m128i curVals = _mm_set1_epi8(*p8);
+ __m128i curVals = _mm_set1_epi8((*p8) ^ 0x80u);
p8 += channels;
- minVal = _mm_min_epi8(minVal, curVals);
- maxVal = _mm_max_epi8(maxVal, curVals);
+ minVal = _mm_min_epu8(minVal, curVals);
+ maxVal = _mm_max_epu8(maxVal, curVals);
}
- smin = static_cast<int8>(_mm_cvtsi128_si32(minVal));
- smax = static_cast<int8>(_mm_cvtsi128_si32(maxVal));
+ smin = static_cast<int8>(_mm_cvtsi128_si32(minVal) ^ 0x80u);
+ smax = static_cast<int8>(_mm_cvtsi128_si32(maxVal) ^ 0x80u);
}
@@ -3003,10 +3007,10 @@
const CSoundFile &sndFile = GetDocument()->GetrSoundFile();
// zoomOrder: Biggest to smallest zoom order.
int zoomOrder[(-MIN_ZOOM - 1) + (MAX_ZOOM + 1)];
- for(size_t i = 2; i < -MIN_ZOOM + 1; ++i)
+ for(int i = 2; i < -MIN_ZOOM + 1; ++i)
zoomOrder[i - 2] = MIN_ZOOM + i - 2; // -6, -5, -4, -3...
- for(size_t i = 1; i <= MAX_ZOOM; ++i)
+ for(int i = 1; i <= MAX_ZOOM; ++i)
zoomOrder[i + - 1 + (-MIN_ZOOM - 1)] = i; // 1, 2, 3...
zoomOrder[CountOf(zoomOrder) - 1] = 0;
int* const pZoomOrderEnd = zoomOrder + CountOf(zoomOrder);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-12-02 22:33:54
|
Revision: 4626
http://sourceforge.net/p/modplug/code/4626
Author: saga-games
Date: 2014-12-02 22:33:39 +0000 (Tue, 02 Dec 2014)
Log Message:
-----------
[Fix] Sample tab: Sustain loop display accidentally changed in r4614
[Imp] Sample tab: Visually distinguish sustain loop and sample grid markers
Revision Links:
--------------
http://sourceforge.net/p/modplug/code/4614
Modified Paths:
--------------
trunk/OpenMPT/mptrack/View_smp.cpp
Modified: trunk/OpenMPT/mptrack/View_smp.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_smp.cpp 2014-12-02 19:53:57 UTC (rev 4625)
+++ trunk/OpenMPT/mptrack/View_smp.cpp 2014-12-02 22:33:39 UTC (rev 4626)
@@ -1111,6 +1111,7 @@
// Sustain Loop Start/End
if ((sample.nSustainEnd > nSmpScrollPos) && (sample.nSustainEnd > sample.nSustainStart))
{
+ offScreenDC.SetBkColor(RGB(0xFF, 0xFF, 0xFF));
offScreenDC.SelectObject(CMainFrame::penHalfDarkGray);
int xl = SampleToScreen(sample.nSustainStart);
if ((xl >= 0) && (xl < rcClient.right))
@@ -1167,6 +1168,7 @@
if(m_nGridSegments && m_nGridSegments < sample.nLength)
{
// Draw sample grid
+ offScreenDC.SetBkColor(TrackerSettings::Instance().rgbCustomColors[MODCOLOR_BACKSAMPLE]);
offScreenDC.SelectObject(CMainFrame::penHalfDarkGray);
for(SmpLength i = 1; i < m_nGridSegments; i++)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|