|
From: <sag...@us...> - 2014-09-29 23:37:55
|
Revision: 4329
http://sourceforge.net/p/modplug/code/4329
Author: saga-games
Date: 2014-09-29 23:37:44 +0000 (Mon, 29 Sep 2014)
Log Message:
-----------
[Ref] Split MOD-/DIGI-specific part of CSoundFile::GetNoteFromPeriod into the MOD pattern reader. It is not needed in any other cases and may lead to unwanted effects when trying to use this function in other contexts.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_mod.cpp
trunk/OpenMPT/soundlib/Snd_fx.cpp
Modified: trunk/OpenMPT/soundlib/Load_mod.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mod.cpp 2014-09-29 14:44:41 UTC (rev 4328)
+++ trunk/OpenMPT/soundlib/Load_mod.cpp 2014-09-29 23:37:44 UTC (rev 4329)
@@ -464,7 +464,25 @@
uint16 period = (((static_cast<uint16>(data[0]) & 0x0F) << 8) | data[1]);
if(period > 0 && period != 0xFFF)
{
- m.note = static_cast<ModCommand::NOTE>(GetNoteFromPeriod(period * 4));
+ m.note = 6 * 12 + 35 + NOTE_MIN;
+ for(int i = 0; i < 6 * 12; i++)
+ {
+ if(period >= ProTrackerPeriodTable[i])
+ {
+ if(period != ProTrackerPeriodTable[i] && i != 0)
+ {
+ uint16 p1 = ProTrackerPeriodTable[i - 1];
+ uint16 p2 = ProTrackerPeriodTable[i];
+ if(p1 - period < (period - p2))
+ {
+ m.note = static_cast<ModCommand::NOTE>(i + 35 + NOTE_MIN);
+ break;
+ }
+ }
+ m.note = static_cast<ModCommand::NOTE>(i + 36 + NOTE_MIN);
+ break;
+ }
+ }
}
// Read Instrument
m.instr = (data[2] >> 4) | (data[0] & 0x10);
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-09-29 14:44:41 UTC (rev 4328)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-09-29 23:37:44 UTC (rev 4329)
@@ -4928,46 +4928,25 @@
//---------------------------------------------------------------------------------
{
if (!period) return 0;
- if (GetType() & (MOD_TYPE_MED|MOD_TYPE_MOD|MOD_TYPE_DIGI|MOD_TYPE_MTM|MOD_TYPE_669|MOD_TYPE_OKT|MOD_TYPE_AMF0))
+ // This essentially implements std::lower_bound, with the difference that we don't need an iterable container.
+ uint32 minNote = NOTE_MIN, maxNote = NOTE_MAX, count = maxNote - minNote + 1;
+ while(count > 0)
{
- period >>= 2;
- for (UINT i=0; i<6*12; i++)
+ const uint32 step = count / 2, midNote = minNote + step;
+ uint32 n = GetPeriodFromNote(midNote, nFineTune, nC5Speed);
+ if(n > period || !n)
{
- if (period >= ProTrackerPeriodTable[i])
- {
- if ((period != ProTrackerPeriodTable[i]) && (i))
- {
- UINT p1 = ProTrackerPeriodTable[i-1];
- UINT p2 = ProTrackerPeriodTable[i];
- if (p1 - period < (period - p2)) return i+36;
- }
- return i+1+36;
- }
- }
- return 6*12+36;
- } else
- {
- // This essentially implements std::lower_bound, with the difference that we don't need an iterable container.
- uint32 minNote = NOTE_MIN, maxNote = NOTE_MAX, count = maxNote - minNote + 1;
- while(count > 0)
+ minNote = midNote + 1;
+ count -= step + 1;
+ } else
{
- const uint32 step = count / 2, midNote = minNote + step;
- uint32 n = GetPeriodFromNote(midNote, nFineTune, nC5Speed);
- if(n > period || !n)
- {
- minNote = midNote + 1;
- count -= step + 1;
- } else
- {
- count = step;
- }
+ count = step;
}
- return minNote;
}
+ return minNote;
}
-
UINT CSoundFile::GetPeriodFromNote(UINT note, int nFineTune, UINT nC5Speed) const
//-------------------------------------------------------------------------------
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|