|
From: <man...@us...> - 2013-05-23 18:10:13
|
Revision: 2179
http://sourceforge.net/p/modplug/code/2179
Author: manxorist
Date: 2013-05-23 18:10:04 +0000 (Thu, 23 May 2013)
Log Message:
-----------
[Ref] GCC before 4.6 does not have pragma diagnostic push. Fix the warning.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/MIDIMacros.cpp
trunk/OpenMPT/soundlib/SampleIO.cpp
Modified: trunk/OpenMPT/soundlib/MIDIMacros.cpp
===================================================================
--- trunk/OpenMPT/soundlib/MIDIMacros.cpp 2013-05-23 14:52:10 UTC (rev 2178)
+++ trunk/OpenMPT/soundlib/MIDIMacros.cpp 2013-05-23 18:10:04 UTC (rev 2179)
@@ -74,7 +74,9 @@
#if MPT_COMPILER_GCC
+#if MPT_GCC_AT_LEAST(4,6,0)
#pragma GCC diagnostic push
+#endif
#pragma GCC diagnostic ignored "-Wswitch"
#elif MPT_COMPILER_CLANG
#pragma clang diagnostic push
@@ -117,14 +119,18 @@
}
#if MPT_COMPILER_GCC
+#if MPT_GCC_AT_LEAST(4,6,0)
#pragma GCC diagnostic pop
+#endif
#elif MPT_COMPILER_CLANG
#pragma clang diagnostic pop
#endif
#if MPT_COMPILER_GCC
+#if MPT_GCC_AT_LEAST(4,6,0)
#pragma GCC diagnostic push
+#endif
#pragma GCC diagnostic ignored "-Wswitch"
#elif MPT_COMPILER_CLANG
#pragma clang diagnostic push
@@ -185,7 +191,9 @@
}
#if MPT_COMPILER_GCC
+#if MPT_GCC_AT_LEAST(4,6,0)
#pragma GCC diagnostic pop
+#endif
#elif MPT_COMPILER_CLANG
#pragma clang diagnostic pop
#endif
Modified: trunk/OpenMPT/soundlib/SampleIO.cpp
===================================================================
--- trunk/OpenMPT/soundlib/SampleIO.cpp 2013-05-23 14:52:10 UTC (rev 2178)
+++ trunk/OpenMPT/soundlib/SampleIO.cpp 2013-05-23 18:10:04 UTC (rev 2179)
@@ -24,7 +24,9 @@
#if MPT_COMPILER_GCC
+#if MPT_GCC_AT_LEAST(4,6,0)
#pragma GCC diagnostic push
+#endif
#pragma GCC diagnostic ignored "-Wswitch"
#elif MPT_COMPILER_CLANG
#pragma clang diagnostic push
@@ -401,7 +403,9 @@
}
#if MPT_COMPILER_GCC
+#if MPT_GCC_AT_LEAST(4,6,0)
#pragma GCC diagnostic pop
+#endif
#elif MPT_COMPILER_CLANG
#pragma clang diagnostic pop
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-05-24 20:01:49
|
Revision: 2182
http://sourceforge.net/p/modplug/code/2182
Author: manxorist
Date: 2013-05-24 20:01:34 +0000 (Fri, 24 May 2013)
Log Message:
-----------
[Mod] Remove rather questionable frequency rounding in TransposeToFrequency which was inherited from the modplug codebase.
[Mod] Remove other questionable rounding and frequency clamping in ReadNote(). Hope that nothing breaks.
[Ref] Remove inline asm in really not performance cirtical codepaths (TransposeToFrequency, FrequencyToTranspose, PatchFreqToNote) and replace it with a readable c++ implementation.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/ModSample.cpp
trunk/OpenMPT/soundlib/SampleFormats.cpp
trunk/OpenMPT/soundlib/Sndmix.cpp
Modified: trunk/OpenMPT/soundlib/ModSample.cpp
===================================================================
--- trunk/OpenMPT/soundlib/ModSample.cpp 2013-05-24 12:42:41 UTC (rev 2181)
+++ trunk/OpenMPT/soundlib/ModSample.cpp 2013-05-24 20:01:34 UTC (rev 2182)
@@ -185,45 +185,10 @@
/////////////////////////////////////////////////////////////
// Transpose <-> Frequency conversions
-// returns 8363*2^((transp*128+ftune)/(12*128))
uint32 ModSample::TransposeToFrequency(int transpose, int finetune)
//-----------------------------------------------------------------
{
- // return (unsigned int) (8363.0 * pow(2, (transp * 128.0 + ftune) / 1536.0));
- const float _fbase = 8363;
- const float _factor = 1.0f / (12.0f * 128.0f);
- uint32 freq;
-
-#if defined(ENABLE_X86)
- int result;
- transpose = (transpose << 7) + finetune;
- _asm
- {
- fild transpose
- fld _factor
- fmulp st(1), st(0)
- fist result
- fisub result
- f2xm1
- fild result
- fld _fbase
- fscale
- fstp st(1)
- fmul st(1), st(0)
- faddp st(1), st(0)
- fistp freq
- }
-#else // !ENABLE_X86
- freq = static_cast<uint32>(std::pow(2.0f, (transpose * 128 + finetune) * _factor) * _fbase);
-#endif // ENABLE_X86
-
- uint32 derr = freq % 11025;
- if(derr <= 8) freq -= derr;
- if(derr >= 11015) freq += 11025 - derr;
- derr = freq % 1000;
- if(derr <= 5) freq -= derr;
- if(derr >= 995) freq += 1000 - derr;
- return freq;
+ return Util::Round<uint32>(std::pow(2.0f, (transpose * 128.0f + finetune) * (1.0f / (12.0f * 128.0f))) * 8363.0f);
}
@@ -234,36 +199,11 @@
}
-// returns 12*128*log2(freq/8363)
int ModSample::FrequencyToTranspose(uint32 freq)
//----------------------------------------------
{
- // return (int) (1536.0 * (log(freq / 8363.0) / log(2)));
-
- const float _f1_8363 = 1.0f / 8363.0f;
- const float _factor = 128 * 12;
- int result;
-
- if(!freq)
- {
- return 0;
- }
-
-#if defined(ENABLE_X86)
- _asm
- {
- fld _factor
- fild freq
- fld _f1_8363
- fmulp st(1), st(0)
- fyl2x
- fistp result
- }
-#else // !ENABLE_X86
const float inv_log_2 = 1.44269504089f; // 1.0f/std::log(2.0f)
- result = std::log(freq * _f1_8363) * (_factor * inv_log_2);
-#endif // ENABLE_X86
- return result;
+ return Util::Round<int>(std::log(freq * (1.0f / 8363.0f)) * (12.0f * 128.0f * inv_log_2));
}
Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp
===================================================================
--- trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-05-24 12:42:41 UTC (rev 2181)
+++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-05-24 20:01:34 UTC (rev 2182)
@@ -677,28 +677,12 @@
#pragma pack(pop)
#endif
-// returns 12*Log2(nFreq/2044)
-LONG PatchFreqToNote(ULONG nFreq)
-//-------------------------------
+static int32 PatchFreqToNote(uint32 nFreq)
+//----------------------------------------
{
- const float k_base = 1.0f / 2044.0f;
- const float k_12 = 12;
- LONG result;
- if (nFreq < 1) return 0;
-#if defined(ENABLE_X86)
- _asm {
- fld k_12
- fild nFreq
- fld k_base
- fmulp ST(1), ST(0)
- fyl2x
- fistp result
- }
-#else // !ENABLE_X86
const float inv_log_2 = 1.44269504089f; // 1.0f/std::log(2.0f)
- result = std::log(nFreq * k_base) * (k_12 * inv_log_2);
-#endif // ENABLE_X86
- return result;
+ const float base = 1.0f / 2044.0f;
+ return Util::Round<int32>(std::log(nFreq * base) * (12.0f * inv_log_2));
}
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-05-24 12:42:41 UTC (rev 2181)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-05-24 20:01:34 UTC (rev 2182)
@@ -1906,13 +1906,15 @@
pChn->nCalcVolume = 0;
}
- int32 ninc = Util::muldiv(freq, 0x10000, m_MixerSettings.gdwMixingFreq << FREQ_FRACBITS);
- if ((ninc >= 0xFFB0) && (ninc <= 0x10090)) ninc = 0x10000;
+ uint32 ninc = Util::muldivr(freq, 0x10000, m_MixerSettings.gdwMixingFreq << FREQ_FRACBITS);
#ifndef MODPLUG_TRACKER
ninc = Util::muldivr(ninc, m_nFreqFactor, 128);
#endif // !MODPLUG_TRACKER
- Limit(ninc, 3, 0xFF0000);
- pChn->nInc = (ninc + 1) & ~3;
+ if(ninc == 0)
+ {
+ ninc = 1;
+ }
+ pChn->nInc = ninc;
} else
{
// Avoid nasty noises...
@@ -2008,27 +2010,19 @@
//if (pChn->nNewRightVol > 0xFFFF) pChn->nNewRightVol = 0xFFFF;
//if (pChn->nNewLeftVol > 0xFFFF) pChn->nNewLeftVol = 0xFFFF;
- ResamplingMode resamplingMode = m_Resampler.m_Settings.SrcMode; // default to global mixer settings
- if(pChn->pModInstrument && IsKnownResamplingMode(pChn->pModInstrument->nResampling))
- {
- // for defined resampling modes, use per-instrument resampling modes if set
- resamplingMode = (ResamplingMode)pChn->pModInstrument->nResampling;
- }
- // disable interpolation in certain cases
if(pChn->nInc == 0x10000)
{
// exact samplerate match, do not resample at all, regardless of selected resampler
- resamplingMode = SRCMODE_NEAREST;
- } else if(resamplingMode == SRCMODE_LINEAR)
+ pChn->resamplingMode = SRCMODE_NEAREST;
+ } else if(pChn->pModInstrument && IsKnownResamplingMode(pChn->pModInstrument->nResampling))
{
- if(((pChn->nInc >= 0xFF00) && (pChn->nInc < 0x10100)))
- {
- // disable interpolation if rates are too close
- resamplingMode = SRCMODE_NEAREST;
- }
+ // for defined resampling modes, use per-instrument resampling mode if set
+ pChn->resamplingMode = (ResamplingMode)pChn->pModInstrument->nResampling;
+ } else
+ {
+ // default to global mixer settings
+ pChn->resamplingMode = m_Resampler.m_Settings.SrcMode;
}
- // store for the mixer
- pChn->resamplingMode = (uint8)resamplingMode;
/*if (m_pConfig->getUseGlobalPreAmp())
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-05-25 08:11:32
|
Revision: 2185
http://sourceforge.net/p/modplug/code/2185
Author: manxorist
Date: 2013-05-25 08:11:21 +0000 (Sat, 25 May 2013)
Log Message:
-----------
[Fix] Fix types of format string arguments to match format specifier on non-windows 64bit systems.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_mod.cpp
trunk/OpenMPT/soundlib/MIDIMacros.cpp
Modified: trunk/OpenMPT/soundlib/Load_mod.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mod.cpp 2013-05-24 20:36:35 UTC (rev 2184)
+++ trunk/OpenMPT/soundlib/Load_mod.cpp 2013-05-25 08:11:21 UTC (rev 2185)
@@ -1184,7 +1184,7 @@
}
} else
{
- sprintf(modMagic, "%luCHN", writeChannels);
+ sprintf(modMagic, "%uCHN", writeChannels);
}
fwrite(&modMagic, 4, 1, f);
Modified: trunk/OpenMPT/soundlib/MIDIMacros.cpp
===================================================================
--- trunk/OpenMPT/soundlib/MIDIMacros.cpp 2013-05-24 20:36:35 UTC (rev 2184)
+++ trunk/OpenMPT/soundlib/MIDIMacros.cpp 2013-05-25 08:11:21 UTC (rev 2185)
@@ -141,7 +141,7 @@
void MIDIMacroConfig::CreateFixedMacro(char (&fixedMacros)[128][MACRO_LENGTH], fixedMacroType macroType) const
//------------------------------------------------------------------------------------------------------------
{
- for(size_t i = 0; i < 128; i++)
+ for(unsigned int i = 0; i < 128; i++)
{
switch(macroType)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-05-25 12:08:54
|
Revision: 2190
http://sourceforge.net/p/modplug/code/2190
Author: manxorist
Date: 2013-05-25 12:08:42 +0000 (Sat, 25 May 2013)
Log Message:
-----------
[Ref] Make file saving functions build with non-MSVC.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_it.cpp
trunk/OpenMPT/soundlib/SampleFormats.cpp
Modified: trunk/OpenMPT/soundlib/Load_it.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_it.cpp 2013-05-25 10:53:32 UTC (rev 2189)
+++ trunk/OpenMPT/soundlib/Load_it.cpp 2013-05-25 12:08:42 UTC (rev 2190)
@@ -22,6 +22,9 @@
#include "../common/version.h"
#include "ITTools.h"
#include <time.h>
+#if MPT_COMPILER_GCC
+#include <ext/stdio_sync_filebuf.h>
+#endif
#define str_tooMuchPatternData (GetStrI18N((MPT_TEXT("Warning: File format limit was reached. Some pattern data may not get written to file."))))
#define str_pattern (GetStrI18N((MPT_TEXT("pattern"))))
@@ -1047,6 +1050,7 @@
const size_t num = (pModDoc != nullptr) ? pModDoc->GetFileHistory().size() + 1 : 0; // + 1 for this session
#else
const size_t num = 0;
+ UNREFERENCED_PARAMETER(pSndFile);
#endif // MODPLUG_TRACKER
uint16 fnum = (uint16)MIN(num, uint16_max); // Number of entries that are actually going to be written
@@ -1599,7 +1603,17 @@
//--------------------
fseek(f, 0, SEEK_END);
+ fflush(f);
+#if MPT_COMPILER_MSVC
std::ofstream fout(f);
+#elif MPT_COMPILER_GCC
+ __gnu_cxx::stdio_sync_filebuf<char> fout_buf(f);
+ std::ostream fout(&fout_buf);
+#else
+ fclose(f);
+ std::ofstream(lpszFileName, std::ios::binary | std::ios::ate);
+#endif
+
const uint32 MPTStartPos = (uint32)fout.tellp();
srlztn::Ssb ssb(fout);
@@ -1630,7 +1644,17 @@
return false;
}
fout.write(reinterpret_cast<const char*>(&MPTStartPos), sizeof(MPTStartPos));
+
+ fout.flush();
+#if MPT_COMPILER_MSVC
fout.close();
+#elif MPT_COMPILER_GCC
+ fflush(f);
+ fclose(f);
+#else
+ fout.close();
+#endif
+
//END : MPT SPECIFIC
//-------------------
@@ -1850,35 +1874,35 @@
return;
}*/
- code = 'MPTX'; // write extension header code
+ code = MULTICHAR4_LE_MSVC('M','P','T','X'); // write extension header code
fwrite(&code, 1, sizeof(uint32), f);
if (nInstruments == 0)
return;
- WriteInstrumentPropertyForAllInstruments('VR..', sizeof(ModInstrument().nVolRampUp), f, nInstruments);
- WriteInstrumentPropertyForAllInstruments('MiP.', sizeof(ModInstrument().nMixPlug), f, nInstruments);
- WriteInstrumentPropertyForAllInstruments('MC..', sizeof(ModInstrument().nMidiChannel),f, nInstruments);
- WriteInstrumentPropertyForAllInstruments('MP..', sizeof(ModInstrument().nMidiProgram),f, nInstruments);
- WriteInstrumentPropertyForAllInstruments('MB..', sizeof(ModInstrument().wMidiBank), f, nInstruments);
- WriteInstrumentPropertyForAllInstruments('P...', sizeof(ModInstrument().nPan), f, nInstruments);
- WriteInstrumentPropertyForAllInstruments('GV..', sizeof(ModInstrument().nGlobalVol), f, nInstruments);
- WriteInstrumentPropertyForAllInstruments('FO..', sizeof(ModInstrument().nFadeOut), f, nInstruments);
- WriteInstrumentPropertyForAllInstruments('R...', sizeof(ModInstrument().nResampling), f, nInstruments);
- WriteInstrumentPropertyForAllInstruments('CS..', sizeof(ModInstrument().nCutSwing), f, nInstruments);
- WriteInstrumentPropertyForAllInstruments('RS..', sizeof(ModInstrument().nResSwing), f, nInstruments);
- WriteInstrumentPropertyForAllInstruments('FM..', sizeof(ModInstrument().nFilterMode), f, nInstruments);
- WriteInstrumentPropertyForAllInstruments('PERN', sizeof(ModInstrument().PitchEnv.nReleaseNode ), f, nInstruments);
- WriteInstrumentPropertyForAllInstruments('AERN', sizeof(ModInstrument().PanEnv.nReleaseNode), f, nInstruments);
- WriteInstrumentPropertyForAllInstruments('VERN', sizeof(ModInstrument().VolEnv.nReleaseNode), f, nInstruments);
- WriteInstrumentPropertyForAllInstruments('PTTL', sizeof(ModInstrument().wPitchToTempoLock), f, nInstruments);
- WriteInstrumentPropertyForAllInstruments('PVEH', sizeof(ModInstrument().nPluginVelocityHandling), f, nInstruments);
- WriteInstrumentPropertyForAllInstruments('PVOH', sizeof(ModInstrument().nPluginVolumeHandling), f, nInstruments);
+ WriteInstrumentPropertyForAllInstruments(MULTICHAR4_LE_MSVC('V','R','.','.'), sizeof(ModInstrument().nVolRampUp), f, nInstruments);
+ WriteInstrumentPropertyForAllInstruments(MULTICHAR4_LE_MSVC('M','i','P','.'), sizeof(ModInstrument().nMixPlug), f, nInstruments);
+ WriteInstrumentPropertyForAllInstruments(MULTICHAR4_LE_MSVC('M','C','.','.'), sizeof(ModInstrument().nMidiChannel),f, nInstruments);
+ WriteInstrumentPropertyForAllInstruments(MULTICHAR4_LE_MSVC('M','P','.','.'), sizeof(ModInstrument().nMidiProgram),f, nInstruments);
+ WriteInstrumentPropertyForAllInstruments(MULTICHAR4_LE_MSVC('M','B','.','.'), sizeof(ModInstrument().wMidiBank), f, nInstruments);
+ WriteInstrumentPropertyForAllInstruments(MULTICHAR4_LE_MSVC('P','.','.','.'), sizeof(ModInstrument().nPan), f, nInstruments);
+ WriteInstrumentPropertyForAllInstruments(MULTICHAR4_LE_MSVC('G','V','.','.'), sizeof(ModInstrument().nGlobalVol), f, nInstruments);
+ WriteInstrumentPropertyForAllInstruments(MULTICHAR4_LE_MSVC('F','O','.','.'), sizeof(ModInstrument().nFadeOut), f, nInstruments);
+ WriteInstrumentPropertyForAllInstruments(MULTICHAR4_LE_MSVC('R','.','.','.'), sizeof(ModInstrument().nResampling), f, nInstruments);
+ WriteInstrumentPropertyForAllInstruments(MULTICHAR4_LE_MSVC('C','S','.','.'), sizeof(ModInstrument().nCutSwing), f, nInstruments);
+ WriteInstrumentPropertyForAllInstruments(MULTICHAR4_LE_MSVC('R','S','.','.'), sizeof(ModInstrument().nResSwing), f, nInstruments);
+ WriteInstrumentPropertyForAllInstruments(MULTICHAR4_LE_MSVC('F','M','.','.'), sizeof(ModInstrument().nFilterMode), f, nInstruments);
+ WriteInstrumentPropertyForAllInstruments(MULTICHAR4_LE_MSVC('P','E','R','N'), sizeof(ModInstrument().PitchEnv.nReleaseNode ), f, nInstruments);
+ WriteInstrumentPropertyForAllInstruments(MULTICHAR4_LE_MSVC('A','E','R','N'), sizeof(ModInstrument().PanEnv.nReleaseNode), f, nInstruments);
+ WriteInstrumentPropertyForAllInstruments(MULTICHAR4_LE_MSVC('V','E','R','N'), sizeof(ModInstrument().VolEnv.nReleaseNode), f, nInstruments);
+ WriteInstrumentPropertyForAllInstruments(MULTICHAR4_LE_MSVC('P','T','T','L'), sizeof(ModInstrument().wPitchToTempoLock), f, nInstruments);
+ WriteInstrumentPropertyForAllInstruments(MULTICHAR4_LE_MSVC('P','V','E','H'), sizeof(ModInstrument().nPluginVelocityHandling), f, nInstruments);
+ WriteInstrumentPropertyForAllInstruments(MULTICHAR4_LE_MSVC('P','V','O','H'), sizeof(ModInstrument().nPluginVolumeHandling), f, nInstruments);
if(!(GetType() & MOD_TYPE_XM))
{
// XM instrument headers already have support for this
- WriteInstrumentPropertyForAllInstruments('MPWD', sizeof(ModInstrument().midiPWD), f, nInstruments);
+ WriteInstrumentPropertyForAllInstruments(MULTICHAR4_LE_MSVC('M','P','W','D'), sizeof(ModInstrument().midiPWD), f, nInstruments);
}
if(GetType() & MOD_TYPE_MPT)
@@ -1893,17 +1917,17 @@
// write full envelope information for MPTM files (more env points)
if(maxNodes > 25)
{
- WriteInstrumentPropertyForAllInstruments('VE..', sizeof(ModInstrument().VolEnv.nNodes), f, nInstruments);
- WriteInstrumentPropertyForAllInstruments('VP[.', sizeof(ModInstrument().VolEnv.Ticks), f, nInstruments);
- WriteInstrumentPropertyForAllInstruments('VE[.', sizeof(ModInstrument().VolEnv.Values), f, nInstruments);
+ WriteInstrumentPropertyForAllInstruments(MULTICHAR4_LE_MSVC('V','E','.','.'), sizeof(ModInstrument().VolEnv.nNodes), f, nInstruments);
+ WriteInstrumentPropertyForAllInstruments(MULTICHAR4_LE_MSVC('V','P','[','.'), sizeof(ModInstrument().VolEnv.Ticks), f, nInstruments);
+ WriteInstrumentPropertyForAllInstruments(MULTICHAR4_LE_MSVC('V','E','[','.'), sizeof(ModInstrument().VolEnv.Values), f, nInstruments);
- WriteInstrumentPropertyForAllInstruments('PE..', sizeof(ModInstrument().PanEnv.nNodes), f, nInstruments);
- WriteInstrumentPropertyForAllInstruments('PP[.', sizeof(ModInstrument().PanEnv.Ticks), f, nInstruments);
- WriteInstrumentPropertyForAllInstruments('PE[.', sizeof(ModInstrument().PanEnv.Values), f, nInstruments);
+ WriteInstrumentPropertyForAllInstruments(MULTICHAR4_LE_MSVC('P','E','.','.'), sizeof(ModInstrument().PanEnv.nNodes), f, nInstruments);
+ WriteInstrumentPropertyForAllInstruments(MULTICHAR4_LE_MSVC('P','P','[','.'), sizeof(ModInstrument().PanEnv.Ticks), f, nInstruments);
+ WriteInstrumentPropertyForAllInstruments(MULTICHAR4_LE_MSVC('P','E','[','.'), sizeof(ModInstrument().PanEnv.Values), f, nInstruments);
- WriteInstrumentPropertyForAllInstruments('PiE.', sizeof(ModInstrument().PitchEnv.nNodes), f, nInstruments);
- WriteInstrumentPropertyForAllInstruments('PiP[', sizeof(ModInstrument().PitchEnv.Ticks), f, nInstruments);
- WriteInstrumentPropertyForAllInstruments('PiE[', sizeof(ModInstrument().PitchEnv.Values), f, nInstruments);
+ WriteInstrumentPropertyForAllInstruments(MULTICHAR4_LE_MSVC('P','i','E','.'), sizeof(ModInstrument().PitchEnv.nNodes), f, nInstruments);
+ WriteInstrumentPropertyForAllInstruments(MULTICHAR4_LE_MSVC('P','i','P','['), sizeof(ModInstrument().PitchEnv.Ticks), f, nInstruments);
+ WriteInstrumentPropertyForAllInstruments(MULTICHAR4_LE_MSVC('P','i','E','['), sizeof(ModInstrument().PitchEnv.Values), f, nInstruments);
}
}
@@ -1936,28 +1960,28 @@
{
//Extra song data - Yet Another Hack.
int16 size;
- uint32 code = 'MPTS'; //Extra song file data
+ uint32 code = MULTICHAR4_LE_MSVC('M','P','T','S'); //Extra song file data
fwrite(&code, 1, sizeof(uint32), f);
- code = 'DT..'; //write m_nDefaultTempo field code
+ code = MULTICHAR4_LE_MSVC('D','T','.','.'); //write m_nDefaultTempo field code
fwrite(&code, 1, sizeof(uint32), f);
size = sizeof(m_nDefaultTempo); //write m_nDefaultTempo field size
fwrite(&size, 1, sizeof(int16), f);
fwrite(&m_nDefaultTempo, 1, size, f); //write m_nDefaultTempo
- code = 'RPB.'; //write m_nRowsPerBeat
+ code = MULTICHAR4_LE_MSVC('R','P','B','.'); //write m_nRowsPerBeat
fwrite(&code, 1, sizeof(uint32), f);
size = sizeof(m_nDefaultRowsPerBeat);
fwrite(&size, 1, sizeof(int16), f);
fwrite(&m_nDefaultRowsPerBeat, 1, size, f);
- code = 'RPM.'; //write m_nRowsPerMeasure
+ code = MULTICHAR4_LE_MSVC('R','P','M','.'); //write m_nRowsPerMeasure
fwrite(&code, 1, sizeof(uint32), f);
size = sizeof(m_nDefaultRowsPerMeasure);
fwrite(&size, 1, sizeof(int16), f);
fwrite(&m_nDefaultRowsPerMeasure, 1, size, f);
- code = 'C...'; //write m_nChannels
+ code = MULTICHAR4_LE_MSVC('C','.','.','.'); //write m_nChannels
fwrite(&code, 1, sizeof(uint32), f);
size = sizeof(m_nChannels);
fwrite(&size, 1, sizeof(int16), f);
@@ -1965,7 +1989,7 @@
if(TypeIsIT_MPT() && GetNumChannels() > 64) //IT header has room only for 64 channels. Save the
{ //settings that do not fit to the header here as an extension.
- code = 'ChnS';
+ code = MULTICHAR4_LE_MSVC('C','h','n','S');
fwrite(&code, 1, sizeof(uint32), f);
size = (GetNumChannels() - 64) * 2;
fwrite(&size, 1, sizeof(int16), f);
@@ -1980,49 +2004,49 @@
}
}
- code = 'TM..'; //write m_nTempoMode
+ code = MULTICHAR4_LE_MSVC('T','M','.','.'); //write m_nTempoMode
fwrite(&code, 1, sizeof(uint32), f);
size = sizeof(m_nTempoMode);
fwrite(&size, 1, sizeof(int16), f);
fwrite(&m_nTempoMode, 1, size, f);
- code = 'PMM.'; //write m_nMixLevels
+ code = MULTICHAR4_LE_MSVC('P','M','M','.'); //write m_nMixLevels
fwrite(&code, 1, sizeof(uint32), f);
size = sizeof(m_nMixLevels);
fwrite(&size, 1, sizeof(int16), f);
fwrite(&m_nMixLevels, 1, size, f);
- code = 'CWV.'; //write m_dwCreatedWithVersion
+ code = MULTICHAR4_LE_MSVC('C','W','V','.'); //write m_dwCreatedWithVersion
fwrite(&code, 1, sizeof(uint32), f);
size = sizeof(m_dwCreatedWithVersion);
fwrite(&size, 1, sizeof(int16), f);
fwrite(&m_dwCreatedWithVersion, 1, size, f);
- code = 'LSWV'; //write m_dwLastSavedWithVersion
+ code = MULTICHAR4_LE_MSVC('L','S','W','V'); //write m_dwLastSavedWithVersion
fwrite(&code, 1, sizeof(uint32), f);
size = sizeof(m_dwLastSavedWithVersion);
fwrite(&size, 1, sizeof(int16), f);
fwrite(&m_dwLastSavedWithVersion, 1, size, f);
- code = 'SPA.'; //write m_nSamplePreAmp
+ code = MULTICHAR4_LE_MSVC('S','P','A','.'); //write m_nSamplePreAmp
fwrite(&code, 1, sizeof(uint32), f);
size = sizeof(m_nSamplePreAmp);
fwrite(&size, 1, sizeof(int16), f);
fwrite(&m_nSamplePreAmp, 1, size, f);
- code = 'VSTV'; //write m_nVSTiVolume
+ code = MULTICHAR4_LE_MSVC('V','S','T','V'); //write m_nVSTiVolume
fwrite(&code, 1, sizeof(uint32), f);
size = sizeof(m_nVSTiVolume);
fwrite(&size, 1, sizeof(int16), f);
fwrite(&m_nVSTiVolume, 1, size, f);
- code = 'DGV.'; //write m_nDefaultGlobalVolume
+ code = MULTICHAR4_LE_MSVC('D','G','V','.'); //write m_nDefaultGlobalVolume
fwrite(&code, 1, sizeof(uint32), f);
size = sizeof(m_nDefaultGlobalVolume);
fwrite(&size, 1, sizeof(int16), f);
fwrite(&m_nDefaultGlobalVolume, 1, size, f);
- code = 'RP..'; //write m_nRestartPos
+ code = MULTICHAR4_LE_MSVC('R','P','.','.'); //write m_nRestartPos
fwrite(&code, 1, sizeof(uint32), f);
size = sizeof(m_nRestartPos);
fwrite(&size, 1, sizeof(int16), f);
@@ -2032,7 +2056,7 @@
//Additional flags for XM/IT/MPTM
if(m_ModFlags)
{
- code = 'MSF.';
+ code = MULTICHAR4_LE_MSVC('M','S','F','.');
fwrite(&code, 1, sizeof(uint32), f);
size = sizeof(m_ModFlags);
fwrite(&size, 1, sizeof(int16), f);
@@ -2050,7 +2074,7 @@
}
else
{
- code = 'MIMA';
+ code = MULTICHAR4_LE_MSVC('M','I','M','A');
fwrite(&code, 1, sizeof(uint32), f);
size = static_cast<int16>(objectsize);
fwrite(&size, 1, sizeof(int16), f);
@@ -2221,7 +2245,7 @@
}
uint32 modularInstSize = 0;
- uint32 id = 'INSM';
+ uint32 id = MULTICHAR4_LE_MSVC('I','N','S','M');
SwapBytesLE(id);
fwrite(&id, 1, sizeof(id), f); // mark this as an instrument with modular extensions
long sizePos = ftell(f); // we will want to write the modular data's total size here
@@ -2229,7 +2253,7 @@
// Write chunks
{ //VST Slot chunk:
- id = 'PLUG';
+ id = MULTICHAR4_LE_MSVC('P','L','U','G');
SwapBytesLE(id);
fwrite(&id, 1, sizeof(uint32), f);
fwrite(&(pIns->nMixPlug), 1, sizeof(uint8), f);
Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp
===================================================================
--- trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-05-25 10:53:32 UTC (rev 2189)
+++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-05-25 12:08:42 UTC (rev 2190)
@@ -1120,7 +1120,7 @@
}
}
- int32 code = 'MPTX';
+ int32 code = MULTICHAR4_LE_MSVC('M','P','T','X');
fwrite(&code, 1, sizeof(int32), f); // Write extension tag
WriteInstrumentHeaderStruct(pIns, f); // Write full extended header.
@@ -1705,7 +1705,7 @@
}
fseek(f, 0, SEEK_END);
- int32 code = 'MPTX';
+ int32 code = MULTICHAR4_LE_MSVC('M','P','T','X');
SwapBytesLE(code);
fwrite(&code, 1, sizeof(int32), f); // Write extension tag
WriteInstrumentHeaderStruct(pIns, f); // Write full extended header.
@@ -2284,6 +2284,8 @@
FLAC__stream_encoder_delete(encoder);
return true;
#else
+ UNREFERENCED_PARAMETER(nSample);
+ UNREFERENCED_PARAMETER(lpszFileName);
return false;
#endif // NO_FLAC
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-06-06 23:16:38
|
Revision: 2310
http://sourceforge.net/p/modplug/code/2310
Author: manxorist
Date: 2013-06-06 23:16:28 +0000 (Thu, 06 Jun 2013)
Log Message:
-----------
[Fix] In ApplyGlobalVolume, ramping up and down lengths were mixed up.
[Fix] For stereo or quad output, the global volume ramping length in ApplyGlobalVolume was only half the configured length.
[Fix] For stereo or quad output, the ramped volume that got applied to the left and right channels differed slightly.
[Ref] Make the last parameter of ApplyGlobalVolume the number of samples per channel instead of the total number of samples in the mix buffer.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Sndfile.h
trunk/OpenMPT/soundlib/Sndmix.cpp
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2013-06-06 18:42:34 UTC (rev 2309)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2013-06-06 23:16:28 UTC (rev 2310)
@@ -785,7 +785,7 @@
#ifdef MODPLUG_TRACKER
void ProcessMidiOut(CHANNELINDEX nChn);
#endif // MODPLUG_TRACKER
- void ApplyGlobalVolume(int SoundBuffer[], int RearBuffer[], long lTotalSampleCount);
+ void ApplyGlobalVolume(int *SoundBuffer, int *RearBuffer, long lCount);
#ifndef MODPLUG_TRACKER
void ApplyFinalOutputGain(int SoundBuffer[], int RearBuffer[], long lCount); // lCount meaning the number of frames, totally independet from the numer of channels
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-06-06 18:42:34 UTC (rev 2309)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-06-06 23:16:28 UTC (rev 2310)
@@ -310,7 +310,7 @@
// Apply global volume
if (m_PlayConfig.getGlobalVolumeAppliesToMaster())
{
- ApplyGlobalVolume(MixSoundBuffer, MixRearBuffer, lSampleCount);
+ ApplyGlobalVolume(MixSoundBuffer, MixRearBuffer, lCount);
}
} else
{
@@ -326,7 +326,7 @@
// Apply global volume
if (m_PlayConfig.getGlobalVolumeAppliesToMaster())
{
- ApplyGlobalVolume(MixSoundBuffer, nullptr, lSampleCount);
+ ApplyGlobalVolume(MixSoundBuffer, MixRearBuffer, lCount);
}
}
@@ -2270,11 +2270,41 @@
#endif // MODPLUG_TRACKER
-void CSoundFile::ApplyGlobalVolume(int SoundBuffer[], int RearBuffer[], long lTotalSampleCount)
-//---------------------------------------------------------------------------------------------
+template<int channels>
+forceinline void ApplyGlobalVolumeWithRamping(int *SoundBuffer, int *RearBuffer, long lCount, UINT m_nGlobalVolume, long step, UINT &m_nSamplesToGlobalVolRampDest, long &m_lHighResRampingGlobalVolume)
{
- long step = 0;
+ const bool isStereo = (channels >= 2);
+ const bool hasRear = (channels >= 4);
+ for(int pos = 0; pos < lCount; ++pos)
+ {
+ if(m_nSamplesToGlobalVolRampDest > 0)
+ {
+ // Ramping required
+ m_lHighResRampingGlobalVolume += step;
+ SoundBuffer[0] = Util::muldiv(SoundBuffer[0], m_lHighResRampingGlobalVolume, MAX_GLOBAL_VOLUME << VOLUMERAMPPRECISION);
+ if(isStereo) SoundBuffer[1] = Util::muldiv(SoundBuffer[1], m_lHighResRampingGlobalVolume, MAX_GLOBAL_VOLUME << VOLUMERAMPPRECISION);
+ if(hasRear) RearBuffer[0] = Util::muldiv(RearBuffer[0] , m_lHighResRampingGlobalVolume, MAX_GLOBAL_VOLUME << VOLUMERAMPPRECISION);
+ if(hasRear) RearBuffer[1] = Util::muldiv(RearBuffer[1] , m_lHighResRampingGlobalVolume, MAX_GLOBAL_VOLUME << VOLUMERAMPPRECISION);
+ m_nSamplesToGlobalVolRampDest--;
+ } else
+ {
+ SoundBuffer[0] = Util::muldiv(SoundBuffer[0], m_nGlobalVolume, MAX_GLOBAL_VOLUME);
+ if(isStereo) SoundBuffer[1] = Util::muldiv(SoundBuffer[1], m_nGlobalVolume, MAX_GLOBAL_VOLUME);
+ if(hasRear) RearBuffer[0] = Util::muldiv(RearBuffer[0] , m_nGlobalVolume, MAX_GLOBAL_VOLUME);
+ if(hasRear) RearBuffer[1] = Util::muldiv(RearBuffer[1] , m_nGlobalVolume, MAX_GLOBAL_VOLUME);
+ m_lHighResRampingGlobalVolume = m_nGlobalVolume << VOLUMERAMPPRECISION;
+ }
+ SoundBuffer += isStereo ? 2 : 1;
+ if(hasRear) RearBuffer += 2;
+ }
+}
+
+void CSoundFile::ApplyGlobalVolume(int *SoundBuffer, int *RearBuffer, long lCount)
+//--------------------------------------------------------------------------------
+{
+
+ // should we ramp?
if(IsGlobalVolumeUnset())
{
// do not ramp if no global volume was set before (which is the case at song start), to prevent audible glitches when default volume is > 0 and it is set to 0 in the first row
@@ -2284,13 +2314,20 @@
} else if(m_nGlobalVolumeDestination != m_nGlobalVolume)
{
// User has provided new global volume
- const bool rampUp = m_nGlobalVolumeDestination > m_nGlobalVolume;
+
+ // m_nGlobalVolume: the last global volume which got set e.g. by a pattern command
+ // m_nGlobalVolumeDestination: the current target of the ramping algorithm
+ const bool rampUp = m_nGlobalVolume > m_nGlobalVolumeDestination;
+
m_nGlobalVolumeDestination = m_nGlobalVolume;
m_nSamplesToGlobalVolRampDest = m_nGlobalVolumeRampAmount = rampUp ? m_MixerSettings.glVolumeRampUpSamples : m_MixerSettings.glVolumeRampDownSamples;
}
+ // calculate ramping step
+ long step = 0;
if (m_nSamplesToGlobalVolRampDest > 0)
{
+
// Still some ramping left to do.
long highResGlobalVolumeDestination = static_cast<long>(m_nGlobalVolumeDestination) << VOLUMERAMPPRECISION;
@@ -2307,32 +2344,18 @@
}
}
- const long highResVolume = m_lHighResRampingGlobalVolume;
- const UINT samplesToRamp = m_nSamplesToGlobalVolRampDest;
-
- // SoundBuffer has interleaved left/right channels for the front channels; RearBuffer has the rear left/right channels.
- // So we process the pairs independently for ramping.
- for (int pairs = MAX(m_MixerSettings.gnChannels / 2, 1); pairs > 0; pairs--)
+ // apply volume and ramping
+ if(m_MixerSettings.gnChannels == 1)
{
- int *sample = (pairs == 1) ? SoundBuffer : RearBuffer;
- m_lHighResRampingGlobalVolume = highResVolume;
- m_nSamplesToGlobalVolRampDest = samplesToRamp;
+ ApplyGlobalVolumeWithRamping<1>(SoundBuffer, RearBuffer, lCount, m_nGlobalVolume, step, m_nSamplesToGlobalVolRampDest, m_lHighResRampingGlobalVolume);
+ } else if(m_MixerSettings.gnChannels == 2)
+ {
+ ApplyGlobalVolumeWithRamping<2>(SoundBuffer, RearBuffer, lCount, m_nGlobalVolume, step, m_nSamplesToGlobalVolRampDest, m_lHighResRampingGlobalVolume);
+ } else if(m_MixerSettings.gnChannels == 4)
+ {
+ ApplyGlobalVolumeWithRamping<4>(SoundBuffer, RearBuffer, lCount, m_nGlobalVolume, step, m_nSamplesToGlobalVolRampDest, m_lHighResRampingGlobalVolume);
+ }
- for (int pos = lTotalSampleCount; pos > 0; pos--, sample++)
- {
- if (m_nSamplesToGlobalVolRampDest > 0)
- {
- // Ramping required
- m_lHighResRampingGlobalVolume += step;
- *sample = Util::muldiv(*sample, m_lHighResRampingGlobalVolume, MAX_GLOBAL_VOLUME << VOLUMERAMPPRECISION);
- m_nSamplesToGlobalVolRampDest--;
- } else
- {
- *sample = Util::muldiv(*sample, m_nGlobalVolume, MAX_GLOBAL_VOLUME);
- m_lHighResRampingGlobalVolume = m_nGlobalVolume << VOLUMERAMPPRECISION;
- }
- }
- }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-06-07 18:08:26
|
Revision: 2313
http://sourceforge.net/p/modplug/code/2313
Author: manxorist
Date: 2013-06-07 18:08:18 +0000 (Fri, 07 Jun 2013)
Log Message:
-----------
[Ref] Add 1:1 bit-exact C translation of X86_Dither().
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Fastmix.cpp
trunk/OpenMPT/soundlib/Sndmix.cpp
trunk/OpenMPT/soundlib/Waveform.cpp
Modified: trunk/OpenMPT/soundlib/Fastmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Fastmix.cpp 2013-06-07 00:24:30 UTC (rev 2312)
+++ trunk/OpenMPT/soundlib/Fastmix.cpp 2013-06-07 18:08:18 UTC (rev 2313)
@@ -2089,6 +2089,7 @@
#ifdef ENABLE_X86
+
void X86_Dither(int *pBuffer, UINT nSamples, UINT nBits)
//------------------------------------------------------
{
@@ -2116,18 +2117,6 @@
mov edx, ebx
sar edx, cl
add eax, edx
-/*
- int a = 0, b = 0;
- for (UINT i=0; i<len; i++)
- {
- a = (a << 1) | (((DWORD)a) >> (BYTE)31);
- a ^= 0x10204080;
- a += 0x78649E7D + (b << 2);
- b += ((a << 16) | (a >> 16)) * 5;
- int c = a + b;
- p[i] = ((signed char)c ) >> 1;
- }
-*/
dec ebp
mov dword ptr [esi-4], eax
jnz noiseloop
@@ -2136,9 +2125,52 @@
mov gDitherB, ebx
}
}
-#endif
+#endif // ENABLE_X86
+
+static forceinline int32 dither_rand(uint32 &a, uint32 &b)
+//--------------------------------------------------------
+{
+ a = (a << 1) | (a >> 31);
+ a ^= 0x10204080u;
+ a += 0x78649E7Du + (b * 4);
+ b += ((a << 16 ) | (a >> 16)) * 5;
+ return (int32)b;
+}
+
+static void C_Dither(int *pBuffer, UINT nSamples, UINT nBits)
+//-----------------------------------------------------------
+{
+
+ static uint32 global_a = 0;
+ static uint32 global_b = 0;
+
+ uint32 a = global_a;
+ uint32 b = global_b;
+
+ while(nSamples--)
+ {
+ *pBuffer += dither_rand(a, b) >> (nBits + MIXING_ATTENUATION + 1);
+ pBuffer++;
+ }
+
+ global_a = a;
+ global_b = b;
+
+}
+
+void Dither(int *pBuffer, UINT nSamples, UINT nBits)
+//--------------------------------------------------
+{
+ #if defined(ENABLE_X86)
+ X86_Dither(pBuffer, nSamples, nBits);
+ #else
+ C_Dither(pBuffer, nSamples, nBits);
+ #endif
+}
+
+
#ifdef ENABLE_X86
static void X86_InterleaveFrontRear(int *pFrontBuf, int *pRearBuf, DWORD nFrames)
//-------------------------------------------------------------------------------
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-06-07 00:24:30 UTC (rev 2312)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-06-07 18:08:18 UTC (rev 2313)
@@ -62,9 +62,7 @@
-#ifdef ENABLE_X86
-extern VOID X86_Dither(int *pBuffer, UINT nSamples, UINT nBits);
-#endif
+extern void Dither(int *pBuffer, UINT nSamples, UINT nBits);
extern void InterleaveFrontRear(int *pFrontBuf, int *pRearBuf, DWORD nFrames);
extern void StereoFill(int *pBuffer, UINT nSamples, LPLONG lpROfs, LPLONG lpLOfs);
extern void MonoFromStereo(int *pMixBuf, UINT nSamples);
@@ -364,14 +362,12 @@
lTotalSampleCount *= 2;
}
-#ifdef ENABLE_X86
// Noise Shaping
if (m_MixerSettings.GetBitsPerSample() <= 16)
{
if(m_Resampler.IsHQ())
- X86_Dither(MixSoundBuffer, lTotalSampleCount, m_MixerSettings.GetBitsPerSample());
+ Dither(MixSoundBuffer, lTotalSampleCount, m_MixerSettings.GetBitsPerSample());
}
-#endif
#ifdef MODPLUG_TRACKER
// Hook Function
Modified: trunk/OpenMPT/soundlib/Waveform.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Waveform.cpp 2013-06-07 00:24:30 UTC (rev 2312)
+++ trunk/OpenMPT/soundlib/Waveform.cpp 2013-06-07 18:08:18 UTC (rev 2313)
@@ -53,9 +53,7 @@
#endif
-#ifdef ENABLE_X86
-extern void X86_Dither(int *pBuffer, UINT nSamples, UINT nBits);
-#endif
+extern void Dither(int *pBuffer, UINT nSamples, UINT nBits);
extern DWORD Convert32To8(LPVOID lpBuffer, int *, DWORD nSamples);
extern DWORD Convert32To16(LPVOID lpBuffer, int *, DWORD nSamples);
extern DWORD Convert32To24(LPVOID lpBuffer, int *, DWORD nSamples);
@@ -70,7 +68,7 @@
{
int nbuf = (n > MIXBUFFERSIZE * 2) ? MIXBUFFERSIZE * 2 : n;
X86_Normalize24BitBuffer(pbuffer, nbuf, lmax24, tempbuf);
- X86_Dither(tempbuf, nbuf, 8 * dwByteInc);
+ Dither(tempbuf, nbuf, 8 * dwByteInc);
switch(dwByteInc)
{
case 2: Convert32To16(pbuffer, tempbuf, nbuf); break;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-06-08 17:17:49
|
Revision: 2323
http://sourceforge.net/p/modplug/code/2323
Author: manxorist
Date: 2013-06-08 17:17:41 +0000 (Sat, 08 Jun 2013)
Log Message:
-----------
[Ref] Clear both, front and rear mix buffers in CreateStereoMix().
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Fastmix.cpp
trunk/OpenMPT/soundlib/Sndmix.cpp
Modified: trunk/OpenMPT/soundlib/Fastmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Fastmix.cpp 2013-06-08 00:20:19 UTC (rev 2322)
+++ trunk/OpenMPT/soundlib/Fastmix.cpp 2013-06-08 17:17:41 UTC (rev 2323)
@@ -1448,8 +1448,12 @@
CHANNELINDEX nchused, nchmixed;
if (!count) return;
+
+ // Resetting sound buffer
+ StereoFill(MixSoundBuffer, count, &gnDryROfsVol, &gnDryLOfsVol);
+ if(m_MixerSettings.gnChannels > 2) InitMixBuffer(MixRearBuffer, count*2);
+
bool ITPingPongMode = IsITPingPongMode();
- if (m_MixerSettings.gnChannels > 2) InitMixBuffer(MixRearBuffer, count*2);
nchused = nchmixed = 0;
for(CHANNELINDEX nChn=0; nChn<m_nMixChannels; nChn++)
{
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-06-08 00:20:19 UTC (rev 2322)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-06-08 17:17:41 UTC (rev 2323)
@@ -287,9 +287,6 @@
m_nMixStat = 0;
}
nMixStatCount++;
-
- // Resetting sound buffer
- StereoFill(MixSoundBuffer, lCount, &gnDryROfsVol, &gnDryLOfsVol);
if (m_MixerSettings.gnChannels >= 2)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-06-08 18:10:18
|
Revision: 2327
http://sourceforge.net/p/modplug/code/2327
Author: manxorist
Date: 2013-06-08 18:10:12 +0000 (Sat, 08 Jun 2013)
Log Message:
-----------
[Ref] There is no reason for the Convert32ToXX functions to return the written byte count because the caller has to know it up front anyway. Make them all return void.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Fastmix.cpp
trunk/OpenMPT/soundlib/Sndmix.cpp
trunk/OpenMPT/soundlib/Waveform.cpp
Modified: trunk/OpenMPT/soundlib/Fastmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Fastmix.cpp 2013-06-08 17:36:40 UTC (rev 2326)
+++ trunk/OpenMPT/soundlib/Fastmix.cpp 2013-06-08 18:10:12 UTC (rev 2327)
@@ -1730,10 +1730,9 @@
#ifdef ENABLE_X86
-static DWORD X86_Convert32To8(LPVOID lp16, int *pBuffer, DWORD lSampleCount)
-//--------------------------------------------------------------------------
+static void X86_Convert32To8(LPVOID lp16, int *pBuffer, DWORD lSampleCount)
+//-------------------------------------------------------------------------
{
- DWORD result;
_asm {
mov ebx, lp16 // ebx = 8-bit buffer
mov edx, pBuffer // edx = pBuffer
@@ -1761,15 +1760,12 @@
mov eax, MIXING_CLIPMAX
jmp cliprecover
done:
- mov eax, lSampleCount
- mov result, eax
}
- return result;
}
#endif
-static DWORD C_Convert32To8(LPVOID lp16, int *pBuffer, DWORD lSampleCount)
-//------------------------------------------------------------------------
+static void C_Convert32To8(LPVOID lp16, int *pBuffer, DWORD lSampleCount)
+//-----------------------------------------------------------------------
{
uint8 * p = (uint8*)lp16;
for(DWORD i=0; i<lSampleCount; i++)
@@ -1779,17 +1775,16 @@
else if(v > MIXING_CLIPMAX) v = MIXING_CLIPMAX;
p[i] = (uint8)((v >> (24-MIXING_ATTENUATION))+0x80); // unsigned
}
- return lSampleCount * 1;
}
// Clip and convert to 8 bit
-DWORD Convert32To8(LPVOID lp16, int *pBuffer, DWORD lSampleCount)
-//---------------------------------------------------------------
+void Convert32To8(LPVOID lp16, int *pBuffer, DWORD lSampleCount)
+//--------------------------------------------------------------
{
#ifdef ENABLE_X86
- return X86_Convert32To8(lp16, pBuffer, lSampleCount);
+ X86_Convert32To8(lp16, pBuffer, lSampleCount);
#else
- return C_Convert32To8(lp16, pBuffer, lSampleCount);
+ C_Convert32To8(lp16, pBuffer, lSampleCount);
#endif
}
@@ -1811,10 +1806,9 @@
#ifdef ENABLE_X86
-static DWORD X86_Convert32To16(LPVOID lp16, int *pBuffer, DWORD lSampleCount)
-//---------------------------------------------------------------------------
+static void X86_Convert32To16(LPVOID lp16, int *pBuffer, DWORD lSampleCount)
+//--------------------------------------------------------------------------
{
- DWORD result;
_asm {
mov ebx, lp16 // ebx = 16-bit buffer
mov edx, pBuffer // edx = pBuffer
@@ -1841,16 +1835,12 @@
mov eax, MIXING_CLIPMAX
jmp cliprecover
done:
- mov eax, lSampleCount
- add eax, eax
- mov result, eax
}
- return result;
}
#endif
-static DWORD C_Convert32To16(LPVOID lp16, int *pBuffer, DWORD lSampleCount)
-//-------------------------------------------------------------------------
+static void C_Convert32To16(LPVOID lp16, int *pBuffer, DWORD lSampleCount)
+//------------------------------------------------------------------------
{
int16 * p = (int16*)lp16;
for(DWORD i=0; i<lSampleCount; i++)
@@ -1860,17 +1850,16 @@
else if(v > MIXING_CLIPMAX) v = MIXING_CLIPMAX;
p[i] = (int16)(v >> (16-MIXING_ATTENUATION));
}
- return lSampleCount * 2;
}
// Clip and convert to 16 bit
-DWORD Convert32To16(LPVOID lp16, int *pBuffer, DWORD lSampleCount)
-//----------------------------------------------------------------
+void Convert32To16(LPVOID lp16, int *pBuffer, DWORD lSampleCount)
+//---------------------------------------------------------------
{
#ifdef ENABLE_X86
- return X86_Convert32To16(lp16, pBuffer, lSampleCount);
+ X86_Convert32To16(lp16, pBuffer, lSampleCount);
#else
- return C_Convert32To16(lp16, pBuffer, lSampleCount);
+ C_Convert32To16(lp16, pBuffer, lSampleCount);
#endif
}
@@ -1889,10 +1878,9 @@
#ifdef ENABLE_X86
-static DWORD X86_Convert32To24(LPVOID lp16, int *pBuffer, DWORD lSampleCount)
-//---------------------------------------------------------------------------
+static void X86_Convert32To24(LPVOID lp16, int *pBuffer, DWORD lSampleCount)
+//--------------------------------------------------------------------------
{
- DWORD result;
_asm {
mov ebx, lp16 // ebx = 8-bit buffer
mov edx, pBuffer // edx = pBuffer
@@ -1921,16 +1909,12 @@
mov eax, MIXING_CLIPMAX
jmp cliprecover
done:
- mov eax, lSampleCount
- lea eax, [eax*2+eax]
- mov result, eax
}
- return result;
}
#endif
-static DWORD C_Convert32To24(LPVOID lp16, int *pBuffer, DWORD lSampleCount)
-//-------------------------------------------------------------------------
+static void C_Convert32To24(LPVOID lp16, int *pBuffer, DWORD lSampleCount)
+//------------------------------------------------------------------------
{
int24 * p = (int24*)lp16;
for(DWORD i=0; i<lSampleCount; i++)
@@ -1941,16 +1925,16 @@
v >>= (8-MIXING_ATTENUATION);
p[i] = (int24)v;
}
- return lSampleCount * 3;
}
// Clip and convert to 24 bit
-DWORD Convert32To24(LPVOID lp16, int *pBuffer, DWORD lSampleCount)
+void Convert32To24(LPVOID lp16, int *pBuffer, DWORD lSampleCount)
+//---------------------------------------------------------------
{
#ifdef ENABLE_X86
- return X86_Convert32To24(lp16, pBuffer, lSampleCount);
+ X86_Convert32To24(lp16, pBuffer, lSampleCount);
#else
- return C_Convert32To24(lp16, pBuffer, lSampleCount);
+ C_Convert32To24(lp16, pBuffer, lSampleCount);
#endif
}
@@ -1969,10 +1953,9 @@
#ifdef ENABLE_X86
-static DWORD X86_Convert32To32(LPVOID lp16, int *pBuffer, DWORD lSampleCount)
-//---------------------------------------------------------------------------
+static void X86_Convert32To32(LPVOID lp16, int *pBuffer, DWORD lSampleCount)
+//--------------------------------------------------------------------------
{
- DWORD result;
_asm {
mov ebx, lp16 // ebx = 32-bit buffer
mov edx, pBuffer // edx = pBuffer
@@ -1998,16 +1981,12 @@
mov eax, MIXING_CLIPMAX
jmp cliprecover
done:
- mov eax, lSampleCount
- lea eax, [eax*4]
- mov result, eax
}
- return result;
}
#endif
-static DWORD C_Convert32To32(LPVOID lp16, int *pBuffer, DWORD lSampleCount)
-//-------------------------------------------------------------------------
+static void C_Convert32To32(LPVOID lp16, int *pBuffer, DWORD lSampleCount)
+//------------------------------------------------------------------------
{
int32 * p = (int32*)lp16;
for(DWORD i=0; i<lSampleCount; i++)
@@ -2017,17 +1996,16 @@
else if(v > MIXING_CLIPMAX) v = MIXING_CLIPMAX;
p[i] = v << MIXING_ATTENUATION;
}
- return lSampleCount * 4;
}
// Clip and convert to 32 bit
-DWORD Convert32To32(LPVOID lp16, int *pBuffer, DWORD lSampleCount)
-//----------------------------------------------------------------
+void Convert32To32(LPVOID lp16, int *pBuffer, DWORD lSampleCount)
+//---------------------------------------------------------------
{
#ifdef ENABLE_X86
- return X86_Convert32To32(lp16, pBuffer, lSampleCount);
+ X86_Convert32To32(lp16, pBuffer, lSampleCount);
#else
- return C_Convert32To32(lp16, pBuffer, lSampleCount);
+ C_Convert32To32(lp16, pBuffer, lSampleCount);
#endif
}
@@ -2046,8 +2024,8 @@
// convert to 32 bit floats and do NOT clip to [-1,1]
-DWORD Convert32ToFloat32(LPVOID lpBuffer, int *pBuffer, DWORD lSampleCount)
-//-------------------------------------------------------------------------
+void Convert32ToFloat32(LPVOID lpBuffer, int *pBuffer, DWORD lSampleCount)
+//------------------------------------------------------------------------
{
const float factor = (1.0f/(float)MIXING_CLIPMAX);
float *out = (float*)lpBuffer;
@@ -2055,7 +2033,6 @@
{
out[i] = pBuffer[i] * factor;
}
- return lSampleCount * 4;
}
void Convert32ToNonInterleaved(float * const * const buffers, const int *mixbuffer, std::size_t channels, std::size_t count)
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-06-08 17:36:40 UTC (rev 2326)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-06-08 18:10:12 UTC (rev 2327)
@@ -33,13 +33,13 @@
PMIXPLUGINCREATEPROC CSoundFile::gpMixPluginCreateProc = NULL;
#endif
-typedef DWORD (* LPCONVERTPROC)(LPVOID, int *, DWORD);
+typedef void (* LPCONVERTPROC)(LPVOID, int *, DWORD);
-extern DWORD Convert32To8(LPVOID lpBuffer, int *, DWORD nSamples);
-extern DWORD Convert32To16(LPVOID lpBuffer, int *, DWORD nSamples);
-extern DWORD Convert32To24(LPVOID lpBuffer, int *, DWORD nSamples);
-extern DWORD Convert32To32(LPVOID lpBuffer, int *, DWORD nSamples);
-extern DWORD Convert32ToFloat32(LPVOID lpBuffer, int *pBuffer, DWORD lSampleCount);
+extern void Convert32To8(LPVOID lpBuffer, int *, DWORD nSamples);
+extern void Convert32To16(LPVOID lpBuffer, int *, DWORD nSamples);
+extern void Convert32To24(LPVOID lpBuffer, int *, DWORD nSamples);
+extern void Convert32To32(LPVOID lpBuffer, int *, DWORD nSamples);
+extern void Convert32ToFloat32(LPVOID lpBuffer, int *pBuffer, DWORD lSampleCount);
extern void Convert32ToNonInterleaved(uint8 * const * const buffers, const int *mixbuffer, std::size_t channels, std::size_t count);
extern void Convert32ToNonInterleaved(int16 * const * const buffers, const int *mixbuffer, std::size_t channels, std::size_t count);
@@ -393,7 +393,8 @@
#endif
// Convert to output sample format and optionally perform clipping if needed
- lpBuffer += pCvt(lpBuffer, MixSoundBuffer, lTotalSampleCount);
+ pCvt(lpBuffer, MixSoundBuffer, lTotalSampleCount);
+ lpBuffer += lTotalSampleCount * (m_MixerSettings.GetBitsPerSample()/8);
#ifndef MODPLUG_TRACKER
LPBYTE buf_end = lpBuffer;
Modified: trunk/OpenMPT/soundlib/Waveform.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Waveform.cpp 2013-06-08 17:36:40 UTC (rev 2326)
+++ trunk/OpenMPT/soundlib/Waveform.cpp 2013-06-08 18:10:12 UTC (rev 2327)
@@ -54,9 +54,9 @@
#endif
extern void Dither(int *pBuffer, UINT nSamples, UINT nBits);
-extern DWORD Convert32To8(LPVOID lpBuffer, int *, DWORD nSamples);
-extern DWORD Convert32To16(LPVOID lpBuffer, int *, DWORD nSamples);
-extern DWORD Convert32To24(LPVOID lpBuffer, int *, DWORD nSamples);
+extern void Convert32To8(LPVOID lpBuffer, int *, DWORD nSamples);
+extern void Convert32To16(LPVOID lpBuffer, int *, DWORD nSamples);
+extern void Convert32To24(LPVOID lpBuffer, int *, DWORD nSamples);
UINT CSoundFile::Normalize24BitBuffer(LPBYTE pbuffer, UINT dwSize, DWORD lmax24, DWORD dwByteInc)
//-----------------------------------------------------------------------------------------------
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-06-08 20:00:38
|
Revision: 2333
http://sourceforge.net/p/modplug/code/2333
Author: manxorist
Date: 2013-06-08 20:00:30 +0000 (Sat, 08 Jun 2013)
Log Message:
-----------
[Fix] Do not only dither 8bit and 16bit integer output but also 24bit. The integer mixer has 28 bit significant precision so we benefit from ditherering to 24bit.
[Ref] Add support for multiple dithering algorithms (only the old ModPlug one is there so far).
[Ref] Add support for stateful dithering algorithms.
[Ref] Make the state of the old dithering RNG non-global.
[Ref] Deprecate the old stateless dither interface (which still uses global RNG state). This is still used in Waveform.cpp in Normalize24BitBuffer (which probably has to be rewritten sometime soon anyway).
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Fastmix.cpp
trunk/OpenMPT/soundlib/Sndfile.h
trunk/OpenMPT/soundlib/Sndmix.cpp
trunk/OpenMPT/soundlib/Waveform.cpp
Modified: trunk/OpenMPT/soundlib/Fastmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Fastmix.cpp 2013-06-08 19:23:18 UTC (rev 2332)
+++ trunk/OpenMPT/soundlib/Fastmix.cpp 2013-06-08 20:00:30 UTC (rev 2333)
@@ -2027,7 +2027,7 @@
//////////////////////////////////////////////////////////////////////////
-// Noise Shaping (Dither)
+// Noise Shaping (Dithering)
#if MPT_COMPILER_MSVC
#pragma warning(disable:4731) // ebp modified
@@ -2036,11 +2036,19 @@
#ifdef ENABLE_X86
-void X86_Dither(int *pBuffer, UINT nSamples, UINT nBits)
-//------------------------------------------------------
+void X86_Dither(int *pBuffer, UINT nSamples, UINT nBits, DitherModPlugState *state)
+//---------------------------------------------------------------------------------
{
- static int gDitherA, gDitherB;
+ if(nBits + MIXING_ATTENUATION + 1 >= 32) //if(nBits>16)
+ {
+ return;
+ }
+ static int gDitherA_global, gDitherB_global;
+
+ int gDitherA = state ? state->rng_a : gDitherA_global;
+ int gDitherB = state ? state->rng_b : gDitherB_global;
+
_asm {
mov esi, pBuffer // esi = pBuffer+i
mov eax, nSamples // ebp = i
@@ -2070,6 +2078,10 @@
mov gDitherA, edi
mov gDitherB, ebx
}
+
+ if(state) state->rng_a = gDitherA; else gDitherA_global = gDitherA;
+ if(state) state->rng_b = gDitherB; else gDitherB_global = gDitherB;
+
}
#endif // ENABLE_X86
@@ -2085,15 +2097,19 @@
return (int32)b;
}
-static void C_Dither(int *pBuffer, UINT nSamples, UINT nBits)
-//-----------------------------------------------------------
+static void C_Dither(int *pBuffer, UINT nSamples, UINT nBits, DitherModPlugState *state)
+//--------------------------------------------------------------------------------------
{
+ if(nBits + MIXING_ATTENUATION + 1 >= 32) //if(nBits>16)
+ {
+ return;
+ }
static uint32 global_a = 0;
static uint32 global_b = 0;
- uint32 a = global_a;
- uint32 b = global_b;
+ uint32 a = state ? state->rng_a : global_a;
+ uint32 b = state ? state->rng_b : global_b;
while(nSamples--)
{
@@ -2101,18 +2117,63 @@
pBuffer++;
}
- global_a = a;
- global_b = b;
+ if(state) state->rng_a = a; else global_a = a;
+ if(state) state->rng_b = b; else global_b = b;
}
-void Dither(int *pBuffer, UINT nSamples, UINT nBits)
-//--------------------------------------------------
+static void Dither_ModPlug(int *pBuffer, UINT nSamples, UINT nChannels, UINT nBits, DitherModPlugState &state)
+//------------------------------------------------------------------------------------------------------------
{
+ #ifdef ENABLE_X86
+ X86_Dither(pBuffer, nSamples * nChannels, nBits, &state);
+ #else // !ENABLE_X86
+ C_Dither(pBuffer, nSamples * nChannels, nBits, &state);
+ #endif // ENABLE_X86
+}
+
+
+void Dither::Reset()
+{
+ state = DitherState();
+}
+
+Dither::Dither()
+{
+ mode = DitherModPlug;
+}
+
+void Dither::SetMode(DitherMode &mode_)
+{
+ mode = mode_;
+}
+
+DitherMode Dither::GetMode() const
+{
+ return mode;
+}
+
+void Dither::Process(int *mixbuffer, std::size_t count, std::size_t channels, int bits)
+{
+ switch(mode)
+ {
+ case DitherNone:
+ // nothing
+ break;
+ case DitherModPlug:
+ Dither_ModPlug(mixbuffer, count, channels, bits, state.modplug);
+ break;
+ }
+}
+
+
+void DitherStateless(int *pBuffer, UINT nSamples, UINT nBits)
+//-----------------------------------------------------------
+{
#if defined(ENABLE_X86)
- X86_Dither(pBuffer, nSamples, nBits);
+ X86_Dither(pBuffer, nSamples, nBits, nullptr);
#else
- C_Dither(pBuffer, nSamples, nBits);
+ C_Dither(pBuffer, nSamples, nBits, nullptr);
#endif
}
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2013-06-08 19:23:18 UTC (rev 2332)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2013-06-08 20:00:30 UTC (rev 2333)
@@ -185,7 +185,44 @@
class CModDoc;
#endif // MODPLUG_TRACKER
+struct DitherModPlugState
+{
+ uint32 rng_a;
+ uint32 rng_b;
+ DitherModPlugState()
+ {
+ rng_a = 0;
+ rng_b = 0;
+ }
+};
+struct DitherState
+{
+ DitherModPlugState modplug;
+};
+
+enum DitherMode
+{
+ DitherNone = 0,
+ DitherModPlug = 1
+};
+
+class Dither
+{
+private:
+ DitherState state;
+ DitherMode mode;
+public:
+ Dither();
+ void SetMode(DitherMode &mode);
+ DitherMode GetMode() const;
+ void Reset();
+ void Process(int *mixbuffer, std::size_t count, std::size_t channels, int bits);
+};
+
+DEPRECATED void DitherStateless(int *pBuffer, UINT nSamples, UINT nBits);
+
+
void StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc);
void FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic);
void MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc);
@@ -319,6 +356,7 @@
#ifndef NO_AGC
CAGC m_AGC;
#endif
+ Dither m_Dither;
#ifdef MODPLUG_TRACKER
static LPSNDMIXHOOKPROC gpSndMixHook;
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-06-08 19:23:18 UTC (rev 2332)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-06-08 20:00:30 UTC (rev 2333)
@@ -56,7 +56,6 @@
-extern void Dither(int *pBuffer, UINT nSamples, UINT nBits);
extern void InterleaveFrontRear(int *pFrontBuf, int *pRearBuf, DWORD nFrames);
extern void StereoFill(int *pBuffer, UINT nSamples, LPLONG lpROfs, LPLONG lpLOfs);
extern void MonoFromStereo(int *pMixBuf, UINT nSamples);
@@ -147,6 +146,7 @@
#ifndef NO_AGC
if(bReset) m_AGC.Reset();
#endif
+ m_Dither.Reset();
}
@@ -365,11 +365,8 @@
}
// Noise Shaping
- if (m_MixerSettings.GetBitsPerSample() <= 16)
- {
- if(m_Resampler.IsHQ())
- Dither(MixSoundBuffer, lTotalSampleCount, m_MixerSettings.GetBitsPerSample());
- }
+ if(m_Resampler.IsHQ())
+ m_Dither.Process(MixSoundBuffer, lCount, m_MixerSettings.gnChannels, m_MixerSettings.GetBitsPerSample());
#ifdef MODPLUG_TRACKER
// Hook Function
Modified: trunk/OpenMPT/soundlib/Waveform.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Waveform.cpp 2013-06-08 19:23:18 UTC (rev 2332)
+++ trunk/OpenMPT/soundlib/Waveform.cpp 2013-06-08 20:00:30 UTC (rev 2333)
@@ -53,7 +53,6 @@
#endif
-extern void Dither(int *pBuffer, UINT nSamples, UINT nBits);
UINT CSoundFile::Normalize24BitBuffer(LPBYTE pbuffer, UINT dwSize, DWORD lmax24, DWORD dwByteInc)
//-----------------------------------------------------------------------------------------------
@@ -65,7 +64,7 @@
{
int nbuf = (n > MIXBUFFERSIZE * 2) ? MIXBUFFERSIZE * 2 : n;
X86_Normalize24BitBuffer(pbuffer, nbuf, lmax24, tempbuf);
- Dither(tempbuf, nbuf, 8 * dwByteInc);
+ DitherStateless(tempbuf, nbuf, 8 * dwByteInc);
switch(dwByteInc)
{
case 1: Convert32ToInterleaved((uint8*)pbuffer, tempbuf, nbuf); break;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-06-15 04:42:33
|
Revision: 2368
http://sourceforge.net/p/modplug/code/2368
Author: manxorist
Date: 2013-06-15 04:42:22 +0000 (Sat, 15 Jun 2013)
Log Message:
-----------
[Imp] Improve precision of polyphase 8-tap resampling filter tables by 1 bit.
[Ref] Use proper constants instead of magic values for filter coefficients table lookup.
[Ref] Avoid unneeded pointer cast in filter coefficients table lookup.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Fastmix.cpp
trunk/OpenMPT/soundlib/Resampler.h
trunk/OpenMPT/soundlib/Tables.cpp
Modified: trunk/OpenMPT/soundlib/Fastmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Fastmix.cpp 2013-06-14 11:13:43 UTC (rev 2367)
+++ trunk/OpenMPT/soundlib/Fastmix.cpp 2013-06-15 04:42:22 UTC (rev 2368)
@@ -92,19 +92,19 @@
// 8-taps polyphase
#define SNDMIX_GETMONOVOL8KAISER\
int poshi = nPos >> 16;\
- const short int *poslo = (const short int *)(sinc+(nPos&0xfff0));\
- int vol = (poslo[0]*p[poshi-3] + poslo[1]*p[poshi-2]\
+ const SINC_TYPE *poslo = sinc + ((nPos >> (16-SINC_PHASES_BITS)) & SINC_MASK) * SINC_WIDTH;\
+ int vol = ((poslo[0]*p[poshi-3] + poslo[1]*p[poshi-2]\
+ poslo[2]*p[poshi-1] + poslo[3]*p[poshi]\
+ poslo[4]*p[poshi+1] + poslo[5]*p[poshi+2]\
- + poslo[6]*p[poshi+3] + poslo[7]*p[poshi+4]) >> 6;\
+ + poslo[6]*p[poshi+3] + poslo[7]*p[poshi+4]) >> (SINC_QUANTSHIFT-8));\
#define SNDMIX_GETMONOVOL16KAISER\
int poshi = nPos >> 16;\
- const short int *poslo = (const short int *)(sinc+(nPos&0xfff0));\
- int vol = (poslo[0]*p[poshi-3] + poslo[1]*p[poshi-2]\
+ const SINC_TYPE *poslo = sinc + ((nPos >> (16-SINC_PHASES_BITS)) & SINC_MASK) * SINC_WIDTH;\
+ int vol = ((poslo[0]*p[poshi-3] + poslo[1]*p[poshi-2]\
+ poslo[2]*p[poshi-1] + poslo[3]*p[poshi]\
+ poslo[4]*p[poshi+1] + poslo[5]*p[poshi+2]\
- + poslo[6]*p[poshi+3] + poslo[7]*p[poshi+4]) >> 14;\
+ + poslo[6]*p[poshi+3] + poslo[7]*p[poshi+4]) >> SINC_QUANTSHIFT);\
// rewbs.resamplerConf
#define SNDMIX_GETMONOVOL8FIRFILTER \
int poshi = nPos >> 16;\
@@ -137,7 +137,7 @@
// end rewbs.resamplerConf
#define SNDMIX_INITSINCTABLE\
- const char * const sinc = (const char *)(((pChannel->nInc > 0x13000) || (pChannel->nInc < -0x13000)) ?\
+ const SINC_TYPE * const sinc = (((pChannel->nInc > 0x13000) || (pChannel->nInc < -0x13000)) ?\
(((pChannel->nInc > 0x18000) || (pChannel->nInc < -0x18000)) ? pResampler->gDownsample2x : pResampler->gDownsample13x) : pResampler->gKaiserSinc);
#define SNDMIX_INITFIRTABLE\
@@ -195,27 +195,27 @@
// 8-taps polyphase
#define SNDMIX_GETSTEREOVOL8KAISER\
int poshi = nPos >> 16;\
- const short int *poslo = (const short int *)(sinc+(nPos&0xfff0));\
- int vol_l = (poslo[0]*p[poshi*2-6] + poslo[1]*p[poshi*2-4]\
+ const SINC_TYPE *poslo = sinc + ((nPos >> (16-SINC_PHASES_BITS)) & SINC_MASK) * SINC_WIDTH;\
+ int vol_l = ((poslo[0]*p[poshi*2-6] + poslo[1]*p[poshi*2-4]\
+ poslo[2]*p[poshi*2-2] + poslo[3]*p[poshi*2]\
+ poslo[4]*p[poshi*2+2] + poslo[5]*p[poshi*2+4]\
- + poslo[6]*p[poshi*2+6] + poslo[7]*p[poshi*2+8]) >> 6;\
- int vol_r = (poslo[0]*p[poshi*2-5] + poslo[1]*p[poshi*2-3]\
+ + poslo[6]*p[poshi*2+6] + poslo[7]*p[poshi*2+8]) >> (SINC_QUANTSHIFT-8));\
+ int vol_r = ((poslo[0]*p[poshi*2-5] + poslo[1]*p[poshi*2-3]\
+ poslo[2]*p[poshi*2-1] + poslo[3]*p[poshi*2+1]\
+ poslo[4]*p[poshi*2+3] + poslo[5]*p[poshi*2+5]\
- + poslo[6]*p[poshi*2+7] + poslo[7]*p[poshi*2+9]) >> 6;\
+ + poslo[6]*p[poshi*2+7] + poslo[7]*p[poshi*2+9]) >> (SINC_QUANTSHIFT-8));\
#define SNDMIX_GETSTEREOVOL16KAISER\
int poshi = nPos >> 16;\
- const short int *poslo = (const short int *)(sinc+(nPos&0xfff0));\
- int vol_l = (poslo[0]*p[poshi*2-6] + poslo[1]*p[poshi*2-4]\
+ const SINC_TYPE *poslo = sinc + ((nPos >> (16-SINC_PHASES_BITS)) & SINC_MASK) * SINC_WIDTH;\
+ int vol_l = ((poslo[0]*p[poshi*2-6] + poslo[1]*p[poshi*2-4]\
+ poslo[2]*p[poshi*2-2] + poslo[3]*p[poshi*2]\
+ poslo[4]*p[poshi*2+2] + poslo[5]*p[poshi*2+4]\
- + poslo[6]*p[poshi*2+6] + poslo[7]*p[poshi*2+8]) >> 14;\
- int vol_r = (poslo[0]*p[poshi*2-5] + poslo[1]*p[poshi*2-3]\
+ + poslo[6]*p[poshi*2+6] + poslo[7]*p[poshi*2+8]) >> SINC_QUANTSHIFT);\
+ int vol_r = ((poslo[0]*p[poshi*2-5] + poslo[1]*p[poshi*2-3]\
+ poslo[2]*p[poshi*2-1] + poslo[3]*p[poshi*2+1]\
+ poslo[4]*p[poshi*2+3] + poslo[5]*p[poshi*2+5]\
- + poslo[6]*p[poshi*2+7] + poslo[7]*p[poshi*2+9]) >> 14;\
+ + poslo[6]*p[poshi*2+7] + poslo[7]*p[poshi*2+9]) >> SINC_QUANTSHIFT);\
// rewbs.resamplerConf
// fir interpolation
#define SNDMIX_GETSTEREOVOL8FIRFILTER \
Modified: trunk/OpenMPT/soundlib/Resampler.h
===================================================================
--- trunk/OpenMPT/soundlib/Resampler.h 2013-06-14 11:13:43 UTC (rev 2367)
+++ trunk/OpenMPT/soundlib/Resampler.h 2013-06-15 04:42:22 UTC (rev 2368)
@@ -14,9 +14,18 @@
#include "MixerSettings.h"
-#define SINC_PHASES 4096
+#define SINC_WIDTH 8
+#define SINC_PHASES_BITS 12
+#define SINC_PHASES (1<<SINC_PHASES_BITS)
+#define SINC_TYPE int16
+#define SINC_QUANTSHIFT 15
+
+#define SINC_MASK (SINC_PHASES-1)
+STATIC_ASSERT((SINC_MASK & 0xffff) == SINC_MASK); // exceeding fractional freq
+
+
//======================
class CResamplerSettings
//======================
@@ -48,15 +57,15 @@
CResamplerSettings m_Settings;
CWindowedFIR m_WindowedFIR;
static const int16 FastSincTable[256*4];
- int16 gKaiserSinc[SINC_PHASES*8]; // Upsampling
+ SINC_TYPE gKaiserSinc[SINC_PHASES*8]; // Upsampling
#ifdef MODPLUG_TRACKER
static bool StaticTablesInitialized;
- static int16 gDownsample13x[SINC_PHASES*8]; // Downsample 1.333x
- static int16 gDownsample2x[SINC_PHASES*8]; // Downsample 2x
+ static SINC_TYPE gDownsample13x[SINC_PHASES*8]; // Downsample 1.333x
+ static SINC_TYPE gDownsample2x[SINC_PHASES*8]; // Downsample 2x
#else
// no global data which has to be initialized by hand in the library
- int16 gDownsample13x[SINC_PHASES*8]; // Downsample 1.333x
- int16 gDownsample2x[SINC_PHASES*8]; // Downsample 2x
+ SINC_TYPE gDownsample13x[SINC_PHASES*8]; // Downsample 1.333x
+ SINC_TYPE gDownsample2x[SINC_PHASES*8]; // Downsample 2x
#endif
private:
CResamplerSettings m_OldSettings;
Modified: trunk/OpenMPT/soundlib/Tables.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Tables.cpp 2013-06-14 11:13:43 UTC (rev 2367)
+++ trunk/OpenMPT/soundlib/Tables.cpp 2013-06-15 04:42:22 UTC (rev 2368)
@@ -712,7 +712,7 @@
return s;
}
-static void getsinc(short int *psinc, double beta, double lowpass_factor)
+static void getsinc(SINC_TYPE *psinc, double beta, double lowpass_factor)
{
const double izero_beta = izero(beta);
const double kPi = 4.0*atan(1.0)*lowpass_factor;
@@ -729,8 +729,11 @@
double x = (double)(ix - (4*SINC_PHASES)) * (double)(1.0/SINC_PHASES);
fsinc = sin(x*kPi) * izero(beta*sqrt(1-x*x*(1.0/16.0))) / (izero_beta*x*kPi); // Kaiser window
}
- int n = (int)(fsinc * lowpass_factor * (16384*256));
- *psinc++ = static_cast<short>((n+0x80)>>8); // force rounding
+ double coeff = fsinc * lowpass_factor;
+ int n = (int)std::floor(coeff * (1<<SINC_QUANTSHIFT) + 0.5);
+ ASSERT(n <= int16_max);
+ ASSERT(n > int16_min);
+ *psinc++ = static_cast<SINC_TYPE>(n);
}
}
@@ -773,8 +776,8 @@
#ifdef MODPLUG_TRACKER
bool CResampler::StaticTablesInitialized = false;
-int16 CResampler::gDownsample13x[SINC_PHASES*8]; // Downsample 1.333x
-int16 CResampler::gDownsample2x[SINC_PHASES*8]; // Downsample 2x
+SINC_TYPE CResampler::gDownsample13x[SINC_PHASES*8]; // Downsample 1.333x
+SINC_TYPE CResampler::gDownsample2x[SINC_PHASES*8]; // Downsample 2x
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-06-16 12:32:59
|
Revision: 2389
http://sourceforge.net/p/modplug/code/2389
Author: manxorist
Date: 2013-06-16 12:32:51 +0000 (Sun, 16 Jun 2013)
Log Message:
-----------
[Ref] Remove ancient and unused GlobalFadeSong and IsSongFinished.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Snd_defs.h
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/Sndfile.cpp
trunk/OpenMPT/soundlib/Sndfile.h
trunk/OpenMPT/soundlib/Sndmix.cpp
Modified: trunk/OpenMPT/soundlib/Snd_defs.h
===================================================================
--- trunk/OpenMPT/soundlib/Snd_defs.h 2013-06-16 12:05:44 UTC (rev 2388)
+++ trunk/OpenMPT/soundlib/Snd_defs.h 2013-06-16 12:32:51 UTC (rev 2389)
@@ -255,7 +255,7 @@
SONG_PAUSED = 0x0080, // Song is paused
SONG_FADINGSONG = 0x0100, // Song is fading out
SONG_ENDREACHED = 0x0200, // Song is finished
- SONG_GLOBALFADE = 0x0400, // Song is fading out
+ //SONG_GLOBALFADE = 0x0400, // Song is fading out
//SONG_CPUVERYHIGH = 0x0800, // High CPU usage
SONG_FIRSTTICK = 0x1000, // Is set when the current tick is the first tick of the row
SONG_MPTFILTERMODE = 0x2000, // Local filter mode (reset filter on each note)
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-06-16 12:05:44 UTC (rev 2388)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-06-16 12:32:51 UTC (rev 2389)
@@ -4402,17 +4402,6 @@
void CSoundFile::SetSpeed(UINT param)
//-----------------------------------
{
- // ModPlug Tracker and Mod-Plugin don't do this check
-#ifdef MODPLUG_PLAYER
- // Big Hack!!!
- if ((!param) || (param >= 0x80) || ((GetType() & (MOD_TYPE_MOD|MOD_TYPE_XM|MOD_TYPE_MT2)) && (param >= 0x1E)))
- {
- if ((!m_nRepeatCount) && (IsSongFinished(m_nCurrentOrder, m_nRow+1)))
- {
- GlobalFadeSong(1000);
- }
- }
-#endif // MODPLUG_PLAYER
// Allow high speed values here for VBlank MODs. (Maybe it would be better to have a "VBlank MOD" flag somewhere? Is it worth the effort?)
if ((param) && (param <= GetModSpecifications().speedMax || (GetType() & MOD_TYPE_MOD))) m_nMusicSpeed = param;
}
@@ -4551,43 +4540,6 @@
}
-DWORD CSoundFile::IsSongFinished(UINT nStartOrder, UINT nStartRow) const
-//----------------------------------------------------------------------
-{
- UINT nOrd;
-
- for (nOrd=nStartOrder; nOrd<Order.size(); nOrd++)
- {
- UINT nPat = Order[nOrd];
- if (nPat != Order.GetIgnoreIndex())
- {
- if (nPat >= Patterns.Size()) break;
- const MODPATTERN& p = Patterns[nPat];
- if (p)
- {
- UINT len = Patterns[nPat].GetNumRows() * m_nChannels;
- UINT pos = (nOrd == nStartOrder) ? nStartRow : 0;
- pos *= m_nChannels;
- while (pos < len)
- {
- UINT cmd;
- if ((p[pos].note) || (p[pos].volcmd)) return 0;
- cmd = p[pos].command;
- if (cmd == CMD_MODCMDEX)
- {
- UINT cmdex = p[pos].param & 0xF0;
- if ((!cmdex) || (cmdex == 0x60) || (cmdex == 0xE0) || (cmdex == 0xF0)) cmd = 0;
- }
- if ((cmd) && (cmd != CMD_SPEED) && (cmd != CMD_TEMPO)) return 0;
- pos++;
- }
- }
- }
- }
- return (nOrd < Order.size()) ? nOrd : Order.size()-1;
-}
-
-
//////////////////////////////////////////////////////
// Note/Period/Frequency functions
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-06-16 12:05:44 UTC (rev 2388)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-06-16 12:32:51 UTC (rev 2389)
@@ -1075,7 +1075,7 @@
visitedSongRows.Initialize(true);
}
- m_SongFlags.reset(SONG_FADINGSONG | SONG_ENDREACHED | SONG_GLOBALFADE);
+ m_SongFlags.reset(SONG_FADINGSONG | SONG_ENDREACHED);
for (nPattern = 0; nPattern < Order.size(); nPattern++)
{
UINT ord = Order[nPattern];
@@ -1172,7 +1172,7 @@
m_nNextPatStartRow = 0;
}
- m_SongFlags.reset(SONG_FADINGSONG | SONG_ENDREACHED | SONG_GLOBALFADE);
+ m_SongFlags.reset(SONG_FADINGSONG | SONG_ENDREACHED);
}
//rewbs.VSTCompliance
@@ -1259,7 +1259,7 @@
void CSoundFile::ResetChannels()
//------------------------------
{
- m_SongFlags.reset(SONG_FADINGSONG | SONG_ENDREACHED | SONG_GLOBALFADE);
+ m_SongFlags.reset(SONG_FADINGSONG | SONG_ENDREACHED);
m_nBufferCount = 0;
for (UINT i=0; i<MAX_CHANNELS; i++)
{
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2013-06-16 12:05:44 UTC (rev 2388)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2013-06-16 12:32:51 UTC (rev 2389)
@@ -411,7 +411,6 @@
UINT m_nOldGlbVolSlide;
LONG m_nMinPeriod, m_nMaxPeriod; // min period = highest possible frequency, max period = lowest possible frequency
LONG m_nRepeatCount; // -1 means repeat infinitely.
- DWORD m_nGlobalFadeSamples, m_nGlobalFadeMaxSamples;
UINT m_nMaxOrderPosition;
CHANNELINDEX ChnMix[MAX_CHANNELS]; // Channels to be mixed
ModChannel Chn[MAX_CHANNELS]; // Mixing channels... First m_nChannel channels are master channels (i.e. they are never NNA channels)!
@@ -644,7 +643,6 @@
void CreateStereoMix(int count);
public:
BOOL FadeSong(UINT msec);
- BOOL GlobalFadeSong(UINT msec);
private:
void ProcessDSP(std::size_t countChunk);
void ProcessPlugins(UINT nCount);
@@ -755,7 +753,6 @@
// Low-Level effect processing
void DoFreqSlide(ModChannel *pChn, LONG nFreqSlide);
void GlobalVolSlide(UINT param, UINT &nOldGlobalVolSlide);
- DWORD IsSongFinished(UINT nOrder, UINT nRow) const;
void UpdateTimeSignature();
UINT GetNumTicksOnCurrentRow() const
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-06-16 12:05:44 UTC (rev 2388)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-06-16 12:32:51 UTC (rev 2389)
@@ -154,17 +154,6 @@
}
-BOOL CSoundFile::GlobalFadeSong(UINT msec)
-//----------------------------------------
-{
- if(m_SongFlags[SONG_GLOBALFADE]) return FALSE;
- m_nGlobalFadeMaxSamples = Util::muldiv(msec, m_MixerSettings.gdwMixingFreq, 1000);
- m_nGlobalFadeSamples = m_nGlobalFadeMaxSamples;
- m_SongFlags.set(SONG_GLOBALFADE);
- return TRUE;
-}
-
-
CSoundFile::samplecount_t CSoundFile::ReadInterleaved(void *outputBuffer, samplecount_t count)
//--------------------------------------------------------------------------------------------
{
@@ -1710,11 +1699,6 @@
mastervol = m_nSamplePreAmp;
}
- if(m_SongFlags[SONG_GLOBALFADE] && m_nGlobalFadeMaxSamples != 0)
- {
- mastervol = Util::muldiv(mastervol, m_nGlobalFadeSamples, m_nGlobalFadeMaxSamples);
- }
-
if (m_PlayConfig.getUseGlobalPreAmp())
{
UINT attenuation =
@@ -2118,18 +2102,6 @@
}
}
}
- if(m_SongFlags[SONG_GLOBALFADE])
- {
- if (!m_nGlobalFadeSamples)
- {
- m_SongFlags.set(SONG_ENDREACHED);
- return FALSE;
- }
- if (m_nGlobalFadeSamples > m_nBufferCount)
- m_nGlobalFadeSamples -= m_nBufferCount;
- else
- m_nGlobalFadeSamples = 0;
- }
return TRUE;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-06-27 13:41:14
|
Revision: 2414
http://sourceforge.net/p/modplug/code/2414
Author: manxorist
Date: 2013-06-27 13:41:04 +0000 (Thu, 27 Jun 2013)
Log Message:
-----------
[Ref] Do not import standard library types into global namespace, qualify them with std:: instead.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/tuning.cpp
trunk/OpenMPT/soundlib/tuning.h
trunk/OpenMPT/soundlib/tuningCollection.cpp
trunk/OpenMPT/soundlib/tuningbase.cpp
trunk/OpenMPT/soundlib/tuningbase.h
trunk/OpenMPT/soundlib/tuningcollection.h
Modified: trunk/OpenMPT/soundlib/tuning.cpp
===================================================================
--- trunk/OpenMPT/soundlib/tuning.cpp 2013-06-27 13:03:26 UTC (rev 2413)
+++ trunk/OpenMPT/soundlib/tuning.cpp 2013-06-27 13:41:04 UTC (rev 2414)
@@ -21,15 +21,15 @@
typedef CTuningRTI::NOTEINDEXTYPE NOTEINDEXTYPE;
typedef CTuningRTI::UNOTEINDEXTYPE UNOTEINDEXTYPE;
typedef CTuningRTI::STEPINDEXTYPE STEPINDEXTYPE;
-typedef CTuningRTI::USTEPINDEXTYPE USTEPINDEXTYPE;
+typedef CTuningRTI::USTEPINDEXTYPE USTEPINDEXTYPE;
-const string CTuningRTI::s_DerivedclassID = "RTI";
+const std::string CTuningRTI::s_DerivedclassID = "RTI";
namespace CTuningS11n
{
void ReadStr(std::istream& iStrm, std::string& str, const size_t);
void ReadNoteMap(std::istream& iStrm, CTuningBase::NOTENAMEMAP& m, const size_t);
- void ReadRatioTable(std::istream& iStrm, vector<CTuningRTI::RATIOTYPE>& v, const size_t);
+ void ReadRatioTable(std::istream& iStrm, std::vector<CTuningRTI::RATIOTYPE>& v, const size_t);
void WriteNoteMap(std::ostream& oStrm, const CTUNINGBASE::NOTENAMEMAP& m);
void WriteStr(std::ostream& oStrm, const std::string& str);
@@ -90,7 +90,7 @@
}
-bool CTuningRTI::CreateRatioTableGG(const vector<RATIOTYPE>& v, const RATIOTYPE r, const VRPAIR& vr, const NOTEINDEXTYPE ratiostartpos)
+bool CTuningRTI::CreateRatioTableGG(const std::vector<RATIOTYPE>& v, const RATIOTYPE r, const VRPAIR& vr, const NOTEINDEXTYPE ratiostartpos)
//-------------------------------------------------------------------------------------------------
{
if(v.size() == 0 || r <= 0) return true;
@@ -116,7 +116,7 @@
}
-bool CTuningRTI::ProCreateGroupGeometric(const vector<RATIOTYPE>& v, const RATIOTYPE& r, const VRPAIR& vr, const NOTEINDEXTYPE ratiostartpos)
+bool CTuningRTI::ProCreateGroupGeometric(const std::vector<RATIOTYPE>& v, const RATIOTYPE& r, const VRPAIR& vr, const NOTEINDEXTYPE ratiostartpos)
//---------------------------------------------------------------------
{
//Note: Setting finestep is handled by base class when CreateGroupGeometric is called.
@@ -156,7 +156,7 @@
{
const NOTEINDEXTYPE pos = ((x % m_GroupSize) + m_GroupSize) % m_GroupSize;
const NOTEINDEXTYPE middlePeriodNumber = 5;
- string rValue;
+ std::string rValue;
NNM_CITER nmi = m_NoteNameMap.find(pos);
if(nmi != m_NoteNameMap.end())
{
@@ -371,7 +371,7 @@
}
-CTuningBase* CTuningRTI::Deserialize(istream& iStrm)
+CTuningBase* CTuningRTI::Deserialize(std::istream& iStrm)
//--------------------------------------------------
{
if(iStrm.fail())
@@ -467,7 +467,7 @@
}
-CTUNINGBASE::SERIALIZATION_RETURN_TYPE CTuningRTI::Serialize(ostream& outStrm) const
+CTUNINGBASE::SERIALIZATION_RETURN_TYPE CTuningRTI::Serialize(std::ostream& outStrm) const
//----------------------------------------------------------------------------------
{
srlztn::Ssb ssb(outStrm);
@@ -536,7 +536,7 @@
}
-void ReadRatioTable(std::istream& iStrm, vector<CTuningRTI::RATIOTYPE>& v, const size_t)
+void ReadRatioTable(std::istream& iStrm, std::vector<CTuningRTI::RATIOTYPE>& v, const size_t)
//------------------------------------------------------------------------------------------
{
uint64 val;
Modified: trunk/OpenMPT/soundlib/tuning.h
===================================================================
--- trunk/OpenMPT/soundlib/tuning.h 2013-06-27 13:03:26 UTC (rev 2413)
+++ trunk/OpenMPT/soundlib/tuning.h 2013-06-27 13:41:04 UTC (rev 2414)
@@ -63,21 +63,21 @@
virtual STEPINDEXTYPE GetStepDistance(const NOTEINDEXTYPE& noteFrom, const STEPINDEXTYPE& stepDistFrom, const NOTEINDEXTYPE& noteTo, const STEPINDEXTYPE& stepDistTo) const
{return GetStepDistance(noteFrom, noteTo) + stepDistTo - stepDistFrom;}
- static CTuningBase* Deserialize(istream& inStrm);
+ static CTuningBase* Deserialize(std::istream& inStrm);
static uint32 GetVersion() {return s_SerializationVersion;}
//Try to read old version (v.3) and return pointer to new instance if succesfull, else nullptr.
- static CTuningRTI* DeserializeOLD(istream&) {return 0;}
+ static CTuningRTI* DeserializeOLD(std::istream&) {return 0;}
- SERIALIZATION_RETURN_TYPE Serialize(ostream& out) const;
+ SERIALIZATION_RETURN_TYPE Serialize(std::ostream& out) const;
public:
//PUBLIC CONSTRUCTORS/DESTRUCTORS:
- CTuningRTI(const vector<RATIOTYPE>& ratios,
+ CTuningRTI(const std::vector<RATIOTYPE>& ratios,
const NOTEINDEXTYPE& stepMin = s_StepMinDefault,
- const string& name = "")
+ const std::string& name = "")
: CTuning(name)
{
SetDummyValues();
@@ -90,9 +90,9 @@
CTuningRTI() {SetDummyValues();}
- CTuningRTI(const string& name) : CTuning(name) {SetDummyValues();}
+ CTuningRTI(const std::string& name) : CTuning(name) {SetDummyValues();}
- CTuningRTI(const NOTEINDEXTYPE& stepMin, const string& name) : CTuning(name)
+ CTuningRTI(const NOTEINDEXTYPE& stepMin, const std::string& name) : CTuning(name)
{
SetDummyValues();
m_StepMin = stepMin;
@@ -103,7 +103,7 @@
//BEGIN PROTECTED VIRTUALS:
protected:
bool ProSetRatio(const NOTEINDEXTYPE&, const RATIOTYPE&);
- bool ProCreateGroupGeometric(const vector<RATIOTYPE>&, const RATIOTYPE&, const VRPAIR&, const NOTEINDEXTYPE ratiostartpos);
+ bool ProCreateGroupGeometric(const std::vector<RATIOTYPE>&, const RATIOTYPE&, const VRPAIR&, const NOTEINDEXTYPE ratiostartpos);
bool ProCreateGeometric(const UNOTEINDEXTYPE&, const RATIOTYPE&, const VRPAIR&);
void ProSetFineStepCount(const USTEPINDEXTYPE&);
@@ -126,7 +126,7 @@
protected:
//BEGIN PROTECTED CLASS SPECIFIC METHODS:
//GroupGeometric.
- bool CreateRatioTableGG(const vector<RATIOTYPE>&, const RATIOTYPE, const VRPAIR& vr, const NOTEINDEXTYPE ratiostartpos);
+ bool CreateRatioTableGG(const std::vector<RATIOTYPE>&, const RATIOTYPE, const VRPAIR& vr, const NOTEINDEXTYPE ratiostartpos);
//Note: Stepdiff should be in range [1, finestepcount]
virtual RATIOTYPE GetRatioFine(const NOTEINDEXTYPE& note, USTEPINDEXTYPE stepDiff) const;
@@ -136,7 +136,7 @@
//For example GetRefNote(-1) is to return note :'groupsize-1'.
NOTEINDEXTYPE GetRefNote(NOTEINDEXTYPE note) const;
- virtual const string& GetDerivedClassID() const {return s_DerivedclassID;}
+ virtual const std::string& GetDerivedClassID() const {return s_DerivedclassID;}
private:
//PRIVATE METHODS:
@@ -157,10 +157,10 @@
//NOTE: Update SetDummyValues when adding members.
//Noteratios
- vector<RATIOTYPE> m_RatioTable;
+ std::vector<RATIOTYPE> m_RatioTable;
//'Fineratios'
- vector<RATIOTYPE> m_RatioTableFine;
+ std::vector<RATIOTYPE> m_RatioTableFine;
//The lowest index of note in the table
NOTEINDEXTYPE m_StepMin;
@@ -179,7 +179,7 @@
mutable UNOTEINDEXTYPE m_SerHelperRatiotableSize;
- static const string s_DerivedclassID;
+ static const std::string s_DerivedclassID;
}; //End: CTuningRTI declaration.
Modified: trunk/OpenMPT/soundlib/tuningCollection.cpp
===================================================================
--- trunk/OpenMPT/soundlib/tuningCollection.cpp 2013-06-27 13:03:26 UTC (rev 2413)
+++ trunk/OpenMPT/soundlib/tuningCollection.cpp 2013-06-27 13:41:04 UTC (rev 2414)
@@ -37,7 +37,7 @@
void ReadStr(std::istream& iStrm, std::string& str, const size_t);
void ReadNoteMap(std::istream& iStrm, CTuningBase::NOTENAMEMAP& m, const size_t);
- void ReadRatioTable(std::istream& iStrm, vector<CTuningRTI::RATIOTYPE>& v, const size_t);
+ void ReadRatioTable(std::istream& iStrm, std::vector<CTuningRTI::RATIOTYPE>& v, const size_t);
void WriteStr(std::ostream& oStrm, const std::string& str);
void ReadTuning(istream& iStrm, CTuningCollection& Tc, const size_t) {Tc.AddTuning(iStrm, true);}
@@ -47,7 +47,7 @@
using namespace CTuningS11n;
-CTuningCollection::CTuningCollection(const string& name) : m_Name(name), m_EditMask(EM_ALLOWALL)
+CTuningCollection::CTuningCollection(const std::string& name) : m_Name(name), m_EditMask(EM_ALLOWALL)
//------------------------------------
{
if(m_Name.size() > GetNameLengthMax()) m_Name.resize(GetNameLengthMax());
@@ -70,7 +70,7 @@
m_DeletedTunings.clear();
}
-CTuning* CTuningCollection::FindTuning(const string& name) const
+CTuning* CTuningCollection::FindTuning(const std::string& name) const
//------------------------------------------------------
{
for(size_t i = 0; i<m_Tunings.size(); i++)
@@ -88,13 +88,13 @@
}
-CTuning* CTuningCollection::GetTuning(const string& name)
+CTuning* CTuningCollection::GetTuning(const std::string& name)
//----------------------------------------------
{
return FindTuning(name);
}
-const CTuning* CTuningCollection::GetTuning(const string& name) const
+const CTuning* CTuningCollection::GetTuning(const std::string& name) const
//-------------------------------------------------------------------
{
return FindTuning(name);
@@ -353,7 +353,7 @@
}
-string CTuningCollection::GetEditMaskString() const
+std::string CTuningCollection::GetEditMaskString() const
//-------------------------------------------------
{
std::bitset<16> mask(m_EditMask);
Modified: trunk/OpenMPT/soundlib/tuningbase.cpp
===================================================================
--- trunk/OpenMPT/soundlib/tuningbase.cpp 2013-06-27 13:03:26 UTC (rev 2413)
+++ trunk/OpenMPT/soundlib/tuningbase.cpp 2013-06-27 13:41:04 UTC (rev 2414)
@@ -94,7 +94,7 @@
if(allowExactnamecopy)
to.m_TuningName = from.m_TuningName;
else
- to.m_TuningName = string("Copy of ") + from.m_TuningName;
+ to.m_TuningName = std::string("Copy of ") + from.m_TuningName;
to.m_NoteNameMap = from.m_NoteNameMap;
to.m_EditMask = from.m_EditMask;
@@ -165,7 +165,7 @@
}
TEMPLATEDEC
-string CTUNINGBASE::GetTuningTypeStr(const TUNINGTYPE& tt)
+std::string CTUNINGBASE::GetTuningTypeStr(const TUNINGTYPE& tt)
//----------------------------------------------------------------
{
if(tt == TT_GENERAL)
@@ -220,7 +220,7 @@
}
TEMPLATEDEC
-bool CTUNINGBASE::SetNoteName(const NOTEINDEXTYPE& n, const string& str)
+bool CTUNINGBASE::SetNoteName(const NOTEINDEXTYPE& n, const std::string& str)
//-----------------------------------------------------------------------
{
if(MayEdit(EM_NOTENAME))
@@ -283,7 +283,7 @@
if(s < 1 || r <= 0 || startindex < GetValidityRange().first)
return true;
- vector<RATIOTYPE> v;
+ std::vector<RATIOTYPE> v;
v.reserve(s);
for(NOTEINDEXTYPE i = startindex; i<startindex+s; i++)
v.push_back(GetRatio(i));
@@ -291,7 +291,7 @@
}
TEMPLATEDEC
-bool CTUNINGBASE::CreateGroupGeometric(const vector<RATIOTYPE>& v, const RATIOTYPE& r, const VRPAIR vr, const NOTEINDEXTYPE ratiostartpos)
+bool CTUNINGBASE::CreateGroupGeometric(const std::vector<RATIOTYPE>& v, const RATIOTYPE& r, const VRPAIR vr, const NOTEINDEXTYPE ratiostartpos)
//------------------------------------------------------------------------------------------
{
if(MayEdit(EM_RATIOS) &&
@@ -425,7 +425,7 @@
TEMPLATEDEC
-bool CTUNINGBASE::DeserializeOLD(istream& inStrm)
+bool CTUNINGBASE::DeserializeOLD(std::istream& inStrm)
//------------------------------------------------
{
char begin[8];
@@ -457,7 +457,7 @@
for(size_t i = 0; i<size; i++)
{
NOTEINDEXTYPE n;
- string str;
+ std::string str;
inStrm.read(reinterpret_cast<char*>(&n), sizeof(n));
if(srlztn::StringFromBinaryStream<uint8>(inStrm, str))
return SERIALIZATION_FAILURE;
Modified: trunk/OpenMPT/soundlib/tuningbase.h
===================================================================
--- trunk/OpenMPT/soundlib/tuningbase.h 2013-06-27 13:03:26 UTC (rev 2413)
+++ trunk/OpenMPT/soundlib/tuningbase.h 2013-06-27 13:41:04 UTC (rev 2414)
@@ -29,11 +29,6 @@
#include <limits>
#include "../common/misc_util.h"
#include "../common/typedefs.h"
-using std::string;
-using std::vector;
-using std::istream;
-using std::ostream;
-using std::map;
namespace srlztn {class Ssb;}
@@ -158,7 +153,7 @@
virtual bool Multiply(const RATIOTYPE&);
//Create GroupGeometric tuning of *this using virtual ProCreateGroupGeometric.
- bool CreateGroupGeometric(const vector<RATIOTYPE>&, const RATIOTYPE&, const VRPAIR vr, const NOTEINDEXTYPE ratiostartpos);
+ bool CreateGroupGeometric(const std::vector<RATIOTYPE>&, const RATIOTYPE&, const VRPAIR vr, const NOTEINDEXTYPE ratiostartpos);
//Create GroupGeometric of *this using ratios from 'itself' and ratios starting from
//position given as third argument.
@@ -168,15 +163,15 @@
bool CreateGeometric(const UNOTEINDEXTYPE& p, const RATIOTYPE& r) {return CreateGeometric(p,r,GetValidityRange());}
bool CreateGeometric(const UNOTEINDEXTYPE&, const RATIOTYPE&, const VRPAIR vr);
- virtual SERIALIZATION_RETURN_TYPE Serialize(ostream& /*out*/) const {return false;}
+ virtual SERIALIZATION_RETURN_TYPE Serialize(std::ostream& /*out*/) const {return false;}
NOTESTR GetNoteName(const NOTEINDEXTYPE& x) const;
- void SetName(const string& s);
+ void SetName(const std::string& s);
- string GetName() const {return m_TuningName;}
+ std::string GetName() const {return m_TuningName;}
- bool SetNoteName(const NOTEINDEXTYPE&, const string&);
+ bool SetNoteName(const NOTEINDEXTYPE&, const std::string&);
bool ClearNoteName(const NOTEINDEXTYPE& n, const bool clearAll = false);
@@ -184,7 +179,7 @@
TUNINGTYPE GetTuningType() const {return m_TuningType;}
- static string GetTuningTypeStr(const TUNINGTYPE& tt);
+ static std::string GetTuningTypeStr(const TUNINGTYPE& tt);
static TUNINGTYPE GetTuningType(const char* str);
bool IsOfType(const TUNINGTYPE& type) const;
@@ -225,7 +220,7 @@
EDITMASK GetEditMask() const {return m_EditMask;}
- bool DeserializeOLD(istream&);
+ bool DeserializeOLD(std::istream&);
virtual ~CTuningBase() {};
@@ -240,7 +235,7 @@
virtual NOTESTR ProGetNoteName(const NOTEINDEXTYPE&) const;
//The two methods below return false if action was done, true otherwise.
- virtual bool ProCreateGroupGeometric(const vector<RATIOTYPE>&, const RATIOTYPE&, const VRPAIR&, const NOTEINDEXTYPE /*ratiostartpos*/) {return true;}
+ virtual bool ProCreateGroupGeometric(const std::vector<RATIOTYPE>&, const RATIOTYPE&, const VRPAIR&, const NOTEINDEXTYPE /*ratiostartpos*/) {return true;}
virtual bool ProCreateGeometric(const UNOTEINDEXTYPE&, const RATIOTYPE&, const VRPAIR&) {return true;}
virtual VRPAIR ProSetValidityRange(const VRPAIR&) {return GetValidityRange();}
@@ -263,7 +258,7 @@
TUNINGTYPE GetType() const {return m_TuningType;}
//This is appended to baseclassID in serialization with which objects are identified when loading.
- virtual const string& GetDerivedClassID() const = 0;
+ virtual const std::string& GetDerivedClassID() const = 0;
//Return true if data loading failed, false otherwise.
virtual bool ProProcessUnserializationdata() = 0;
@@ -280,7 +275,7 @@
//BEGIN: DATA MEMBERS
protected:
- string m_TuningName;
+ std::string m_TuningName;
EDITMASK m_EditMask; //Behavior: true <~> allow modification
TUNINGTYPE m_TuningType;
NOTENAMEMAP m_NoteNameMap;
@@ -290,7 +285,7 @@
//END DATA MEMBERS
protected:
- CTuningBase(const string name = "Unnamed") :
+ CTuningBase(const std::string name = "Unnamed") :
m_TuningName(name),
m_EditMask(uint16_max), //All bits to true - allow all by default.
m_TuningType(TT_GENERAL), //Unspecific tuning by default.
@@ -299,8 +294,8 @@
private:
CTuningBase(CTuningBase&) {}
CTuningBase& operator=(const CTuningBase&) {return *this;}
- static void ReadNotenamemapPair(istream& iStrm, TYPENAME NOTENAMEMAP::value_type& val, const size_t);
- static void WriteNotenamemappair(ostream& oStrm, const TYPENAME NOTENAMEMAP::value_type& val, const size_t);
+ static void ReadNotenamemapPair(std::istream& iStrm, TYPENAME NOTENAMEMAP::value_type& val, const size_t);
+ static void WriteNotenamemappair(std::ostream& oStrm, const TYPENAME NOTENAMEMAP::value_type& val, const size_t);
public:
static const char* s_TuningDescriptionGeneral;
@@ -330,7 +325,7 @@
}
TEMPLATEDEC
-inline void CTUNINGBASE::SetName(const string& s)
+inline void CTUNINGBASE::SetName(const std::string& s)
//-----------------------------------------------
{
if(MayEdit(EM_NAME)) m_TuningName = s;
Modified: trunk/OpenMPT/soundlib/tuningcollection.h
===================================================================
--- trunk/OpenMPT/soundlib/tuningcollection.h 2013-06-27 13:03:26 UTC (rev 2413)
+++ trunk/OpenMPT/soundlib/tuningcollection.h 2013-06-27 13:41:04 UTC (rev 2414)
@@ -18,7 +18,7 @@
namespace CTuningS11n
{
- void ReadTuning(istream& iStrm, CTuningCollection& Tc, const size_t);
+ void ReadTuning(std::istream& iStrm, CTuningCollection& Tc, const size_t);
}
@@ -34,7 +34,7 @@
//If changing this, see whether serialization should be
//modified as well.
- typedef vector<CTuning*> TUNINGVECTOR;
+ typedef std::vector<CTuning*> TUNINGVECTOR;
typedef TUNINGVECTOR::iterator TITER; //Tuning ITERator.
typedef TUNINGVECTOR::const_iterator CTITER;
@@ -66,13 +66,13 @@
//BEGIN INTERFACE:
public:
- CTuningCollection(const string& name = "");
+ CTuningCollection(const std::string& name = "");
~CTuningCollection();
//Note: Given pointer is deleted by CTuningCollection
//at some point.
bool AddTuning(CTuning* const pT);
- bool AddTuning(istream& inStrm) {return AddTuning(inStrm, false);}
+ bool AddTuning(std::istream& inStrm) {return AddTuning(inStrm, false);}
bool Remove(const size_t i);
bool Remove(const CTuning*);
@@ -83,28 +83,28 @@
const EDITMASK& GetEditMask() const {return m_EditMask;}
- string GetEditMaskString() const;
+ std::string GetEditMaskString() const;
CTuning& GetTuning(size_t i) {return *m_Tunings.at(i);}
const CTuning& GetTuning(size_t i) const {return *m_Tunings.at(i);}
- CTuning* GetTuning(const string& name);
- const CTuning* GetTuning(const string& name) const;
+ CTuning* GetTuning(const std::string& name);
+ const CTuning* GetTuning(const std::string& name) const;
size_t GetNumTunings() const {return m_Tunings.size();}
- const string& GetName() const {return m_Name;}
+ const std::string& GetName() const {return m_Name;}
void SetSavefilePath(const std::string &psz) {m_SavefilePath = psz;}
- const string& GetSaveFilePath() const {return m_SavefilePath;}
+ const std::string& GetSaveFilePath() const {return m_SavefilePath;}
- string GetVersionString() const {return Stringify(static_cast<int>(s_SerializationVersion));}
+ std::string GetVersionString() const {return Stringify(static_cast<int>(s_SerializationVersion));}
size_t GetNameLengthMax() const {return 256;}
//Serialization/unserialisation
- bool Serialize(ostream&) const;
+ bool Serialize(std::ostream&) const;
bool Serialize() const;
- bool Deserialize(istream&);
+ bool Deserialize(std::istream&);
bool Deserialize();
//Transfer tuning pT from pTCsrc to pTCdest
@@ -118,25 +118,25 @@
private:
//BEGIN: SERIALIZABLE DATA MEMBERS
TUNINGVECTOR m_Tunings; //The actual tuningobjects are stored as deletable pointers here.
- string m_Name;
+ std::string m_Name;
EDITMASK m_EditMask;
//END: SERIALIZABLE DATA MEMBERS
//BEGIN: NONSERIALIZABLE DATA MEMBERS
TUNINGVECTOR m_DeletedTunings; //See Remove()-method for explanation of this.
- string m_SavefilePath;
+ std::string m_SavefilePath;
//END: NONSERIALIZABLE DATA MEMBERS
//END: DATA MEMBERS
- friend void CTuningS11n::ReadTuning(istream& iStrm, CTuningCollection& Tc, const size_t);
+ friend void CTuningS11n::ReadTuning(std::istream& iStrm, CTuningCollection& Tc, const size_t);
//BEGIN PRIVATE METHODS
private:
- CTuning* FindTuning(const string& name) const;
+ CTuning* FindTuning(const std::string& name) const;
size_t FindTuning(const CTuning* const) const;
- bool AddTuning(istream& inStrm, const bool ignoreEditmask);
+ bool AddTuning(std::istream& inStrm, const bool ignoreEditmask);
bool Remove(TITER removable, bool moveToTrashBin = true);
@@ -144,7 +144,7 @@
CTuningCollection& operator=(const CTuningCollection&) {return *this;}
CTuningCollection(const CTuningCollection&) {}
- bool DeserializeOLD(istream&, bool& loadingSuccessful);
+ bool DeserializeOLD(std::istream&, bool& loadingSuccessful);
//END PRIVATE METHODS.
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-06-28 21:02:41
|
Revision: 2433
http://sourceforge.net/p/modplug/code/2433
Author: manxorist
Date: 2013-06-28 21:02:30 +0000 (Fri, 28 Jun 2013)
Log Message:
-----------
[Fix] Replace ReadArray and ReadVector with ReadArrayLE and ReadVectorLE where appropriate.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/FileReader.h
trunk/OpenMPT/soundlib/LOAD_AMF.CPP
trunk/OpenMPT/soundlib/Load_ams.cpp
trunk/OpenMPT/soundlib/Load_it.cpp
Modified: trunk/OpenMPT/soundlib/FileReader.h
===================================================================
--- trunk/OpenMPT/soundlib/FileReader.h 2013-06-28 20:43:06 UTC (rev 2432)
+++ trunk/OpenMPT/soundlib/FileReader.h 2013-06-28 21:02:30 UTC (rev 2433)
@@ -859,12 +859,13 @@
}
}
- // Read an array.
+ // Read an array of byte-sized values.
// If successful, the file cursor is advanced by the size of the array.
// Otherwise, the target is zeroed.
template<typename T, off_t destSize>
bool ReadArray(T (&destArray)[destSize])
{
+ //STATIC_ASSERT(sizeof(T) == 1);
if(CanRead(sizeof(destArray)))
{
for(std::size_t i = 0; i < destSize; ++i)
@@ -879,12 +880,33 @@
}
}
- // Read destSize elements of type T into a vector.
+ // Read an array.
+ // If successful, the file cursor is advanced by the size of the array.
+ // Otherwise, the target is zeroed.
+ template<typename T, off_t destSize>
+ bool ReadArrayLE(T (&destArray)[destSize])
+ {
+ if(CanRead(sizeof(destArray)))
+ {
+ for(std::size_t i = 0; i < destSize; ++i)
+ {
+ destArray[i] = ReadIntLE<T>();
+ }
+ return true;
+ } else
+ {
+ MemsetZero(destArray);
+ return false;
+ }
+ }
+
+ // Read destSize elements of byte-sized type T into a vector.
// If successful, the file cursor is advanced by the size of the vector.
// Otherwise, the vector is resized to destSize, but possibly existing contents are not cleared.
template<typename T>
bool ReadVector(std::vector<T> &destVector, size_t destSize)
{
+ STATIC_ASSERT(sizeof(T) == 1);
const off_t readSize = sizeof(T) * destSize;
destVector.resize(destSize);
if(CanRead(readSize))
@@ -900,6 +922,27 @@
}
}
+ // Read destSize elements of type T into a vector.
+ // If successful, the file cursor is advanced by the size of the vector.
+ // Otherwise, the vector is resized to destSize, but possibly existing contents are not cleared.
+ template<typename T>
+ bool ReadVectorLE(std::vector<T> &destVector, size_t destSize)
+ {
+ const off_t readSize = sizeof(T) * destSize;
+ destVector.resize(destSize);
+ if(CanRead(readSize))
+ {
+ for(std::size_t i = 0; i < destSize; ++i)
+ {
+ destVector[i] = ReadIntLE<T>();
+ }
+ return true;
+ } else
+ {
+ return false;
+ }
+ }
+
// Compare a magic string with the current stream position.
// Returns true if they are identical and advances the file cursor by the the length of the "magic" string.
// Returns false if the string could not be found. The file cursor is not advanced in this case.
Modified: trunk/OpenMPT/soundlib/LOAD_AMF.CPP
===================================================================
--- trunk/OpenMPT/soundlib/LOAD_AMF.CPP 2013-06-28 20:43:06 UTC (rev 2432)
+++ trunk/OpenMPT/soundlib/LOAD_AMF.CPP 2013-06-28 21:02:30 UTC (rev 2433)
@@ -513,7 +513,7 @@
// Read Track Mapping Table
std::vector<uint16> trackMap;
- file.ReadVector(trackMap, fileHeader.numTracks);
+ file.ReadVectorLE(trackMap, fileHeader.numTracks);
uint16 trackCount = 0;
for(std::vector<uint16>::const_iterator i = trackMap.begin(); i != trackMap.end(); i++)
{
@@ -573,7 +573,7 @@
// Get table with per-channel track assignments
file.Seek(trackStartPos + pat * (GetNumChannels() * 2 + (fileHeader.version >= 14 ? 2 : 0)));
std::vector<uint16> tracks;
- file.ReadVector(tracks, GetNumChannels());
+ file.ReadVectorLE(tracks, GetNumChannels());
for(CHANNELINDEX chn = 0; chn < GetNumChannels(); chn++)
{
Modified: trunk/OpenMPT/soundlib/Load_ams.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_ams.cpp 2013-06-28 20:43:06 UTC (rev 2432)
+++ trunk/OpenMPT/soundlib/Load_ams.cpp 2013-06-28 21:02:30 UTC (rev 2433)
@@ -469,12 +469,12 @@
// Read Order List
std::vector<uint16> orders;
- if(file.ReadVector(orders, fileHeader.numOrds))
+ if(file.ReadVectorLE(orders, fileHeader.numOrds))
{
Order.resize(fileHeader.numOrds);
for(size_t i = 0; i < fileHeader.numOrds; i++)
{
- Order[i] = SwapBytesLE(orders[i]);
+ Order[i] = orders[i];
}
}
@@ -913,12 +913,12 @@
// Read Order List
std::vector<uint16> orders;
- if(file.ReadVector(orders, fileHeader.numOrds))
+ if(file.ReadVectorLE(orders, fileHeader.numOrds))
{
Order.resize(fileHeader.numOrds);
for(size_t i = 0; i < fileHeader.numOrds; i++)
{
- Order[i] = SwapBytesLE(orders[i]);
+ Order[i] = orders[i];
}
}
Modified: trunk/OpenMPT/soundlib/Load_it.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_it.cpp 2013-06-28 20:43:06 UTC (rev 2432)
+++ trunk/OpenMPT/soundlib/Load_it.cpp 2013-06-28 21:02:30 UTC (rev 2433)
@@ -482,9 +482,9 @@
// Reading instrument, sample and pattern offsets
std::vector<uint32> insPos, smpPos, patPos;
- file.ReadVector(insPos, fileHeader.insnum);
- file.ReadVector(smpPos, fileHeader.smpnum);
- file.ReadVector(patPos, fileHeader.patnum);
+ file.ReadVectorLE(insPos, fileHeader.insnum);
+ file.ReadVectorLE(smpPos, fileHeader.smpnum);
+ file.ReadVectorLE(patPos, fileHeader.patnum);
// Find the first parapointer.
// This is used for finding out whether the edit history is actually stored in the file or not,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-06-30 16:07:16
|
Revision: 2447
http://sourceforge.net/p/modplug/code/2447
Author: manxorist
Date: 2013-06-30 16:07:07 +0000 (Sun, 30 Jun 2013)
Log Message:
-----------
[Ref] Convert IMAADPCMUnpack16() to use FileReader.
[Fix] Fix possible out-of-bounds arary access in IMAADPCMUnpack16().
[Fix] Make IMAADPCMUnpack16() work on big-endian.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_wav.cpp
trunk/OpenMPT/soundlib/SampleFormats.cpp
Modified: trunk/OpenMPT/soundlib/Load_wav.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_wav.cpp 2013-06-30 14:43:01 UTC (rev 2446)
+++ trunk/OpenMPT/soundlib/Load_wav.cpp 2013-06-30 16:07:07 UTC (rev 2447)
@@ -184,8 +184,8 @@
// Note: Only works for mono samples.
-bool IMAADPCMUnpack16(int16 *target, SmpLength sampleLen, const void *source, size_t sourceSize, uint16 blockAlign)
-//-----------------------------------------------------------------------------------------------------------------
+bool IMAADPCMUnpack16(int16 *target, SmpLength sampleLen, FileReader file, uint16 blockAlign)
+//-------------------------------------------------------------------------------------------
{
static const int32 IMAIndexTab[8] = { -1, -1, -1, -1, 2, 4, 6, 8 };
static const int32 IMAUnpackTable[90] =
@@ -204,29 +204,27 @@
32767, 0
};
- if ((sampleLen < 4) || (!target) || (!source)
- || (blockAlign < 5) || (blockAlign > sourceSize)) return false;
+ if((sampleLen < 4) || (!target) || (blockAlign < 5) || (blockAlign > file.GetLength()))
+ return false;
+
SmpLength nPos = 0;
-
- const uint8 *psrc = static_cast<const uint8 *>(source);
- while((nPos < sampleLen) && (sourceSize > 4))
+ while((nPos < sampleLen) && file.CanRead(5))
{
- int32 nIndex;
- int32 value = *((int16 *)psrc);
- nIndex = psrc[2];
- psrc += 4;
- sourceSize -= 4;
+ int32 value = file.ReadIntLE<int16>();
+ int32 nIndex = file.ReadIntLE<uint8>();
+ nIndex = Clamp(nIndex, 0, 89);
+ file.Skip(1);
target[nPos++] = (int16)value;
- for(uint32 i = 0; (i < (blockAlign - 4u) * 2u) && (nPos < sampleLen) && sourceSize > 0; i++)
+ for(uint32 i = 0; (i < (blockAlign - 4u) * 2u) && (nPos < sampleLen) && file.AreBytesLeft(); i++)
{
uint8 delta;
if(i & 1)
{
- delta = ((*(psrc++)) >> 4) & 0x0F;
- sourceSize--;
+ delta = (file.ReadIntLE<uint8>() >> 4) & 0x0F;
} else
{
- delta = (*psrc) & 0x0F;
+ delta = file.ReadIntLE<uint8>() & 0x0F;
+ file.SkipBack(1);
}
int32 v = IMAUnpackTable[nIndex] >> 3;
if (delta & 1) v += IMAUnpackTable[nIndex] >> 2;
@@ -234,8 +232,7 @@
if (delta & 4) v += IMAUnpackTable[nIndex];
if (delta & 8) value -= v; else value += v;
nIndex += IMAIndexTab[delta & 7];
- if (nIndex < 0) nIndex = 0; else
- if (nIndex > 88) nIndex = 88;
+ nIndex = Clamp(nIndex, 0, 88);
target[nPos++] = static_cast<int16>(Clamp(value, -32768, 32767));
}
}
Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp
===================================================================
--- trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-06-30 14:43:01 UTC (rev 2446)
+++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-06-30 16:07:07 UTC (rev 2447)
@@ -319,7 +319,7 @@
////////////////////////////////////////////////////////////////////////////////
// WAV Open
-extern bool IMAADPCMUnpack16(int16 *target, SmpLength sampleLen, const void *source, size_t sourceSize, uint16 blockAlign);
+extern bool IMAADPCMUnpack16(int16 *target, SmpLength sampleLen, FileReader file, uint16 blockAlign);
bool CSoundFile::ReadWAVSample(SAMPLEINDEX nSample, FileReader &file, FileReader *wsmpChunk)
//------------------------------------------------------------------------------------------
@@ -356,7 +356,7 @@
{
return false;
}
- IMAADPCMUnpack16((int16 *)sample.pSample, sample.nLength, sampleChunk.GetRawData(), sampleChunk.BytesLeft(), wavFile.GetBlockAlign());
+ IMAADPCMUnpack16((int16 *)sample.pSample, sample.nLength, FileReader(sampleChunk.GetRawData(), sampleChunk.BytesLeft()), wavFile.GetBlockAlign());
AdjustSampleLoop(sample);
} else if(wavFile.GetSampleFormat() == WAVFormatChunk::fmtMP3)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2013-06-30 22:29:13
|
Revision: 2457
http://sourceforge.net/p/modplug/code/2457
Author: saga-games
Date: 2013-06-30 22:29:04 +0000 (Sun, 30 Jun 2013)
Log Message:
-----------
[Ref] Rewrote PTM loader using FileReader.
[Imp] PTM: Note cut should work better, added support for reversed samples.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_ptm.cpp
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/Sndfile.cpp
trunk/OpenMPT/soundlib/Sndfile.h
Modified: trunk/OpenMPT/soundlib/Load_ptm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_ptm.cpp 2013-06-30 20:24:50 UTC (rev 2456)
+++ trunk/OpenMPT/soundlib/Load_ptm.cpp 2013-06-30 22:29:04 UTC (rev 2457)
@@ -4,7 +4,6 @@
* Purpose: PTM (PolyTracker) module loader
* Notes : (currently none)
* Authors: Olivier Lapicque
- * Adam Goode (endian and char fixes for PPC)
* OpenMPT Devs
* The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
*/
@@ -13,227 +12,259 @@
#include "stdafx.h"
#include "Loaders.h"
-#if MPT_COMPILER_MSVC
-#pragma warning(disable:4244) //"conversion from 'type1' to 'type2', possible loss of data"
-#endif
-
#ifdef NEEDS_PRAGMA_PACK
#pragma pack(push, 1)
#endif
-typedef struct PACKED PTMFILEHEADER
+struct PACKED PTMFileHeader
{
- char songname[28]; // name of song, asciiz string
- CHAR eof; // 26
- BYTE version_lo; // 03 version of file, currently 0203h
- BYTE version_hi; // 02
- BYTE reserved1; // reserved, set to 0
- WORD norders; // number of orders (0..256)
- WORD nsamples; // number of instruments (1..255)
- WORD npatterns; // number of patterns (1..128)
- WORD nchannels; // number of channels (voices) used (1..32)
- WORD fileflags; // set to 0
- WORD reserved2; // reserved, set to 0
- DWORD ptmf_id; // song identification, 'PTMF' or 0x464d5450
- BYTE reserved3[16]; // reserved, set to 0
- BYTE chnpan[32]; // channel panning settings, 0..15, 0 = left, 7 = middle, 15 = right
- BYTE orders[256]; // order list, valid entries 0..nOrders-1
- WORD patseg[128]; // pattern offsets (*16)
-} PTMFILEHEADER, *LPPTMFILEHEADER;
+ char songname[28]; // Name of song, asciiz string
+ uint8 dosEOF; // 26
+ uint8 versionLo; // 03 version of file, currently 0203h
+ uint8 versionHi; // 02
+ uint8 reserved1; // Reserved, set to 0
+ uint16 numOrders; // Number of orders (0..256)
+ uint16 numSamples; // Number of instruments (1..255)
+ uint16 numPatterns; // Number of patterns (1..128)
+ uint16 numChannels; // Number of channels (voices) used (1..32)
+ uint8 flags[2]; // Set to 0
+ uint8 reserved2[2]; // Reserved, set to 0
+ char magic[4]; // Song identification, 'PTMF'
+ uint8 reserved3[16]; // Reserved, set to 0
+ uint8 chnPan[32]; // Channel panning settings, 0..15, 0 = left, 7 = middle, 15 = right
+ uint8 orders[256]; // Order list, valid entries 0..nOrders-1
+ uint16 patOffsets[128]; // Pattern offsets (*16)
-STATIC_ASSERT(sizeof(PTMFILEHEADER) == 608);
+ // Convert all multi-byte numeric values to current platform's endianness or vice versa.
+ void ConvertEndianness()
+ {
+ SwapBytesLE(numOrders);
+ SwapBytesLE(numSamples);
+ SwapBytesLE(numPatterns);
+ SwapBytesLE(numChannels);
+ for(int i = 0; i < CountOf(patOffsets); i++)
+ {
+ SwapBytesLE(patOffsets[i]);
+ }
+ }
+};
-typedef struct PACKED PTMSAMPLE
+STATIC_ASSERT(sizeof(PTMFileHeader) == 608);
+
+struct PACKED PTMSampleHeader
{
- BYTE sampletype; // sample type (bit array)
- char filename[12]; // name of external sample file
- BYTE volume; // default volume
- WORD nC4Spd; // C4 speed
- WORD sampleseg; // sample segment (used internally)
- WORD fileofs[2]; // offset of sample data
- WORD length[2]; // sample size (in bytes)
- WORD loopbeg[2]; // start of loop
- WORD loopend[2]; // end of loop
- WORD gusdata[7];
- char samplename[28]; // name of sample, asciiz
- DWORD ptms_id; // sample identification, 'PTMS' or 0x534d5450
-} PTMSAMPLE;
+ enum SampleFlags
+ {
+ smpTypeMask = 0x03,
+ smpPCM = 0x01,
-STATIC_ASSERT(sizeof(PTMSAMPLE) == 80);
+ smpLoop = 0x04,
+ smpPingPong = 0x08,
+ smp16Bit = 0x10,
+ };
+ uint8 flags; // Sample type (see SampleFlags)
+ char filename[12]; // Name of external sample file
+ uint8 volume; // Default volume
+ uint16 c4speed; // C-4 speed (yep, not C-5)
+ uint8 smpSegment[2]; // Sample segment (used internally)
+ uint32 dataOffset; // Offset of sample data
+ uint32 length; // Sample size (in bytes)
+ uint32 loopStart; // Start of loop
+ uint32 loopEnd; // End of loop
+ uint8 gusdata[14];
+ char samplename[28]; // Name of sample, ASCIIZ
+ char magic[4]; // Sample identification, 'PTMS'
+
+ // Convert all multi-byte numeric values to current platform's endianness or vice versa.
+ void ConvertEndianness()
+ {
+ SwapBytesLE(c4speed);
+ SwapBytesLE(dataOffset);
+ SwapBytesLE(length);
+ SwapBytesLE(loopStart);
+ SwapBytesLE(loopEnd);
+ }
+
+ // Convert an PTM sample header to OpenMPT's internal sample header.
+ SampleIO ConvertToMPT(ModSample &mptSmp) const
+ {
+ mptSmp.Initialize(MOD_TYPE_S3M);
+ mptSmp.nVolume = std::min(volume, uint8(64)) * 4;
+ mptSmp.nC5Speed = c4speed * 2;
+
+ mpt::String::Read<mpt::String::maybeNullTerminated>(mptSmp.filename, filename);
+
+ SampleIO sampleIO(
+ SampleIO::_8bit,
+ SampleIO::mono,
+ SampleIO::littleEndian,
+ SampleIO::deltaPCM);
+
+ if((flags & smpTypeMask) == smpPCM)
+ {
+ mptSmp.nLength = length;
+ mptSmp.nLoopStart = loopStart;
+ mptSmp.nLoopEnd = loopEnd;
+
+ if(flags & smpLoop) mptSmp.uFlags.set(CHN_LOOP);
+ if(flags & smpPingPong) mptSmp.uFlags.set(CHN_PINGPONGLOOP);
+ if(flags & smp16Bit)
+ {
+ sampleIO |= SampleIO::_16bit;
+ sampleIO |= SampleIO::PTM8Dto16;
+
+ mptSmp.nLength /= 2;
+ mptSmp.nLoopStart /= 2;
+ mptSmp.nLoopEnd /= 2;
+ }
+ }
+
+ return sampleIO;
+ }
+};
+
+STATIC_ASSERT(sizeof(PTMSampleHeader) == 80);
+
#ifdef NEEDS_PRAGMA_PACK
#pragma pack(pop)
#endif
-bool CSoundFile::ReadPTM(const BYTE *lpStream, const DWORD dwMemLength, ModLoadingFlags loadFlags)
-//------------------------------------------------------------------------------------------------
+bool CSoundFile::ReadPTM(FileReader &file, ModLoadingFlags loadFlags)
+//-------------------------------------------------------------------
{
- if(lpStream == nullptr || dwMemLength < sizeof(PTMFILEHEADER))
- return false;
+ file.Rewind();
- PTMFILEHEADER pfh = *(LPPTMFILEHEADER)lpStream;
- DWORD dwMemPos;
- UINT nOrders;
-
- pfh.norders = LittleEndianW(pfh.norders);
- pfh.nsamples = LittleEndianW(pfh.nsamples);
- pfh.npatterns = LittleEndianW(pfh.npatterns);
- pfh.nchannels = LittleEndianW(pfh.nchannels);
- pfh.fileflags = LittleEndianW(pfh.fileflags);
- pfh.reserved2 = LittleEndianW(pfh.reserved2);
- pfh.ptmf_id = LittleEndian(pfh.ptmf_id);
- for (size_t j = 0; j < CountOf(pfh.patseg); j++)
+ PTMFileHeader fileHeader;
+ if(!file.ReadConvertEndianness(fileHeader)
+ || memcmp(fileHeader.magic, "PTMF", 4)
+ || !fileHeader.numChannels
+ || fileHeader.numChannels > 32
+ || !fileHeader.numOrders || fileHeader.numOrders > 256
+ || !fileHeader.numSamples || fileHeader.numSamples > 255
+ || !fileHeader.numPatterns || fileHeader.numPatterns > 128
+ || !file.CanRead(fileHeader.numSamples * sizeof(PTMSampleHeader)))
{
- pfh.patseg[j] = LittleEndianW(pfh.patseg[j]);
- }
-
- if ((pfh.ptmf_id != 0x464d5450) || (!pfh.nchannels)
- || (pfh.nchannels > 32)
- || (pfh.norders > 256) || (!pfh.norders)
- || (!pfh.nsamples) || (pfh.nsamples > 255)
- || (!pfh.npatterns) || (pfh.npatterns > 128)
- || (sizeof(PTMFILEHEADER) + pfh.nsamples * sizeof(PTMSAMPLE) >= dwMemLength))
- {
return false;
} else if(loadFlags == onlyVerifyHeader)
{
return true;
}
- mpt::String::Read<mpt::String::maybeNullTerminated>(m_szNames[0], pfh.songname);
+ mpt::String::Read<mpt::String::maybeNullTerminated>(m_szNames[0], fileHeader.songname);
InitializeGlobals();
- madeWithTracker = mpt::String::Format("PolyTracker %d.%d", pfh.version_hi, pfh.version_lo);
+ madeWithTracker = mpt::String::Format("PolyTracker %d.%02x", fileHeader.versionHi, fileHeader.versionLo);
m_nType = MOD_TYPE_PTM;
- m_nChannels = pfh.nchannels;
- m_nSamples = MIN(pfh.nsamples, MAX_SAMPLES - 1);
- dwMemPos = sizeof(PTMFILEHEADER);
- nOrders = (pfh.norders < MAX_ORDERS) ? pfh.norders : MAX_ORDERS-1;
- Order.ReadFromArray(pfh.orders, nOrders);
+ m_nChannels = fileHeader.numChannels;
+ m_nSamples = std::min<SAMPLEINDEX>(fileHeader.numSamples, MAX_SAMPLES - 1);
+ Order.ReadFromArray(fileHeader.orders, fileHeader.numOrders);
- for (CHANNELINDEX ipan = 0; ipan < m_nChannels; ipan++)
+ // Reading channel panning
+ for(CHANNELINDEX chn = 0; chn < m_nChannels; chn++)
{
- ChnSettings[ipan].Reset();
- ChnSettings[ipan].nPan = ((pfh.chnpan[ipan] & 0x0F) << 4) + 4;
+ ChnSettings[chn].Reset();
+ ChnSettings[chn].nPan = ((fileHeader.chnPan[chn] & 0x0F) << 4) + 4;
}
- for (SAMPLEINDEX ismp = 0; ismp < m_nSamples; ismp++, dwMemPos += sizeof(PTMSAMPLE))
+
+ // Reading samples
+ FileReader sampleHeaderChunk = file.GetChunk(fileHeader.numSamples * sizeof(PTMSampleHeader));
+ for(SAMPLEINDEX smp = 0; smp < m_nSamples; smp++)
{
- ModSample &sample = Samples[ismp + 1];
- PTMSAMPLE *psmp = (PTMSAMPLE *)(lpStream+dwMemPos);
+ PTMSampleHeader sampleHeader;
+ sampleHeaderChunk.ReadConvertEndianness(sampleHeader);
- sample.Initialize();
- mpt::String::Read<mpt::String::maybeNullTerminated>(m_szNames[ismp + 1], psmp->samplename);
- mpt::String::Read<mpt::String::maybeNullTerminated>(sample.filename, psmp->filename);
+ ModSample &sample = Samples[smp + 1];
+ mpt::String::Read<mpt::String::maybeNullTerminated>(m_szNames[smp + 1], sampleHeader.samplename);
+ SampleIO sampleIO = sampleHeader.ConvertToMPT(sample);
- sample.nVolume = psmp->volume * 4;
- sample.nC5Speed = LittleEndianW(psmp->nC4Spd) * 2;
-
- if((psmp->sampletype & 3) == 1)
+ if((loadFlags & loadSampleData) && sample.nLength && sampleHeader.dataOffset && file.Seek(sampleHeader.dataOffset))
{
- SampleIO sampleIO(
- SampleIO::_8bit,
- SampleIO::mono,
- SampleIO::littleEndian,
- SampleIO::deltaPCM);
-
- DWORD samplepos;
- sample.nLength = LittleEndian(*(LPDWORD)(psmp->length));
- sample.nLoopStart = LittleEndian(*(LPDWORD)(psmp->loopbeg));
- sample.nLoopEnd = LittleEndian(*(LPDWORD)(psmp->loopend));
- samplepos = LittleEndian(*(LPDWORD)(&psmp->fileofs));
- if (psmp->sampletype & 4) sample.uFlags |= CHN_LOOP;
- if (psmp->sampletype & 8) sample.uFlags |= CHN_PINGPONGLOOP;
- if (psmp->sampletype & 16)
- {
- sampleIO |= SampleIO::_16bit;
- sampleIO |= SampleIO::PTM8Dto16;
-
- sample.nLength /= 2;
- sample.nLoopStart /= 2;
- sample.nLoopEnd /= 2;
- }
- if(sample.nLength && samplepos && samplepos < dwMemLength && (loadFlags & loadSampleData))
- {
- FileReader chunk(lpStream + samplepos, dwMemLength - samplepos);
- sampleIO.ReadSample(sample, chunk);
- }
+ sampleIO.ReadSample(sample, file);
}
}
+
// Reading Patterns
if(!(loadFlags && loadPatternData))
{
return true;
}
- for (UINT ipat=0; ipat<pfh.npatterns; ipat++)
+
+ for(PATTERNINDEX pat = 0; pat < fileHeader.numPatterns; pat++)
{
- dwMemPos = ((UINT)pfh.patseg[ipat]) << 4;
- if ((!dwMemPos) || (dwMemPos >= dwMemLength)) continue;
- if(Patterns.Insert(ipat, 64))
- break;
- //
- ModCommand *m = Patterns[ipat];
- for (UINT row=0; ((row < 64) && (dwMemPos < dwMemLength)); )
+ if(Patterns.Insert(pat, 64)
+ || fileHeader.patOffsets[pat] == 0
+ || !file.Seek(fileHeader.patOffsets[pat] << 4))
{
- UINT b = lpStream[dwMemPos++];
+ continue;
+ }
- if (dwMemPos >= dwMemLength) break;
- if (b)
+ ModCommand *rowBase = Patterns[pat];
+ ROWINDEX row = 0;
+ while(row < 64 && file.AreBytesLeft())
+ {
+ uint8 b = file.ReadUint8();
+
+ if(b == 0)
{
- UINT nChn = b & 0x1F;
+ row++;
+ rowBase += m_nChannels;
+ continue;
+ }
+ CHANNELINDEX chn = (b & 0x1F);
+ ModCommand dummy;
+ ModCommand &m = chn < GetNumChannels() ? rowBase[chn] : dummy;
- if (b & 0x20)
+ if(b & 0x20)
+ {
+ m.note = file.ReadUint8();
+ m.instr = file.ReadUint8();
+ if(m.note == 254)
+ m.note = NOTE_NOTECUT;
+ else if(!m.note || m.note > 120)
+ m.note = NOTE_NONE;
+ }
+ if(b & 0x40)
+ {
+ m.command = file.ReadUint8();
+ m.param = file.ReadUint8();
+ if(m.command < 0x10)
{
- if (dwMemPos + 2 > dwMemLength) break;
- m[nChn].note = lpStream[dwMemPos++];
- m[nChn].instr = lpStream[dwMemPos++];
- }
- if (b & 0x40)
+ // Beware: Effect letters are as in MOD, but portamento and volume slides behave like in S3M (i.e. fine slides share the same effect letters)
+ ConvertModCommand(m);
+ } else
{
- if (dwMemPos + 2 > dwMemLength) break;
- m[nChn].command = lpStream[dwMemPos++];
- m[nChn].param = lpStream[dwMemPos++];
- if (m[nChn].command < 0x10)
+ switch(m.command)
{
- ConvertModCommand(m[nChn]);
- m[nChn].ExtendedMODtoS3MEffect();
- // Note cut does just mute the sample, not cut it. We have to fix that, if possible.
- if(m[nChn].command == CMD_S3MCMDEX && (m[nChn].param & 0xF0) == 0xC0 && m[nChn].volcmd == VOLCMD_NONE)
+ case 0x10:
+ m.command = CMD_GLOBALVOLUME;
+ break;
+ case 0x11:
+ m.command = CMD_RETRIG;
+ break;
+ case 0x12:
+ m.command = CMD_FINEVIBRATO;
+ break;
+ case 0x17:
+ // Reverse sample + offset (start with offset 256 * xx bytes) -- is this an offset from the sample end...?
+ if(m.param)
{
- // SCx => v00 + SDx
- // This is a pretty dumb solution because many (?) PTM files make usage of the volume column + note cut at the same time.
- m[nChn].param = 0xD0 | (m[nChn].param & 0x0F);
- m[nChn].volcmd = VOLCMD_VOLUME;
- m[nChn].vol = 0;
+ m.volcmd = VOLCMD_OFFSET;
+ m.vol = m.param >> 3;
}
- } else
- {
- switch(m[nChn].command)
- {
- case 16:
- m[nChn].command = CMD_GLOBALVOLUME;
- break;
- case 17:
- m[nChn].command = CMD_RETRIG;
- break;
- case 18:
- m[nChn].command = CMD_FINEVIBRATO;
- break;
- default:
- m[nChn].command = 0;
- }
+ m.command = CMD_S3MCMDEX;
+ m.param = 0x9F;
+ break;
+ default:
+ m.command = CMD_NONE;
}
}
- if (b & 0x80)
- {
- if (dwMemPos >= dwMemLength) break;
- m[nChn].volcmd = VOLCMD_VOLUME;
- m[nChn].vol = lpStream[dwMemPos++];
- }
- } else
+ }
+ if(b & 0x80)
{
- row++;
- m += m_nChannels;
+ m.volcmd = VOLCMD_VOLUME;
+ m.vol = file.ReadUint8();
}
}
}
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-06-30 20:24:50 UTC (rev 2456)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-06-30 22:29:04 UTC (rev 2457)
@@ -1676,7 +1676,7 @@
//:xy --> note delay until tick x, note cut at tick x+y
nStartTick = (param & 0xF0) >> 4;
const UINT cutAtTick = nStartTick + (param & 0x0F);
- NoteCut(nChn, cutAtTick);
+ NoteCut(nChn, cutAtTick, IsCompatibleMode(TRK_IMPULSETRACKER | TRK_SCREAMTRACKER));
} else if ((cmd == CMD_MODCMDEX) || (cmd == CMD_S3MCMDEX))
{
if ((!param) && (GetType() & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT))) param = pChn->nOldCmdEx; else pChn->nOldCmdEx = param;
@@ -3457,7 +3457,7 @@
// EBx: Fine Volume Down
case 0xB0: if ((param) || (GetType() & (MOD_TYPE_XM|MOD_TYPE_MT2))) FineVolumeDown(pChn, param, false); break;
// ECx: Note Cut
- case 0xC0: NoteCut(nChn, param); break;
+ case 0xC0: NoteCut(nChn, param, false); break;
// EDx: Note Delay
// EEx: Pattern Delay
case 0xF0:
@@ -3631,7 +3631,9 @@
else if(GetType() == MOD_TYPE_S3M)
return;
}
- NoteCut(nChn, param);
+ // S3M/IT compatibility: Note Cut really cuts notes and does not just mute them (so that following volume commands could restore the sample)
+ // Test case: scx.it
+ NoteCut(nChn, param, IsCompatibleMode(TRK_IMPULSETRACKER | TRK_SCREAMTRACKER));
break;
// SDx: Note Delay
// SEx: Pattern Delay for x rows
@@ -4354,16 +4356,14 @@
}
-void CSoundFile::NoteCut(CHANNELINDEX nChn, UINT nTick)
-//-----------------------------------------------------
+void CSoundFile::NoteCut(CHANNELINDEX nChn, UINT nTick, bool cutSample)
+//---------------------------------------------------------------------
{
if (m_nTickCount == nTick)
{
ModChannel *pChn = &Chn[nChn];
pChn->nVolume = 0;
- // S3M/IT compatibility: Note Cut really cuts notes and does not just mute them (so that following volume commands could restore the sample)
- // Test case: scx.it
- if(IsCompatibleMode(TRK_IMPULSETRACKER|TRK_SCREAMTRACKER))
+ if(cutSample)
{
pChn->nFadeOutVol = 0;
pChn->dwFlags.set(CHN_NOTEFADE);
@@ -4949,7 +4949,7 @@
if(m_nTickCount == 0)
pChn->nOldFinePortaUpDown = 0;
- const int tickParam = (m_nTickCount + 1.0) * param / m_nMusicSpeed;
+ const int tickParam = static_cast<int>((m_nTickCount + 1.0) * param / m_nMusicSpeed);
pChn->m_PortamentoFineSteps += (param >= 0) ? tickParam - pChn->nOldFinePortaUpDown : tickParam + pChn->nOldFinePortaUpDown;
if(m_nTickCount + 1 == m_nMusicSpeed)
pChn->nOldFinePortaUpDown = abs(param);
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-06-30 20:24:50 UTC (rev 2456)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-06-30 22:29:04 UTC (rev 2457)
@@ -590,7 +590,7 @@
// Global variable initializer for loader functions
void CSoundFile::InitializeGlobals()
-//---------------------------
+//----------------------------------
{
// Do not add or change any of these values! And if you do, review each and every loader to check if they require these defaults!
m_nType = MOD_TYPE_NONE;
@@ -707,7 +707,7 @@
&& !ReadAMS(file, loadFlags)
&& !ReadAMS2(file, loadFlags)
&& !ReadOKT(file, loadFlags)
- && !ReadPTM(lpStream, dwMemLength, loadFlags)
+ && !ReadPTM(file, loadFlags)
&& !ReadUlt(file, loadFlags)
&& !ReadDMF(file, loadFlags)
&& !ReadDSM(lpStream, dwMemLength, loadFlags)
@@ -1295,12 +1295,12 @@
void CSoundFile::LoopPattern(PATTERNINDEX nPat, ROWINDEX nRow)
//------------------------------------------------------------
{
- if ((nPat < 0) || (nPat >= Patterns.Size()) || (!Patterns[nPat]))
+ if(!Patterns.IsValidPat(nPat))
{
m_SongFlags.reset(SONG_PATTERNLOOP);
} else
{
- if ((nRow < 0) || (nRow >= (int)Patterns[nPat].GetNumRows())) nRow = 0;
+ if(nRow >= Patterns[nPat].GetNumRows()) nRow = 0;
m_nPattern = nPat;
m_nRow = m_nNextRow = nRow;
m_nTickCount = m_nMusicSpeed;
@@ -1309,7 +1309,6 @@
m_nBufferCount = 0;
m_nNextPatStartRow = 0;
m_SongFlags.set(SONG_PATTERNLOOP);
- // m_nSeqOverride = 0;
}
}
@@ -1318,8 +1317,8 @@
void CSoundFile::DontLoopPattern(PATTERNINDEX nPat, ROWINDEX nRow)
//----------------------------------------------------------------
{
- if ((nPat < 0) || (nPat >= Patterns.Size()) || (!Patterns[nPat])) nPat = 0;
- if ((nRow < 0) || (nRow >= (int)Patterns[nPat].GetNumRows())) nRow = 0;
+ if(!Patterns.IsValidPat(nPat)) nPat = 0;
+ if(nRow >= Patterns[nPat].GetNumRows()) nRow = 0;
m_nPattern = nPat;
m_nRow = m_nNextRow = nRow;
m_nTickCount = m_nMusicSpeed;
@@ -1328,7 +1327,6 @@
m_nBufferCount = 0;
m_nNextPatStartRow = 0;
m_SongFlags.reset(SONG_PATTERNLOOP);
- //m_nSeqOverride = 0;
}
//end rewbs.playSongFromCursor
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2013-06-30 20:24:50 UTC (rev 2456)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2013-06-30 22:29:04 UTC (rev 2457)
@@ -574,7 +574,7 @@
bool ReadMDL(const LPCBYTE lpStream, const DWORD dwMemLength, ModLoadingFlags loadFlags = loadCompleteModule);
bool ReadOKT(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
bool ReadDMF(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadPTM(const LPCBYTE lpStream, const DWORD dwMemLength, ModLoadingFlags loadFlags = loadCompleteModule);
+ bool ReadPTM(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
bool ReadDBM(const LPCBYTE lpStream, const DWORD dwMemLength, ModLoadingFlags loadFlags = loadCompleteModule);
bool ReadAMF_Asylum(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
bool ReadAMF_DSMI(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
@@ -738,7 +738,7 @@
void Panbrello(ModChannel *pChn, UINT param);
void RetrigNote(CHANNELINDEX nChn, int param, UINT offset=0); //rewbs.volOffset: added last param
void SampleOffset(CHANNELINDEX nChn, UINT param);
- void NoteCut(CHANNELINDEX nChn, UINT nTick);
+ void NoteCut(CHANNELINDEX nChn, UINT nTick, bool cutSample);
ROWINDEX PatternLoop(ModChannel *, UINT param);
void ExtendedMODCommands(CHANNELINDEX nChn, UINT param);
void ExtendedS3MCommands(CHANNELINDEX nChn, UINT param);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-07-01 11:36:52
|
Revision: 2460
http://sourceforge.net/p/modplug/code/2460
Author: manxorist
Date: 2013-07-01 11:36:41 +0000 (Mon, 01 Jul 2013)
Log Message:
-----------
[Ref] Silence 2 signed/unsigned comparison warnings.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_ams.cpp
trunk/OpenMPT/soundlib/Load_ptm.cpp
Modified: trunk/OpenMPT/soundlib/Load_ams.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_ams.cpp 2013-07-01 11:14:47 UTC (rev 2459)
+++ trunk/OpenMPT/soundlib/Load_ams.cpp 2013-07-01 11:36:41 UTC (rev 2460)
@@ -184,7 +184,7 @@
}
break;
}
- } else if(effect - 0x10 < CountOf(effTrans))
+ } else if(effect - 0x10 < (int)CountOf(effTrans))
{
// Extended commands
m.command = effTrans[effect - 0x10];
Modified: trunk/OpenMPT/soundlib/Load_ptm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_ptm.cpp 2013-07-01 11:14:47 UTC (rev 2459)
+++ trunk/OpenMPT/soundlib/Load_ptm.cpp 2013-07-01 11:36:41 UTC (rev 2460)
@@ -42,7 +42,7 @@
SwapBytesLE(numSamples);
SwapBytesLE(numPatterns);
SwapBytesLE(numChannels);
- for(int i = 0; i < CountOf(patOffsets); i++)
+ for(std::size_t i = 0; i < CountOf(patOffsets); i++)
{
SwapBytesLE(patOffsets[i]);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2013-07-03 23:57:36
|
Revision: 2489
http://sourceforge.net/p/modplug/code/2489
Author: saga-games
Date: 2013-07-03 23:57:30 +0000 (Wed, 03 Jul 2013)
Log Message:
-----------
[Imp] AMS Loader: Support for reversed sample loop (no support in GUI for now)
[Fix] AMS Loader: Velvet Studio version was upside down.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Fastmix.cpp
trunk/OpenMPT/soundlib/Load_ams.cpp
trunk/OpenMPT/soundlib/Snd_defs.h
trunk/OpenMPT/soundlib/Snd_fx.cpp
Modified: trunk/OpenMPT/soundlib/Fastmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Fastmix.cpp 2013-07-03 23:10:59 UTC (rev 2488)
+++ trunk/OpenMPT/soundlib/Fastmix.cpp 2013-07-03 23:57:30 UTC (rev 2489)
@@ -1340,7 +1340,15 @@
}
nInc = -nInc;
pChn->nInc = nInc;
- pChn->dwFlags.reset(CHN_PINGPONGFLAG); // go forward
+ if(pChn->dwFlags[CHN_PINGPONGLOOP])
+ {
+ pChn->dwFlags.reset(CHN_PINGPONGFLAG); // go forward
+ } else
+ {
+ pChn->dwFlags.set(CHN_PINGPONGFLAG);
+ pChn->nPos = pChn->nLength - 1;
+ pChn->nInc = -nInc;
+ }
if(!pChn->dwFlags[CHN_LOOP] || pChn->nPos >= pChn->nLength)
{
pChn->nPos = pChn->nLength;
Modified: trunk/OpenMPT/soundlib/Load_ams.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_ams.cpp 2013-07-03 23:10:59 UTC (rev 2488)
+++ trunk/OpenMPT/soundlib/Load_ams.cpp 2013-07-03 23:57:30 UTC (rev 2489)
@@ -647,6 +647,7 @@
smp16Bit = 0x04,
smpLoop = 0x08,
smpBidiLoop = 0x10,
+ smpReverse = 0x40,
};
uint32 length;
@@ -696,15 +697,19 @@
if(flags & smp16Bit)
{
- mptSmp.uFlags |= CHN_16BIT;
+ mptSmp.uFlags.set(CHN_16BIT);
}
if((flags & smpLoop) && mptSmp.nLoopStart < mptSmp.nLoopEnd)
{
- mptSmp.uFlags |= CHN_LOOP;
+ mptSmp.uFlags.set(CHN_LOOP);
if(flags & smpBidiLoop)
{
- mptSmp.uFlags |= CHN_PINGPONGLOOP;
+ mptSmp.uFlags.set(CHN_PINGPONGLOOP);
}
+ if(flags & smpReverse)
+ {
+ mptSmp.uFlags.set(CHN_REVRSE);
+ }
}
}
};
@@ -778,7 +783,7 @@
m_nChannels = 32;
SetModFlag(MSF_COMPATIBLE_PLAY, true);
SetupMODPanning(true);
- madeWithTracker = mpt::String::Format("Velvet Studio %d.%d", fileHeader.format >> 4, fileHeader.format & 0x0F);
+ madeWithTracker = mpt::String::Format("Velvet Studio %d.%02x", fileHeader.format & 0x0F, fileHeader.format >> 4);
// Instruments
std::vector<SAMPLEINDEX> firstSample; // First sample of instrument
Modified: trunk/OpenMPT/soundlib/Snd_defs.h
===================================================================
--- trunk/OpenMPT/soundlib/Snd_defs.h 2013-07-03 23:10:59 UTC (rev 2488)
+++ trunk/OpenMPT/soundlib/Snd_defs.h 2013-07-03 23:57:30 UTC (rev 2489)
@@ -124,7 +124,7 @@
// Channel flags:
enum ChannelFlags
{
- // Bits 0-7: Sample Flags
+ // Sample Flags
CHN_16BIT = 0x01, // 16-bit sample
CHN_LOOP = 0x02, // looped sample
CHN_PINGPONGLOOP = 0x04, // bidi-looped sample
@@ -132,8 +132,9 @@
CHN_PINGPONGSUSTAIN = 0x10, // sample with bidi sustain loop
CHN_PANNING = 0x20, // sample with forced panning
CHN_STEREO = 0x40, // stereo sample
+ CHN_REVRSE = 0x80, // start sample playback from sample / loop end (Velvet Studio feature) - this is intentionally the same flag as CHN_PINGPONGFLAG.
+ // Channel Flags
CHN_PINGPONGFLAG = 0x80, // when flag is on, sample is processed backwards
- // Bits 8-31: Channel Flags
CHN_MUTE = 0x100, // muted channel
CHN_KEYOFF = 0x200, // exit sustain
CHN_NOTEFADE = 0x400, // fade note (instrument mode)
@@ -158,7 +159,7 @@
DECLARE_FLAGSET(ChannelFlags)
-#define CHN_SAMPLEFLAGS (CHN_16BIT | CHN_LOOP | CHN_PINGPONGLOOP | CHN_SUSTAINLOOP | CHN_PINGPONGSUSTAIN | CHN_PANNING | CHN_STEREO | CHN_PINGPONGFLAG)
+#define CHN_SAMPLEFLAGS (CHN_16BIT | CHN_LOOP | CHN_PINGPONGLOOP | CHN_SUSTAINLOOP | CHN_PINGPONGSUSTAIN | CHN_PANNING | CHN_STEREO | CHN_PINGPONGFLAG | CHN_REVRSE)
#define CHN_CHANNELFLAGS (~CHN_SAMPLEFLAGS)
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-07-03 23:10:59 UTC (rev 2488)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-07-03 23:57:30 UTC (rev 2489)
@@ -1129,6 +1129,8 @@
pChn->nLength = pSmp->nLength;
pChn->nLoopEnd = pSmp->nLength;
pChn->nLoopStart = 0;
+ pChn->nPos = 0;
+ pChn->nPosLo = 0;
pChn->dwFlags = (pChn->dwFlags & CHN_CHANNELFLAGS) | (static_cast<ChannelFlags>(pSmp->uFlags) & CHN_SAMPLEFLAGS);
if(pChn->dwFlags[CHN_SUSTAINLOOP])
{
@@ -1143,8 +1145,13 @@
pChn->nLoopEnd = pSmp->nLoopEnd;
if (pChn->nLength > pChn->nLoopEnd) pChn->nLength = pChn->nLoopEnd;
}
- pChn->nPos = 0;
- pChn->nPosLo = 0;
+
+ if(pChn->dwFlags[CHN_REVRSE])
+ {
+ pChn->dwFlags.set(CHN_PINGPONGFLAG);
+ pChn->nPos = pChn->nLength - 1;
+ }
+
// Handle "retrigger" waveform type
if(pChn->nVibratoType < 4)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-07-08 00:32:27
|
Revision: 2522
http://sourceforge.net/p/modplug/code/2522
Author: manxorist
Date: 2013-07-08 00:32:18 +0000 (Mon, 08 Jul 2013)
Log Message:
-----------
[Fix] Loading .wav files as modules broke in r2438 .
Revision Links:
--------------
http://sourceforge.net/p/modplug/code/2438
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_wav.cpp
trunk/OpenMPT/soundlib/SampleFormatConverters.h
Modified: trunk/OpenMPT/soundlib/Load_wav.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_wav.cpp 2013-07-08 00:13:03 UTC (rev 2521)
+++ trunk/OpenMPT/soundlib/Load_wav.cpp 2013-07-08 00:32:18 UTC (rev 2522)
@@ -26,7 +26,7 @@
ASSERT(sample.GetNumChannels() == 1);
ASSERT(sample.GetElementarySampleSize() == sizeof(typename SampleConverter::output_t));
- const size_t offset = channelIndex * sizeof(typename SampleConverter::input_t);
+ const size_t offset = channelIndex * sizeof(typename SampleConverter::input_t) * SampleConverter::input_inc;
if(sample.AllocateSample() == 0 || !file.CanRead(offset))
{
Modified: trunk/OpenMPT/soundlib/SampleFormatConverters.h
===================================================================
--- trunk/OpenMPT/soundlib/SampleFormatConverters.h 2013-07-08 00:13:03 UTC (rev 2521)
+++ trunk/OpenMPT/soundlib/SampleFormatConverters.h 2013-07-08 00:32:18 UTC (rev 2522)
@@ -441,7 +441,7 @@
// SampleConversion: Functor of type SampleConversionFunctor to apply sample conversion (see above for existing functors).
template <typename SampleConversion>
size_t CopySample(typename SampleConversion::output_t *outBuf, size_t numSamples, size_t incTarget, const typename SampleConversion::input_t *inBuf, size_t sourceSize, size_t incSource)
-//---------------------------------------------------------------------------------------------------------------------------------------
+//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
{
const size_t sampleSize = incSource * SampleConversion::input_inc;
LimitMax(numSamples, sourceSize / sampleSize);
@@ -462,7 +462,7 @@
// Copy a mono sample data buffer.
template <typename SampleConversion>
size_t CopyMonoSample(ModSample &sample, const char *sourceBuffer, size_t sourceSize)
-//------------------------------------------------------------------------------------
+//-----------------------------------------------------------------------------------
{
ASSERT(sample.GetNumChannels() == 1);
ASSERT(sample.GetElementarySampleSize() == sizeof(typename SampleConversion::output_t));
@@ -486,7 +486,7 @@
// Copy a stereo interleaved sample data buffer.
template <typename SampleConversion>
size_t CopyStereoInterleavedSample(ModSample &sample, const char *sourceBuffer, size_t sourceSize)
-//-------------------------------------------------------------------------------------------------
+//------------------------------------------------------------------------------------------------
{
ASSERT(sample.GetNumChannels() == 2);
ASSERT(sample.GetElementarySampleSize() == sizeof(typename SampleConversion::output_t));
@@ -514,7 +514,7 @@
// Copy a stereo split sample data buffer.
template <typename SampleConversion>
size_t CopyStereoSplitSample(ModSample &sample, const char *sourceBuffer, size_t sourceSize)
-//-------------------------------------------------------------------------------------------
+//------------------------------------------------------------------------------------------
{
ASSERT(sample.GetNumChannels() == 2);
ASSERT(sample.GetElementarySampleSize() == sizeof(typename SampleConversion::output_t));
@@ -543,7 +543,7 @@
// Copy a sample data buffer and normalize it. Requires slightly advanced sample conversion functor.
template<typename SampleConversion>
size_t CopyAndNormalizeSample(ModSample &sample, const char *sourceBuffer, size_t sourceSize)
-//--------------------------------------------------------------------------------------------
+//-------------------------------------------------------------------------------------------
{
const size_t inSize = sizeof(typename SampleConversion::input_t);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2013-07-27 19:21:58
|
Revision: 2546
http://sourceforge.net/p/modplug/code/2546
Author: saga-games
Date: 2013-07-27 19:21:51 +0000 (Sat, 27 Jul 2013)
Log Message:
-----------
[Fix] Sample editor: When applying sample normalization, the sample's global volume was also changed in formats that don't support global volume.
[Fix] XM compatibility: Finally got that FT2-style arpeggio to be balls-on!
Modified Paths:
--------------
trunk/OpenMPT/soundlib/SampleFormats.cpp
trunk/OpenMPT/soundlib/Sndmix.cpp
Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp
===================================================================
--- trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-07-21 12:51:21 UTC (rev 2545)
+++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-07-27 19:21:51 UTC (rev 2546)
@@ -374,7 +374,6 @@
sample.nLength = wavFile.GetSampleLength();
sample.nC5Speed = wavFile.GetSampleRate();
wavFile.ApplySampleSettings(sample, m_szNames[nSample]);
- sample.Convert(MOD_TYPE_IT, GetType());
FileReader sampleChunk = wavFile.GetSampleData();
@@ -448,6 +447,8 @@
*wsmpChunk = wavFile.GetWsmpChunk();
}
+ sample.Convert(MOD_TYPE_IT, GetType());
+
return true;
}
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-07-21 12:51:21 UTC (rev 2545)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-07-27 19:21:51 UTC (rev 2546)
@@ -1267,25 +1267,29 @@
{
switch(tick % 3)
{
- case 1: period = Util::Round<int>(period / TwoToPowerXOver12(pChn->nArpeggio >> 4)); break;
- case 2: period = Util::Round<int>(period / TwoToPowerXOver12(pChn->nArpeggio & 0x0F)); break;
+ case 1: period = Util::Round<int>(period / TwoToPowerXOver12(pChn->nArpeggio >> 4)); break;
+ case 2: period = Util::Round<int>(period / TwoToPowerXOver12(pChn->nArpeggio & 0x0F)); break;
}
}
}
// FastTracker 2: Swedish tracker logic (TM) arpeggio
else if(IsCompatibleMode(TRK_FASTTRACKER2))
{
- BYTE note = pChn->nNote;
+ uint8 note = pChn->nNote;
int arpPos = 0;
if(!m_SongFlags[SONG_FIRSTTICK])
{
- arpPos = ((int)m_nMusicSpeed - (int)m_nTickCount) % 3;
- if((m_nMusicSpeed > 18) && (m_nMusicSpeed - m_nTickCount > 16)) arpPos = 2; // swedish tracker logic, I love it
+ arpPos = m_nMusicSpeed - (m_nTickCount % m_nMusicSpeed);
+ // The fact that arpeggio behaves in a totally fucked up way at 16 ticks/row or more is that the arpeggio offset LUT only has 16 entries in FT2.
+ // At more than 16 ticks/row, FT2 reads into the vibrato table, which is placed right after the arpeggio table.
+ if(arpPos > 16) arpPos = 2;
+ else if(arpPos == 16) arpPos = 0;
+ else arpPos %= 3;
switch(arpPos)
{
- case 1: note += (pChn->nArpeggio >> 4); break;
- case 2: note += (pChn->nArpeggio & 0x0F); break;
+ case 1: note += (pChn->nArpeggio >> 4); break;
+ case 2: note += (pChn->nArpeggio & 0x0F); break;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2013-07-28 14:05:25
|
Revision: 2547
http://sourceforge.net/p/modplug/code/2547
Author: saga-games
Date: 2013-07-28 14:05:17 +0000 (Sun, 28 Jul 2013)
Log Message:
-----------
[Fix] STM: Improved support for ST2-style arpeggio (libopenmpt only, no change in OpenMPT)
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_stm.cpp
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/Sndmix.cpp
Modified: trunk/OpenMPT/soundlib/Load_stm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_stm.cpp 2013-07-27 19:21:51 UTC (rev 2546)
+++ trunk/OpenMPT/soundlib/Load_stm.cpp 2013-07-28 14:05:17 UTC (rev 2547)
@@ -142,11 +142,15 @@
m_nChannels = 4;
m_nMinPeriod = 64;
m_nMaxPeriod = 0x7FFF;
+#ifdef MODPLUG_TRACKER
+ m_nDefaultTempo = 125;
m_nDefaultSpeed = fileHeader.initTempo >> 4;
+#else
+ m_nDefaultTempo = 125 * 16;
+ m_nDefaultSpeed = fileHeader.initTempo;
+#endif // MODPLUG_TRACKER
if(m_nDefaultSpeed < 1) m_nDefaultSpeed = 1;
- m_nDefaultTempo = 125;
- m_nDefaultGlobalVolume = fileHeader.globalVolume * 4;
- LimitMax(m_nDefaultGlobalVolume, MAX_GLOBAL_VOLUME);
+ m_nDefaultGlobalVolume = std::min<uint8>(fileHeader.globalVolume, 64) * 4;
// Setting up channels
for(CHANNELINDEX chn = 0; chn < 4; chn++)
@@ -226,13 +230,15 @@
switch(m->command)
{
+#ifdef MODPLUG_TRACKER
case CMD_SPEED:
// ST2 assumes that the tempo is 125 * 16 BPM, and effects are updated
- // on every 16th tick of a row. This is pretty hard to handle, so we just
- // assume the tempo is 125 and divide the speed by 16 instead.
+ // on every 16th tick of a row. This is pretty hard to handle in the tracker,
+ // so we just assume the tempo is 125 and divide the speed by 16 instead.
// Parameters below 10 might behave weird.
m->param >>= 4;
break;
+#endif // MODPLUG_TRACKER
case CMD_PATTERNBREAK:
m->param = (m->param & 0xF0) * 10 + (m->param & 0x0F);
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-07-27 19:21:51 UTC (rev 2546)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-07-28 14:05:17 UTC (rev 2547)
@@ -35,39 +35,6 @@
// Length
-/*
-void CSoundFile::GenerateSamplePosMap() {
-
-
-
-
-
- double accurateBufferCount =
-
- long lSample = 0;
- nPattern
-
- //for each order
- //get pattern for this order
- //if pattern if duff: break, we're done.
- //for each row in this pattern
- //get ticks for this row
- //get ticks per row and tempo for this row
- //for each tick
-
- //Recalc if ticks per row or tempo has changed
-
- samplesPerTick = (double)gdwMixingFreq * (60.0/(double)m_nMusicTempo / ((double)m_nMusicSpeed * (double)m_nRowsPerBeat));
- lSample += samplesPerTick;
-
-
- nPattern = ++nOrder;
- }
-
-}
-*/
-
-
// Memory class for GetLength() code
class GetLengthMemory
{
@@ -782,7 +749,7 @@
}
// Default sample panning
- if(pSmp->uFlags[CHN_PANNING] && (bUpdVol || GetType() != MOD_TYPE_XM))
+ if(pSmp->uFlags[CHN_PANNING] && (bUpdVol || !(GetType() & (MOD_TYPE_XM | MOD_TYPE_MT2))))
{
// FT2 compatibility: Only reset panning on instrument numbers, not notes (bUpdVol condition)
// Test case: PanMemory.xm
@@ -1597,10 +1564,16 @@
//-------------------------------
{
ModChannel *pChn = Chn;
- ROWINDEX nBreakRow = ROWINDEX_INVALID; // Is changed if a break to row command is encountere.d
+ ROWINDEX nBreakRow = ROWINDEX_INVALID; // Is changed if a break to row command is encountered
ROWINDEX nPatLoopRow = ROWINDEX_INVALID; // Is changed if a pattern loop jump-back is executed
ORDERINDEX nPosJump = ORDERINDEX_INVALID;
+ // ScreamTracker 2 only updates effects on every 16th tick.
+ if((m_nTickCount & 0x0F) != 0 && GetType() == MOD_TYPE_STM)
+ {
+ return TRUE;
+ }
+
// -> CODE#0010
// -> DESC="add extended parameter mechanism to pattern effects"
ModCommand *m = nullptr;
@@ -2719,7 +2692,7 @@
// Channels effects
-// Update the effect memory of all S3M effects that use the last non-zero effect parameter ot show up (Dxy, Exx, Fxx, Ixy, Jxy, Kxy, Lxy, Qxy, Rxy, Sxy)
+// Update the effect memory of all S3M effects that use the last non-zero effect parameter as memory (Dxy, Exx, Fxx, Ixy, Jxy, Kxy, Lxy, Qxy, Rxy, Sxy)
// Test case: ParamMemory.s3m
void CSoundFile::UpdateS3MEffectMemory(ModChannel *pChn, UINT param) const
//------------------------------------------------------------------------
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-07-27 19:21:51 UTC (rev 2546)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-07-28 14:05:17 UTC (rev 2547)
@@ -1283,6 +1283,7 @@
arpPos = m_nMusicSpeed - (m_nTickCount % m_nMusicSpeed);
// The fact that arpeggio behaves in a totally fucked up way at 16 ticks/row or more is that the arpeggio offset LUT only has 16 entries in FT2.
// At more than 16 ticks/row, FT2 reads into the vibrato table, which is placed right after the arpeggio table.
+ // Test case: Arpeggio.xm
if(arpPos > 16) arpPos = 2;
else if(arpPos == 16) arpPos = 0;
else arpPos %= 3;
@@ -1302,13 +1303,19 @@
// Other trackers
else
{
+ uint32 tick = m_nTickCount;
+ // ScreamTracker 2 only updates effects on every 16th tick.
+ if(GetType() == MOD_TYPE_STM)
+ {
+ tick >>= 4;
+ }
int note = pChn->nNote;
- switch(m_nTickCount % 3)
+ switch(tick % 3)
{
case 1: note += (pChn->nArpeggio >> 4); break;
case 2: note += (pChn->nArpeggio & 0x0F); break;
}
- if(note != pChn->nNote)
+ if(note != pChn->nNote || GetType() == MOD_TYPE_STM)
{
if(m_SongFlags[SONG_PT1XMODE] && note >= NOTE_MIDDLEC + 24)
{
@@ -1317,6 +1324,13 @@
note -= 37;
}
period = GetPeriodFromNote(note, pChn->nFineTune, pChn->nC5Speed);
+
+ // The arpeggio note offset remains effective after the end of the current row in ScreamTracker 2.
+ // This fixes the flute lead in MORPH.STM by Skaven, pattern 27.
+ if(GetType() == MOD_TYPE_STM)
+ {
+ pChn->nPeriod = period;
+ }
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-09-07 13:24:12
|
Revision: 2650
http://sourceforge.net/p/modplug/code/2650
Author: manxorist
Date: 2013-09-07 13:24:00 +0000 (Sat, 07 Sep 2013)
Log Message:
-----------
[Ref] WavWriter should be #ifndef MODPLUG_NO_FILESAVE .
Modified Paths:
--------------
trunk/OpenMPT/soundlib/WAVTools.cpp
trunk/OpenMPT/soundlib/WAVTools.h
Modified: trunk/OpenMPT/soundlib/WAVTools.cpp
===================================================================
--- trunk/OpenMPT/soundlib/WAVTools.cpp 2013-09-06 21:44:06 UTC (rev 2649)
+++ trunk/OpenMPT/soundlib/WAVTools.cpp 2013-09-07 13:24:00 UTC (rev 2650)
@@ -245,6 +245,8 @@
}
+#ifndef MODPLUG_NO_FILESAVE
+
///////////////////////////////////////////////////////////
// WAV Writing
@@ -550,3 +552,5 @@
WriteArray(filename);
}
}
+
+#endif // MODPLUG_NO_FILESAVE
Modified: trunk/OpenMPT/soundlib/WAVTools.h
===================================================================
--- trunk/OpenMPT/soundlib/WAVTools.h 2013-09-06 21:44:06 UTC (rev 2649)
+++ trunk/OpenMPT/soundlib/WAVTools.h 2013-09-07 13:24:00 UTC (rev 2650)
@@ -366,6 +366,8 @@
};
+#ifndef MODPLUG_NO_FILESAVE
+
//=============
class WAVWriter
//=============
@@ -462,3 +464,5 @@
// Write some data to the file.
void Write(const void *data, size_t numBytes);
};
+
+#endif // MODPLUG_NO_FILESAVE
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-09-09 10:14:57
|
Revision: 2668
http://sourceforge.net/p/modplug/code/2668
Author: manxorist
Date: 2013-09-09 10:14:49 +0000 (Mon, 09 Sep 2013)
Log Message:
-----------
[Ref] Replace last occurances of TCHAR with char in soundlib/ .
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_it.cpp
trunk/OpenMPT/soundlib/Load_mo3.cpp
trunk/OpenMPT/soundlib/ModSequence.cpp
trunk/OpenMPT/soundlib/Sndfile.cpp
trunk/OpenMPT/soundlib/Sndfile.h
trunk/OpenMPT/soundlib/Tables.cpp
trunk/OpenMPT/soundlib/modsmp_ctrl.cpp
Modified: trunk/OpenMPT/soundlib/Load_it.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_it.cpp 2013-09-09 10:11:53 UTC (rev 2667)
+++ trunk/OpenMPT/soundlib/Load_it.cpp 2013-09-09 10:14:49 UTC (rev 2668)
@@ -26,11 +26,11 @@
#include <ext/stdio_sync_filebuf.h>
#endif
-#define str_tooMuchPatternData (GetStrI18N((MPT_TEXT("Warning: File format limit was reached. Some pattern data may not get written to file."))))
-#define str_pattern (GetStrI18N((MPT_TEXT("pattern"))))
-#define str_PatternSetTruncationNote (GetStrI18N((MPT_TEXT("The module contains %u patterns but only %u patterns can be loaded in this OpenMPT version."))))
-#define str_LoadingIncompatibleVersion MPT_TEXT("The file informed that it is incompatible with this version of OpenMPT. Loading was terminated.")
-#define str_LoadingMoreRecentVersion MPT_TEXT("The loaded file was made with a more recent OpenMPT version and this version may not be able to load all the features or play the file correctly.")
+#define str_tooMuchPatternData (GetStrI18N(("Warning: File format limit was reached. Some pattern data may not get written to file.")))
+#define str_pattern (GetStrI18N(("pattern")))
+#define str_PatternSetTruncationNote (GetStrI18N(("The module contains %u patterns but only %u patterns can be loaded in this OpenMPT version.")))
+#define str_LoadingIncompatibleVersion "The file informed that it is incompatible with this version of OpenMPT. Loading was terminated."
+#define str_LoadingMoreRecentVersion "The loaded file was made with a more recent OpenMPT version and this version may not be able to load all the features or play the file correctly."
const uint16 verMptFileVer = 0x891;
const uint16 verMptFileVerLoadLimit = 0x1000; // If cwtv-field is greater or equal to this value,
Modified: trunk/OpenMPT/soundlib/Load_mo3.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mo3.cpp 2013-09-09 10:11:53 UTC (rev 2667)
+++ trunk/OpenMPT/soundlib/Load_mo3.cpp 2013-09-09 10:14:49 UTC (rev 2668)
@@ -39,7 +39,7 @@
return false;
}
- AddToLog(GetStrI18N(MPT_TEXT("The file appears to be a MO3 file, but this OpenMPT build does not support loading MO3 files.")));
+ AddToLog(GetStrI18N("The file appears to be a MO3 file, but this OpenMPT build does not support loading MO3 files."));
return false;
#else
@@ -61,7 +61,7 @@
#endif // MODPLUG_TRACKER
if(unmo3 == nullptr) // Didn't succeed.
{
- AddToLog(GetStrI18N(MPT_TEXT("Loading MO3 file failed because unmo3.dll could not be loaded.")));
+ AddToLog(GetStrI18N("Loading MO3 file failed because unmo3.dll could not be loaded."));
}
else // case: dll loaded succesfully.
{
Modified: trunk/OpenMPT/soundlib/ModSequence.cpp
===================================================================
--- trunk/OpenMPT/soundlib/ModSequence.cpp 2013-09-09 10:11:53 UTC (rev 2667)
+++ trunk/OpenMPT/soundlib/ModSequence.cpp 2013-09-09 10:14:49 UTC (rev 2668)
@@ -20,7 +20,7 @@
#include "FileReader.h"
#include <functional>
-#define str_SequenceTruncationNote (GetStrI18N((MPT_TEXT("Module has sequence of length %u; it will be truncated to maximum supported length, %u."))))
+#define str_SequenceTruncationNote (GetStrI18N("Module has sequence of length %u; it will be truncated to maximum supported length, %u."))
#if defined(MODPLUG_TRACKER)
#ifdef _DEBUG
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-09-09 10:11:53 UTC (rev 2667)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-09-09 10:14:49 UTC (rev 2668)
@@ -1382,8 +1382,8 @@
}
-LPCTSTR CSoundFile::GetSampleName(UINT nSample) const
-//---------------------------------------------------
+const char *CSoundFile::GetSampleName(UINT nSample) const
+//-------------------------------------------------------
{
ASSERT(nSample <= GetNumSamples());
if (nSample < MAX_SAMPLES)
@@ -1400,7 +1400,7 @@
//---------------------------------------------------------------------
{
if((nInstr >= MAX_INSTRUMENTS) || (!Instruments[nInstr]))
- return MPT_TEXT("");
+ return "";
ASSERT(nInstr <= GetNumInstruments());
return Instruments[nInstr]->name;
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2013-09-09 10:11:53 UTC (rev 2667)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2013-09-09 10:14:49 UTC (rev 2668)
@@ -480,7 +480,7 @@
void SetCurrentOrder(ORDERINDEX nOrder);
std::string GetTitle() const { return songName; }
bool SetTitle(const std::string &newTitle); // Return true if title was changed.
- LPCTSTR GetSampleName(UINT nSample) const;
+ const char *GetSampleName(UINT nSample) const;
const char *GetInstrumentName(INSTRUMENTINDEX nInstr) const;
UINT GetMusicSpeed() const { return m_nMusicSpeed; }
UINT GetMusicTempo() const { return m_nMusicTempo; }
@@ -806,7 +806,7 @@
extern const LPCSTR szNoteNames[12];
-extern const LPCTSTR szDefaultNoteNames[NOTE_MAX];
+extern const LPCSTR szDefaultNoteNames[NOTE_MAX];
inline IMixPlugin* CSoundFile::GetInstrumentPlugin(INSTRUMENTINDEX instr)
Modified: trunk/OpenMPT/soundlib/Tables.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Tables.cpp 2013-09-09 10:11:53 UTC (rev 2667)
+++ trunk/OpenMPT/soundlib/Tables.cpp 2013-09-09 10:14:49 UTC (rev 2668)
@@ -29,17 +29,17 @@
"F#", "G-", "G#", "A-", "A#", "B-"
};
-const LPCTSTR szDefaultNoteNames[NOTE_MAX] = {
- MPT_TEXT("C-0"), MPT_TEXT("C#0"), MPT_TEXT("D-0"), MPT_TEXT("D#0"), MPT_TEXT("E-0"), MPT_TEXT("F-0"), MPT_TEXT("F#0"), MPT_TEXT("G-0"), MPT_TEXT("G#0"), MPT_TEXT("A-0"), MPT_TEXT("A#0"), MPT_TEXT("B-0"),
- MPT_TEXT("C-1"), MPT_TEXT("C#1"), MPT_TEXT("D-1"), MPT_TEXT("D#1"), MPT_TEXT("E-1"), MPT_TEXT("F-1"), MPT_TEXT("F#1"), MPT_TEXT("G-1"), MPT_TEXT("G#1"), MPT_TEXT("A-1"), MPT_TEXT("A#1"), MPT_TEXT("B-1"),
- MPT_TEXT("C-2"), MPT_TEXT("C#2"), MPT_TEXT("D-2"), MPT_TEXT("D#2"), MPT_TEXT("E-2"), MPT_TEXT("F-2"), MPT_TEXT("F#2"), MPT_TEXT("G-2"), MPT_TEXT("G#2"), MPT_TEXT("A-2"), MPT_TEXT("A#2"), MPT_TEXT("B-2"),
- MPT_TEXT("C-3"), MPT_TEXT("C#3"), MPT_TEXT("D-3"), MPT_TEXT("D#3"), MPT_TEXT("E-3"), MPT_TEXT("F-3"), MPT_TEXT("F#3"), MPT_TEXT("G-3"), MPT_TEXT("G#3"), MPT_TEXT("A-3"), MPT_TEXT("A#3"), MPT_TEXT("B-3"),
- MPT_TEXT("C-4"), MPT_TEXT("C#4"), MPT_TEXT("D-4"), MPT_TEXT("D#4"), MPT_TEXT("E-4"), MPT_TEXT("F-4"), MPT_TEXT("F#4"), MPT_TEXT("G-4"), MPT_TEXT("G#4"), MPT_TEXT("A-4"), MPT_TEXT("A#4"), MPT_TEXT("B-4"),
- MPT_TEXT("C-5"), MPT_TEXT("C#5"), MPT_TEXT("D-5"), MPT_TEXT("D#5"), MPT_TEXT("E-5"), MPT_TEXT("F-5"), MPT_TEXT("F#5"), MPT_TEXT("G-5"), MPT_TEXT("G#5"), MPT_TEXT("A-5"), MPT_TEXT("A#5"), MPT_TEXT("B-5"),
- MPT_TEXT("C-6"), MPT_TEXT("C#6"), MPT_TEXT("D-6"), MPT_TEXT("D#6"), MPT_TEXT("E-6"), MPT_TEXT("F-6"), MPT_TEXT("F#6"), MPT_TEXT("G-6"), MPT_TEXT("G#6"), MPT_TEXT("A-6"), MPT_TEXT("A#6"), MPT_TEXT("B-6"),
- MPT_TEXT("C-7"), MPT_TEXT("C#7"), MPT_TEXT("D-7"), MPT_TEXT("D#7"), MPT_TEXT("E-7"), MPT_TEXT("F-7"), MPT_TEXT("F#7"), MPT_TEXT("G-7"), MPT_TEXT("G#7"), MPT_TEXT("A-7"), MPT_TEXT("A#7"), MPT_TEXT("B-7"),
- MPT_TEXT("C-8"), MPT_TEXT("C#8"), MPT_TEXT("D-8"), MPT_TEXT("D#8"), MPT_TEXT("E-8"), MPT_TEXT("F-8"), MPT_TEXT("F#8"), MPT_TEXT("G-8"), MPT_TEXT("G#8"), MPT_TEXT("A-8"), MPT_TEXT("A#8"), MPT_TEXT("B-8"),
- MPT_TEXT("C-9"), MPT_TEXT("C#9"), MPT_TEXT("D-9"), MPT_TEXT("D#9"), MPT_TEXT("E-9"), MPT_TEXT("F-9"), MPT_TEXT("F#9"), MPT_TEXT("G-9"), MPT_TEXT("G#9"), MPT_TEXT("A-9"), MPT_TEXT("A#9"), MPT_TEXT("B-9"),
+const LPCSTR szDefaultNoteNames[NOTE_MAX] = {
+ "C-0", "C#0", "D-0", "D#0", "E-0", "F-0", "F#0", "G-0", "G#0", "A-0", "A#0", "B-0",
+ "C-1", "C#1", "D-1", "D#1", "E-1", "F-1", "F#1", "G-1", "G#1", "A-1", "A#1", "B-1",
+ "C-2", "C#2", "D-2", "D#2", "E-2", "F-2", "F#2", "G-2", "G#2", "A-2", "A#2", "B-2",
+ "C-3", "C#3", "D-3", "D#3", "E-3", "F-3", "F#3", "G-3", "G#3", "A-3", "A#3", "B-3",
+ "C-4", "C#4", "D-4", "D#4", "E-4", "F-4", "F#4", "G-4", "G#4", "A-4", "A#4", "B-4",
+ "C-5", "C#5", "D-5", "D#5", "E-5", "F-5", "F#5", "G-5", "G#5", "A-5", "A#5", "B-5",
+ "C-6", "C#6", "D-6", "D#6", "E-6", "F-6", "F#6", "G-6", "G#6", "A-6", "A#6", "B-6",
+ "C-7", "C#7", "D-7", "D#7", "E-7", "F-7", "F#7", "G-7", "G#7", "A-7", "A#7", "B-7",
+ "C-8", "C#8", "D-8", "D#8", "E-8", "F-8", "F#8", "G-8", "G#8", "A-8", "A#8", "B-8",
+ "C-9", "C#9", "D-9", "D#9", "E-9", "F-9", "F#9", "G-9", "G#9", "A-9", "A#9", "B-9",
};
Modified: trunk/OpenMPT/soundlib/modsmp_ctrl.cpp
===================================================================
--- trunk/OpenMPT/soundlib/modsmp_ctrl.cpp 2013-09-09 10:11:53 UTC (rev 2667)
+++ trunk/OpenMPT/soundlib/modsmp_ctrl.cpp 2013-09-09 10:14:49 UTC (rev 2668)
@@ -73,7 +73,7 @@
memcpy(pNewSmp, smp.pSample, nOldBytes);
}
else
- sndFile.AddToLog(LogNotification, MPT_TEXT("Unsupported start position in InsertSilence."));
+ sndFile.AddToLog(LogNotification, "Unsupported start position in InsertSilence.");
}
// Set loop points automatically
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-09-09 10:22:06
|
Revision: 2670
http://sourceforge.net/p/modplug/code/2670
Author: manxorist
Date: 2013-09-09 10:21:59 +0000 (Mon, 09 Sep 2013)
Log Message:
-----------
[Ref] Replace TCHAR with CHAR .
Modified Paths:
--------------
trunk/OpenMPT/soundlib/tuningCollection.cpp
trunk/OpenMPT/soundlib/tuningbase.cpp
trunk/OpenMPT/soundlib/tuningbase.h
trunk/OpenMPT/soundlib/tuningcollection.h
Modified: trunk/OpenMPT/soundlib/tuningCollection.cpp
===================================================================
--- trunk/OpenMPT/soundlib/tuningCollection.cpp 2013-09-09 10:17:13 UTC (rev 2669)
+++ trunk/OpenMPT/soundlib/tuningCollection.cpp 2013-09-09 10:21:59 UTC (rev 2670)
@@ -27,7 +27,7 @@
-Handle const-status better(e.g. status check in unserialization)
*/
-const TCHAR CTuningCollection::s_FileExtension[4] = MPT_TEXT(".tc");
+const CHAR CTuningCollection::s_FileExtension[4] = ".tc";
namespace CTuningS11n
{
Modified: trunk/OpenMPT/soundlib/tuningbase.cpp
===================================================================
--- trunk/OpenMPT/soundlib/tuningbase.cpp 2013-09-09 10:17:13 UTC (rev 2669)
+++ trunk/OpenMPT/soundlib/tuningbase.cpp 2013-09-09 10:21:59 UTC (rev 2670)
@@ -48,7 +48,7 @@
const CTuningBase::SERIALIZATION_RETURN_TYPE CTuningBase::SERIALIZATION_FAILURE = true;
-const TCHAR CTuningBase::s_FileExtension[5] = MPT_TEXT(".tun");
+const CHAR CTuningBase::s_FileExtension[5] = ".tun";
const CTuningBase::EDITMASK CTuningBase::EM_RATIOS = 1; //1b
Modified: trunk/OpenMPT/soundlib/tuningbase.h
===================================================================
--- trunk/OpenMPT/soundlib/tuningbase.h 2013-09-09 10:17:13 UTC (rev 2669)
+++ trunk/OpenMPT/soundlib/tuningbase.h 2013-09-09 10:21:59 UTC (rev 2670)
@@ -69,7 +69,7 @@
static const SERIALIZATION_RETURN_TYPE SERIALIZATION_SUCCESS;
static const SERIALIZATION_RETURN_TYPE SERIALIZATION_FAILURE;
- static const TCHAR s_FileExtension[5];
+ static const CHAR s_FileExtension[5];
static const EDITMASK EM_RATIOS;
static const EDITMASK EM_NOTENAME;
Modified: trunk/OpenMPT/soundlib/tuningcollection.h
===================================================================
--- trunk/OpenMPT/soundlib/tuningcollection.h 2013-09-09 10:17:13 UTC (rev 2669)
+++ trunk/OpenMPT/soundlib/tuningcollection.h 2013-09-09 10:21:59 UTC (rev 2670)
@@ -59,7 +59,7 @@
SERIALIZATION_FAILURE = true
};
- static const TCHAR s_FileExtension[4];
+ static const CHAR s_FileExtension[4];
static const size_t s_nMaxTuningCount = 255;
//END PUBLIC STATIC CONSTS
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-09-29 23:46:34
|
Revision: 2815
http://sourceforge.net/p/modplug/code/2815
Author: manxorist
Date: 2013-09-29 23:46:24 +0000 (Sun, 29 Sep 2013)
Log Message:
-----------
[Fix] Split SwapBytesLE/SwapBytesBE into in-place and function-style functions. This removes the crude workaround for GCC not being able to bind reference types to packed structure fields. Instead of converting the reference parameter to a pointer to byte-aligned integer type, we now explicitly assign to the parameter variable inside a wrapper macro. This removes any need for Endianness.h to even care about structure packing at all.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Endianness.h
trunk/OpenMPT/soundlib/FileReader.h
trunk/OpenMPT/soundlib/Load_dmf.cpp
trunk/OpenMPT/soundlib/Load_psm.cpp
trunk/OpenMPT/soundlib/SampleFormats.cpp
trunk/OpenMPT/soundlib/Sndfile.cpp
trunk/OpenMPT/soundlib/WAVTools.h
trunk/OpenMPT/soundlib/load_j2b.cpp
Modified: trunk/OpenMPT/soundlib/Endianness.h
===================================================================
--- trunk/OpenMPT/soundlib/Endianness.h 2013-09-29 22:12:56 UTC (rev 2814)
+++ trunk/OpenMPT/soundlib/Endianness.h 2013-09-29 23:46:24 UTC (rev 2815)
@@ -39,61 +39,67 @@
// Deprecated. Use "SwapBytesXX" versions below.
#ifdef MPT_PLATFORM_BIG_ENDIAN
-// PPC
inline uint32 LittleEndian(uint32 x) { return bswap32(x); }
inline uint16 LittleEndianW(uint16 x) { return bswap16(x); }
#define BigEndian(x) (x)
#define BigEndianW(x) (x)
#else
-// x86
inline uint32 BigEndian(uint32 x) { return bswap32(x); }
inline uint16 BigEndianW(uint16 x) { return bswap16(x); }
#define LittleEndian(x) (x)
#define LittleEndianW(x) (x)
#endif
-//#pragma deprecated(BigEndian, BigEndianW, LittleEndian, LittleEndianW)
-typedef uint32 ALIGN(1) unaligned_uint32;
-typedef uint16 ALIGN(1) unaligned_uint16;
-typedef int32 ALIGN(1) unaligned_int32;
-typedef int16 ALIGN(1) unaligned_int16;
+#if defined(MPT_PLATFORM_BIG_ENDIAN)
+#define bswap32le(x) bswap32(x)
+#define bswap16le(x) bswap16(x)
+#define bswap32be(x) (x)
+#define bswap16be(x) (x)
+#elif defined(MPT_PLATFORM_LITTLE_ENDIAN)
+#define bswap32be(x) bswap32(x)
+#define bswap16be(x) bswap16(x)
+#define bswap32le(x) (x)
+#define bswap16le(x) (x)
+#endif
-#ifdef MPT_PLATFORM_BIG_ENDIAN
-// PPC
-inline uint32 SwapBytesBE_(unaligned_uint32 *value) { return *value; }
-inline uint16 SwapBytesBE_(unaligned_uint16 *value) { return *value; }
-inline uint32 SwapBytesLE_(unaligned_uint32 *value) { return *value = bswap32(*value); }
-inline uint16 SwapBytesLE_(unaligned_uint16 *value) { return *value = bswap16(*value); }
-inline int32 SwapBytesBE_(unaligned_int32 *value) { return *value; }
-inline int16 SwapBytesBE_(unaligned_int16 *value) { return *value; }
-inline int32 SwapBytesLE_(unaligned_int32 *value) { return *value = bswap32(*value); }
-inline int16 SwapBytesLE_(unaligned_int16 *value) { return *value = bswap16(*value); }
-#else
-// x86
-inline uint32 SwapBytesBE_(unaligned_uint32 *value) { return *value = bswap32(*value); }
-inline uint16 SwapBytesBE_(unaligned_uint16 *value) { return *value = bswap16(*value); }
-inline uint32 SwapBytesLE_(unaligned_uint32 *value) { return *value; }
-inline uint16 SwapBytesLE_(unaligned_uint16 *value) { return *value; }
-inline int32 SwapBytesBE_(unaligned_int32 *value) { return *value = bswap32(*value); }
-inline int16 SwapBytesBE_(unaligned_int16 *value) { return *value = bswap16(*value); }
-inline int32 SwapBytesLE_(unaligned_int32 *value) { return *value; }
-inline int16 SwapBytesLE_(unaligned_int16 *value) { return *value; }
-#endif
+inline uint32 SwapBytesBE_(uint32 value) { return bswap32be(value); }
+inline uint16 SwapBytesBE_(uint16 value) { return bswap16be(value); }
+inline uint32 SwapBytesLE_(uint32 value) { return bswap32le(value); }
+inline uint16 SwapBytesLE_(uint16 value) { return bswap16le(value); }
+inline int32 SwapBytesBE_(int32 value) { return bswap32be(value); }
+inline int16 SwapBytesBE_(int16 value) { return bswap16be(value); }
+inline int32 SwapBytesLE_(int32 value) { return bswap32le(value); }
+inline int16 SwapBytesLE_(int16 value) { return bswap16le(value); }
+
// Do NOT remove these overloads, even if they seem useless.
-// We do not want risking to extend 8bit integers to int and then endian-converting and casting back to int.
+// We do not want risking to extend 8bit integers to int and then
+// endian-converting and casting back to int.
// Thus these overloads.
-inline uint8 SwapBytesLE_(uint8 *value) { return *value; }
-inline int8 SwapBytesLE_(int8 *value) { return *value; }
-inline char SwapBytesLE_(char *value) { return *value; }
-inline uint8 SwapBytesBE_(uint8 *value) { return *value; }
-inline int8 SwapBytesBE_(int8 *value) { return *value; }
-inline char SwapBytesBE_(char *value) { return *value; }
+inline uint8 SwapBytesLE_(uint8 value) { return value; }
+inline int8 SwapBytesLE_(int8 value) { return value; }
+inline char SwapBytesLE_(char value) { return value; }
+inline uint8 SwapBytesBE_(uint8 value) { return value; }
+inline int8 SwapBytesBE_(int8 value) { return value; }
+inline char SwapBytesBE_(char value) { return value; }
-// GCC will not bind references to members of packed structures, workaround it by using a raw pointer.
-// This is a temporary solution as this pointer might of course be unaligned which GCC seems to not care about in that case.
-#define SwapBytesBE(value) SwapBytesBE_(&(value))
-#define SwapBytesLE(value) SwapBytesLE_(&(value))
+// SwapBytesLE/SwapBytesBE is mostly used throughout the code with in-place
+// argument-modifying semantics.
+// As GCC will not bind references to members of packed structures,
+// we implement reference semantics by explicitly assigning to a macro
+// argument.
+// In-place modifying version:
+#define SwapBytesBE(value) do { (value) = SwapBytesBE_((value)); } while(0)
+#define SwapBytesLE(value) do { (value) = SwapBytesLE_((value)); } while(0)
+
+// Alternative, function-style syntax:
+#define SwapBytesReturnBE(value) SwapBytesBE_((value))
+#define SwapBytesReturnLE(value) SwapBytesLE_((value))
+
+#undef bswap16le
+#undef bswap32le
+#undef bswap16be
+#undef bswap32be
#undef bswap16
#undef bswap32
Modified: trunk/OpenMPT/soundlib/FileReader.h
===================================================================
--- trunk/OpenMPT/soundlib/FileReader.h 2013-09-29 22:12:56 UTC (rev 2814)
+++ trunk/OpenMPT/soundlib/FileReader.h 2013-09-29 23:46:24 UTC (rev 2815)
@@ -585,7 +585,7 @@
T target;
if(Read(target))
{
- return SwapBytesLE(target);
+ return SwapBytesReturnLE(target);
} else
{
return 0;
@@ -601,7 +601,7 @@
T target;
if(Read(target))
{
- return SwapBytesBE(target);
+ return SwapBytesReturnBE(target);
} else
{
return 0;
@@ -645,7 +645,7 @@
}
T target;
std::memcpy(&target, buf, sizeof(T));
- return SwapBytesLE(target);
+ return SwapBytesReturnLE(target);
}
// Read a supplied-size little endian integer to a fixed size variable.
Modified: trunk/OpenMPT/soundlib/Load_dmf.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_dmf.cpp 2013-09-29 22:12:56 UTC (rev 2814)
+++ trunk/OpenMPT/soundlib/Load_dmf.cpp 2013-09-29 23:46:24 UTC (rev 2815)
@@ -61,14 +61,12 @@
size_t GetLength() const
{
- uint32 l = length;
- return SwapBytesLE(l);
+ return SwapBytesReturnLE(length);
}
id_type GetID() const
{
- uint32 i = id;
- return static_cast<id_type>(SwapBytesLE(i));
+ return static_cast<id_type>(SwapBytesReturnLE(id));
}
};
Modified: trunk/OpenMPT/soundlib/Load_psm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_psm.cpp 2013-09-29 22:12:56 UTC (rev 2814)
+++ trunk/OpenMPT/soundlib/Load_psm.cpp 2013-09-29 23:46:24 UTC (rev 2815)
@@ -86,14 +86,12 @@
size_t GetLength() const
{
- uint32 l = length;
- return SwapBytesLE(l);
+ return SwapBytesReturnLE(length);
}
id_type GetID() const
{
- uint32 i = id;
- return static_cast<id_type>(SwapBytesLE(i));
+ return static_cast<id_type>(SwapBytesReturnLE(id));
}
};
Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp
===================================================================
--- trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-09-29 22:12:56 UTC (rev 2814)
+++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-09-29 23:46:24 UTC (rev 2815)
@@ -1143,14 +1143,12 @@
size_t GetLength() const
{
- uint32 l = length;
- return SwapBytesBE(l);
+ return SwapBytesReturnBE(length);
}
id_type GetID() const
{
- uint32 i = id;
- return static_cast<id_type>(SwapBytesBE(i));
+ return static_cast<id_type>(SwapBytesReturnBE(id));
}
};
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-09-29 22:12:56 UTC (rev 2814)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-09-29 23:46:24 UTC (rev 2815)
@@ -194,7 +194,7 @@
if(only_this_code == fcode || only_this_code == Util::MaxValueOfType(only_this_code)) \
{ \
type tmp = input-> name; \
- tmp = SwapBytesLE(tmp); \
+ tmp = SwapBytesReturnLE(tmp); \
fwrite(&tmp , 1 , fsize , file); \
} \
/**/
@@ -211,7 +211,7 @@
fwrite(& fcode , 1 , sizeof( uint32 ) , file);\
fwrite(& fsize , 1 , sizeof( int16 ) , file);\
type tmp = (type)(input-> name ); \
- tmp = SwapBytesLE(tmp); \
+ tmp = SwapBytesReturnLE(tmp); \
fwrite(&tmp , 1 , fsize , file); \
} else if(only_this_code == fcode)\
{ \
@@ -220,7 +220,7 @@
/* This worked fine on little-endian, on big-endian not so much. Thus support writing size-mismatched fields. */ \
ASSERT(fixedsize >= fsize); \
type tmp = (type)(input-> name ); \
- tmp = SwapBytesLE(tmp); \
+ tmp = SwapBytesReturnLE(tmp); \
fwrite(&tmp , 1 , fsize , file); \
if(fixedsize > fsize) \
{ \
@@ -256,7 +256,7 @@
{ \
type tmp; \
tmp = input-> name [i]; \
- tmp = SwapBytesLE(tmp); \
+ tmp = SwapBytesReturnLE(tmp); \
fwrite(&tmp, 1, sizeof(type), file); \
} \
} \
@@ -310,7 +310,7 @@
fwrite(&fcode, 1, sizeof(int32), file);
fwrite(&fsize, 1, sizeof(int16), file);
}
- dwFlags = SwapBytesLE(dwFlags);
+ dwFlags = SwapBytesReturnLE(dwFlags);
fwrite(&dwFlags, 1, fsize, file);
}
Modified: trunk/OpenMPT/soundlib/WAVTools.h
===================================================================
--- trunk/OpenMPT/soundlib/WAVTools.h 2013-09-29 22:12:56 UTC (rev 2814)
+++ trunk/OpenMPT/soundlib/WAVTools.h 2013-09-29 23:46:24 UTC (rev 2815)
@@ -86,14 +86,12 @@
size_t GetLength() const
{
- uint32 l = length;
- return SwapBytesLE(l);
+ return SwapBytesReturnLE(length);
}
id_type GetID() const
{
- uint32 i = id;
- return static_cast<id_type>(SwapBytesLE(i));
+ return static_cast<id_type>(SwapBytesReturnLE(id));
}
// Convert all multi-byte numeric values to current platform's endianness or vice versa.
Modified: trunk/OpenMPT/soundlib/load_j2b.cpp
===================================================================
--- trunk/OpenMPT/soundlib/load_j2b.cpp 2013-09-29 22:12:56 UTC (rev 2814)
+++ trunk/OpenMPT/soundlib/load_j2b.cpp 2013-09-29 23:46:24 UTC (rev 2815)
@@ -97,14 +97,12 @@
size_t GetLength() const
{
- uint32 l = length;
- return SwapBytesLE(l);
+ return SwapBytesReturnLE(length);
}
id_type GetID() const
{
- uint32 i = id;
- return static_cast<id_type>(SwapBytesLE(i));
+ return static_cast<id_type>(SwapBytesReturnLE(id));
}
// Convert all multi-byte numeric values to current platform's endianness or vice versa.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-10-22 05:58:54
|
Revision: 2975
http://sourceforge.net/p/modplug/code/2975
Author: manxorist
Date: 2013-10-22 05:58:46 +0000 (Tue, 22 Oct 2013)
Log Message:
-----------
[Ref] Like ReadVector, make ReadArray only accept arrays of single-byte type to make it harder to forget converting endiannesss on the read data.
[Ref] Some small related changes.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/FileReader.h
trunk/OpenMPT/soundlib/Load_dsm.cpp
trunk/OpenMPT/soundlib/Load_stm.cpp
Modified: trunk/OpenMPT/soundlib/FileReader.h
===================================================================
--- trunk/OpenMPT/soundlib/FileReader.h 2013-10-21 19:53:42 UTC (rev 2974)
+++ trunk/OpenMPT/soundlib/FileReader.h 2013-10-22 05:58:46 UTC (rev 2975)
@@ -869,7 +869,7 @@
template<typename T, off_t destSize>
bool ReadArray(T (&destArray)[destSize])
{
- //STATIC_ASSERT(sizeof(T) == 1);
+ STATIC_ASSERT(sizeof(T) == 1);
if(CanRead(sizeof(destArray)))
{
for(std::size_t i = 0; i < destSize; ++i)
Modified: trunk/OpenMPT/soundlib/Load_dsm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_dsm.cpp 2013-10-21 19:53:42 UTC (rev 2974)
+++ trunk/OpenMPT/soundlib/Load_dsm.cpp 2013-10-22 05:58:46 UTC (rev 2975)
@@ -129,14 +129,20 @@
{
file.Rewind();
- char fileMagic[3][4];
- file.ReadArray(fileMagic);
- if(!memcmp(fileMagic[0], "RIFF", 4)
- && !memcmp(fileMagic[2], "DSMF", 4))
+ char fileMagic0[4];
+ char fileMagic1[4];
+ char fileMagic2[4];
+
+ if(!file.ReadArray(fileMagic0)) return false;
+ if(!file.ReadArray(fileMagic1)) return false;
+ if(!file.ReadArray(fileMagic2)) return false;
+
+ if(!memcmp(fileMagic0, "RIFF", 4)
+ && !memcmp(fileMagic2, "DSMF", 4))
{
// "Normal" DSM files with RIFF header
// <RIFF> <file size> <DSMF>
- } else if(!memcmp(fileMagic[0], "DSMF", 4))
+ } else if(!memcmp(fileMagic0, "DSMF", 4))
{
// DSM files with alternative header
// <DSMF> <4 bytes, usually 4x NUL or RIFF> <file size> <4 bytes, usually DSMF but not always>
Modified: trunk/OpenMPT/soundlib/Load_stm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_stm.cpp 2013-10-21 19:53:42 UTC (rev 2974)
+++ trunk/OpenMPT/soundlib/Load_stm.cpp 2013-10-22 05:58:46 UTC (rev 2975)
@@ -109,6 +109,18 @@
STATIC_ASSERT(sizeof(STMPatternEntry) == 4);
+struct PACKED STMPatternData
+{
+ STMPatternEntry entry[64 * 4];
+ void ConvertEndianness()
+ {
+ // nothing
+ }
+};
+
+STATIC_ASSERT(sizeof(STMPatternData) == 4*64*4);
+
+
#ifdef NEEDS_PRAGMA_PACK
#pragma pack(pop)
#endif
@@ -179,9 +191,9 @@
for(PATTERNINDEX pat = 0; pat < fileHeader.numPatterns; pat++)
{
- STMPatternEntry patternData[64 * 4];
+ STMPatternData patternData;
- if(!(loadFlags & loadPatternData) || Patterns.Insert(pat, 64) || !file.ReadArray(patternData))
+ if(!(loadFlags & loadPatternData) || Patterns.Insert(pat, 64) || !file.ReadConvertEndianness(patternData))
{
file.Skip(sizeof(patternData));
continue;
@@ -193,7 +205,7 @@
for(size_t n = 0; n < 64 * 4; n++, m++)
{
- const STMPatternEntry &entry = patternData[n];
+ const STMPatternEntry &entry = patternData.entry[n];
if(entry.note == 0xFE || entry.note == 0xFC)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|