|
From: <sag...@us...> - 2014-02-26 15:49:49
|
Revision: 3775
http://sourceforge.net/p/modplug/code/3775
Author: saga-games
Date: 2014-02-26 15:49:41 +0000 (Wed, 26 Feb 2014)
Log Message:
-----------
[Mod] Disable ACM and portaudio debug logging by default, since it can slow down the application quite a bit (which slows down testing quite a bit for me). They can be re-enabled by choosing the proper ACMLOG and PALOG defines.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp
trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp
Modified: trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp
===================================================================
--- trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp 2014-02-25 18:00:00 UTC (rev 3774)
+++ trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp 2014-02-26 15:49:41 UTC (rev 3775)
@@ -28,6 +28,10 @@
#include <cstdlib>
+// For ACM debugging purposes
+#define ACMLOG(x, ...)
+//#define ACMLOG Log
+
#ifdef MPT_MP3ENCODER_LAME
//#define MPT_USE_LAME_H
#ifdef MPT_USE_LAME_H
@@ -917,27 +921,27 @@
}
BOOL AcmFormatEnumCB(HACMDRIVERID driver, LPACMFORMATDETAILS pafd, DWORD fdwSupport)
{
- Log("ACM format found:");
- Log(mpt::String::Print(" fdwSupport = 0x%1", mpt::fmt::hex0<8>(fdwSupport)));
+ ACMLOG("ACM format found:");
+ ACMLOG(mpt::String::Print(" fdwSupport = 0x%1", mpt::fmt::hex0<8>(fdwSupport)));
if(pafd)
{
- Log(" ACMFORMATDETAILS:");
- Log(mpt::String::Print(" cbStruct = %1", pafd->cbStruct));
- Log(mpt::String::Print(" dwFormatIndex = %1", pafd->dwFormatIndex));
- Log(mpt::String::Print(" dwFormatTag = %1", pafd->dwFormatTag));
- Log(mpt::String::Print(" fdwSupport = 0x%1", mpt::fmt::hex0<8>(pafd->fdwSupport)));
+ ACMLOG(" ACMFORMATDETAILS:");
+ ACMLOG(mpt::String::Print(" cbStruct = %1", pafd->cbStruct));
+ ACMLOG(mpt::String::Print(" dwFormatIndex = %1", pafd->dwFormatIndex));
+ ACMLOG(mpt::String::Print(" dwFormatTag = %1", pafd->dwFormatTag));
+ ACMLOG(mpt::String::Print(" fdwSupport = 0x%1", mpt::fmt::hex0<8>(pafd->fdwSupport)));
std::string str;
mpt::String::Read<mpt::String::maybeNullTerminated>(str, pafd->szFormat);
- Log(mpt::String::Print(" Format = %1", str));
+ ACMLOG(mpt::String::Print(" Format = %1", str));
} else
{
- Log(" ACMFORMATDETAILS = NULL");
+ ACMLOG(" ACMFORMATDETAILS = NULL");
}
if(pafd && pafd->pwfx && (fdwSupport & ACMDRIVERDETAILS_SUPPORTF_CODEC) && (pafd->dwFormatTag == WAVE_FORMAT_MPEGLAYER3))
{
- Log(" MP3 format found!");
+ ACMLOG(" MP3 format found!");
ACMDRIVERDETAILS add;
MemsetZero(add);
@@ -946,35 +950,35 @@
{
if(acmDriverDetails(driver, &add, 0) != MMSYSERR_NOERROR)
{
- Log(" acmDriverDetails = ERROR");
+ ACMLOG(" acmDriverDetails = ERROR");
// No driver details? Skip it.
return TRUE;
}
- Log(" ACMDRIVERDETAILS:");
- Log(mpt::String::Print(" cbStruct = %1", add.cbStruct));
- Log(mpt::String::Print(" fccType = 0x%1", mpt::fmt::hex0<4>(add.fccType)));
- Log(mpt::String::Print(" fccComp = 0x%1", mpt::fmt::hex0<4>(add.fccComp)));
- Log(mpt::String::Print(" wMid = %1", add.wMid));
- Log(mpt::String::Print(" wPid = %1", add.wPid));
- Log(mpt::String::Print(" vdwACM = 0x%1", mpt::fmt::hex0<8>(add.vdwACM)));
- Log(mpt::String::Print(" vdwDriver = 0x%1", mpt::fmt::hex0<8>(add.vdwDriver)));
- Log(mpt::String::Print(" fdwSupport = %1", mpt::fmt::hex0<8>(add.fdwSupport)));
- Log(mpt::String::Print(" cFormatTags = %1", add.cFormatTags));
- Log(mpt::String::Print(" cFilterTags = %1", add.cFilterTags));
+ ACMLOG(" ACMDRIVERDETAILS:");
+ ACMLOG(mpt::String::Print(" cbStruct = %1", add.cbStruct));
+ ACMLOG(mpt::String::Print(" fccType = 0x%1", mpt::fmt::hex0<4>(add.fccType)));
+ ACMLOG(mpt::String::Print(" fccComp = 0x%1", mpt::fmt::hex0<4>(add.fccComp)));
+ ACMLOG(mpt::String::Print(" wMid = %1", add.wMid));
+ ACMLOG(mpt::String::Print(" wPid = %1", add.wPid));
+ ACMLOG(mpt::String::Print(" vdwACM = 0x%1", mpt::fmt::hex0<8>(add.vdwACM)));
+ ACMLOG(mpt::String::Print(" vdwDriver = 0x%1", mpt::fmt::hex0<8>(add.vdwDriver)));
+ ACMLOG(mpt::String::Print(" fdwSupport = %1", mpt::fmt::hex0<8>(add.fdwSupport)));
+ ACMLOG(mpt::String::Print(" cFormatTags = %1", add.cFormatTags));
+ ACMLOG(mpt::String::Print(" cFilterTags = %1", add.cFilterTags));
std::string str;
mpt::String::Read<mpt::String::maybeNullTerminated>(str, add.szShortName);
- Log(mpt::String::Print(" ShortName = %1", str));
+ ACMLOG(mpt::String::Print(" ShortName = %1", str));
mpt::String::Read<mpt::String::maybeNullTerminated>(str, add.szLongName);
- Log(mpt::String::Print(" LongName = %1", str));
+ ACMLOG(mpt::String::Print(" LongName = %1", str));
mpt::String::Read<mpt::String::maybeNullTerminated>(str, add.szCopyright);
- Log(mpt::String::Print(" Copyright = %1", str));
+ ACMLOG(mpt::String::Print(" Copyright = %1", str));
mpt::String::Read<mpt::String::maybeNullTerminated>(str, add.szLicensing);
- Log(mpt::String::Print(" Licensing = %1", str));
+ ACMLOG(mpt::String::Print(" Licensing = %1", str));
mpt::String::Read<mpt::String::maybeNullTerminated>(str, add.szFeatures);
- Log(mpt::String::Print(" Features = %1", str));
+ ACMLOG(mpt::String::Print(" Features = %1", str));
} catch(...)
{
- Log(" acmDriverDetails = EXCEPTION");
+ ACMLOG(" acmDriverDetails = EXCEPTION");
// Driver crashed? Skip it.
return TRUE;
}
Modified: trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2014-02-25 18:00:00 UTC (rev 3774)
+++ trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2014-02-26 15:49:41 UTC (rev 3775)
@@ -26,6 +26,8 @@
#ifndef NO_PORTAUDIO
+#define PALOG(x, ...)
+//#define PALOG Log
#include "../include/portaudio/src/common/pa_debugprint.h"
@@ -402,9 +404,9 @@
result.name = mpt::ToWide(mpt::CharsetUTF8, Pa_GetDeviceInfo(dev)->name);
result.apiName = HostApiToString(Pa_GetDeviceInfo(dev)->hostApi);
result.isDefault = (Pa_GetHostApiInfo(Pa_GetDeviceInfo(dev)->hostApi)->defaultOutputDevice == (PaDeviceIndex)dev);
- Log(mpt::String::Print("PortAudio: %1, %2, %3, %4", result.id.GetIdRaw(), mpt::ToLocale(result.name), mpt::ToLocale(result.apiName), result.isDefault));
- Log(mpt::String::Print(" low : %1", Pa_GetDeviceInfo(dev)->defaultLowOutputLatency));
- Log(mpt::String::Print(" high : %1", Pa_GetDeviceInfo(dev)->defaultHighOutputLatency));
+ PALOG(mpt::String::Print("PortAudio: %1, %2, %3, %4", result.id.GetIdRaw(), mpt::ToLocale(result.name), mpt::ToLocale(result.apiName), result.isDefault));
+ PALOG(mpt::String::Print(" low : %1", Pa_GetDeviceInfo(dev)->defaultLowOutputLatency));
+ PALOG(mpt::String::Print(" high : %1", Pa_GetDeviceInfo(dev)->defaultHighOutputLatency));
return true;
}
@@ -433,10 +435,12 @@
static bool g_PortaudioInitialized = false;
-static void PortaudioLog(const char *text) {
+static void PortaudioLog(const char *text)
+//----------------------------------------
+{
if(text)
{
- Log("PortAudio: %s", text);
+ PALOG("PortAudio: %s", text);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2014-02-26 20:29:16
|
Revision: 3779
http://sourceforge.net/p/modplug/code/3779
Author: manxorist
Date: 2014-02-26 20:29:10 +0000 (Wed, 26 Feb 2014)
Log Message:
-----------
[New] build: Add experimental support for building libopenmpt with emscripten.
Modified Paths:
--------------
trunk/OpenMPT/Makefile
trunk/OpenMPT/libopenmpt/libopenmpt_config.h
Added Paths:
-----------
trunk/OpenMPT/build/make/Makefile.config.emscripten
trunk/OpenMPT/build/make/test-pre.js
Modified: trunk/OpenMPT/Makefile
===================================================================
--- trunk/OpenMPT/Makefile 2014-02-26 19:07:20 UTC (rev 3778)
+++ trunk/OpenMPT/Makefile 2014-02-26 20:29:10 UTC (rev 3779)
@@ -216,7 +216,7 @@
CXXFLAGS += -fvisibility=hidden
CFLAGS += -fvisibility=hidden
LDFLAGS +=
-LDLIBS += -lm
+LDLIBS +=
ARFLAGS +=
ifeq ($(DEBUG),1)
@@ -537,11 +537,11 @@
.PHONY: test
test: bin/libopenmpt_test$(EXESUFFIX)
- bin/libopenmpt_test$(EXESUFFIX)
+ $(RUNPREFIX) bin/libopenmpt_test$(EXESUFFIX)
bin/libopenmpt_test$(EXESUFFIX): $(LIBOPENMPTTEST_OBJECTS)
$(INFO) [LD-TEST] $@
- $(SILENT)$(LINK.cc) $(LDFLAGS_RPATH) $(LIBOPENMPTTEST_OBJECTS) $(LOADLIBES) $(LDLIBS) -o $@
+ $(SILENT)$(LINK.cc) $(LDFLAGS_RPATH) $(TEST_LDFLAGS) $(LIBOPENMPTTEST_OBJECTS) $(LOADLIBES) $(LDLIBS) -o $@
bin/libopenmpt.pc:
$(INFO) [GEN] $@
Added: trunk/OpenMPT/build/make/Makefile.config.emscripten
===================================================================
--- trunk/OpenMPT/build/make/Makefile.config.emscripten (rev 0)
+++ trunk/OpenMPT/build/make/Makefile.config.emscripten 2014-02-26 20:29:10 UTC (rev 3779)
@@ -0,0 +1,34 @@
+
+CC = emcc
+CXX = em++
+LD = em++
+AR = emar
+
+CPPFLAGS += -DMPT_EMSCRIPTEN -DMPT_CHARSET_CPP -DMPT_CHARSET_ASSUME_UTF8_LOCALE
+CXXFLAGS += -std=c++0x -fPIC
+CFLAGS += -std=c99 -fPIC
+LDFLAGS += -O2 -s DISABLE_EXCEPTION_CATCHING=0
+LDLIBS +=
+ARFLAGS := rcs
+
+CXXFLAGS_WARNINGS += -Wmissing-prototypes
+CFLAGS_WARNINGS += -Wmissing-prototypes
+
+EXESUFFIX=.js
+SOSUFFIX=.js
+RUNPREFIX=nodejs
+TEST_LDFLAGS= --pre-js build/make/test-pre.js
+
+DYNLINK=0
+SHARED_LIB=1
+STATIC_LIB=0
+EXAMPLES=1
+OPENMPT123=0
+SHARED_SONAME=0
+
+NO_ZLIB=1
+NO_PORTAUDIO=1
+NO_SDL=1
+NO_FLAC=1
+NO_WAVPACK=1
+NO_SNDFILE=1
Added: trunk/OpenMPT/build/make/test-pre.js
===================================================================
--- trunk/OpenMPT/build/make/test-pre.js (rev 0)
+++ trunk/OpenMPT/build/make/test-pre.js 2014-02-26 20:29:10 UTC (rev 3779)
@@ -0,0 +1,7 @@
+
+var Module = {
+ 'preInit': function(text) {
+ FS.mkdir('/test');
+ FS.mount(NODEFS, {'root': './test/'}, '/test');
+ }
+};
Modified: trunk/OpenMPT/libopenmpt/libopenmpt_config.h
===================================================================
--- trunk/OpenMPT/libopenmpt/libopenmpt_config.h 2014-02-26 19:07:20 UTC (rev 3778)
+++ trunk/OpenMPT/libopenmpt/libopenmpt_config.h 2014-02-26 20:29:10 UTC (rev 3779)
@@ -38,6 +38,7 @@
#elif defined(__GNUC__) || defined(__clang__)
+#if !defined(MPT_EMSCRIPTEN)
#if defined(_WIN32)
#define LIBOPENMPT_API_HELPER_EXPORT __declspec(dllexport)
#define LIBOPENMPT_API_HELPER_IMPORT __declspec(dllimport)
@@ -47,6 +48,10 @@
#endif
#define LIBOPENMPT_API_HELPER_PUBLIC __attribute__((visibility("default")))
#define LIBOPENMPT_API_HELPER_LOCAL __attribute__((visibility("hidden")))
+#else
+#define LIBOPENMPT_API_HELPER_PUBLIC __attribute__((visibility("default"))) __attribute__((used))
+#define LIBOPENMPT_API_HELPER_LOCAL __attribute__((visibility("hidden")))
+#endif
#else
@@ -66,7 +71,9 @@
#endif
#ifdef __cplusplus
+
#define LIBOPENMPT_CXX_API LIBOPENMPT_API
+
#if defined(LIBOPENMPT_USE_DLL)
#if defined(_MSC_VER) && !defined(_DLL)
#error "C++ interface is disabled if libopenmpt is built as a DLL and the runtime is statically linked. This is not supported by microsoft and cannot possibly work. Ever."
@@ -74,8 +81,15 @@
#define LIBOPENMPT_CXX_API LIBOPENMPT_API_HELPER_LOCAL
#endif
#endif
+
+#if defined(MPT_EMSCRIPTEN)
+/* Only the C API is supported for emscripten. Disable the C++ API. */
+#undef LIBOPENMPT_CXX_API
+#define LIBOPENMPT_CXX_API LIBOPENMPT_API_HELPER_LOCAL
#endif
+#endif
+
/*!
@}
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2014-02-27 11:46:13
|
Revision: 3783
http://sourceforge.net/p/modplug/code/3783
Author: manxorist
Date: 2014-02-27 11:45:57 +0000 (Thu, 27 Feb 2014)
Log Message:
-----------
[Fix] MAKE_VERSION_NUMERIC should return an unsigned value.
[Ref] Make test suite less bloated by using noinline templates instead of macros. This speeds up compilation.
[Ref] Silence some resulting signed/unsigned comparison warnings.
Modified Paths:
--------------
trunk/OpenMPT/common/version.h
trunk/OpenMPT/test/test.cpp
Modified: trunk/OpenMPT/common/version.h
===================================================================
--- trunk/OpenMPT/common/version.h 2014-02-27 11:34:21 UTC (rev 3782)
+++ trunk/OpenMPT/common/version.h 2014-02-27 11:45:57 UTC (rev 3783)
@@ -17,7 +17,7 @@
//For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of
//version 1.17.02.28.
#define MAKE_VERSION_NUMERIC_HELPER(prefix,v0,v1,v2,v3) ((prefix##v0 << 24) | (prefix##v1<<16) | (prefix##v2<<8) | (prefix##v3))
-#define MAKE_VERSION_NUMERIC(v0,v1,v2,v3) MAKE_VERSION_NUMERIC_HELPER(0x,v0,v1,v2,v3)
+#define MAKE_VERSION_NUMERIC(v0,v1,v2,v3) (MptVersion::VersionNum(MAKE_VERSION_NUMERIC_HELPER(0x,v0,v1,v2,v3)))
namespace MptVersion
Modified: trunk/OpenMPT/test/test.cpp
===================================================================
--- trunk/OpenMPT/test/test.cpp 2014-02-27 11:34:21 UTC (rev 3782)
+++ trunk/OpenMPT/test/test.cpp 2014-02-27 11:45:57 UTC (rev 3783)
@@ -262,54 +262,62 @@
#endif // MODPLUG_TRACKER
+template <typename Tx, typename Ty>
+noinline void VerifyEqualImpl(const Tx &x, const Ty &y, const char *const description)
+{
+ TEST_TRY
+ TEST_START();
+ if(x != y)
+ {
+ TEST_FAIL();
+ } else
+ {
+ TEST_OK();
+ }
+ TEST_CATCH
+}
+
+template <typename Tx, typename Ty>
+noinline void VerifyEqualNonContImpl(const Tx &x, const Ty &y, const char *const description)
+{
+ TEST_TRY
+ TEST_START();
+ if(x != y)
+ {
+ TEST_FAIL_STOP();
+ } else
+ {
+ TEST_OK();
+ }
+ TEST_CATCH
+}
+
+
+template <typename Tx, typename Ty>
+noinline void VerifyEqualQuietNonContImpl(const Tx &x, const Ty &y, const char *const description)
+{
+ TEST_TRY
+ if(x != y)
+ {
+ TEST_FAIL_STOP();
+ }
+ TEST_CATCH
+}
+
+
//Verify that given parameters are 'equal'(show error message if not).
//The exact meaning of equality is not specified; for now using operator!=.
//The macro is active in both 'debug' and 'release' build.
-#define VERIFY_EQUAL(x,y) \
-do{ \
- const char * const description = #x " == " #y ; \
- TEST_TRY \
- TEST_START(); \
- if((x) != (y)) \
- { \
- TEST_FAIL(); \
- } else \
- { \
- TEST_OK(); \
- } \
- TEST_CATCH \
-}while(0)
+#define VERIFY_EQUAL(x,y) VerifyEqualImpl( (x) , (y) , #x " == " #y )
// Like VERIFY_EQUAL, but throws exception if comparison fails.
-#define VERIFY_EQUAL_NONCONT(x,y) \
-do{ \
- const char * const description = #x " == " #y ; \
- TEST_TRY \
- TEST_START(); \
- if((x) != (y)) \
- { \
- TEST_FAIL_STOP(); \
- } else \
- { \
- TEST_OK(); \
- } \
- TEST_CATCH \
-}while(0)
+#define VERIFY_EQUAL_NONCONT(x,y) VerifyEqualNonContImpl( (x) , (y) , #x " == " #y )
// Like VERIFY_EQUAL_NONCONT, but do not show message if test succeeds
-#define VERIFY_EQUAL_QUIET_NONCONT(x,y) \
-do{ \
- const char * const description = #x " == " #y ; \
- TEST_TRY \
- if((x) != (y)) \
- { \
- TEST_FAIL_STOP(); \
- } \
- TEST_CATCH \
-}while(0)
+#define VERIFY_EQUAL_QUIET_NONCONT(x,y) VerifyEqualQuietNonContImpl( (x) , (y) , #x " == " #y )
#define DO_TEST(func) \
@@ -325,16 +333,16 @@
-void TestVersion();
-void TestTypes();
-void TestMisc();
-void TestSettings();
-void TestStringIO();
-void TestMIDIEvents();
-void TestSampleConversion();
-void TestITCompression();
-void TestPCnoteSerialization();
-void TestLoadSaveFile();
+static noinline void TestVersion();
+static noinline void TestTypes();
+static noinline void TestMisc();
+static noinline void TestSettings();
+static noinline void TestStringIO();
+static noinline void TestMIDIEvents();
+static noinline void TestSampleConversion();
+static noinline void TestITCompression();
+static noinline void TestPCnoteSerialization();
+static noinline void TestLoadSaveFile();
@@ -359,18 +367,18 @@
// Test if functions related to program version data work
-void TestVersion()
-//----------------
+static noinline void TestVersion()
+//--------------------------------
{
//Verify that macros and functions work.
{
VERIFY_EQUAL( MptVersion::ToNum(MptVersion::ToStr(MptVersion::num)), MptVersion::num );
VERIFY_EQUAL( MptVersion::ToStr(MptVersion::ToNum(MptVersion::str)), MptVersion::str );
VERIFY_EQUAL( MptVersion::ToStr(18285096), "1.17.02.28" );
- VERIFY_EQUAL( MptVersion::ToNum("1.17.02.28"), 18285096 );
- VERIFY_EQUAL( MptVersion::ToNum("1.fe.02.28"), 0x01fe0228 );
- VERIFY_EQUAL( MptVersion::ToNum("01.fe.02.28"), 0x01fe0228 );
- VERIFY_EQUAL( MptVersion::ToNum("1.22"), 0x01220000 );
+ VERIFY_EQUAL( MptVersion::ToNum("1.17.02.28"), MptVersion::VersionNum(18285096) );
+ VERIFY_EQUAL( MptVersion::ToNum("1.fe.02.28"), MptVersion::VersionNum(0x01fe0228) );
+ VERIFY_EQUAL( MptVersion::ToNum("01.fe.02.28"), MptVersion::VersionNum(0x01fe0228) );
+ VERIFY_EQUAL( MptVersion::ToNum("1.22"), MptVersion::VersionNum(0x01220000) );
VERIFY_EQUAL( MptVersion::ToNum(MptVersion::str), MptVersion::num );
VERIFY_EQUAL( MptVersion::ToStr(MptVersion::num), MptVersion::str );
VERIFY_EQUAL( MptVersion::RemoveBuildNumber(MAKE_VERSION_NUMERIC(1,19,02,00)), MAKE_VERSION_NUMERIC(1,19,02,00));
@@ -439,8 +447,8 @@
// Test if data types are interpreted correctly
-void TestTypes()
-//--------------
+static noinline void TestTypes()
+//------------------------------
{
VERIFY_EQUAL(int8_min, (std::numeric_limits<int8>::min)());
VERIFY_EQUAL(int8_max, (std::numeric_limits<int8>::max)());
@@ -536,8 +544,8 @@
}
-void TestMisc()
-//-------------
+static noinline void TestMisc()
+//-----------------------------
{
VERIFY_EQUAL(0x3f800000u, AsInt(1.0f));
@@ -580,7 +588,7 @@
VERIFY_EQUAL(Stringify(58.65403492763), "58.654");
VERIFY_EQUAL(mpt::Format("%3.1f").ToString(23.42), "23.4");
- VERIFY_EQUAL(ConvertStrTo<uint32>("586"), 586);
+ VERIFY_EQUAL(ConvertStrTo<uint32>("586"), 586u);
VERIFY_EQUAL(ConvertStrTo<uint32>("2147483647"), (uint32)int32_max);
VERIFY_EQUAL(ConvertStrTo<uint32>("4294967295"), uint32_max);
@@ -588,7 +596,7 @@
VERIFY_EQUAL(ConvertStrTo<int64>("-159"), -159);
VERIFY_EQUAL(ConvertStrTo<int64>("9223372036854775807"), int64_max);
- VERIFY_EQUAL(ConvertStrTo<uint64>("85059"), 85059);
+ VERIFY_EQUAL(ConvertStrTo<uint64>("85059"), 85059u);
VERIFY_EQUAL(ConvertStrTo<uint64>("9223372036854775807"), (uint64)int64_max);
VERIFY_EQUAL(ConvertStrTo<uint64>("18446744073709551615"), uint64_max);
@@ -696,7 +704,7 @@
VERIFY_EQUAL( mpt::String::Trim(" "), "" );
// weird things with std::string containing \0 in the middle and trimming \0
- VERIFY_EQUAL( std::string("\0\ta\0b ",6).length(), 6 );
+ VERIFY_EQUAL( std::string("\0\ta\0b ",6).length(), (std::size_t)6 );
VERIFY_EQUAL( mpt::String::RTrim(std::string("\0\ta\0b ",6)), std::string("\0\ta\0b",5) );
VERIFY_EQUAL( mpt::String::Trim(std::string("\0\ta\0b\0",6),std::string("\0",1)), std::string("\ta\0b",4) );
@@ -711,8 +719,8 @@
// Check for completeness of supported effect list in mod specifications
for(size_t i = 0; i < CountOf(ModSpecs::Collection); i++)
{
- VERIFY_EQUAL(strlen(ModSpecs::Collection[i]->commands), MAX_EFFECTS);
- VERIFY_EQUAL(strlen(ModSpecs::Collection[i]->volcommands), MAX_VOLCMDS);
+ VERIFY_EQUAL(strlen(ModSpecs::Collection[i]->commands), (size_t)MAX_EFFECTS);
+ VERIFY_EQUAL(strlen(ModSpecs::Collection[i]->volcommands), (size_t)MAX_VOLCMDS);
}
// Charset conversions (basic sanity checks)
@@ -842,8 +850,8 @@
#endif // MODPLUG_TRACKER
-void TestSettings()
-//-----------------
+static noinline void TestSettings()
+//---------------------------------
{
#ifdef MODPLUG_TRACKER
@@ -922,8 +930,8 @@
// Test MIDI Event generating / reading
-void TestMIDIEvents()
-//-------------------
+static noinline void TestMIDIEvents()
+//-----------------------------------
{
uint32 midiEvent;
@@ -1058,7 +1066,7 @@
VERIFY_EQUAL_NONCONT(pIns->nPPC, NOTE_MIDDLEC - 1);
VERIFY_EQUAL_NONCONT(pIns->nVolRampUp, 1200);
- VERIFY_EQUAL_NONCONT(pIns->nResampling, SRCMODE_POLYPHASE);
+ VERIFY_EQUAL_NONCONT(pIns->nResampling, (unsigned)SRCMODE_POLYPHASE);
VERIFY_EQUAL_NONCONT(pIns->IsCutoffEnabled(), false);
VERIFY_EQUAL_NONCONT(pIns->GetCutoff(), 0);
@@ -1292,7 +1300,7 @@
VERIFY_EQUAL_NONCONT(pIns->nPPC, (NOTE_MIDDLEC - NOTE_MIN) + 6); // F#5
VERIFY_EQUAL_NONCONT(pIns->nVolRampUp, 1200);
- VERIFY_EQUAL_NONCONT(pIns->nResampling, SRCMODE_POLYPHASE);
+ VERIFY_EQUAL_NONCONT(pIns->nResampling, (unsigned)SRCMODE_POLYPHASE);
VERIFY_EQUAL_NONCONT(pIns->IsCutoffEnabled(), true);
VERIFY_EQUAL_NONCONT(pIns->GetCutoff(), 0x32);
@@ -1386,6 +1394,7 @@
VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetpModCommand(0, 0)->instr, 99);
VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetpModCommand(0, 0)->GetValueVolCol(), 1);
VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetpModCommand(0, 0)->GetValueEffectCol(), 200);
+
VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetpModCommand(31, 0)->IsEmpty(), true);
VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetpModCommand(31, 1)->IsEmpty(), false);
VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetpModCommand(31, 1)->IsPcNote(), false);
@@ -1684,8 +1693,8 @@
// Test file loading and saving
-void TestLoadSaveFile()
-//---------------------
+static noinline void TestLoadSaveFile()
+//-------------------------------------
{
if(!ShouldRunTests())
{
@@ -1825,8 +1834,8 @@
}
-void TestITCompression()
-//----------------------
+static noinline void TestITCompression()
+//--------------------------------------
{
if(!ShouldRunTests())
{
@@ -1887,8 +1896,8 @@
// Test PC note serialization
-void TestPCnoteSerialization()
-//----------------------------
+static noinline void TestPCnoteSerialization()
+//--------------------------------------------
{
FileReader file;
MPT_SHARED_PTR<CSoundFile> pSndFile(new CSoundFile());
@@ -1954,8 +1963,8 @@
// Test String I/O functionality
-void TestStringIO()
-//-----------------
+static noinline void TestStringIO()
+//---------------------------------
{
char src0[4] = { '\0', 'X', ' ', 'X' }; // Weird empty buffer
char src1[4] = { 'X', ' ', '\0', 'X' }; // Weird buffer (hello Impulse Tracker)
@@ -2193,8 +2202,8 @@
}
-void TestSampleConversion()
-//-------------------------
+static noinline void TestSampleConversion()
+//-----------------------------------------
{
uint8 *sourceBuf = new uint8[65536 * 4];
void *targetBuf = new uint8[65536 * 6];
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-02-27 22:55:13
|
Revision: 3786
http://sourceforge.net/p/modplug/code/3786
Author: saga-games
Date: 2014-02-27 22:55:00 +0000 (Thu, 27 Feb 2014)
Log Message:
-----------
[New] Experimental feature: Seeking in a module tries to keep sample sync. This only works under some basic conditions, e.g. samples with ping-pong loops or portamento effects are not supported. Can be enabled from the general options.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/Ctrl_seq.cpp
trunk/OpenMPT/mptrack/Moddoc.cpp
trunk/OpenMPT/mptrack/Moptions.cpp
trunk/OpenMPT/mptrack/TrackerSettings.h
trunk/OpenMPT/mptrack/View_pat.cpp
trunk/OpenMPT/soundlib/ModChannel.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/mptrack/Ctrl_seq.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2014-02-27 22:39:08 UTC (rev 3785)
+++ trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2014-02-27 22:55:00 UTC (rev 3786)
@@ -326,26 +326,26 @@
if(isPlaying && sndFile.m_SongFlags[SONG_PATTERNLOOP])
{
- // update channel parameters and play time
- m_pModDoc.SetElapsedTime(m_nScrollPos, 0);
-
sndFile.m_nPattern = n;
sndFile.m_nCurrentOrder = sndFile.m_nNextOrder = m_nScrollPos;
pMainFrm->ResetNotificationBuffer();
sndFile.m_nNextRow = 0;
+ // update channel parameters and play time
+ m_pModDoc.SetElapsedTime(m_nScrollPos, 0);
+
changedPos = true;
} else if(m_pParent.GetFollowSong())
{
SongFlags pausedFlags = sndFile.m_SongFlags & (SONG_PAUSED | SONG_STEP | SONG_PATTERNLOOP);
- // update channel parameters and play time
- m_pModDoc.SetElapsedTime(m_nScrollPos, 0);
-
sndFile.m_nCurrentOrder = m_nScrollPos;
sndFile.SetCurrentOrder(m_nScrollPos);
sndFile.m_SongFlags.set(pausedFlags);
+ // update channel parameters and play time
+ m_pModDoc.SetElapsedTime(m_nScrollPos, 0);
+
if(isPlaying) pMainFrm->ResetNotificationBuffer();
changedPos = true;
}
Modified: trunk/OpenMPT/mptrack/Moddoc.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Moddoc.cpp 2014-02-27 22:39:08 UTC (rev 3785)
+++ trunk/OpenMPT/mptrack/Moddoc.cpp 2014-02-27 22:55:00 UTC (rev 3786)
@@ -1282,7 +1282,7 @@
if ((nPlug) && (nPlug<=MAX_MIXPLUGINS))
{
CVstPlugin *pPlug = (CVstPlugin*)m_SndFile.m_MixPlugins[nPlug - 1].pMixPlugin;
- ModInstrument* pIns = m_SndFile.Chn[nChn].pModInstrument;
+ const ModInstrument* pIns = m_SndFile.Chn[nChn].pModInstrument;
if (pPlug && pIns)
{
pPlug->MidiCommand(m_SndFile.GetBestMidiChannel(nChn), pIns->nMidiProgram, pIns->wMidiBank, NOTE_KEYOFF, 0, nChn);
@@ -2768,7 +2768,7 @@
void CModDoc::SetElapsedTime(ORDERINDEX nOrd, ROWINDEX nRow)
//----------------------------------------------------------
{
- double t = m_SndFile.GetPlaybackTimeAt(nOrd, nRow, true);
+ double t = m_SndFile.GetPlaybackTimeAt(nOrd, nRow, true, (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_SYNCSAMPLEPOS) != 0);
CMainFrame *pMainFrm = CMainFrame::GetMainFrame();
if(pMainFrm != nullptr)
{
Modified: trunk/OpenMPT/mptrack/Moptions.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Moptions.cpp 2014-02-27 22:39:08 UTC (rev 3785)
+++ trunk/OpenMPT/mptrack/Moptions.cpp 2014-02-27 22:55:00 UTC (rev 3786)
@@ -572,6 +572,7 @@
{PATTERN_MIDIRECORD, "MIDI record", "Enable MIDI in record by default."},
{PATTERN_OLDCTXMENUSTYLE, "Old style pattern context menu", "Check this option to hide unavailable items in the pattern editor context menu. Uncheck to grey-out unavailable items instead."},
{PATTERN_SYNCMUTE, "Maintain sample sync on mute", "Samples continue to be processed when channels are muted (like in IT2 and FT2)"},
+ {PATTERN_SYNCSAMPLEPOS, "Maintain sample sync on seek", "Sample that are still active from previous patterns are continued to be played after seeking.\nNote: Samples with portamento effects applied are not synced. This feature may slow down seeking."},
{PATTERN_AUTODELAY, "Automatic delay commands", "Automatically insert appropriate note-delay commands when recording notes during live playback."},
{PATTERN_NOTEFADE, "Note fade on key up", "Enable to fade / stop notes on key up in pattern tab."},
{PATTERN_OVERFLOWPASTE, "Overflow paste mode", "Wrap pasted pattern data into next pattern. This is useful for creating echo channels."},
Modified: trunk/OpenMPT/mptrack/TrackerSettings.h
===================================================================
--- trunk/OpenMPT/mptrack/TrackerSettings.h 2014-02-27 22:39:08 UTC (rev 3785)
+++ trunk/OpenMPT/mptrack/TrackerSettings.h 2014-02-27 22:55:00 UTC (rev 3786)
@@ -111,6 +111,7 @@
#define PATTERN_SHOWDEFAULTVOLUME 0x10000000 // if there is no volume command next to note+instr, display the sample's default volume.
#define PATTERN_RESETCHANNELS 0x20000000 // reset channels when looping
#define PATTERN_LIVEUPDATETREE 0x40000000 // update active sample / instr icons in treeview
+#define PATTERN_SYNCSAMPLEPOS 0x80000000 // sync sample positions when seeking
// Midi Setup
Modified: trunk/OpenMPT/mptrack/View_pat.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_pat.cpp 2014-02-27 22:39:08 UTC (rev 3785)
+++ trunk/OpenMPT/mptrack/View_pat.cpp 2014-02-27 22:55:00 UTC (rev 3786)
@@ -6545,7 +6545,7 @@
ORDERINDEX currentOrder = GetCurrentOrder();
if(pSndFile->Order[currentOrder] == m_nPattern)
{
- const double t = pSndFile->GetPlaybackTimeAt(currentOrder, GetCurrentRow(), false);
+ const double t = pSndFile->GetPlaybackTimeAt(currentOrder, GetCurrentRow(), false, false);
if(t < 0)
msg.Format("Unable to determine the time. Possible cause: No order %d, row %d found from play sequence.", currentOrder, GetCurrentRow());
else
Modified: trunk/OpenMPT/soundlib/ModChannel.h
===================================================================
--- trunk/OpenMPT/soundlib/ModChannel.h 2014-02-27 22:39:08 UTC (rev 3785)
+++ trunk/OpenMPT/soundlib/ModChannel.h 2014-02-27 22:55:00 UTC (rev 3786)
@@ -59,11 +59,11 @@
uint32 nRampLength;
// Up to here: 100 bytes
- ModSample *pModSample; // Currently assigned sample slot (can already be stopped)
+ const ModSample *pModSample; // Currently assigned sample slot (can already be stopped)
// Information not used in the mixer
- ModInstrument *pModInstrument; // Currently assigned instrument slot
- FlagSet<ChannelFlags> dwOldFlags; // Flags from previous tick
+ const ModInstrument *pModInstrument; // Currently assigned instrument slot
+ FlagSet<ChannelFlags> dwOldFlags; // Flags from previous tick
int32 newLeftVol, newRightVol;
int32 nRealVolume, nRealPan;
int32 nVolume, nPan, nFadeOutVol;
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-02-27 22:39:08 UTC (rev 3785)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-02-27 22:55:00 UTC (rev 3786)
@@ -122,6 +122,15 @@
retval.lastOrder = retval.endOrder = ORDERINDEX_INVALID;
retval.lastRow = retval.endRow = ROWINDEX_INVALID;
+ ModChannel origChannels[CountOf(Chn)];
+ if(adjustMode & eAdjust)
+ {
+ for(CHANNELINDEX i = 0; i < CountOf(Chn); i++)
+ {
+ origChannels[i] = Chn[i];
+ }
+ }
+
// Are we trying to reach a certain pattern position?
const bool hasSearchTarget = target.mode != GetLengthTarget::NoTarget;
@@ -290,7 +299,7 @@
nNextPatStartRow = 0; // FT2 E60 bug
if (nRow < Patterns[nPattern].GetNumRows() - 1)
{
- nextRow = Patterns[nPattern].GetpModCommand(nRow +1, nChn);
+ nextRow = Patterns[nPattern].GetpModCommand(nRow + 1, nChn);
}
if (nextRow && nextRow->command == CMD_XPARAM)
{
@@ -548,10 +557,84 @@
}
const uint32 tickDuration = GetTickDuration(memory.musicTempo, memory.musicSpeed, rowsPerBeat);
- const uint32 rowDuration = tickDuration * (memory.musicSpeed + tickDelay) * MAX(rowDelay, 1);
+ const uint32 numTicks = (memory.musicSpeed + tickDelay) * MAX(rowDelay, 1);
+ const uint32 rowDuration = tickDuration * numTicks;
memory.elapsedTime += static_cast<double>(rowDuration) / static_cast<double>(m_MixerSettings.gdwMixingFreq);
memory.renderedSamples += rowDuration;
+ if((adjustMode & eAdjustSamplePositions) == eAdjustSamplePositions)
+ {
+ // Super experimental and dirty sample seeking
+ pChn = Chn;
+ p = Patterns[nPattern].GetRow(nRow);
+ for(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); p++, pChn++, nChn++)
+ {
+ uint32 startTick = 0;
+ uint32 paramHi = p->param >> 4, paramLo = p->param & 0x0F;
+ if(p->IsNote() && p->instr)
+ {
+ InstrumentChange(pChn, p->instr);
+ NoteChange(nChn, p->note);
+ pChn->nInc = GetChannelIncrement(pChn, pChn->nPeriod, 0);
+
+ if((p->command == CMD_MODCMDEX || p->command == CMD_S3MCMDEX) && (p->param & 0xF0) == 0xD0 && paramLo < numTicks)
+ {
+ startTick = p->param & 0x0F;
+ } else if(p->command == CMD_DELAYCUT && paramHi < numTicks)
+ {
+ startTick = p->param >> 4;
+ } else if(p->command == CMD_OFFSET && p->IsNote())
+ {
+ // TODO: xParam not supported! (Note: xParam doesn't use hiOffset)
+ pChn->nPos = (memory.chnSettings[nChn].hiOffset << 16) + (p->param << 8);
+ } else if(p->volcmd == VOLCMD_OFFSET && p->IsNote())
+ {
+ pChn->nPos = (memory.chnSettings[nChn].hiOffset << 16) + (p->vol << 11);
+ }
+ }
+ if(p->note == NOTE_KEYOFF || p->note == NOTE_NOTECUT || (p->note == NOTE_FADE && GetNumInstruments())
+ || pChn->dwFlags[CHN_PINGPONGFLAG] // Ping-pong loops are not supported for now.
+ || p->command != CMD_NONE && // Sample stop commands.
+ (((p->command == CMD_MODCMDEX || p->command == CMD_S3MCMDEX) && (p->param & 0xF0) == 0xC0 && paramLo < numTicks)
+ || (p->command == CMD_DELAYCUT && (p->command & 0x0F) != 0 && startTick + paramLo < numTicks)
+ || p->command == CMD_TONEPORTAMENTO || p->command == CMD_TONEPORTAVOL || p->command == CMD_PORTAMENTOUP || p->command == CMD_PORTAMENTODOWN)
+ || p->volcmd == VOLCMD_TONEPORTAMENTO || p->volcmd == VOLCMD_PORTAUP || p->volcmd == VOLCMD_PORTADOWN)
+ {
+ // Stop channel.
+ pChn->nPeriod = 0;
+ pChn->nInc = 0;
+ pChn->nPos = pChn->nPosLo = 0;
+ }
+ if(pChn->nInc != 0 && pChn->pModSample)
+ {
+ // Increment playback position of sample and envelopes
+ for(uint32 i = 0; i < (numTicks - startTick); i++)
+ {
+ pChn->nPosLo += pChn->nInc * tickDuration;
+ pChn->nPos += (pChn->nPosLo >> 16);
+ pChn->nPosLo &= 0xFFFF;
+ IncrementEnvelopePositions(pChn);
+ int vol = 0;
+ ProcessInstrumentFade(pChn, vol);
+ }
+ if(pChn->pModSample->uFlags[CHN_SUSTAINLOOP | CHN_LOOP])
+ {
+ // Check if we exceeded the sample loop.
+ while(pChn->nPos >= pChn->nLoopEnd)
+ {
+ pChn->nPos -= (pChn->nLoopEnd - pChn->nLoopStart);
+ }
+ } else if(pChn->nPos >= pChn->nLength)
+ {
+ // Past sample end.
+ pChn->nLeftVU = pChn->nRightVU = 0;
+ pChn->nVolume = 0;
+ pChn->pCurrentSample = nullptr;
+ }
+ }
+ }
+ }
+
if(patternLoopEndedOnThisRow)
{
p = Patterns[nPattern].GetRow(nRow);
@@ -633,6 +716,10 @@
m_nMusicSpeed = m_nDefaultSpeed;
m_nMusicTempo = m_nDefaultTempo;
m_nGlobalVolume = m_nDefaultGlobalVolume;
+ for(CHANNELINDEX i = 0; i < CountOf(Chn); i++)
+ {
+ Chn[i] = origChannels[i];
+ }
}
// When adjusting the playback status, we will also want to update the visited rows vector according to the current position.
visitedSongRows.Set(visitedRows);
@@ -647,12 +734,12 @@
// Effects
// Change sample or instrument number.
-void CSoundFile::InstrumentChange(ModChannel *pChn, UINT instr, bool bPorta, bool bUpdVol, bool bResetEnv)
-//--------------------------------------------------------------------------------------------------------
+void CSoundFile::InstrumentChange(ModChannel *pChn, UINT instr, bool bPorta, bool bUpdVol, bool bResetEnv) const
+//--------------------------------------------------------------------------------------------------------------
{
if(instr >= MAX_INSTRUMENTS) return;
- ModInstrument *pIns = (instr < MAX_INSTRUMENTS) ? Instruments[instr] : nullptr;
- ModSample *pSmp = &Samples[instr];
+ const ModInstrument *pIns = (instr < MAX_INSTRUMENTS) ? Instruments[instr] : nullptr;
+ const ModSample *pSmp = &Samples[instr];
UINT note = pChn->nNewNote;
if(note == NOTE_NONE && IsCompatibleMode(TRK_IMPULSETRACKER)) return;
@@ -993,9 +1080,9 @@
//-------------------------------------------------------------------------------------------------
{
if (note < NOTE_MIN) return;
- ModChannel * const pChn = &Chn[nChn];
- ModSample *pSmp = pChn->pModSample;
- ModInstrument *pIns = pChn->pModInstrument;
+ ModChannel *pChn = &Chn[nChn];
+ const ModSample *pSmp = pChn->pModSample;
+ const ModInstrument *pIns = pChn->pModInstrument;
const bool newTuning = (GetType() == MOD_TYPE_MPT && pIns != nullptr && pIns->pTuning);
// save the note that's actually used, as it's necessary to properly calculate PPS and stuff
@@ -1358,7 +1445,7 @@
//-------------------------------------------------------------------------------
{
ModChannel *pChn = &Chn[nChn];
- ModInstrument *pIns = nullptr;
+ const ModInstrument *pIns = nullptr;
if(!ModCommand::IsNote(note))
{
return;
@@ -3779,7 +3866,7 @@
if(GetType() != MOD_TYPE_MOD || pChn->nEFxSpeed == 0) return;
// we obviously also need a sample for this
- ModSample *pModSample = pChn->pModSample;
+ ModSample *pModSample = const_cast<ModSample *>(pChn->pModSample);
if(pModSample == nullptr || pModSample->pSample == nullptr || !pModSample->uFlags[CHN_LOOP] || pModSample->uFlags[CHN_16BIT]) return;
pChn->nEFxDelay += ModEFxTable[pChn->nEFxSpeed & 0x0F];
@@ -4187,8 +4274,7 @@
if(m && m->command == CMD_XPARAM) param = (param << 16) + (tmp << 8) + m->param;
else param = (param<<8) + tmp;
- }
- else
+ } else
{
if (param) pChn->nOldOffset = param; else param = pChn->nOldOffset;
param <<= 8;
@@ -4389,8 +4475,8 @@
}
-void CSoundFile::DoFreqSlide(ModChannel *pChn, LONG nFreqSlide)
-//-------------------------------------------------------------
+void CSoundFile::DoFreqSlide(ModChannel *pChn, LONG nFreqSlide) const
+//-------------------------------------------------------------------
{
// IT Linear slides
if (!pChn->nPeriod) return;
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2014-02-27 22:39:08 UTC (rev 3785)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2014-02-27 22:55:00 UTC (rev 3786)
@@ -1075,7 +1075,7 @@
{ //with other modes, we calculate it:
double ticksPerBeat = m_nMusicSpeed * m_nCurrentRowsPerBeat; //ticks/beat = ticks/row * rows/beat
double samplesPerBeat = m_nSamplesPerTick * ticksPerBeat; //samps/beat = samps/tick * ticks/beat
- bpm = m_MixerSettings.gdwMixingFreq/samplesPerBeat * 60; //beats/sec = samps/sec / samps/beat
+ bpm = m_MixerSettings.gdwMixingFreq/samplesPerBeat * 60; //beats/sec = samps/sec / samps/beat
} //beats/min = beats/sec * 60
return bpm;
@@ -1107,7 +1107,7 @@
m_SongFlags.reset(SONG_FADINGSONG | SONG_ENDREACHED);
for (nPattern = 0; nPattern < Order.size(); nPattern++)
{
- UINT ord = Order[nPattern];
+ ORDERINDEX ord = Order[nPattern];
if(ord == Order.GetIgnoreIndex()) continue;
if (ord == Order.GetInvalidPatIndex()) break;
if (ord < Patterns.Size())
@@ -1843,10 +1843,10 @@
}
-double CSoundFile::GetPlaybackTimeAt(ORDERINDEX ord, ROWINDEX row, bool updateVars)
-//---------------------------------------------------------------------------------
+double CSoundFile::GetPlaybackTimeAt(ORDERINDEX ord, ROWINDEX row, bool updateVars, bool updateSamplePos)
+//-------------------------------------------------------------------------------------------------------
{
- const GetLengthType t = GetLength(updateVars ? eAdjust : eNoAdjust, GetLengthTarget(ord, row));
+ const GetLengthType t = GetLength(updateVars ? (updateSamplePos ? eAdjustSamplePositions : eAdjust) : eNoAdjust, GetLengthTarget(ord, row));
if(t.targetReached) return t.duration;
else return -1; //Given position not found from play sequence.
}
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2014-02-27 22:39:08 UTC (rev 3785)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2014-02-27 22:55:00 UTC (rev 3786)
@@ -172,6 +172,8 @@
eAdjust = 0x01,
// Same as above, but global variables will only be memorized if the target could be reached. This does *NOT* influence the visited rows vector - it will *ALWAYS* be adjusted in this mode.
eAdjustOnSuccess = 0x02 | eAdjust,
+ // Same as previous option, but will also try to emulate sample playback so that voices from previous patterns will sound when continuing playback at the target position.
+ eAdjustSamplePositions = 0x04 | eAdjustOnSuccess,
};
@@ -261,7 +263,8 @@
// Returns value in seconds. If given position won't be played at all, returns -1.
// If updateVars is true, the state of various playback variables will be updated according to the playback position.
- double GetPlaybackTimeAt(ORDERINDEX ord, ROWINDEX row, bool updateVars);
+ // If updateSamplePos is also true, the sample positions of samples still playing from previous patterns will be kept in sync.
+ double GetPlaybackTimeAt(ORDERINDEX ord, ROWINDEX row, bool updateVars, bool updateSamplePos);
uint16 GetModFlags() const {return static_cast<uint16>(m_ModFlags);}
void SetModFlags(const uint16 v) {m_ModFlags = static_cast<ModSpecificFlag>(v);}
@@ -705,7 +708,7 @@
CHANNELINDEX GetNNAChannel(CHANNELINDEX nChn) const;
void CheckNNA(CHANNELINDEX nChn, UINT instr, int note, bool forceCut);
void NoteChange(CHANNELINDEX nChn, int note, bool bPorta = false, bool bResetEnv = true, bool bManual = false);
- void InstrumentChange(ModChannel *pChn, UINT instr, bool bPorta = false, bool bUpdVol = true, bool bResetEnv = true);
+ void InstrumentChange(ModChannel *pChn, UINT instr, bool bPorta = false, bool bUpdVol = true, bool bResetEnv = true) const;
// Channel Effects
void KeyOff(CHANNELINDEX nChn);
@@ -717,30 +720,32 @@
// Channel effect processing
int GetVibratoDelta(int type, int position) const;
- void ProcessVolumeSwing(ModChannel *pChn, int &vol);
- void ProcessPanningSwing(ModChannel *pChn);
- void ProcessTremolo(ModChannel *pChn, int &vol);
- void ProcessTremor(ModChannel *pChn, int &vol);
+ void ProcessVolumeSwing(ModChannel *pChn, int &vol) const;
+ void ProcessPanningSwing(ModChannel *pChn) const;
+ void ProcessTremolo(ModChannel *pChn, int &vol) const;
+ void ProcessTremor(ModChannel *pChn, int &vol) const;
bool IsEnvelopeProcessed(const ModChannel *pChn, enmEnvelopeTypes env) const;
- void ProcessVolumeEnvelope(ModChannel *pChn, int &vol);
- void ProcessPanningEnvelope(ModChannel *pChn);
- void ProcessPitchFilterEnvelope(ModChannel *pChn, int &period);
+ void ProcessVolumeEnvelope(ModChannel *pChn, int &vol) const;
+ void ProcessPanningEnvelope(ModChannel *pChn) const;
+ void ProcessPitchFilterEnvelope(ModChannel *pChn, int &period) const;
- void IncrementEnvelopePosition(ModChannel *pChn, enmEnvelopeTypes envType);
- void IncrementEnvelopePositions(ModChannel *pChn);
+ void IncrementEnvelopePosition(ModChannel *pChn, enmEnvelopeTypes envType) const;
+ void IncrementEnvelopePositions(ModChannel *pChn) const;
- void ProcessInstrumentFade(ModChannel *pChn, int &vol);
+ void ProcessInstrumentFade(ModChannel *pChn, int &vol) const;
- void ProcessPitchPanSeparation(ModChannel *pChn);
- void ProcessPanbrello(ModChannel *pChn);
+ void ProcessPitchPanSeparation(ModChannel *pChn) const;
+ void ProcessPanbrello(ModChannel *pChn) const;
void ProcessArpeggio(CHANNELINDEX nChn, int &period, CTuning::NOTEINDEXTYPE &arpeggioSteps);
void ProcessVibrato(CHANNELINDEX nChn, int &period, CTuning::RATIOTYPE &vibratoFactor);
- void ProcessSampleAutoVibrato(ModChannel *pChn, int &period, CTuning::RATIOTYPE &vibratoFactor, int &nPeriodFrac);
+ void ProcessSampleAutoVibrato(ModChannel *pChn, int &period, CTuning::RATIOTYPE &vibratoFactor, int &nPeriodFrac) const;
- void ProcessRamping(ModChannel *pChn);
+ void ProcessRamping(ModChannel *pChn) const;
+ uint32 GetChannelIncrement(ModChannel *pChn, uint32 period, int periodFrac) const;
+
protected:
// Channel Effects
void UpdateS3MEffectMemory(ModChannel *pChn, UINT param) const;
@@ -778,7 +783,7 @@
void SetupChannelFilter(ModChannel *pChn, bool bReset, int flt_modifier = 256) const;
// Low-Level effect processing
- void DoFreqSlide(ModChannel *pChn, LONG nFreqSlide);
+ void DoFreqSlide(ModChannel *pChn, LONG nFreqSlide) const;
void GlobalVolSlide(UINT param, UINT &nOldGlobalVolSlide);
void UpdateTimeSignature();
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2014-02-27 22:39:08 UTC (rev 3785)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2014-02-27 22:55:00 UTC (rev 3786)
@@ -613,8 +613,8 @@
}
-void CSoundFile::ProcessVolumeSwing(ModChannel *pChn, int &vol)
-//-------------------------------------------------------------
+void CSoundFile::ProcessVolumeSwing(ModChannel *pChn, int &vol) const
+//-------------------------------------------------------------------
{
if(IsCompatibleMode(TRK_IMPULSETRACKER))
{
@@ -634,8 +634,8 @@
}
-void CSoundFile::ProcessPanningSwing(ModChannel *pChn)
-//----------------------------------------------------
+void CSoundFile::ProcessPanningSwing(ModChannel *pChn) const
+//----------------------------------------------------------
{
if(IsCompatibleMode(TRK_IMPULSETRACKER) || GetModFlag(MSF_OLDVOLSWING))
{
@@ -651,8 +651,8 @@
}
-void CSoundFile::ProcessTremolo(ModChannel *pChn, int &vol)
-//---------------------------------------------------------
+void CSoundFile::ProcessTremolo(ModChannel *pChn, int &vol) const
+//---------------------------------------------------------------
{
if (pChn->dwFlags[CHN_TREMOLO])
{
@@ -684,8 +684,8 @@
}
-void CSoundFile::ProcessTremor(ModChannel *pChn, int &vol)
-//--------------------------------------------------------
+void CSoundFile::ProcessTremor(ModChannel *pChn, int &vol) const
+//--------------------------------------------------------------
{
if(IsCompatibleMode(TRK_FASTTRACKER2))
{
@@ -786,8 +786,8 @@
}
-void CSoundFile::ProcessVolumeEnvelope(ModChannel *pChn, int &vol)
-//----------------------------------------------------------------
+void CSoundFile::ProcessVolumeEnvelope(ModChannel *pChn, int &vol) const
+//----------------------------------------------------------------------
{
if(IsEnvelopeProcessed(pChn, ENV_VOLUME))
{
@@ -827,8 +827,8 @@
}
-void CSoundFile::ProcessPanningEnvelope(ModChannel *pChn)
-//-------------------------------------------------------
+void CSoundFile::ProcessPanningEnvelope(ModChannel *pChn) const
+//-------------------------------------------------------------
{
if(IsEnvelopeProcessed(pChn, ENV_PANNING))
{
@@ -858,8 +858,8 @@
}
-void CSoundFile::ProcessPitchFilterEnvelope(ModChannel *pChn, int &period)
-//------------------------------------------------------------------------
+void CSoundFile::ProcessPitchFilterEnvelope(ModChannel *pChn, int &period) const
+//------------------------------------------------------------------------------
{
if(IsEnvelopeProcessed(pChn, ENV_PITCH))
{
@@ -920,8 +920,8 @@
}
-void CSoundFile::IncrementEnvelopePosition(ModChannel *pChn, enmEnvelopeTypes envType)
-//------------------------------------------------------------------------------------
+void CSoundFile::IncrementEnvelopePosition(ModChannel *pChn, enmEnvelopeTypes envType) const
+//------------------------------------------------------------------------------------------
{
ModChannel::EnvInfo &chnEnv = pChn->GetEnvelope(envType);
@@ -1038,8 +1038,8 @@
}
-void CSoundFile::IncrementEnvelopePositions(ModChannel *pChn)
-//-----------------------------------------------------------
+void CSoundFile::IncrementEnvelopePositions(ModChannel *pChn) const
+//-----------------------------------------------------------------
{
IncrementEnvelopePosition(pChn, ENV_VOLUME);
IncrementEnvelopePosition(pChn, ENV_PANNING);
@@ -1047,8 +1047,8 @@
}
-void CSoundFile::ProcessInstrumentFade(ModChannel *pChn, int &vol)
-//----------------------------------------------------------------
+void CSoundFile::ProcessInstrumentFade(ModChannel *pChn, int &vol) const
+//----------------------------------------------------------------------
{
// FadeOut volume
if(pChn->dwFlags[CHN_NOTEFADE])
@@ -1069,8 +1069,8 @@
}
-void CSoundFile::ProcessPitchPanSeparation(ModChannel *pChn)
-//----------------------------------------------------------
+void CSoundFile::ProcessPitchPanSeparation(ModChannel *pChn) const
+//----------------------------------------------------------------
{
const ModInstrument *pIns = pChn->pModInstrument;
@@ -1084,8 +1084,8 @@
}
-void CSoundFile::ProcessPanbrello(ModChannel *pChn)
-//-------------------------------------------------
+void CSoundFile::ProcessPanbrello(ModChannel *pChn) const
+//-------------------------------------------------------
{
if(pChn->dwFlags[CHN_PANBRELLO])
{
@@ -1271,7 +1271,7 @@
void CSoundFile::ProcessVibrato(CHANNELINDEX nChn, int &period, CTuning::RATIOTYPE &vibratoFactor)
-//-----------------------------------------------------------------------------------------------
+//------------------------------------------------------------------------------------------------
{
ModChannel &chn = Chn[nChn];
@@ -1382,8 +1382,8 @@
}
-void CSoundFile::ProcessSampleAutoVibrato(ModChannel *pChn, int &period, CTuning::RATIOTYPE &vibratoFactor, int &nPeriodFrac)
-//---------------------------------------------------------------------------------------------------------------------------
+void CSoundFile::ProcessSampleAutoVibrato(ModChannel *pChn, int &period, CTuning::RATIOTYPE &vibratoFactor, int &nPeriodFrac) const
+//---------------------------------------------------------------------------------------------------------------------------------
{
// Sample Auto-Vibrato
if ((pChn->pModSample) && (pChn->pModSample->nVibDepth))
@@ -1545,8 +1545,8 @@
}
-void CSoundFile::ProcessRamping(ModChannel *pChn)
-//-----------------------------------------------
+void CSoundFile::ProcessRamping(ModChannel *pChn) const
+//-----------------------------------------------------
{
pChn->leftRamp = pChn->rightRamp = 0;
if(pChn->dwFlags[CHN_VOLUMERAMP] && (pChn->leftVol != pChn->newLeftVol || pChn->rightVol != pChn->newRightVol))
@@ -1611,6 +1611,38 @@
}
+uint32 CSoundFile::GetChannelIncrement(ModChannel *pChn, uint32 period, int periodFrac) const
+//-------------------------------------------------------------------------------------------
+{
+ uint32 freq;
+
+ const ModInstrument *pIns = pChn->pModInstrument;
+ if(GetType() != MOD_TYPE_MPT || pIns == nullptr || pIns->pTuning == nullptr)
+ {
+ freq = GetFreqFromPeriod(period, pChn->nC5Speed, periodFrac);
+ } else
+ {
+ freq = pChn->m_Freq;
+ }
+
+ // Applying Pitch/Tempo lock.
+ if(pIns && pIns->wPitchToTempoLock)
+ {
+ freq = Util::muldivr(freq, m_nMusicTempo, pIns->wPitchToTempoLock);
+ }
+
+ if ((GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) && (freq < 256))
+ {
+ pChn->nFadeOutVol = 0;
+ pChn->dwFlags.set(CHN_NOTEFADE);
+ pChn->nRealVolume = 0;
+ pChn->nCalcVolume = 0;
+ }
+
+ return Util::muldivr(freq, 0x10000, m_MixerSettings.gdwMixingFreq << FREQ_FRACBITS);
+}
+
+
////////////////////////////////////////////////////////////////////////////////////////////
// Handles envelopes & mixer setup
@@ -1709,7 +1741,7 @@
CTuning::RATIOTYPE vibratoFactor = 1;
CTuning::NOTEINDEXTYPE arpeggioSteps = 0;
- ModInstrument *pIns = pChn->pModInstrument;
+ const ModInstrument *pIns = pChn->pModInstrument;
// Calc Frequency
int period;
@@ -1741,7 +1773,7 @@
// so we have to update the position before we actually process the envelopes.
// When using MPT behaviour, we get the envelope position for the next tick while we are still calculating the current tick,
// which then results in wrong position information when the envelope is paused on the next row.
- // Test cases: s77.it, EnvLoops.xm
+ // Test cases: s77.it
IncrementEnvelopePositions(pChn);
}
ProcessVolumeEnvelope(pChn, vol);
@@ -1854,13 +1886,9 @@
period = m_nMaxPeriod;
nPeriodFrac = 0;
}*/
- UINT freq = 0;
-
- if(GetType() != MOD_TYPE_MPT || pIns == nullptr || pIns->pTuning == nullptr)
+
+ if(GetType() == MOD_TYPE_MPT && pIns != nullptr && pIns->pTuning != nullptr)
{
- freq = GetFreqFromPeriod(period, pChn->nC5Speed, nPeriodFrac);
- } else
- {
// In this case: GetType() == MOD_TYPE_MPT and using custom tunings.
if(pChn->m_CalculateFreq || (pChn->m_ReCalculateFreqOnFirstTick && m_nTickCount == 0))
{
@@ -1870,25 +1898,10 @@
else
pChn->m_CalculateFreq = false;
}
-
- freq = pChn->m_Freq;
}
- // Applying Pitch/Tempo lock.
- if(GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT) && pIns && pIns->wPitchToTempoLock)
- {
- freq = Util::muldivr(freq, m_nMusicTempo, pIns->wPitchToTempoLock);
- }
- if ((GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) && (freq < 256))
- {
- pChn->nFadeOutVol = 0;
- pChn->dwFlags.set(CHN_NOTEFADE);
- pChn->nRealVolume = 0;
- pChn->nCalcVolume = 0;
- }
-
- uint32 ninc = Util::muldivr(freq, 0x10000, m_MixerSettings.gdwMixingFreq << FREQ_FRACBITS);
+ uint32 ninc = GetChannelIncrement(pChn, period, nPeriodFrac);
#ifndef MODPLUG_TRACKER
ninc = Util::muldivr(ninc, m_nFreqFactor, 128);
#endif // !MODPLUG_TRACKER
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-02-27 23:28:25
|
Revision: 3787
http://sourceforge.net/p/modplug/code/3787
Author: saga-games
Date: 2014-02-27 23:28:17 +0000 (Thu, 27 Feb 2014)
Log Message:
-----------
[Fix] MIDI Mapping Dialog: Plugin parameter list wasn't updated/filled correctly.
[Mod] OpenMPT: Version is now 1.22.07.26
Modified Paths:
--------------
trunk/OpenMPT/common/versionNumber.h
trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp
Modified: trunk/OpenMPT/common/versionNumber.h
===================================================================
--- trunk/OpenMPT/common/versionNumber.h 2014-02-27 22:55:00 UTC (rev 3786)
+++ trunk/OpenMPT/common/versionNumber.h 2014-02-27 23:28:17 UTC (rev 3787)
@@ -17,7 +17,7 @@
#define VER_MAJORMAJOR 1
#define VER_MAJOR 22
#define VER_MINOR 07
-#define VER_MINORMINOR 25
+#define VER_MINORMINOR 26
//Version string. For example "1.17.02.28"
#define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR)
Modified: trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp
===================================================================
--- trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp 2014-02-27 22:55:00 UTC (rev 3786)
+++ trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp 2014-02-27 23:28:17 UTC (rev 3787)
@@ -185,13 +185,14 @@
void CMIDIMappingDialog::UpdateParameters()
-//------------------------------------------
+//-----------------------------------------
{
m_PlugParamCBox.SetRedraw(FALSE);
m_PlugParamCBox.ResetContent();
- AddPluginParameternamesToCombobox(m_PlugParamCBox, m_rSndFile.m_MixPlugins[m_Setting.GetPlugIndex()]);
+ AddPluginParameternamesToCombobox(m_PlugParamCBox, m_rSndFile.m_MixPlugins[m_Setting.GetPlugIndex() - 1]);
m_PlugParamCBox.SetCurSel(m_Setting.GetParamIndex());
m_PlugParamCBox.SetRedraw(TRUE);
+ m_PlugParamCBox.Invalidate();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-02-28 01:52:51
|
Revision: 3788
http://sourceforge.net/p/modplug/code/3788
Author: saga-games
Date: 2014-02-28 01:52:36 +0000 (Fri, 28 Feb 2014)
Log Message:
-----------
[Ref] Put all variables that are related to the current playback state of CSoundFile into a child object m_PlayState.
Modified Paths:
--------------
trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp
trunk/OpenMPT/mptrack/Ctrl_gen.cpp
trunk/OpenMPT/mptrack/Ctrl_ins.cpp
trunk/OpenMPT/mptrack/Ctrl_seq.cpp
trunk/OpenMPT/mptrack/Draw_pat.cpp
trunk/OpenMPT/mptrack/EffectInfo.cpp
trunk/OpenMPT/mptrack/MainFrm.cpp
trunk/OpenMPT/mptrack/Mainbar.cpp
trunk/OpenMPT/mptrack/Mod2wave.cpp
trunk/OpenMPT/mptrack/ModConvert.cpp
trunk/OpenMPT/mptrack/Moddoc.cpp
trunk/OpenMPT/mptrack/Modedit.cpp
trunk/OpenMPT/mptrack/PSRatioCalc.cpp
trunk/OpenMPT/mptrack/View_ins.cpp
trunk/OpenMPT/mptrack/View_pat.cpp
trunk/OpenMPT/mptrack/View_smp.cpp
trunk/OpenMPT/mptrack/View_tre.cpp
trunk/OpenMPT/mptrack/Vstplug.cpp
trunk/OpenMPT/soundlib/Fastmix.cpp
trunk/OpenMPT/soundlib/SampleFormats.cpp
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/Sndfile.cpp
trunk/OpenMPT/soundlib/Sndfile.h
trunk/OpenMPT/soundlib/Sndmix.cpp
trunk/OpenMPT/soundlib/modsmp_ctrl.cpp
trunk/OpenMPT/test/test.cpp
Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp
===================================================================
--- trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2014-02-27 23:28:17 UTC (rev 3787)
+++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2014-02-28 01:52:36 UTC (rev 3788)
@@ -645,9 +645,9 @@
double module_impl::set_position_seconds( double seconds ) {
GetLengthType t = m_sndFile->GetLength( eNoAdjust, GetLengthTarget( seconds ) );
m_sndFile->InitializeVisitedRows();
- m_sndFile->m_nCurrentOrder = t.lastOrder;
+ m_sndFile->m_PlayState.m_nCurrentOrder = t.lastOrder;
m_sndFile->SetCurrentOrder( t.lastOrder );
- m_sndFile->m_nNextRow = t.lastRow;
+ m_sndFile->m_PlayState.m_nNextRow = t.lastRow;
m_currentPositionSeconds = m_sndFile->GetLength( eAdjust, GetLengthTarget( t.lastOrder, t.lastRow ) ).duration;
return m_currentPositionSeconds;
}
@@ -664,9 +664,9 @@
row = 0;
}
m_sndFile->InitializeVisitedRows();
- m_sndFile->m_nCurrentOrder = order;
+ m_sndFile->m_PlayState.m_nCurrentOrder = order;
m_sndFile->SetCurrentOrder( order );
- m_sndFile->m_nNextRow = row;
+ m_sndFile->m_PlayState.m_nNextRow = row;
m_currentPositionSeconds = m_sndFile->GetLength( eAdjust, GetLengthTarget( order, row ) ).duration;
return m_currentPositionSeconds;
}
@@ -753,10 +753,10 @@
}
std::int32_t module_impl::get_current_speed() const {
- return m_sndFile->m_nMusicSpeed;
+ return m_sndFile->m_PlayState.m_nMusicSpeed;
}
std::int32_t module_impl::get_current_tempo() const {
- return m_sndFile->m_nMusicTempo;
+ return m_sndFile->m_PlayState.m_nMusicTempo;
}
std::int32_t module_impl::get_current_order() const {
return m_sndFile->GetCurrentOrder();
@@ -773,7 +773,7 @@
return pattern;
}
std::int32_t module_impl::get_current_row() const {
- return m_sndFile->m_nRow;
+ return m_sndFile->m_PlayState.m_nRow;
}
std::int32_t module_impl::get_current_playing_channels() const {
return m_sndFile->GetMixStat();
@@ -791,13 +791,13 @@
if ( channel < 0 || channel >= m_sndFile->GetNumChannels() ) {
return 0.0f;
}
- return m_sndFile->Chn[channel].nLeftVU * (1.0f/128.0f);
+ return m_sndFile->m_PlayState.Chn[channel].nLeftVU * (1.0f/128.0f);
}
float module_impl::get_current_channel_vu_right( std::int32_t channel ) const {
if ( channel < 0 || channel >= m_sndFile->GetNumChannels() ) {
return 0.0f;
}
- return m_sndFile->Chn[channel].nRightVU * (1.0f/128.0f);
+ return m_sndFile->m_PlayState.Chn[channel].nRightVU * (1.0f/128.0f);
}
float module_impl::get_current_channel_vu_rear_left( std::int32_t channel ) const {
if ( channel < 0 || channel >= m_sndFile->GetNumChannels() ) {
Modified: trunk/OpenMPT/mptrack/Ctrl_gen.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2014-02-27 23:28:17 UTC (rev 3787)
+++ trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2014-02-28 01:52:36 UTC (rev 3788)
@@ -270,7 +270,7 @@
if ((tempo >= m_sndFile.GetModSpecifications().tempoMin) && (tempo <= m_sndFile.GetModSpecifications().tempoMax) && (tempo != m_sndFile.m_nDefaultTempo))
{
m_sndFile.m_nDefaultTempo = tempo;
- m_sndFile.m_nMusicTempo = tempo;
+ m_sndFile.m_PlayState.m_nMusicTempo = tempo;
m_modDoc.SetModified();
m_modDoc.UpdateAllViews(NULL, HINT_MODGENERAL, this);
@@ -282,7 +282,7 @@
const UINT gv = MAX_SLIDER_GLOBAL_VOL - m_SliderGlobalVol.GetPos();
if ((gv >= 0) && (gv <= MAX_SLIDER_GLOBAL_VOL) && (gv != m_sndFile.m_nDefaultGlobalVolume))
{
- m_sndFile.m_nGlobalVolume = gv;
+ m_sndFile.m_PlayState.m_nGlobalVolume = gv;
m_sndFile.m_nDefaultGlobalVolume = gv;
m_modDoc.SetModified();
@@ -351,7 +351,7 @@
m_bEditsLocked=true;
m_EditTempo.SetModify(FALSE);
m_sndFile.m_nDefaultTempo = n;
- m_sndFile.m_nMusicTempo = n;
+ m_sndFile.m_PlayState.m_nMusicTempo = n;
m_modDoc.SetModified();
m_modDoc.UpdateAllViews(NULL, HINT_MODGENERAL, this);
UpdateView(HINT_MODGENERAL, NULL);
@@ -378,7 +378,7 @@
m_bEditsLocked=true;
m_EditSpeed.SetModify(FALSE);
m_sndFile.m_nDefaultSpeed = n;
- m_sndFile.m_nMusicSpeed = n;
+ m_sndFile.m_PlayState.m_nMusicSpeed = n;
m_modDoc.SetModified();
m_modDoc.UpdateAllViews(NULL, HINT_MODGENERAL, this);
m_bEditsLocked=false;
@@ -453,7 +453,7 @@
m_bEditsLocked = true;
m_EditGlobalVol.SetModify(FALSE);
m_sndFile.m_nDefaultGlobalVolume = n;
- m_sndFile.m_nGlobalVolume = n;
+ m_sndFile.m_PlayState.m_nGlobalVolume = n;
m_modDoc.SetModified();
m_modDoc.UpdateAllViews(NULL, HINT_MODGENERAL, this);
UpdateView(HINT_MODGENERAL, NULL);
@@ -543,7 +543,7 @@
return TRUE;
break;
case IDC_SLIDER_GLOBALVOL:
- (displayDBValues) ? setAsDecibels(pszText, m_sndFile.m_nGlobalVolume, m_sndFile.GetPlayConfig().getNormalGlobalVol()) : wsprintf(pszText, moreRecentMixModeNote);
+ (displayDBValues) ? setAsDecibels(pszText, m_sndFile.m_PlayState.m_nGlobalVolume, m_sndFile.GetPlayConfig().getNormalGlobalVol()) : wsprintf(pszText, moreRecentMixModeNote);
return TRUE;
break;
}
Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2014-02-27 23:28:17 UTC (rev 3787)
+++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2014-02-28 01:52:36 UTC (rev 3788)
@@ -2232,14 +2232,14 @@
pIns->SetCutoff(pIns->GetCutoff(), bCutOff);
for (CHANNELINDEX i = 0; i < MAX_CHANNELS; i++)
{
- if (m_sndFile.Chn[i].pModInstrument == pIns)
+ if (m_sndFile.m_PlayState.Chn[i].pModInstrument == pIns)
{
if (bCutOff)
{
- m_sndFile.Chn[i].nCutOff = pIns->GetCutoff();
+ m_sndFile.m_PlayState.Chn[i].nCutOff = pIns->GetCutoff();
} else
{
- m_sndFile.Chn[i].nCutOff = 0x7F;
+ m_sndFile.m_PlayState.Chn[i].nCutOff = 0x7F;
}
}
}
@@ -2261,14 +2261,14 @@
pIns->SetResonance(pIns->GetResonance(), bReso);
for(CHANNELINDEX i = 0; i < MAX_CHANNELS; i++)
{
- if (m_sndFile.Chn[i].pModInstrument == pIns)
+ if (m_sndFile.m_PlayState.Chn[i].pModInstrument == pIns)
{
if (bReso)
{
- m_sndFile.Chn[i].nResonance = pIns->GetResonance();
+ m_sndFile.m_PlayState.Chn[i].nResonance = pIns->GetResonance();
} else
{
- m_sndFile.Chn[i].nResonance = 0;
+ m_sndFile.m_PlayState.Chn[i].nResonance = 0;
}
}
}
@@ -2296,8 +2296,8 @@
{
for(CHANNELINDEX i = 0; i < MAX_CHANNELS; i++)
{
- if(m_sndFile.Chn[i].pModInstrument == pIns)
- m_sndFile.Chn[i].nFilterMode = instFiltermode;
+ if(m_sndFile.m_PlayState.Chn[i].pModInstrument == pIns)
+ m_sndFile.m_PlayState.Chn[i].nFilterMode = instFiltermode;
}
}
}
@@ -2414,10 +2414,10 @@
{
for (UINT i=0; i<MAX_CHANNELS; i++)
{
- if (m_sndFile.Chn[i].pModInstrument == pIns)
+ if (m_sndFile.m_PlayState.Chn[i].pModInstrument == pIns)
{
- if (pIns->IsCutoffEnabled()) m_sndFile.Chn[i].nCutOff = pIns->GetCutoff();
- if (pIns->IsResonanceEnabled()) m_sndFile.Chn[i].nResonance = pIns->GetResonance();
+ if (pIns->IsCutoffEnabled()) m_sndFile.m_PlayState.Chn[i].nCutOff = pIns->GetCutoff();
+ if (pIns->IsResonanceEnabled()) m_sndFile.m_PlayState.Chn[i].nResonance = pIns->GetResonance();
}
}
}
Modified: trunk/OpenMPT/mptrack/Ctrl_seq.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2014-02-27 23:28:17 UTC (rev 3787)
+++ trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2014-02-28 01:52:36 UTC (rev 3788)
@@ -284,7 +284,7 @@
ORDERINDEX &nOrder = bShiftClick ? m_nScrollPos2nd : m_nScrollPos;
if ((sel < 0) || (sel >= sndFile.Order.GetLength()) || (!m_pParent) || (!pMainFrm)) return false;
- if (!bIgnoreCurSel && sel == nOrder && (sel == sndFile.m_nCurrentOrder || !setPlayPos)) return true;
+ if (!bIgnoreCurSel && sel == nOrder && (sel == sndFile.m_PlayState.m_nCurrentOrder || !setPlayPos)) return true;
const ORDERINDEX nShownLength = GetLength();
InvalidateSelection();
nOrder = sel;
@@ -326,10 +326,10 @@
if(isPlaying && sndFile.m_SongFlags[SONG_PATTERNLOOP])
{
- sndFile.m_nPattern = n;
- sndFile.m_nCurrentOrder = sndFile.m_nNextOrder = m_nScrollPos;
+ sndFile.m_PlayState.m_nPattern = n;
+ sndFile.m_PlayState.m_nCurrentOrder = sndFile.m_PlayState.m_nNextOrder = m_nScrollPos;
pMainFrm->ResetNotificationBuffer();
- sndFile.m_nNextRow = 0;
+ sndFile.m_PlayState.m_nNextRow = 0;
// update channel parameters and play time
m_pModDoc.SetElapsedTime(m_nScrollPos, 0);
@@ -339,7 +339,7 @@
{
SongFlags pausedFlags = sndFile.m_SongFlags & (SONG_PAUSED | SONG_STEP | SONG_PATTERNLOOP);
- sndFile.m_nCurrentOrder = m_nScrollPos;
+ sndFile.m_PlayState.m_nCurrentOrder = m_nScrollPos;
sndFile.SetCurrentOrder(m_nScrollPos);
sndFile.m_SongFlags.set(pausedFlags);
@@ -720,7 +720,7 @@
LineTo(dc.m_hDC, rect.right, rect.bottom);
// Drawing the 'ctrl-transition' indicator
- if(nIndex == sndFile.m_nSeqOverride)
+ if(nIndex == sndFile.m_PlayState.m_nSeqOverride)
{
MoveToEx(dc.m_hDC, rect.left + 4, rect.bottom - 4, NULL);
LineTo(dc.m_hDC, rect.right - 4, rect.bottom - 4);
@@ -1402,10 +1402,10 @@
if(order < length)
{
- if(sndFile.m_nSeqOverride == order)
+ if(sndFile.m_PlayState.m_nSeqOverride == order)
{
// This item is already queued: Dequeue it.
- sndFile.m_nSeqOverride = ORDERINDEX_INVALID;
+ sndFile.m_PlayState.m_nSeqOverride = ORDERINDEX_INVALID;
} else
{
if(sndFile.Order.IsPositionLocked(order))
@@ -1414,7 +1414,7 @@
OnUnlockPlayback();
}
- sndFile.m_nSeqOverride = order;
+ sndFile.m_PlayState.m_nSeqOverride = order;
}
InvalidateRect(NULL, FALSE);
}
Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Draw_pat.cpp 2014-02-27 23:28:17 UTC (rev 3787)
+++ trunk/OpenMPT/mptrack/Draw_pat.cpp 2014-02-28 01:52:36 UTC (rev 3788)
@@ -1669,13 +1669,13 @@
//xtraInfo.Format("Chan: %d; macro: %X; cutoff: %X; reso: %X; pan: %X",
xtraInfo.Format("Chn:%d; Vol:%X; Mac:%X; Cut:%X%s; Res:%X; Pan:%X%s",
nChn + 1,
- pSndFile->Chn[nChn].nGlobalVol,
- pSndFile->Chn[nChn].nActiveMacro,
- pSndFile->Chn[nChn].nCutOff,
- (pSndFile->Chn[nChn].nFilterMode == FLTMODE_HIGHPASS) ? "-Hi" : "",
- pSndFile->Chn[nChn].nResonance,
- pSndFile->Chn[nChn].nPan,
- pSndFile->Chn[nChn].dwFlags[CHN_SURROUND] ? "-S" : "");
+ pSndFile->m_PlayState.Chn[nChn].nGlobalVol,
+ pSndFile->m_PlayState.Chn[nChn].nActiveMacro,
+ pSndFile->m_PlayState.Chn[nChn].nCutOff,
+ (pSndFile->m_PlayState.Chn[nChn].nFilterMode == FLTMODE_HIGHPASS) ? "-Hi" : "",
+ pSndFile->m_PlayState.Chn[nChn].nResonance,
+ pSndFile->m_PlayState.Chn[nChn].nPan,
+ pSndFile->m_PlayState.Chn[nChn].dwFlags[CHN_SURROUND] ? "-S" : "");
pMainFrm->SetXInfoText(xtraInfo);
}
Modified: trunk/OpenMPT/mptrack/EffectInfo.cpp
===================================================================
--- trunk/OpenMPT/mptrack/EffectInfo.cpp 2014-02-27 23:28:17 UTC (rev 3787)
+++ trunk/OpenMPT/mptrack/EffectInfo.cpp 2014-02-28 01:52:36 UTC (rev 3788)
@@ -188,8 +188,8 @@
case CMD_SMOOTHMIDI:
if (param < 0x80 && nChn != CHANNELINDEX_INVALID)
{
- macroIndex = sndFile.Chn[nChn].nActiveMacro;
- chanSpec.Format(": currently %d: ", sndFile.Chn[nChn].nActiveMacro);
+ macroIndex = sndFile.m_PlayState.Chn[nChn].nActiveMacro;
+ chanSpec.Format(": currently %d: ", sndFile.m_PlayState.Chn[nChn].nActiveMacro);
}
else
{
Modified: trunk/OpenMPT/mptrack/MainFrm.cpp
===================================================================
--- trunk/OpenMPT/mptrack/MainFrm.cpp 2014-02-27 23:28:17 UTC (rev 3787)
+++ trunk/OpenMPT/mptrack/MainFrm.cpp 2014-02-28 01:52:36 UTC (rev 3788)
@@ -902,7 +902,7 @@
// Add an entry to the notification history
- Notification notification(notifyType, notifyItem, streamPosition, m_pSndFile->m_nRow, m_pSndFile->m_nTickCount, m_pSndFile->m_nCurrentOrder, m_pSndFile->m_nPattern, m_pSndFile->GetMixStat());
+ Notification notification(notifyType, notifyItem, streamPosition, m_pSndFile->m_PlayState.m_nRow, m_pSndFile->m_PlayState.m_nTickCount, m_pSndFile->m_PlayState.m_nCurrentOrder, m_pSndFile->m_PlayState.m_nPattern, m_pSndFile->GetMixStat());
m_pSndFile->ResetMixStat();
@@ -916,7 +916,7 @@
{
for(CHANNELINDEX k = 0; k < MAX_CHANNELS; k++)
{
- const ModChannel &chn = m_pSndFile->Chn[k];
+ const ModChannel &chn = m_pSndFile->m_PlayState.Chn[k];
if(chn.pModSample == &m_pSndFile->GetSample(smp) && chn.nLength != 0 // Corrent sample is set up on this channel
&& (!chn.dwFlags[CHN_NOTEFADE] || chn.nFadeOutVol)) // And it hasn't completely faded out yet, so it's still playing
{
@@ -946,7 +946,7 @@
{
for(CHANNELINDEX k = 0; k < MAX_CHANNELS; k++)
{
- const ModChannel &chn = m_pSndFile->Chn[k];
+ const ModChannel &chn = m_pSndFile->m_PlayState.Chn[k];
SmpLength pos = Notification::PosInvalid;
if(chn.pModInstrument == m_pSndFile->Instruments[ins] // Correct instrument is set up on this channel
@@ -979,8 +979,8 @@
// Pattern channel VU meters
for(CHANNELINDEX k = 0; k < m_pSndFile->GetNumChannels(); k++)
{
- uint32 vul = m_pSndFile->Chn[k].nLeftVU;
- uint32 vur = m_pSndFile->Chn[k].nRightVU;
+ uint32 vul = m_pSndFile->m_PlayState.Chn[k].nLeftVU;
+ uint32 vur = m_pSndFile->m_PlayState.Chn[k].nRightVU;
notification.pos[k] = (vul << 8) | (vur);
}
}
@@ -1282,9 +1282,9 @@
// Stop sample preview channels
for(CHANNELINDEX i = m_pSndFile->m_nChannels; i < MAX_CHANNELS; i++)
{
- if(!(m_pSndFile->Chn[i].nMasterChn))
+ if(!(m_pSndFile->m_PlayState.Chn[i].nMasterChn))
{
- m_pSndFile->Chn[i].nPos = m_pSndFile->Chn[i].nPosLo = m_pSndFile->Chn[i].nLength = 0;
+ m_pSndFile->m_PlayState.Chn[i].nPos = m_pSndFile->m_PlayState.Chn[i].nPosLo = m_pSndFile->m_PlayState.Chn[i].nLength = 0;
}
}
}
@@ -1570,7 +1570,7 @@
m_WaveFile.Destroy();
m_WaveFile.Create(FileReader());
// Avoid global volume ramping when trying samples in the treeview.
- m_WaveFile.m_nDefaultGlobalVolume = m_WaveFile.m_nGlobalVolume = MAX_GLOBAL_VOLUME;
+ m_WaveFile.m_nDefaultGlobalVolume = m_WaveFile.m_PlayState.m_nGlobalVolume = MAX_GLOBAL_VOLUME;
m_WaveFile.SetMixLevels(mixLevels_117RC3);
m_WaveFile.m_nSamplePreAmp = static_cast<uint32>(m_WaveFile.GetPlayConfig().getNormalSamplePreAmp());
m_WaveFile.m_nDefaultTempo = 125;
@@ -2143,7 +2143,7 @@
if(m_pSndFile != nullptr && m_pSndFile != &m_WaveFile && !m_pSndFile->IsPaused())
{
- PATTERNINDEX nPat = m_pSndFile->m_nPattern;
+ PATTERNINDEX nPat = m_pSndFile->m_PlayState.m_nPattern;
if(m_pSndFile->Patterns.IsValidIndex(nPat))
{
if(nPat < 10) strcat(s, " ");
Modified: trunk/OpenMPT/mptrack/Mainbar.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Mainbar.cpp 2014-02-27 23:28:17 UTC (rev 3787)
+++ trunk/OpenMPT/mptrack/Mainbar.cpp 2014-02-28 01:52:36 UTC (rev 3788)
@@ -430,7 +430,7 @@
// Update play/pause button
if (nCurrentTempo == -1) SetButtonInfo(PLAYCMD_INDEX, ID_PLAYER_PAUSE, TBBS_BUTTON, TOOLBAR_IMAGE_PAUSE);
// Update Speed
- int nSpeed = pSndFile->m_nMusicSpeed;
+ int nSpeed = pSndFile->m_PlayState.m_nMusicSpeed;
if (nSpeed != nCurrentSpeed)
{
//rewbs.envRowGrid
@@ -445,7 +445,7 @@
wsprintf(s, "%d", nCurrentSpeed);
m_EditSpeed.SetWindowText(s);
}
- int nTempo = pSndFile->m_nMusicTempo;
+ int nTempo = pSndFile->m_PlayState.m_nMusicTempo;
if (nTempo != nCurrentTempo)
{
if (nCurrentTempo < 0) m_SpinTempo.EnableWindow(TRUE);
@@ -453,7 +453,7 @@
wsprintf(s, "%d", nCurrentTempo);
m_EditTempo.SetWindowText(s);
}
- int nRowsPerBeat = pSndFile->m_nCurrentRowsPerBeat;
+ int nRowsPerBeat = pSndFile->m_PlayState.m_nCurrentRowsPerBeat;
if (nRowsPerBeat != nCurrentRowsPerBeat)
{
if (nCurrentRowsPerBeat < 0) m_SpinRowsPerBeat.EnableWindow(TRUE);
@@ -518,10 +518,10 @@
{
if (n < 0)
{
- pSndFile->m_nMusicSpeed = std::max(UINT(nCurrentSpeed - 1), pSndFile->GetModSpecifications().speedMin);
+ pSndFile->m_PlayState.m_nMusicSpeed = std::max(UINT(nCurrentSpeed - 1), pSndFile->GetModSpecifications().speedMin);
} else
{
- pSndFile->m_nMusicSpeed = std::min(UINT(nCurrentSpeed + 1), pSndFile->GetModSpecifications().speedMax);
+ pSndFile->m_PlayState.m_nMusicSpeed = std::min(UINT(nCurrentSpeed + 1), pSndFile->GetModSpecifications().speedMax);
}
m_SpinSpeed.SetPos(0);
}
@@ -535,7 +535,7 @@
}
} else
{
- if (static_cast<ROWINDEX>(nCurrentRowsPerBeat) < pSndFile->m_nCurrentRowsPerMeasure)
+ if (static_cast<ROWINDEX>(nCurrentRowsPerBeat) < pSndFile->m_PlayState.m_nCurrentRowsPerMeasure)
{
SetRowsPerBeat(nCurrentRowsPerBeat + 1);
}
@@ -568,7 +568,7 @@
if(pModDoc == nullptr || pSndFile == nullptr)
return;
- pSndFile->m_nCurrentRowsPerBeat = nNewRPB;
+ pSndFile->m_PlayState.m_nCurrentRowsPerBeat = nNewRPB;
PATTERNINDEX nPat = pSndFile->GetCurrentPattern();
if(pSndFile->Patterns[nPat].GetOverrideSignature())
{
Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Mod2wave.cpp 2014-02-27 23:28:17 UTC (rev 3787)
+++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2014-02-28 01:52:36 UTC (rev 3788)
@@ -1065,7 +1065,7 @@
}
m_SndFile.SetCurrentOrder(startOrder);
m_SndFile.GetLength(eAdjust, GetLengthTarget(startOrder, 0)); // adjust playback variables / visited rows vector
- m_SndFile.m_nCurrentOrder = startOrder;
+ m_SndFile.m_PlayState.m_nCurrentOrder = startOrder;
if (l < max) max = l;
Modified: trunk/OpenMPT/mptrack/ModConvert.cpp
===================================================================
--- trunk/OpenMPT/mptrack/ModConvert.cpp 2014-02-27 23:28:17 UTC (rev 3787)
+++ trunk/OpenMPT/mptrack/ModConvert.cpp 2014-02-28 01:52:36 UTC (rev 3788)
@@ -152,7 +152,7 @@
// Removing all instrument headers from channels
for(CHANNELINDEX nChn = 0; nChn < MAX_CHANNELS; nChn++)
{
- m_SndFile.Chn[nChn].pModInstrument = nullptr;
+ m_SndFile.m_PlayState.Chn[nChn].pModInstrument = nullptr;
}
for(INSTRUMENTINDEX nIns = 0; nIns <= m_SndFile.GetNumInstruments(); nIns++) if (m_SndFile.Instruments[nIns])
Modified: trunk/OpenMPT/mptrack/Moddoc.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Moddoc.cpp 2014-02-27 23:28:17 UTC (rev 3787)
+++ trunk/OpenMPT/mptrack/Moddoc.cpp 2014-02-28 01:52:36 UTC (rev 3788)
@@ -145,7 +145,7 @@
m_bsInstrumentModified.reset();
#ifdef _DEBUG
- ModChannel *p = m_SndFile.Chn;
+ ModChannel *p = m_SndFile.m_PlayState.Chn;
if (((DWORD)p) & 7) Log("ModChannel struct is not aligned (0x%08X)\n", p);
#endif
// Fix: save pattern scrollbar position when switching to other tab
@@ -705,13 +705,13 @@
MemsetZero(m_SndFile.m_szNames);
//m_SndFile.SetTitle("untitled");
- m_SndFile.m_nMusicTempo = m_SndFile.m_nDefaultTempo = 125;
- m_SndFile.m_nMusicSpeed = m_SndFile.m_nDefaultSpeed = 6;
+ m_SndFile.m_PlayState.m_nMusicTempo = m_SndFile.m_nDefaultTempo = 125;
+ m_SndFile.m_PlayState.m_nMusicSpeed = m_SndFile.m_nDefaultSpeed = 6;
// Set up levels
//if(m_SndFile.m_nMixLevels == mixLevels_original || m_SndFile.m_nMixLevels == mixLevels_compatible)
{
- m_SndFile.m_nGlobalVolume = m_SndFile.m_nDefaultGlobalVolume = MAX_GLOBAL_VOLUME;
+ m_SndFile.m_PlayState.m_nGlobalVolume = m_SndFile.m_nDefaultGlobalVolume = MAX_GLOBAL_VOLUME;
m_SndFile.m_nSamplePreAmp = m_SndFile.m_nVSTiVolume = 48;
}
/*else
@@ -730,7 +730,7 @@
m_SndFile.ChnSettings[nChn].dwFlags.reset();
m_SndFile.ChnSettings[nChn].nVolume = 64;
m_SndFile.ChnSettings[nChn].nPan = 128;
- m_SndFile.Chn[nChn].nGlobalVol = 64;
+ m_SndFile.m_PlayState.Chn[nChn].nGlobalVol = 64;
}
// Setup LRRL panning scheme for MODs
m_SndFile.SetupMODPanning();
@@ -1054,10 +1054,10 @@
// All notes off
for (UINT i=0; i<MAX_CHANNELS; i++)
{
- if ((i < GetNumChannels()) || (m_SndFile.Chn[i].nMasterChn))
+ if ((i < GetNumChannels()) || (m_SndFile.m_PlayState.Chn[i].nMasterChn))
{
- m_SndFile.Chn[i].dwFlags.set(CHN_KEYOFF | CHN_NOTEFADE);
- m_SndFile.Chn[i].nFadeOutVol = 0;
+ m_SndFile.m_PlayState.Chn[i].dwFlags.set(CHN_KEYOFF | CHN_NOTEFADE);
+ m_SndFile.m_PlayState.Chn[i].nFadeOutVol = 0;
}
}
}
@@ -1072,7 +1072,7 @@
// Find a channel to play on
nChn = FindAvailableChannel();
- ModChannel &chn = m_SndFile.Chn[nChn];
+ ModChannel &chn = m_SndFile.m_PlayState.Chn[nChn];
// reset channel properties; in theory the chan is completely unused anyway.
chn.Reset(ModChannel::resetTotal, m_SndFile, CHANNELINDEX_INVALID);
@@ -1200,7 +1200,7 @@
//end rewbs.vstiLive
const ChannelFlags mask = (fade ? CHN_NOTEFADE : (CHN_NOTEFADE | CHN_KEYOFF));
- ModChannel *pChn = &m_SndFile.Chn[stopChn != CHANNELINDEX_INVALID ? stopChn : m_SndFile.m_nChannels];
+ ModChannel *pChn = &m_SndFile.m_PlayState.Chn[stopChn != CHANNELINDEX_INVALID ? stopChn : m_SndFile.m_nChannels];
for(CHANNELINDEX i = m_SndFile.GetNumChannels(); i < MAX_CHANNELS; i++, pChn++) if (!pChn->nMasterChn)
{
@@ -1224,7 +1224,7 @@
bool CModDoc::IsNotePlaying(UINT note, SAMPLEINDEX nsmp, INSTRUMENTINDEX nins)
//----------------------------------------------------------------------------
{
- ModChannel *pChn = &m_SndFile.Chn[m_SndFile.GetNumChannels()];
+ ModChannel *pChn = &m_SndFile.m_PlayState.Chn[m_SndFile.GetNumChannels()];
for (CHANNELINDEX i = m_SndFile.GetNumChannels(); i < MAX_CHANNELS; i++, pChn++) if (!pChn->nMasterChn)
{
if(pChn->nLength != 0 && !pChn->dwFlags[CHN_NOTEFADE | CHN_KEYOFF| CHN_MUTE]
@@ -1276,13 +1276,13 @@
// Mute pattern channel
if (doMute)
{
- m_SndFile.Chn[nChn].dwFlags.set(muteType);
+ m_SndFile.m_PlayState.Chn[nChn].dwFlags.set(muteType);
// Kill VSTi notes on muted channel.
PLUGINDEX nPlug = m_SndFile.GetBestPlugin(nChn, PrioritiseInstrument, EvenIfMuted);
if ((nPlug) && (nPlug<=MAX_MIXPLUGINS))
{
CVstPlugin *pPlug = (CVstPlugin*)m_SndFile.m_MixPlugins[nPlug - 1].pMixPlugin;
- const ModInstrument* pIns = m_SndFile.Chn[nChn].pModInstrument;
+ const ModInstrument* pIns = m_SndFile.m_PlayState.Chn[nChn].pModInstrument;
if (pPlug && pIns)
{
pPlug->MidiCommand(m_SndFile.GetBestMidiChannel(nChn), pIns->nMidiProgram, pIns->wMidiBank, NOTE_KEYOFF, 0, nChn);
@@ -1291,21 +1291,21 @@
} else
{
// On unmute alway cater for both mute types - this way there's no probs if user changes mute mode.
- m_SndFile.Chn[nChn].dwFlags.reset(CHN_SYNCMUTE | CHN_MUTE);
+ m_SndFile.m_PlayState.Chn[nChn].dwFlags.reset(CHN_SYNCMUTE | CHN_MUTE);
}
// Mute any NNA'd channels
for (CHANNELINDEX i = m_SndFile.GetNumChannels(); i < MAX_CHANNELS; i++)
{
- if (m_SndFile.Chn[i].nMasterChn == nChn + 1u)
+ if (m_SndFile.m_PlayState.Chn[i].nMasterChn == nChn + 1u)
{
if (doMute)
{
- m_SndFile.Chn[i].dwFlags.set(muteType);
+ m_SndFile.m_PlayState.Chn[i].dwFlags.set(muteType);
} else
{
// On unmute alway cater for both mute types - this way there's no probs if user changes mute mode.
- m_SndFile.Chn[i].dwFlags.reset(CHN_SYNCMUTE | CHN_MUTE);
+ m_SndFile.m_PlayState.Chn[i].dwFlags.reset(CHN_SYNCMUTE | CHN_MUTE);
}
}
}
@@ -1350,7 +1350,7 @@
if (m_SndFile.GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) SetModified();
m_SndFile.ChnSettings[nChn].dwFlags.set(CHN_NOFX, bNoFx);
- if(updateMix) m_SndFile.Chn[nChn].dwFlags.set(CHN_NOFX, bNoFx);
+ if(updateMix) m_SndFile.m_PlayState.Chn[nChn].dwFlags.set(CHN_NOFX, bNoFx);
return true;
}
@@ -1460,10 +1460,10 @@
}
// Update playing channel
- m_SndFile.Chn[nChn].dwFlags.set(CHN_SURROUND, surround);
+ m_SndFile.m_PlayState.Chn[nChn].dwFlags.set(CHN_SURROUND, surround);
if(surround)
{
- m_SndFile.Chn[nChn].nPan = 128;
+ m_SndFile.m_PlayState.Chn[nChn].nPan = 128;
}
return true;
}
@@ -1480,7 +1480,7 @@
if(m_SndFile.GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) SetModified();
ok = true;
}
- m_SndFile.Chn[nChn].nGlobalVol = nVolume;
+ m_SndFile.m_PlayState.Chn[nChn].nGlobalVol = nVolume;
return ok;
}
@@ -1497,8 +1497,8 @@
if(m_SndFile.GetType() & (MOD_TYPE_S3M | MOD_TYPE_IT | MOD_TYPE_MPT)) SetModified();
ok = true;
}
- m_SndFile.Chn[nChn].nPan = nPan;
- m_SndFile.Chn[nChn].dwFlags.reset(CHN_SURROUND);
+ m_SndFile.m_PlayState.Chn[nChn].nPan = nPan;
+ m_SndFile.m_PlayState.Chn[nChn].dwFlags.reset(CHN_SURROUND);
return ok;
}
@@ -2003,13 +2003,13 @@
CriticalSection cs;
- for(CHANNELINDEX i = m_SndFile.GetNumChannels(); i < MAX_CHANNELS; i++) if (!m_SndFile.Chn[i].nMasterChn)
+ for(CHANNELINDEX i = m_SndFile.GetNumChannels(); i < MAX_CHANNELS; i++) if (!m_SndFile.m_PlayState.Chn[i].nMasterChn)
{
- m_SndFile.Chn[i].dwFlags.set(CHN_NOTEFADE | CHN_KEYOFF);
- if (!isPlaying) m_SndFile.Chn[i].nLength = 0;
+ m_SndFile.m_PlayState.Chn[i].dwFlags.set(CHN_NOTEFADE | CHN_KEYOFF);
+ if (!isPlaying) m_SndFile.m_PlayState.Chn[i].nLength = 0;
}
- m_SndFile.m_bPositionChanged = true;
+ m_SndFile.m_PlayState.m_bPositionChanged = true;
if(isPlaying)
{
@@ -2033,20 +2033,20 @@
if (pMainFrm->GetModPlaying() == this)
{
bool isLooping = m_SndFile.m_SongFlags[SONG_PATTERNLOOP];
- PATTERNINDEX nPat = m_SndFile.m_nPattern;
- ROWINDEX nRow = m_SndFile.m_nRow;
- ROWINDEX nNextRow = m_SndFile.m_nNextRow;
+ PATTERNINDEX nPat = m_SndFile.m_PlayState.m_nPattern;
+ ROWINDEX nRow = m_SndFile.m_PlayState.m_nRow;
+ ROWINDEX nNextRow = m_SndFile.m_PlayState.m_nNextRow;
pMainFrm->PauseMod();
if ((isLooping) && (nPat < m_SndFile.Patterns.Size()))
{
CriticalSection cs;
- if ((m_SndFile.m_nCurrentOrder < m_SndFile.Order.size()) && (m_SndFile.Order[m_SndFile.m_nCurrentOrder] == nPat))
+ if ((m_SndFile.m_PlayState.m_nCurrentOrder < m_SndFile.Order.size()) && (m_SndFile.Order[m_SndFile.m_PlayState.m_nCurrentOrder] == nPat))
{
- m_SndFile.m_nNextOrder = m_SndFile.m_nCurrentOrder;
- m_SndFile.m_nNextRow = nNextRow;
- m_SndFile.m_nRow = nRow;
+ m_SndFile.m_PlayState.m_nNextOrder = m_SndFile.m_PlayState.m_nCurrentOrder;
+ m_SndFile.m_PlayState.m_nNextRow = nNextRow;
+ m_SndFile.m_PlayState.m_nRow = nRow;
} else
{
for (ORDERINDEX nOrd = 0; nOrd < m_SndFile.Order.size(); nOrd++)
@@ -2054,10 +2054,10 @@
if (m_SndFile.Order[nOrd] == m_SndFile.Order.GetInvalidPatIndex()) break;
if (m_SndFile.Order[nOrd] == nPat)
{
- m_SndFile.m_nCurrentOrder = nOrd;
- m_SndFile.m_nNextOrder = nOrd;
- m_SndFile.m_nNextRow = nNextRow;
- m_SndFile.m_nRow = nRow;
+ m_SndFile.m_PlayState.m_nCurrentOrder = nOrd;
+ m_SndFile.m_PlayState.m_nNextOrder = nOrd;
+ m_SndFile.m_PlayState.m_nNextRow = nNextRow;
+ m_SndFile.m_PlayState.m_nRow = nRow;
break;
}
}
@@ -2097,9 +2097,9 @@
m_SndFile.m_SongFlags.reset(SONG_STEP | SONG_PATTERNLOOP);
m_SndFile.SetCurrentPos(0);
//m_SndFile.visitedSongRows.Initialize(true);
- m_SndFile.m_lTotalSampleCount = 0;
+ m_SndFile.m_PlayState.m_lTotalSampleCount = 0;
- m_SndFile.m_bPositionChanged = true;
+ m_SndFile.m_PlayState.m_bPositionChanged = true;
cs.Leave();
@@ -2258,7 +2258,7 @@
{
case tempo_mode_alternative:
Message.Format("Using alternative tempo interpretation.\n\nAssuming:\n. %d ticks per second\n. %d ticks per row\n. %d rows per beat\nthe tempo is approximately: %.8g BPM",
- m_SndFile.m_nMusicTempo, m_SndFile.m_nMusicSpeed, m_SndFile.m_nCurrentRowsPerBeat, bpm);
+ m_SndFile.m_PlayState.m_nMusicTempo, m_SndFile.m_PlayState.m_nMusicSpeed, m_SndFile.m_PlayState.m_nCurrentRowsPerBeat, bpm);
break;
case tempo_mode_modern:
@@ -2268,7 +2268,7 @@
case tempo_mode_classic:
default:
Message.Format("Using standard tempo interpretation.\n\nAssuming:\n. A mod tempo (tick duration factor) of %d\n. %d ticks per row\n. %d rows per beat\nthe tempo is approximately: %.8g BPM",
- m_SndFile.m_nMusicTempo, m_SndFile.m_nMusicSpeed, m_SndFile.m_nCurrentRowsPerBeat, bpm);
+ m_SndFile.m_PlayState.m_nMusicTempo, m_SndFile.m_PlayState.m_nMusicSpeed, m_SndFile.m_PlayState.m_nCurrentRowsPerBeat, bpm);
break;
}
@@ -2387,18 +2387,18 @@
// Cut instruments/samples
for(CHANNELINDEX i = 0; i < MAX_CHANNELS; i++)
{
- m_SndFile.Chn[i].nPatternLoopCount = 0;
- m_SndFile.Chn[i].nPatternLoop = 0;
- m_SndFile.Chn[i].nFadeOutVol = 0;
- m_SndFile.Chn[i].dwFlags.set(CHN_NOTEFADE | CHN_KEYOFF);
+ m_SndFile.m_PlayState.Chn[i].nPatternLoopCount = 0;
+ m_SndFile.m_PlayState.Chn[i].nPatternLoop = 0;
+ m_SndFile.m_PlayState.Chn[i].nFadeOutVol = 0;
+ m_SndFile.m_PlayState.Chn[i].dwFlags.set(CHN_NOTEFADE | CHN_KEYOFF);
}
- if ((nOrd < m_SndFile.Order.size()) && (m_SndFile.Order[nOrd] == nPat)) m_SndFile.m_nCurrentOrder = m_SndFile.m_nNextOrder = nOrd;
+ if ((nOrd < m_SndFile.Order.size()) && (m_SndFile.Order[nOrd] == nPat)) m_SndFile.m_PlayState.m_nCurrentOrder = m_SndFile.m_PlayState.m_nNextOrder = nOrd;
m_SndFile.m_SongFlags.reset(SONG_PAUSED | SONG_STEP);
if(loop)
m_SndFile.LoopPattern(nPat);
else
m_SndFile.LoopPattern(PATTERNINDEX_INVALID);
- m_SndFile.m_nNextRow = 0;
+ m_SndFile.m_PlayState.m_nNextRow = 0;
// set playback timer in the status bar (and update channel status)
SetElapsedTime(nOrd, 0);
@@ -2448,12 +2448,12 @@
// Cut instruments/samples
for(CHANNELINDEX i = m_SndFile.GetNumChannels(); i < MAX_CHANNELS; i++)
{
- m_SndFile.Chn[i].dwFlags.set(CHN_NOTEFADE | CHN_KEYOFF);
+ m_SndFile.m_PlayState.Chn[i].dwFlags.set(CHN_NOTEFADE | CHN_KEYOFF);
}
- if ((nOrd < m_SndFile.Order.size()) && (m_SndFile.Order[nOrd] == nPat)) m_SndFile.m_nCurrentOrder = m_SndFile.m_nNextOrder = nOrd;
+ if ((nOrd < m_SndFile.Order.size()) && (m_SndFile.Order[nOrd] == nPat)) m_SndFile.m_PlayState.m_nCurrentOrder = m_SndFile.m_PlayState.m_nNextOrder = nOrd;
m_SndFile.m_SongFlags.reset(SONG_PAUSED | SONG_STEP);
m_SndFile.LoopPattern(nPat);
- m_SndFile.m_nNextRow = nRow;
+ m_SndFile.m_PlayState.m_nNextRow = nRow;
// set playback timer in the status bar (and update channel status)
SetElapsedTime(nOrd, nRow);
@@ -2503,7 +2503,7 @@
// Cut instruments/samples
for(CHANNELINDEX i = m_SndFile.GetNumChannels(); i < MAX_CHANNELS; i++)
{
- m_SndFile.Chn[i].dwFlags.set(CHN_NOTEFADE | CHN_KEYOFF);
+ m_SndFile.m_PlayState.Chn[i].dwFlags.set(CHN_NOTEFADE | CHN_KEYOFF);
}
m_SndFile.m_SongFlags.reset(SONG_PAUSED | SONG_STEP);
m_SndFile.SetCurrentOrder(nOrd);
@@ -2511,7 +2511,7 @@
m_SndFile.DontLoopPattern(nPat, nRow);
else
m_SndFile.LoopPattern(nPat);
- m_SndFile.m_nNextRow = nRow;
+ m_SndFile.m_PlayState.m_nNextRow = nRow;
// set playback timer in the status bar (and update channel status)
SetElapsedTime(nOrd, nRow);
@@ -2668,7 +2668,7 @@
// Search for available channel
for(CHANNELINDEX j = m_SndFile.m_nChannels; j < MAX_CHANNELS; j++)
{
- const ModChannel &chn = m_SndFile.Chn[j];
+ const ModChannel &chn = m_SndFile.m_PlayState.Chn[j];
if(!chn.nLength)
return j;
else if(chn.dwFlags[CHN_NOTEFADE])
Modified: trunk/OpenMPT/mptrack/Modedit.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Modedit.cpp 2014-02-27 23:28:17 UTC (rev 3787)
+++ trunk/OpenMPT/mptrack/Modedit.cpp 2014-02-28 01:52:36 UTC (rev 3788)
@@ -203,7 +203,7 @@
for(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); nChn++)
{
settings[nChn] = m_SndFile.ChnSettings[nChn];
- chns[nChn] = m_SndFile.Chn[nChn];
+ chns[nChn] = m_SndFile.m_PlayState.Chn[nChn];
recordStates[nChn] = IsChannelRecord(nChn);
chnMutePendings[nChn] = m_SndFile.m_bChannelMuteTogglePending[nChn];
}
@@ -215,7 +215,7 @@
if(newOrder[nChn] < GetNumChannels())
{
m_SndFile.ChnSettings[nChn] = settings[newOrder[nChn]];
- m_SndFile.Chn[nChn] = chns[newOrder[nChn]];
+ m_SndFile.m_PlayState.Chn[nChn] = chns[newOrder[nChn]];
if(recordStates[newOrder[nChn]] == 1) Record1Channel(nChn, true);
if(recordStates[newOrder[nChn]] == 2) Record2Channel(nChn, true);
m_SndFile.m_bChannelMuteTogglePending[nChn] = chnMutePendings[newOrder[nChn]];
@@ -233,7 +233,7 @@
for(CHANNELINDEX nChn = GetNumChannels(); nChn < MAX_BASECHANNELS; nChn++)
{
m_SndFile.InitChannel(nChn);
- m_SndFile.Chn[nChn].dwFlags.set(CHN_MUTE);
+ m_SndFile.m_PlayState.Chn[nChn].dwFlags.set(CHN_MUTE);
}
return GetNumChannels();
Modified: trunk/OpenMPT/mptrack/PSRatioCalc.cpp
===================================================================
--- trunk/OpenMPT/mptrack/PSRatioCalc.cpp 2014-02-27 23:28:17 UTC (rev 3787)
+++ trunk/OpenMPT/mptrack/PSRatioCalc.cpp 2014-02-28 01:52:36 UTC (rev 3788)
@@ -28,8 +28,8 @@
if(sampleRate <= 0)
sampleRate = 8363;
- m_nSpeed = sndFile.m_nMusicSpeed;
- m_nTempo = sndFile.m_nMusicTempo;
+ m_nSpeed = sndFile.m_PlayState.m_nMusicSpeed;
+ m_nTempo = sndFile.m_PlayState.m_nMusicTempo;
// Sample rate will not change. We can calculate original duration once and disgard sampleRate.
m_lMsOrig = static_cast<ULONGLONG>(1000.0 * ((double)smp.nLength / sampleRate));
@@ -151,7 +151,7 @@
void CPSRatioCalc::CalcRows()
{
- double rowTime = sndFile.GetRowDuration(sndFile.m_nMusicTempo, sndFile.m_nMusicSpeed);
+ double rowTime = sndFile.GetRowDuration(sndFile.m_PlayState.m_nMusicTempo, sndFile.m_PlayState.m_nMusicSpeed);
m_dRowsOrig = (double)m_lMsOrig / rowTime;
m_dRowsNew = m_dRowsOrig*(m_dRatio / 100);
Modified: trunk/OpenMPT/mptrack/View_ins.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_ins.cpp 2014-02-27 23:28:17 UTC (rev 3787)
+++ trunk/OpenMPT/mptrack/View_ins.cpp 2014-02-28 01:52:36 UTC (rev 3788)
@@ -583,9 +583,9 @@
// Update mixing flags...
for(CHANNELINDEX nChn = 0; nChn < MAX_CHANNELS; nChn++)
{
- if(sndFile.Chn[nChn].pModInstrument == &ins)
+ if(sndFile.m_PlayState.Chn[nChn].pModInstrument == &ins)
{
- sndFile.Chn[nChn].GetEnvelope(envelope).flags.set(flags, enable);
+ sndFile.m_PlayState.Chn[nChn].GetEnvelope(envelope).flags.set(flags, enable);
}
}
@@ -886,7 +886,7 @@
m_dcMemMain.FillRect(&m_rcClient, CBrush::FromHandle(CMainFrame::brushBlack));
if (m_bGrid)
{
- DrawGrid(&m_dcMemMain, pModDoc->GetrSoundFile().m_nMusicSpeed);
+ DrawGrid(&m_dcMemMain, pModDoc->GetrSoundFile().m_PlayState.m_nMusicSpeed);
}
// Middle line (half volume or pitch / panning center)
Modified: trunk/OpenMPT/mptrack/View_pat.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_pat.cpp 2014-02-27 23:28:17 UTC (rev 3787)
+++ trunk/OpenMPT/mptrack/View_pat.cpp 2014-02-28 01:52:36 UTC (rev 3788)
@@ -1680,7 +1680,7 @@
const bool isMuted = pModDoc->IsChannelMuted(chn);
if(!isMuted) pModDoc->MuteChannel(chn, true);
- pSndFile->Chn[chn].Reset(ModChannel::resetTotal, *pSndFile, chn);
+ pSndFile->m_PlayState.Chn[chn].Reset(ModChannel::resetTotal, *pSndFile, chn);
if(!isMuted) pModDoc->MuteChannel(chn, false);
}
@@ -2459,10 +2459,10 @@
// Cut instruments/samples in virtual channels
for(CHANNELINDEX i = pSndFile->GetNumChannels(); i < MAX_CHANNELS; i++)
{
- pSndFile->Chn[i].dwFlags.set(CHN_NOTEFADE | CHN_KEYOFF);
+ pSndFile->m_PlayState.Chn[i].dwFlags.set(CHN_NOTEFADE | CHN_KEYOFF);
}
pSndFile->LoopPattern(m_nPattern);
- pSndFile->m_nNextRow = row == ROWINDEX_INVALID ? GetCurrentRow() : row;
+ pSndFile->m_PlayState.m_nNextRow = row == ROWINDEX_INVALID ? GetCurrentRow() : row;
pSndFile->m_SongFlags.reset(SONG_PAUSED);
pSndFile->m_SongFlags.set(SONG_STEP);
@@ -3657,7 +3657,7 @@
ROWINDEX nRow = GetCurrentRow();
PATTERNINDEX nPattern = m_nPattern;
if(IsLiveRecord())
- SetEditPos(*pSndFile, nRow, nPattern, pSndFile->m_nRow, pSndFile->m_nPattern);
+ SetEditPos(*pSndFile, nRow, nPattern, pSndFile->m_PlayState.m_nRow, pSndFile->m_PlayState.m_nPattern);
ModCommand *pRow = pSndFile->Patterns[nPattern].GetpModCommand(nRow, nChn);
@@ -3685,7 +3685,7 @@
//Figure out which plug param (if any) is controllable using the active macro on this channel.
long activePlugParam = -1;
- BYTE activeMacro = pSndFile->Chn[nChn].nActiveMacro;
+ BYTE activeMacro = pSndFile->m_PlayState.Chn[nChn].nActiveMacro;
if (pSndFile->m_MidiCfg.GetParameteredMacroType(activeMacro) == sfx_plug)
{
@@ -3699,7 +3699,7 @@
int foundMacro = pSndFile->m_MidiCfg.FindMacroForParam(paramIndex);
if (foundMacro >= 0)
{
- pSndFile->Chn[nChn].nActiveMacro = foundMacro;
+ pSndFile->m_PlayState.Chn[nChn].nActiveMacro = foundMacro;
if (pRow->command == CMD_NONE || pRow->command == CMD_SMOOTHMIDI || pRow->command == CMD_MIDI) //we overwrite existing Zxx and \xx only.
{
pModDoc->GetPatternUndo().PrepareUndo(nPattern, nChn, nRow, 1, 1, "Automation Entry");
@@ -3737,7 +3737,7 @@
if(m_nPlayPat != PATTERNINDEX_INVALID)
SetEditPos(rSf, editpos.row, editpos.pattern, m_nPlayRow, m_nPlayPat);
else
- SetEditPos(rSf, editpos.row, editpos.pattern, rSf.m_nRow, rSf.m_nPattern);
+ SetEditPos(rSf, editpos.row, editpos.pattern, rSf.m_PlayState.m_nRow, rSf.m_PlayState.m_nPattern);
} else
{
editpos.pattern = m_nPattern;
@@ -5178,7 +5178,7 @@
{
newcmd.command = (sndFile.TypeIsS3M_IT_MPT()) ? CMD_S3MCMDEX : CMD_MODCMDEX;
UINT maxSpeed = 0x0F;
- if(sndFile.m_nMusicSpeed > 0) maxSpeed = MIN(0x0F, sndFile.m_nMusicSpeed - 1);
+ if(sndFile.m_PlayState.m_nMusicSpeed > 0) maxSpeed = MIN(0x0F, sndFile.m_PlayState.m_nMusicSpeed - 1);
newcmd.param = 0xD0 + MIN(maxSpeed, m_nPlayTick);
}
}
@@ -5612,8 +5612,8 @@
return;
}
- const ROWINDEX currentTick = sndFile->m_nMusicSpeed * row + m_nPlayTick;
- const ROWINDEX ticksPerNote = TrackerSettings::Instance().recordQuantizeRows * sndFile->m_nMusicSpeed;
+ const ROWINDEX currentTick = sndFile->m_PlayState.m_nMusicSpeed * row + m_nPlayTick;
+ const ROWINDEX ticksPerNote = TrackerSettings::Instance().recordQuantizeRows * sndFile->m_PlayState.m_nMusicSpeed;
// Previous quantization step
const ROWINDEX quantLow = (currentTick / ticksPerNote) * ticksPerNote;
@@ -5622,10 +5622,10 @@
if(currentTick - quantLow < quantHigh - currentTick)
{
- row = quantLow / sndFile->m_nMusicSpeed;
+ row = quantLow / sndFile->m_PlayState.m_nMusicSpeed;
} else
{
- row = quantHigh / sndFile->m_nMusicSpeed;
+ row = quantHigh / sndFile->m_PlayState.m_nMusicSpeed;
}
if(!sndFile->Patterns[pat].IsValidRow(row))
Modified: trunk/OpenMPT/mptrack/View_smp.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_smp.cpp 2014-02-27 23:28:17 UTC (rev 3787)
+++ trunk/OpenMPT/mptrack/View_smp.cpp 2014-02-28 01:52:36 UTC (rev 3788)
@@ -2222,9 +2222,9 @@
p[i] = (signed char) ((*((short int *)(p+i*2))) / 256);
}
sample.uFlags.reset(CHN_16BIT);
- for (CHANNELINDEX j = 0; j < MAX_CHANNELS; j++) if (sndFile.Chn[j].pModSample == &sample)
+ for (CHANNELINDEX j = 0; j < MAX_CHANNELS; j++) if (sndFile.m_PlayState.Chn[j].pModSample == &sample)
{
- sndFile.Chn[j].dwFlags.reset(CHN_16BIT);
+ sndFile.m_PlayState.Chn[j].dwFlags.reset(CHN_16BIT);
}
sample.PrecomputeLoops(sndFile, false);
@@ -2415,7 +2415,7 @@
{
CSoundFile &sndFile = GetDocument()->GetrSoundFile();
sndFile.KeyOff(noteChannel[note - NOTE_MIN]);
- sndFile.Chn[noteChannel[note - NOTE_MIN]].dwFlags.set(CHN_NOTEFADE);
+ sndFile.m_PlayState.Chn[noteChannel[note - NOTE_MIN]].dwFlags.set(CHN_NOTEFADE);
noteChannel[note - NOTE_MIN] = CHANNELINDEX_INVALID;
}
Modified: trunk/OpenMPT/mptrack/View_tre.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_tre.cpp 2014-02-27 23:28:17 UTC (rev 3787)
+++ trunk/OpenMPT/mptrack/View_tre.cpp 2014-02-28 01:52:36 UTC (rev 3788)
@@ -2250,13 +2250,13 @@
for(CHANNELINDEX nChn = 0; nChn < MAX_CHANNELS; nChn++)
{
- if(sndFile.Chn[nChn].pCurrentSample != nullptr)
+ if(sndFile.m_PlayState.Chn[nChn].pCurrentSample != nullptr)
{
if(updateSamples)
{
for(SAMPLEINDEX nSmp = sndFile.GetNumSamples(); nSmp >= 1; nSmp--)
{
- if(sndFile.Chn[nChn].pModSample == &sndFile.GetSample(nSmp))
+ if(sndFile.m_PlayState.Chn[nChn].pModSample == &sndFile.GetSample(nSmp))
{
pInfo->samplesPlaying.set(nSmp);
break;
@@ -2267,7 +2267,7 @@
{
for(INSTRUMENTINDEX nIns = sndFile.GetNumInstruments(); nIns >= 1; nIns--)
{
- if(sndFile.Chn[nChn].pModInstrument == sndFile.Instruments[nIns])
+ if(sndFile.m_PlayState.Chn[nChn].pModInstrument == sndFile.Instruments[nIns])
{
pInfo->instrumentsPlaying.set(nIns);
break;
Modified: trunk/OpenMPT/mptrack/Vstplug.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Vstplug.cpp 2014-02-27 23:28:17 UTC (rev 3787)
+++ trunk/OpenMPT/mptrack/Vstplug.cpp 2014-02-28 01:52:36 UTC (rev 3788)
@@ -146,7 +146,7 @@
// Time signature. numerator = rows per beats / rows pear measure (should sound somewhat logical to you).
// the denominator is a bit more tricky, since it cannot be set explicitely. so we just assume quarters for now.
- timeInfo.timeSigNumerator = sndFile.m_nCurrentRowsPerMeasure / MAX(sndFile.m_nCurrentRowsPerBeat, 1);
+ timeInfo.timeSigNumerator = sndFile.m_PlayState.m_nCurrentRowsPerMeasure / MAX(sndFile.m_PlayState.m_nCurrentRowsPerBeat, 1);
timeInfo.timeSigDenominator = 4; //gcd(pSndFile->m_nCurrentRowsPerMeasure, pSndFile->m_nCurrentRowsPerBeat);
}
}
Modified: trunk/OpenMPT/soundlib/Fastmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Fastmix.cpp 2014-02-27 23:28:17 UTC (rev 3787)
+++ trunk/OpenMPT/soundlib/Fastmix.cpp 2014-02-28 01:52:36 UTC (rev 3788)
@@ -284,7 +284,7 @@
for(uint32 nChn = 0; nChn < m_nMixChannels; nChn++)
{
- ModChannel &chn = Chn[ChnMix[nChn]];
+ ModChannel &chn = m_PlayState.Chn[m_PlayState.ChnMix[nChn]];
uint32 functionNdx = 0;
if(!chn.pCurrentSample) continue;
@@ -317,7 +317,7 @@
pbuffer = MixRearBuffer;
//Look for plugins associated with this implicit tracker channel.
- PLUGINDEX nMixPlugin = GetBestPlugin(ChnMix[nChn], PrioritiseInstrument, RespectMutes);
+ PLUGINDEX nMixPlugin = GetBestPlugin(m_PlayState.ChnMix[nChn], PrioritiseInstrument, RespectMutes);
if ((nMixPlugin > 0) && (nMixPlugin <= MAX_MIXPLUGINS))
{
Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp
===================================================================
--- trunk/OpenMPT/soundlib/SampleFormats.cpp 2014-02-27 23:28:17 UTC (rev 3787)
+++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2014-02-28 01:52:36 UTC (rev 3788)
@@ -184,9 +184,9 @@
Instruments[nInstr] = nullptr;
for(CHANNELINDEX i = 0; i < MAX_CHANNELS; i++)
{
- if (Chn[i].pModInstrument == pIns)
+ if (m_PlayState.Chn[i].pModInstrument == pIns)
{
- Chn[i].pModInstrument = nullptr;
+ m_PlayState.Chn[i].pModInstrument = nullptr;
}
}
delete pIns;
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-02-27 23:28:17 UTC (rev 3787)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-02-28 01:52:36 UTC (rev 3788)
@@ -122,12 +122,12 @@
retval.lastOrder = retval.endOrder = ORDERINDEX_INVALID;
retval.lastRow = retval.endRow = ROWINDEX_INVALID;
- ModChannel origChannels[CountOf(Chn)];
+ ModChannel origChannels[CountOf(m_PlayState.Chn)];
if(adjustMode & eAdjust)
{
- for(CHANNELINDEX i = 0; i < CountOf(Chn); i++)
+ for(CHANNELINDEX i = 0; i < CountOf(m_PlayState.Chn); i++)
{
- origChannels[i] = Chn[i];
+ origChannels[i] = m_PlayState.Chn[i];
}
}
@@ -255,7 +255,7 @@
memory.chnSettings[chn].patLoop = memory.elapsedTime;
}
- ModChannel *pChn = Chn;
+ ModChannel *pChn = m_PlayState.Chn;
ModCommand *p = Patterns[nPattern].GetRow(nRow);
ModCommand *nextRow = nullptr;
for(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); p++, pChn++, nChn++) if(!p->IsEmpty())
@@ -565,7 +565,7 @@
if((adjustMode & eAdjustSamplePositions) == eAdjustSamplePositions)
{
// Super experimental and dirty sample seeking
- pChn = Chn;
+ pChn = m_PlayState.Chn;
p = Patterns[nPattern].GetRow(nRow);
for(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); p++, pChn++, nChn++)
{
@@ -674,55 +674,55 @@
if(retval.targetReached || target.mode == GetLengthTarget::NoTarget)
{
// Target found, or there is no target (i.e. play whole song)...
- m_nGlobalVolume = memory.glbVol;
- m_nFrameDelay = m_nPatternDelay = 0;
- m_lTotalSampleCount = memory.renderedSamples;
- m_bPositionChanged = true;
+ m_PlayState.m_nGlobalVolume = memory.glbVol;
+ m_PlayState.m_nFrameDelay = m_PlayState.m_nPatternDelay = 0;
+ m_PlayState.m_lTotalSampleCount = memory.renderedSamples;
+ m_PlayState.m_bPositionChanged = true;
if(IsCompatibleMode(TRK_IMPULSETRACKER | TRK_FASTTRACKER2))
{
// IT compatibility 16. Global volume slide params are stored per channel (FT2/IT)
for(CHANNELINDEX n = 0; n < GetNumChannels(); n++)
{
- Chn[n].nOldGlobalVolSlide = memory.chnSettings[n].oldGlbVolSlide;
+ m_PlayState.Chn[n].nOldGlobalVolSlide = memory.chnSettings[n].oldGlbVolSlide;
}
} else
{
- m_nOldGlbVolSlide = memory.chnSettings[0].oldGlbVolSlide;
+ m_PlayState.m_nOldGlbVolSlide = memory.chnSettings[0].oldGlbVolSlide;
}
- m_nMusicSpeed = memory.musicSpeed;
- m_nMusicTempo = memory.musicTempo;
+ m_PlayState.m_nMusicSpeed = memory.musicSpeed;
+ m_PlayState.m_nMusicTempo = memory.musicTempo;
for(CHANNELINDEX n = 0; n < GetNumChannels(); n++)
{
- Chn[n].nOldHiOffset = memory.chnSettings[n].hiOffset;
- Chn[n].nGlobalVol = memory.chnSettings[n].chnVol;
+ m_PlayState.Chn[n].nOldHiOffset = memory.chnSettings[n].hiOffset;
+ m_PlayState.Chn[n].nGlobalVol = memory.chnSettings[n].chnVol;
if(memory.chnSettings[n].note != NOTE_NONE)
{
- Chn[n].nNewNote = memory.chnSettings[n].note;
+ m_PlayState.Chn[n].nNewNote = memory.chnSettings[n].note;
if(ModCommand::IsNote(memory.chnSettings[n].note))
{
- Chn[n].nLastNote = memory.chnSettings[n].note;
+ m_PlayState.Chn[n].nLastNote = memory.chnSettings[n].note;
}
}
- if(memory.chnSettings[n].instr) Chn[n].nNewIns = memory.chnSettings[n].instr;
+ if(memory.chnSettings[n].instr) m_PlayState.Chn[n].nNewIns = memory.chnSettings[n].instr;
if(memory.chnSettings[n].vol != 0xFF)
{
if(memory.chnSettings[n].vol > 64) memory.chnSettings[n].vol = 64;
- Chn[n].nVolume = memory.chnSettings[n].vol * 4;
+ m_PlayState.Chn[n].nVolume = memory.chnSettings[n].vol * 4;
}
}
} else if(adjustMode != eAdjustOnSuccess)
{
// Target not found (e.g. when jumping to a hidden sub song), reset global variables...
- m_nMusicSpeed = m_nDefaultSpeed;
- m_nMusicTempo = m_nDefaultTempo;
- m_nGlobalVolume = m_nDefaultGlobalVolume;
- for(CHANNELINDEX i = 0; i < CountOf(Chn); i++)
+ m_PlayState.m_nMusicSpeed = m_nDefaultSpeed;
+ m_PlayState.m_nMusicTempo = m_nDefaultTempo;
+ m_PlayState.m_nGlobalVolume = m_nDefaultGlobalVolume;
+ for(CHANNELINDEX i = 0; i < CountOf(m_PlayState.Chn); i++)
{
- Chn[i] = origChannels[i];
+ m_PlayState.Chn[i] = origChannels[i];
}
}
// When adjusting the playback status, we will also want to update the visited rows vector according to the current position.
- visitedSongRows.Set(visitedRows);
+ m_PlayState.visitedSongRows.Set(visitedRows);
}
return retval;
@@ -1080,7 +1080,7 @@
//-------------------------------------------------------------------------------------------------
{
if (note < NOTE_MIN) return;
- ModChannel *pChn = &Chn[nChn];
+ ModChannel *pChn = &m_PlayState.Chn[nChn];
const ModSample *pSmp = pChn->pModSample;
const ModInstrument *pIns = pChn->pModInstrument;
@@ -1411,16 +1411,16 @@
CHANNELINDEX CSoundFile::GetNNAChannel(CHANNELINDEX nChn) const
//-------------------------------------------------------------
{
- const ModChannel *pChn = &Chn[nChn];
+ const ModChannel *pChn = &m_PlayState.Chn[nChn];
// Check for empty channel
- const ModChannel *pi = &Chn[m_nChannels];
+ const ModChannel *pi = &m_PlayState.Chn[m_nChannels];
for (CHANNELINDEX i=m_nChannels; i<MAX_CHANNELS; i++, pi++) if (!pi->nLength) return i;
if (!pChn->nFadeOutVol) return 0;
// All channels are used: check for lowest volume
CHANNELINDEX result = 0;
DWORD vol = 64*65536; // 25%
DWORD envpos = 0xFFFFFF;
- const ModChannel *pj = &Chn[m_nChannels];
+ const ModChannel *pj = &m_PlayState.Chn[m_nChannels];
for (CHANNELINDEX j=m_nChannels; j<MAX_CHANNELS; j++, pj++)
{
if (!pj->nFadeOutVol) return j;
@@ -1444,7 +1444,7 @@
void CSoundFile::CheckNNA(CHANNELINDEX nChn, UINT instr, int note, bool forceCut)
//-------------------------------------------------------------------------------
{
- ModChannel *pChn = &Chn[nChn];
+ ModChannel *pChn = &m_PlayState.Chn[nChn];
const ModInstrument *pIns = nullptr;
if(!ModCommand::IsNote(note))
{
@@ -1460,7 +1460,7 @@
CHANNELINDEX n = GetNNAChannel(nChn);
if(!n) return;
- ModChannel &chn = Chn[n];
+ ModChannel &chn = m_PlayState.Chn[n];
// Copy Channel
chn = *pChn;
chn.dwFlags.reset(CHN_VIBRATO | CHN_TREMOLO | CHN_PANBRELLO | CHN_MUTE | CHN_PORTAMENTO);
@@ -1624,7 +1624,7 @@
CHANNELINDEX n = GetNNAChannel(nChn);
if(n != 0)
{
- ModChannel *p = &Chn[n];
+ ModChannel *p = &m_PlayState.Chn[n];
// Copy Channel
*p = *pChn;
p->dwFlags.reset(CHN_VIBRATO | CHN_TREMOLO | CHN_PANBRELLO | CHN_MUTE | CHN_PORTAMENTO);
@@ -1681,13 +1681,13 @@
BOOL CSoundFile::ProcessEffects()
//-------------------------------
{
- ModChannel *pChn = Chn;
+ ModChannel *pChn = m_PlayState.Chn;
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)
+ if((m_PlayState.m_nTickCount & 0x0F) != 0 && GetType() == MOD_TYPE_STM)
{
return TRUE;
}
@@ -1706,7 +1706,7 @@
bool bPorta = (cmd == CMD_TONEPORTAMENTO) || (cmd == CMD_TONEPORTAVOL) || (volcmd == VOLCMD_TONEPORTAMENTO);
UINT nStartTick = 0;
- pChn->isFirstTick = (m_nTickCount == 0);
+ pChn->isFirstTick = (m_PlayState.m_nTickCount == 0);
pChn->dwFlags.reset(CHN_FASTVOLRAMP);
@@ -1745,7 +1745,7 @@
pChn->m_plugParamTargetValue = targetvalue;
pChn->m_plugParamValueStep = (targetvalue - m_MixPlugins[nPlug-1].pMixPlugin->GetParameter(plugparam)) / float(GetNumTicksOnCurrentRow());
}
- if(m_nTickCount + 1 == GetNumTicksOnCurrentRow())
+ if(m_PlayState.m_nTickCount + 1 == GetNumTicksOnCurrentRow())
{ // On last tick, set parameter exactly to target value.
m_MixPlugins[nPlug-1].pMixPlugin->SetParameter(plugparam, pChn->m_plugParamTargetValue);
}
@@ -1770,7 +1770,7 @@
// Process Invert Loop (MOD Effect, called every row)
if(!m_SongFlags[SONG_FIRSTTICK])
{
- InvertLoop(&Chn[nChn]);
+ InvertLoop(&m_PlayState.Chn[nChn]);
}
// Process special effects (note delay, pattern delay, pattern loop)
@@ -1838,8 +1838,8 @@
// ST3 doesn't have per-channel pattern loop memory, so spam all changes to other channels as well.
for (CHANNELINDEX i = 0; i < GetNumChannels(); i++)
{
- Chn[i].nPatternLoop = pChn->nPatternLoop;
- Chn[i].nPatternLoopCount = pChn->nPatternLoopCount;
+ m_PlayState.Chn[i].nPatternLoop = pChn->nPatternLoop;
+ m_PlayState.Chn[i].nPatternLoopCount = pChn->nPatternLoopCount;
}
}
} else if ((param & 0xF0) == 0xE0)
@@ -1848,13 +1848,13 @@
// In Scream Tracker 3 / Impulse Tracker, only the first delay command on this row is considered.
// Test cases: PatternDelays.it, PatternDelays.s3m, PatternDelays.xm
// XXX In Scream Tracker 3, the "left" channels are evaluated before the "right" channels, which is not emulated here!
- if(!(GetType() & (MOD_TYPE_S3M | MOD_TYPE_IT | MOD_TYPE_MPT)) || !m_nPatternDelay)
+ if(!(GetType() & (MOD_TYPE_S3M | MOD_TYPE_IT | MOD_TYPE_MPT)) || !m_PlayState.m_nPatternDelay)
{
if(!(GetType() & (MOD_TYPE_S3M)) || (param & 0x0F) != 0)
{
// While Impulse Tracker *does* count S60 as a valid row delay (and thus ignores any other row delay commands on the right),
// Scream Tracker 3 simply ignores such commands.
- m_nPatternDelay = 1 + (param & 0x0F);
+ m_PlayState.m_nPatternDelay = 1 + (param & 0x0F);
}
}
}
@@ -1868,13 +1868,13 @@
pChn->rowCommand.volcmd = VOLCMD_NONE;
}
- bool triggerNote = (m_nTickCount == nStartTick); // Can be delayed by a note delay effect
- if((GetType() & (MOD_TYPE_S3M | MOD_TYPE_IT | MOD_TYPE_MPT)) && nStartTick > 0 && (m_nTickCount % (m_nMusicSpeed + m_nFrameDelay)) == nStartTick)
+ bool triggerNote = (m_PlayState.m_nTickCount == nStartTick); // Can be delayed by a note delay effect
+ if((GetType() & (MOD_TYPE_S3M | MOD_TYPE_IT | MOD_TYPE_MPT)) && nStartTick > 0 && (m_PlayState.m_nTickCount % (m_PlayState.m_nMusicSpeed + m_PlayState.m_nFrameDelay)) == nStartTick)
{
// IT compatibility: Delayed notes (using SDx) that are on the same row as a Row Delay effect are retriggered. Scream Tracker 3 does the same.
// Test case: PatternDelay-NoteDelay.it
triggerNote = true;
- } else if(IsCompatibleMode(TRK_FASTTRACKER2) && nStartTick >= m_nMusicSpeed)
+ } else if(IsCompatibleMode(TRK_FASTTRACKER2) && nStartTick >= m_PlayState.m_nMusicSpeed)
{
// FT2 compatibility: Note delays greater than the song speed should be ignored.
// However, EEx pattern delay is *not* considered at all.
@@ -2193,13 +2193,13 @@
so... hxx = (hx | (oldhxx & 0xf0)) ???
TODO is this done correctly?
*/
- bool doVolumeColumn = m_nTickCount >= nStartTick;
+ bool doVolumeColumn = m_PlayState.m_nTickCount >= nStartTick;
// FT2 compatibility: If there's a note delay, volume column effects are NOT executed
// on the first tick and, if there's an instrument number, on the delayed tick.
// Test case: VolColDelay.xm, PortaDelay.xm
if(IsCompatibleMode(TRK_FASTTRACKER2) && nStartTick != 0)
{
- doVolumeColumn = m_nTickCount != 0 && (m_nTickCount != nStartTick || (pChn->rowCommand.instr == 0 && volcmd != VOLCMD_TONEPORTAMENTO));
+ doVolumeColumn = m_PlayState.m_nTickCount != 0 && (m_PlayState.m_nTickCount != nStartTick || (pChn->rowCommand.instr == 0 && volcmd != VOLCMD_TONEPORTAMENTO));
}
if(volcmd > VOLCMD_PANNING && doVolumeColumn)
{
@@ -2282,7 +2282,7 @@
case VOLCMD_FINEVOLUP:
// IT Compatibility: Fine volume slides in the volume column are only executed on the first tick, not on multiples of the first tick in case of pattern delay
// Test case: FineVolColSlide.it
- if(m_nTickCount == nStartTick || !IsCompatibleMode(TRK_IMPULSETRACKER))
+ if(m_PlayState.m_nTickCount == nStartTick || !IsCompatibleMode(TRK_IMPULSETRACKER))
{
// IT Compatibility: Volume column volume slides have their own memory
// Test case: VolColMemory.it
@@ -2293,7 +2293,7 @@
case VOLCMD_FINEVOLDOWN:
// IT Compatibility: Fine volume slides in the volume column are only executed on the first tick, not on multiples of the first tick in case of pattern delay
// Test case: FineVolColSlide.it
- if(m_nTickCount == nStartTick || !IsCompatibleMode(TRK_IMPULSETRACKER))
+ if(m_PlayState.m_nTickCount == nStartTick || !IsCompatibleMode(TRK_IMPULSETRACKER))
{
// IT Compatibility: Volume column volume slides have their own memory
// Test case: VolColMemory.it
@@ -2332,7 +2332,7 @@
break;
case VOLCMD_OFFSET: //rewbs.volOff
- if (m_nTickCount == nStartTick)
+ if (m_PlayState.m_nTickCount == nStartTick)
SampleOffset(nChn, vol << 3);
break;
}
@@ -2401,9 +2401,9 @@
// -> CODE#0010
// -> DESC="add extended parameter mechanism to pattern effects"
m = nullptr;
- if (m_nRow < Patterns[m_nPattern].GetNumRows()-1)
+ if (m_PlayState.m_nRow < Patterns[m_PlayState.m_nPattern].GetNumRows()-1)
{
- m = Patterns[m_nPattern].GetpModCommand(m_nRow + 1, nChn);
+ m = Patterns[m_PlayState.m_nPattern].GetpModCommand(m_PlayState.m_nRow + 1, nChn);
}
if (m && m->command == CMD_XPARAM)
{
@@ -2424,7 +2424,7 @@
// Set Offset
case CMD_OFFSET:
- if (m_nTickCount) break;
+ if (m_PlayState.m_nTickCount) break;
// FT2 compatibility: Portamento + Offset = Ignore offset
// Test case: porta-offset.xm
if(bPorta && GetType() == MOD_TYPE_XM)
@@ -2437,7 +2437,7 @@
// Arpeggio
case CMD_ARPEGGIO:
// IT compatibility 01. Don't ignore Arpeggio if no note is playing (also valid for ST3)
- if(m_nTickCount) break;
+ if(m_PlayState.m_nTickCount) break;
if((!pChn->nPeriod || !pChn->nNote)
&& (pChn->pModInstrument == nullptr || !pChn->pModInstrument->HasValidMIDIChannel()) // Plugin arpeggio
&& !IsCompatibleMode(TRK_IMPULSETRACKER | TRK_SCREAMTRACKER)) break;
@@ -2528,7 +2528,7 @@
// Test case: globalvol-invalid.it
if (param <= 128)
{
- m_nGlobalVolume = param * 2;
+ m_PlayState.m_nGlobalVolume = param * 2;
}
break;
@@ -2538,7 +2538,7 @@
if(IsCompatibleMode(TRK_IMPULSETRACKER | TRK_FASTTRACKER2))
GlobalVolSlide(param, pChn->nOldGlobalVolSlide);
else
- GlobalVolSlide(param, m_nOldGlbVolSlide);
+ GlobalVolSlide(param, m_PlayState.m_nOldGlbVolSlide);
break;
// Set 8-bit Panning
@@ -2610,7 +2610,7 @@
// This is how Key Off is supposed to sound... (in FT2 at least)
if(IsCompatibleMode(TRK_FASTTRACKER2))
{
- if (m_nTickCount == param)
+ if (m_PlayState.m_nTickCount == param)
{
// XM: Key-Off + Sample == Note Cut
if(pChn->pModInstrument == nullptr || !pChn->pModInstrument->VolEnv.dwFlags[ENV_ENABLED])
@@ -2692,11 +2692,11 @@
// Position Jump
case CMD_POSITIONJUMP:
- m_nNextPatStartRow = 0; // FT2 E60 bug
+ m_PlayState.m_nNextPatStartRow = 0; // FT2 E60 bug
nPosJump = param;
- if(m_SongFlags[SONG_PATTERNLOOP] && m_nSeqOverride == ORDERINDEX_INVALID)
+ if(m_SongFlags[SONG_PATTERNLOOP] && m_PlayState.m_nSeqOverride == ORDERINDEX_INVALID)
{
- m_nSeqOverride = param;
+ m_PlayState.m_nSeqOverride = param;
//Releasing pattern loop after position jump could cause
//instant jumps - modifying behavior so that now position jumps
//occurs also when pattern loop is enabled.
@@ -2718,12 +2718,12 @@
break;
}
- m_...
[truncated message content] |
|
From: <man...@us...> - 2014-02-28 13:13:07
|
Revision: 3792
http://sourceforge.net/p/modplug/code/3792
Author: manxorist
Date: 2014-02-28 13:12:54 +0000 (Fri, 28 Feb 2014)
Log Message:
-----------
[Ref] Move logging code to its own file Logging.cpp and cleanup the preprocessor mess.
[Ref] Refactor the (file,line,function) tuple into its own class mpt::log::Context .
Modified Paths:
--------------
trunk/OpenMPT/build/android_ndk/Android.mk
trunk/OpenMPT/common/Logging.h
trunk/OpenMPT/common/typedefs.cpp
trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj
trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters
trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj
trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj.filters
trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj
trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj.filters
trunk/OpenMPT/mptrack/mptrack_10.vcxproj
trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters
Added Paths:
-----------
trunk/OpenMPT/common/Logging.cpp
Modified: trunk/OpenMPT/build/android_ndk/Android.mk
===================================================================
--- trunk/OpenMPT/build/android_ndk/Android.mk 2014-02-28 12:07:16 UTC (rev 3791)
+++ trunk/OpenMPT/build/android_ndk/Android.mk 2014-02-28 13:12:54 UTC (rev 3792)
@@ -17,6 +17,7 @@
LOCAL_SRC_FILES := \
common/AudioCriticalSection.cpp \
common/stdafx.cpp \
+ common/Logging.cpp \
common/misc_util.cpp \
common/mptPathString.cpp \
common/mptString.cpp \
Added: trunk/OpenMPT/common/Logging.cpp
===================================================================
--- trunk/OpenMPT/common/Logging.cpp (rev 0)
+++ trunk/OpenMPT/common/Logging.cpp 2014-02-28 13:12:54 UTC (rev 3792)
@@ -0,0 +1,186 @@
+/*
+ * Logging.cpp
+ * -----------
+ * Purpose: General logging and user confirmation support
+ * Notes : (currently none)
+ * Authors: OpenMPT Devs
+ * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
+ */
+
+
+#include "stdafx.h"
+
+#include "Logging.h"
+
+#include <iostream>
+#include <cstring>
+
+
+//#define LOG_TO_FILE
+
+
+namespace mpt
+{
+namespace log
+{
+
+
+#ifndef NO_LOGGING
+
+
+static const std::size_t LOGBUF_SIZE = 1024;
+
+
+Context::Context(const char *file, int line, const char *function)
+//----------------------------------------------------------------
+ : file(file)
+ , line(line)
+ , function(function)
+{
+ return;
+}
+
+
+Context::Context(const Context &c)
+//--------------------------------
+ : file(c.file)
+ , line(c.line)
+ , function(c.function)
+{
+ return;
+}
+
+
+#if defined(MODPLUG_TRACKER)
+
+
+static uint64 GetTimeMS()
+//-----------------------
+{
+ FILETIME filetime;
+ GetSystemTimeAsFileTime(&filetime);
+ return ((uint64)filetime.dwHighDateTime << 32 | filetime.dwLowDateTime) / 10000;
+}
+
+
+static std::string TimeAsAsString(uint64 ms)
+//------------------------------------------
+{
+
+ FILETIME filetime;
+ SYSTEMTIME systime;
+ filetime.dwHighDateTime = (DWORD)(((uint64)ms * 10000) >> 32);
+ filetime.dwLowDateTime = (DWORD)((uint64)ms * 10000);
+ FileTimeToSystemTime(&filetime, &systime);
+
+ std::string result;
+ TCHAR buf[LOGBUF_SIZE];
+
+ GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, &systime, "yyyy-MM-dd ", buf, LOGBUF_SIZE);
+ result.append(buf);
+
+ GetTimeFormat(LOCALE_SYSTEM_DEFAULT, TIME_FORCE24HOURFORMAT, &systime, "HH:mm:ss.", buf, LOGBUF_SIZE);
+ result.append(buf);
+
+ sprintf(buf, "%03u", (unsigned)systime.wMilliseconds);
+ result.append(buf);
+
+ return result;
+}
+
+
+static std::string TimeDiffAsString(uint64 ms)
+//--------------------------------------------
+{
+ return mpt::fmt::dec<6>(ms);
+}
+
+
+static std::wstring TimeDiffAsStringW(uint64 ms)
+//----------------------------------------------
+{
+ return mpt::wfmt::dec<6>(ms);
+}
+
+
+#endif // MODPLUG_TRACKER
+
+
+static noinline void DoLog(const mpt::log::Context &context, std::wstring message)
+//--------------------------------------------------------------------------------
+{
+ // remove eol if already present
+ message = mpt::String::RTrim(message, L"\r\n");
+ #if defined(MODPLUG_TRACKER)
+ static uint64_t s_lastlogtime = 0;
+ uint64 cur = GetTimeMS();
+ uint64 diff = cur - s_lastlogtime;
+ s_lastlogtime = cur;
+ #ifdef LOG_TO_FILE
+ {
+ static FILE * s_logfile = nullptr;
+ if(!s_logfile)
+ {
+ s_logfile = mpt_fopen(MPT_PATHSTRING("mptrack.log"), "a");
+ }
+ if(s_logfile)
+ {
+ fprintf(s_logfile, "%s+%s %s(%i): %s [%s]\n", TimeAsAsString(cur).c_str(), TimeDiffAsString(diff).c_str(), context.file, context.line, mpt::To(mpt::CharsetUTF8, message).c_str(), context.function);
+ fflush(s_logfile);
+ }
+ }
+ #endif // LOG_TO_FILE
+ {
+ OutputDebugStringW(mpt::String::PrintW(L"%1(%2): +%3 %4 [%5]\n", mpt::ToWide(mpt::CharsetASCII, context.file), context.line, TimeDiffAsStringW(diff), message, mpt::ToWide(mpt::CharsetASCII, context.function)).c_str());
+ }
+ #else // !MODPLUG_TRACKER
+ std::clog
+ << "openmpt: "
+ << context.file << "(" << context.line << ")" << ": "
+ << mpt::ToLocale(message)
+ << " [" << context.function << "]"
+ << std::endl;
+ #endif // MODPLUG_TRACKER
+}
+
+
+static noinline void DoLog(const mpt::log::Context &context, const char *format, va_list args)
+//--------------------------------------------------------------------------------------------
+{
+ char message[LOGBUF_SIZE];
+ va_list va;
+ va_copy(va, args);
+ vsnprintf(message, LOGBUF_SIZE, format, va);
+ message[LOGBUF_SIZE - 1] = '\0';
+ va_end(va);
+ DoLog(context, mpt::ToWide(mpt::CharsetLocale, message));
+}
+
+
+void Logger::operator () (const char *format, ...)
+//------------------------------------------------
+{
+ va_list va;
+ va_start(va, format);
+ DoLog(context, format, va);
+ va_end(va);
+}
+
+void Logger::operator () (const std::string &text)
+//------------------------------------------------
+{
+ DoLog(context, mpt::ToWide(mpt::CharsetLocale, text));
+}
+
+void Logger::operator () (const std::wstring &text)
+//-------------------------------------------------
+{
+ DoLog(context, text);
+}
+
+
+#endif // !NO_LOGGING
+
+
+} // namespace log
+} // namespace mpt
Property changes on: trunk/OpenMPT/common/Logging.cpp
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/x-c++src
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/OpenMPT/common/Logging.h
===================================================================
--- trunk/OpenMPT/common/Logging.h 2014-02-28 12:07:16 UTC (rev 3791)
+++ trunk/OpenMPT/common/Logging.h 2014-02-28 13:12:54 UTC (rev 3792)
@@ -41,27 +41,47 @@
};
+
+namespace mpt
+{
+namespace log
+{
+
+
#ifndef NO_LOGGING
-void MPT_PRINTF_FUNC(1,2) Log(const char *format, ...);
-void Log(const std::string &text);
-void Log(const std::wstring &text);
-class Logger
+
+
+class Context
{
-private:
+public:
const char * const file;
- int const line;
+ const int line;
const char * const function;
public:
- Logger(const char *file_, int line_, const char *function_) : file(file_), line(line_), function(function_) {}
+ Context(const char *file, int line, const char *function);
+ Context(const Context &c);
+}; // class Context
+
+#define MPT_LOG_CURRENTCONTEXT() ::mpt::log::Context( __FILE__ , __LINE__ , __FUNCTION__ )
+
+
+class Logger
+{
+private:
+ const Context &context;
+public:
+ Logger(const Context &context) : context(context) {}
void MPT_PRINTF_FUNC(2,3) operator () (const char *format, ...);
void operator () (const std::string &text);
void operator () (const std::wstring &text);
};
-#define Log Logger(__FILE__, __LINE__, __FUNCTION__)
+
+#define Log ::mpt::log::Logger(MPT_LOG_CURRENTCONTEXT())
+
+
#else // !NO_LOGGING
-static inline void MPT_PRINTF_FUNC(1,2) Log(const char * /*format*/, ...) {}
-static inline void Log(const std::string & /*text*/ ) {}
-static inline void Log(const std::wstring & /*text*/ ) {}
+
+
class Logger
{
public:
@@ -69,9 +89,12 @@
inline void operator () (const std::string & /*text*/ ) {}
inline void operator () (const std::wstring & /*text*/ ) {}
};
-#define Log if(true) {} else Logger() // completely compile out arguments to Log() so that they do not even get evaluated
+
+#define Log if(true) {} else ::mpt::log::Logger() // completely compile out arguments to Log() so that they do not even get evaluated
+
+
#endif // NO_LOGGING
-// just #undef Log in files, where this Log redefinition causes problems
-//#undef Log
+} // namespace log
+} // namespace mpt
Modified: trunk/OpenMPT/common/typedefs.cpp
===================================================================
--- trunk/OpenMPT/common/typedefs.cpp 2014-02-28 12:07:16 UTC (rev 3791)
+++ trunk/OpenMPT/common/typedefs.cpp 2014-02-28 13:12:54 UTC (rev 3792)
@@ -10,8 +10,7 @@
#include "stdafx.h"
#include "typedefs.h"
-#include <iostream>
-#include <cstring>
+#include "Logging.h"
#if !defined(MODPLUG_TRACKER) && defined(MPT_ASSERT_HANDLER_NEEDED)
@@ -21,190 +20,12 @@
{
if(msg)
{
- Logger(file, line, function)("ASSERTION FAILED: %s (%s)", msg, expr);
+ mpt::log::Logger(mpt::log::Context(file, line, function))("ASSERTION FAILED: %s (%s)", msg, expr);
} else
{
- Logger(file, line, function)("ASSERTION FAILED: %s", expr);
+ mpt::log::Logger(mpt::log::Context(file, line, function))("ASSERTION FAILED: %s", expr);
}
}
#endif // !MODPLUG_TRACKER && MPT_ASSERT_HANDLER_NEEDED
-
-//#define LOG_TO_FILE
-
-
-static const std::size_t LOGBUF_SIZE = 1024;
-
-
-#if defined(MODPLUG_TRACKER) && !defined(NO_LOGGING)
-
-
-static uint64 GetTimeMS()
-//-----------------------
-{
- FILETIME filetime;
- GetSystemTimeAsFileTime(&filetime);
- return ((uint64)filetime.dwHighDateTime << 32 | filetime.dwLowDateTime) / 10000;
-}
-
-static std::string TimeAsAsString(uint64 ms)
-//------------------------------------------
-{
-
- FILETIME filetime;
- SYSTEMTIME systime;
- filetime.dwHighDateTime = (DWORD)(((uint64)ms * 10000) >> 32);
- filetime.dwLowDateTime = (DWORD)((uint64)ms * 10000);
- FileTimeToSystemTime(&filetime, &systime);
-
- std::string result;
- TCHAR buf[LOGBUF_SIZE];
-
- GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, &systime, "yyyy-MM-dd ", buf, LOGBUF_SIZE);
- result.append(buf);
-
- GetTimeFormat(LOCALE_SYSTEM_DEFAULT, TIME_FORCE24HOURFORMAT, &systime, "HH:mm:ss.", buf, LOGBUF_SIZE);
- result.append(buf);
-
- sprintf(buf, "%03u", (unsigned)systime.wMilliseconds);
- result.append(buf);
-
- return result;
-}
-
-static std::string TimeDiffAsString(uint64 ms)
-//--------------------------------------------
-{
- return mpt::fmt::dec<6>(ms);
-}
-
-
-static std::wstring TimeDiffAsStringW(uint64 ms)
-//----------------------------------------------
-{
- return mpt::wfmt::dec<6>(ms);
-}
-
-
-#endif // MODPLUG_TRACKER
-
-
-static noinline void DoLog(const char *file, int line, const char *function, std::wstring message)
-//------------------------------------------------------------------------------------------------
-{
-#if !defined(MODPLUG_TRACKER) || (defined(MODPLUG_TRACKER) && !defined(NO_LOGGING))
- if(!file)
- {
- file = "unknown";
- }
- if(!function)
- {
- function = "";
- }
- // remove eol if already present
- message = mpt::String::RTrim(message, L"\r\n");
- #if defined(MODPLUG_TRACKER)
- static uint64_t s_lastlogtime = 0;
- uint64 cur = GetTimeMS();
- uint64 diff = cur - s_lastlogtime;
- s_lastlogtime = cur;
- #ifdef LOG_TO_FILE
- {
- static FILE * s_logfile = nullptr;
- if(!s_logfile)
- {
- s_logfile = mpt_fopen(MPT_PATHSTRING("mptrack.log"), "a");
- }
- if(s_logfile)
- {
- fprintf(s_logfile, "%s+%s %s(%i): %s [%s]\n", TimeAsAsString(cur).c_str(), TimeDiffAsString(diff).c_str(), file, line, mpt::To(mpt::CharsetUTF8, message).c_str(), function);
- fflush(s_logfile);
- }
- }
- #endif // LOG_TO_FILE
- {
- OutputDebugStringW(mpt::String::PrintW(L"%1(%2): +%3 %4 [%5]\n", mpt::ToWide(mpt::CharsetASCII, file), line, TimeDiffAsStringW(diff), message, mpt::ToWide(mpt::CharsetASCII, function)).c_str());
- }
- #else // !MODPLUG_TRACKER
- std::clog
- << "openmpt: "
- << file << "(" << line << ")" << ": "
- << mpt::ToLocale(message)
- << " [" << function << "]"
- << std::endl;
- #endif // MODPLUG_TRACKER
-#else
- MPT_UNREFERENCED_PARAMETER(file);
- MPT_UNREFERENCED_PARAMETER(line);
- MPT_UNREFERENCED_PARAMETER(function);
- MPT_UNREFERENCED_PARAMETER(message);
-#endif
-}
-
-
-static noinline void DoLog(const char *file, int line, const char *function, const char *format, va_list args)
-//------------------------------------------------------------------------------------------------------------
-{
-#if !defined(MODPLUG_TRACKER) || (defined(MODPLUG_TRACKER) && !defined(NO_LOGGING))
- char message[LOGBUF_SIZE];
- va_list va;
- va_copy(va, args);
- vsnprintf(message, LOGBUF_SIZE, format, va);
- message[LOGBUF_SIZE - 1] = '\0';
- va_end(va);
- DoLog(file, line, function, mpt::ToWide(mpt::CharsetLocale, message));
-#else
- MPT_UNREFERENCED_PARAMETER(file);
- MPT_UNREFERENCED_PARAMETER(line);
- MPT_UNREFERENCED_PARAMETER(function);
- MPT_UNREFERENCED_PARAMETER(format);
- MPT_UNREFERENCED_PARAMETER(args);
-#endif
-}
-
-
-#ifndef NO_LOGGING
-
-void Logger::operator () (const char *format, ...)
-//------------------------------------------------
-{
- va_list va;
- va_start(va, format);
- DoLog(file, line, function, format, va);
- va_end(va);
-}
-void Logger::operator () (const std::string &text)
-//------------------------------------------------
-{
- DoLog(file, line, function, mpt::ToWide(mpt::CharsetLocale, text));
-}
-void Logger::operator () (const std::wstring &text)
-//-------------------------------------------------
-{
- DoLog(file, line, function, text);
-}
-
-
-#undef Log
-void Log(const char * format, ...)
-//--------------------------------
-{
- va_list va;
- va_start(va, format);
- DoLog(nullptr, 0, nullptr, format, va);
- va_end(va);
-}
-void Log(const std::string &text)
-//-------------------------------
-{
- DoLog(nullptr, 0, nullptr, mpt::ToWide(mpt::CharsetLocale, text));
-}
-void Log(const std::wstring &text)
-//--------------------------------
-{
- DoLog(nullptr, 0, nullptr, text);
-}
-
-#endif // !NO_LOGGING
-
Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj
===================================================================
--- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2014-02-28 12:07:16 UTC (rev 3791)
+++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2014-02-28 13:12:54 UTC (rev 3792)
@@ -254,6 +254,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\common\AudioCriticalSection.cpp" />
+ <ClCompile Include="..\common\Logging.cpp" />
<ClCompile Include="..\common\misc_util.cpp" />
<ClCompile Include="..\common\mptPathString.cpp" />
<ClCompile Include="..\common\mptString.cpp" />
Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters
===================================================================
--- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters 2014-02-28 12:07:16 UTC (rev 3791)
+++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters 2014-02-28 13:12:54 UTC (rev 3792)
@@ -502,5 +502,8 @@
<ClCompile Include="libopenmpt_ext.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="..\common\Logging.cpp">
+ <Filter>Source Files\common</Filter>
+ </ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
Modified: trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj
===================================================================
--- trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj 2014-02-28 12:07:16 UTC (rev 3791)
+++ trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj 2014-02-28 13:12:54 UTC (rev 3792)
@@ -264,6 +264,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\common\AudioCriticalSection.cpp" />
+ <ClCompile Include="..\common\Logging.cpp" />
<ClCompile Include="..\common\misc_util.cpp" />
<ClCompile Include="..\common\mptPathString.cpp" />
<ClCompile Include="..\common\mptString.cpp" />
Modified: trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj.filters
===================================================================
--- trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj.filters 2014-02-28 12:07:16 UTC (rev 3791)
+++ trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj.filters 2014-02-28 13:12:54 UTC (rev 3792)
@@ -508,5 +508,8 @@
<ClCompile Include="libopenmpt_ext.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="..\common\Logging.cpp">
+ <Filter>Source Files\common</Filter>
+ </ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
Modified: trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj
===================================================================
--- trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj 2014-02-28 12:07:16 UTC (rev 3791)
+++ trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj 2014-02-28 13:12:54 UTC (rev 3792)
@@ -258,6 +258,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\common\AudioCriticalSection.cpp" />
+ <ClCompile Include="..\common\Logging.cpp" />
<ClCompile Include="..\common\misc_util.cpp" />
<ClCompile Include="..\common\mptPathString.cpp" />
<ClCompile Include="..\common\mptString.cpp" />
Modified: trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj.filters
===================================================================
--- trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj.filters 2014-02-28 12:07:16 UTC (rev 3791)
+++ trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj.filters 2014-02-28 13:12:54 UTC (rev 3792)
@@ -505,5 +505,8 @@
<ClCompile Include="libopenmpt_ext.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="..\common\Logging.cpp">
+ <Filter>Source Files\common</Filter>
+ </ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj
===================================================================
--- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2014-02-28 12:07:16 UTC (rev 3791)
+++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2014-02-28 13:12:54 UTC (rev 3792)
@@ -445,6 +445,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\common\AudioCriticalSection.cpp" />
+ <ClCompile Include="..\common\Logging.cpp" />
<ClCompile Include="..\common\misc_util.cpp" />
<ClCompile Include="..\common\mptPathString.cpp" />
<ClCompile Include="..\common\mptString.cpp" />
Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters
===================================================================
--- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2014-02-28 12:07:16 UTC (rev 3791)
+++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2014-02-28 13:12:54 UTC (rev 3792)
@@ -499,6 +499,9 @@
<ClCompile Include="..\soundlib\plugins\DmoToVst.cpp">
<Filter>Source Files\soundlib\plugins</Filter>
</ClCompile>
+ <ClCompile Include="..\common\Logging.cpp">
+ <Filter>Source Files\common</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\soundlib\Loaders.h">
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2014-02-28 13:22:26
|
Revision: 3793
http://sourceforge.net/p/modplug/code/3793
Author: manxorist
Date: 2014-02-28 13:22:16 +0000 (Fri, 28 Feb 2014)
Log Message:
-----------
[Ref] build: Emscripten already defines __EMSCRIPTEN__, no need to invent MPT_EMSCRIPTEN.
Modified Paths:
--------------
trunk/OpenMPT/build/make/Makefile.config.emscripten
trunk/OpenMPT/libopenmpt/libopenmpt_config.h
Modified: trunk/OpenMPT/build/make/Makefile.config.emscripten
===================================================================
--- trunk/OpenMPT/build/make/Makefile.config.emscripten 2014-02-28 13:12:54 UTC (rev 3792)
+++ trunk/OpenMPT/build/make/Makefile.config.emscripten 2014-02-28 13:22:16 UTC (rev 3793)
@@ -4,7 +4,7 @@
LD = em++
AR = emar
-CPPFLAGS += -DMPT_EMSCRIPTEN -DMPT_CHARSET_CPP -DMPT_CHARSET_ASSUME_UTF8_LOCALE
+CPPFLAGS += -DMPT_CHARSET_CPP -DMPT_CHARSET_ASSUME_UTF8_LOCALE
CXXFLAGS += -std=c++0x -fPIC
CFLAGS += -std=c99 -fPIC
LDFLAGS += -O2 -s DISABLE_EXCEPTION_CATCHING=0
Modified: trunk/OpenMPT/libopenmpt/libopenmpt_config.h
===================================================================
--- trunk/OpenMPT/libopenmpt/libopenmpt_config.h 2014-02-28 13:12:54 UTC (rev 3792)
+++ trunk/OpenMPT/libopenmpt/libopenmpt_config.h 2014-02-28 13:22:16 UTC (rev 3793)
@@ -38,7 +38,7 @@
#elif defined(__GNUC__) || defined(__clang__)
-#if !defined(MPT_EMSCRIPTEN)
+#if !defined(__EMSCRIPTEN__)
#if defined(_WIN32)
#define LIBOPENMPT_API_HELPER_EXPORT __declspec(dllexport)
#define LIBOPENMPT_API_HELPER_IMPORT __declspec(dllimport)
@@ -82,7 +82,8 @@
#endif
#endif
-#if defined(MPT_EMSCRIPTEN)
+#if defined(__EMSCRIPTEN__)
+
/* Only the C API is supported for emscripten. Disable the C++ API. */
#undef LIBOPENMPT_CXX_API
#define LIBOPENMPT_CXX_API LIBOPENMPT_API_HELPER_LOCAL
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2014-02-28 16:04:38
|
Revision: 3796
http://sourceforge.net/p/modplug/code/3796
Author: manxorist
Date: 2014-02-28 16:04:29 +0000 (Fri, 28 Feb 2014)
Log Message:
-----------
[Mod] libopenmpt: Automatically determine the appropriate character set conversion implementation via preprocessor macros without relying on the build system.
[Mod] libopenmpt: Use iconv only on linux by default.
Modified Paths:
--------------
trunk/OpenMPT/build/android_ndk/Android.mk
trunk/OpenMPT/build/make/Makefile.config.defaults
trunk/OpenMPT/build/make/Makefile.config.emscripten
trunk/OpenMPT/common/BuildSettings.h
trunk/OpenMPT/common/mptString.cpp
trunk/OpenMPT/common/version.cpp
trunk/OpenMPT/libopenmpt/dox/dependencies.md
Modified: trunk/OpenMPT/build/android_ndk/Android.mk
===================================================================
--- trunk/OpenMPT/build/android_ndk/Android.mk 2014-02-28 14:47:09 UTC (rev 3795)
+++ trunk/OpenMPT/build/android_ndk/Android.mk 2014-02-28 16:04:29 UTC (rev 3796)
@@ -10,8 +10,8 @@
LOCAL_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/common $(LOCAL_PATH)/common/svn_version_default
-LOCAL_CFLAGS := -fvisibility=hidden -DLIBOPENMPT_BUILD -DMPT_CHARSET_CUSTOMUTF8 -DMPT_WITH_ZLIB
-LOCAL_CPPFLAGS := -std=c++11 -fvisibility=hidden -DLIBOPENMPT_BUILD -DMPT_CHARSET_CUSTOMUTF8 -DMPT_WITH_ZLIB
+LOCAL_CFLAGS := -fvisibility=hidden -DLIBOPENMPT_BUILD -DMPT_WITH_ZLIB
+LOCAL_CPPFLAGS := -std=c++11 -fvisibility=hidden -DLIBOPENMPT_BUILD -DMPT_WITH_ZLIB
LOCAL_LDLIBS := -lz
LOCAL_SRC_FILES := \
Modified: trunk/OpenMPT/build/make/Makefile.config.defaults
===================================================================
--- trunk/OpenMPT/build/make/Makefile.config.defaults 2014-02-28 14:47:09 UTC (rev 3795)
+++ trunk/OpenMPT/build/make/Makefile.config.defaults 2014-02-28 16:04:29 UTC (rev 3796)
@@ -20,12 +20,12 @@
# Mac OS X overrides
-CPPFLAGS += -DMPT_CHARSET_CPP
DYNLINK=0
# when using iconv
-#CPPFLAGS += -DMPT_ICONV_NO_WCHAR
+#CPPFLAGS += -DMPT_WITH_ICONV
#LDLIBS += -liconv
endif
endif
+
Modified: trunk/OpenMPT/build/make/Makefile.config.emscripten
===================================================================
--- trunk/OpenMPT/build/make/Makefile.config.emscripten 2014-02-28 14:47:09 UTC (rev 3795)
+++ trunk/OpenMPT/build/make/Makefile.config.emscripten 2014-02-28 16:04:29 UTC (rev 3796)
@@ -4,7 +4,7 @@
LD = em++
AR = emar
-CPPFLAGS += -DMPT_CHARSET_CPP -DMPT_CHARSET_ASSUME_UTF8_LOCALE
+CPPFLAGS +=
CXXFLAGS += -std=c++0x -fPIC
CFLAGS += -std=c99 -fPIC
LDFLAGS += -O2 -s DISABLE_EXCEPTION_CATCHING=0
Modified: trunk/OpenMPT/common/BuildSettings.h
===================================================================
--- trunk/OpenMPT/common/BuildSettings.h 2014-02-28 14:47:09 UTC (rev 3795)
+++ trunk/OpenMPT/common/BuildSettings.h 2014-02-28 16:04:29 UTC (rev 3796)
@@ -191,6 +191,44 @@
+#if MPT_OS_WINDOWS
+
+#define MPT_CHARSET_WIN32
+
+#elif MPT_OS_LINUX
+
+#define MPT_CHARSET_ICONV
+
+#elif MPT_OS_ANDROID
+
+#define MPT_CHARSET_INTERNAL
+
+#elif MPT_OS_EMSCRIPTEN
+
+#define MPT_CHARSET_CODECVTUTF8
+#ifndef MPT_LOCALE_ASSUME_CHARSET
+#define MPT_LOCALE_ASSUME_CHARSET CharsetUTF8
+#endif
+
+#elif MPT_OS_MACOSX_OR_IOS
+
+#if defined(MPT_WITH_ICONV)
+#define MPT_CHARSET_ICONV
+#ifndef MPT_ICONV_NO_WCHAR
+#define MPT_ICONV_NO_WCHAR
+#endif
+#else
+#define MPT_CHARSET_CODECVTUTF8
+#endif
+
+#elif defined(MPT_WITH_ICONV)
+
+#define MPT_CHARSET_ICONV
+
+#endif
+
+
+
// fixing stuff up
#if !defined(MODPLUG_TRACKER) && defined(NO_MO3)
@@ -219,8 +257,12 @@
#define MODPLUG_NO_FILESAVE // file saving is broken on big endian
#endif
+#if !defined(MPT_CHARSET_WIN32) && !defined(MPT_CHARSET_ICONV) && !defined(MPT_CHARSET_CODECVTUTF8) && !defined(MPT_CHARSET_INTERNAL)
+#define MPT_CHARSET_INTERNAL
+#endif
+
#if MPT_COMPILER_MSVC
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
Modified: trunk/OpenMPT/common/mptString.cpp
===================================================================
--- trunk/OpenMPT/common/mptString.cpp 2014-02-28 14:47:09 UTC (rev 3795)
+++ trunk/OpenMPT/common/mptString.cpp 2014-02-28 16:04:29 UTC (rev 3796)
@@ -10,9 +10,10 @@
#include "stdafx.h"
#include "mptString.h"
-#if defined(MPT_CHARSET_CPP)
+#if defined(MPT_CHARSET_CODECVTUTF8)
#include <codecvt>
-#elif defined(MPT_CHARSET_CUSTOMUTF8)
+#endif
+#if defined(MPT_CHARSET_INTERNAL)
#include <cstdlib>
#endif
#include <iomanip>
@@ -29,9 +30,9 @@
#include <strings.h> // for strncasecmp
#endif
-#if !defined(MPT_CHARSET_CPP) && !defined(MPT_CHARSET_CUSTOMUTF8) && !defined(WIN32)
+#if defined(MPT_CHARSET_ICONV)
#include <iconv.h>
-#endif // !WIN32
+#endif
namespace mpt {
@@ -108,7 +109,7 @@
};
*/
-#if defined(MPT_CHARSET_CPP) || defined(MPT_CHARSET_CUSTOMUTF8)
+#if defined(MPT_CHARSET_CODECVTUTF8) || defined(MPT_CHARSET_INTERNAL)
static const uint32 CharsetTableISO8859_15[256] = {
0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007,0x0008,0x0009,0x000a,0x000b,0x000c,0x000d,0x000e,0x000f,
@@ -167,8 +168,9 @@
0x2261,0x00b1,0x2265,0x2264,0x2320,0x2321,0x00f7,0x2248,0x00b0,0x2219,0x00b7,0x221a,0x207f,0x00b2,0x25a0,0x00a0
};
-#endif
+#endif // MPT_CHARSET_CODECVTUTF8 || MPT_CHARSET_INTERNAL
+
#define C(x) ((uint8)(x))
// AMS1 actually only supports ASCII plus the modified control characters and no high chars at all.
@@ -277,7 +279,7 @@
return res;
}
-#if defined(MPT_CHARSET_CPP) || defined(MPT_CHARSET_CUSTOMUTF8)
+#if defined(MPT_CHARSET_CODECVTUTF8) || defined(MPT_CHARSET_INTERNAL)
static std::wstring FromAscii(const std::string &str, wchar_t replacement = L'\uFFFD')
//------------------------------------------------------------------------------------
@@ -496,8 +498,10 @@
return String::ToAscii(str, replacement); // fallback
}
-#if defined(MPT_CHARSET_CPP)
+#endif // MPT_CHARSET_CODECVTUTF8 || MPT_CHARSET_INTERNAL
+#if defined(MPT_CHARSET_CODECVTUTF8)
+
static std::wstring FromUTF8(const std::string &str, wchar_t replacement = L'\uFFFD')
//-----------------------------------------------------------------------------------
{
@@ -514,8 +518,10 @@
return conv.to_bytes(str);
}
-#elif defined(MPT_CHARSET_CUSTOMUTF8)
+#endif // MPT_CHARSET_CODECVTUTF8
+#if defined(MPT_CHARSET_INTERNAL)
+
static std::wstring FromUTF8(const std::string &str, wchar_t replacement = L'\uFFFD')
//-----------------------------------------------------------------------------------
{
@@ -673,9 +679,10 @@
}
-#endif // MPT_CHARSET_CPP || MPT_CHARSET_CUSTOMUTF8
+#endif // MPT_CHARSET_INTERNAL
-#elif defined(WIN32)
+#if defined(MPT_CHARSET_WIN32)
+
static UINT CharsetToCodepage(Charset charset)
{
switch(charset)
@@ -692,7 +699,11 @@
}
return 0;
}
-#else // !WIN32
+
+#endif // MPT_CHARSET_WIN32
+
+#if defined(MPT_CHARSET_ICONV)
+
static const char * CharsetToString(Charset charset)
{
switch(charset)
@@ -709,6 +720,7 @@
}
return 0;
}
+
static const char * CharsetToStringTranslit(Charset charset)
{
switch(charset)
@@ -725,6 +737,7 @@
}
return 0;
}
+
static const char * Charset_wchar_t()
{
#if !defined(MPT_ICONV_NO_WCHAR)
@@ -756,9 +769,10 @@
return "";
#endif // !MPT_ICONV_NO_WCHAR | MPT_ICONV_NO_WCHAR
}
-#endif // WIN32
+#endif // MPT_CHARSET_ICONV
+
// templated on 8bit strings because of type-safe variants
template<typename Tdststring>
Tdststring EncodeImpl(Charset charset, const std::wstring &src)
@@ -773,30 +787,13 @@
std::copy(out.begin(), out.end(), std::back_inserter(result));
return result;
}
- #if defined(MPT_CHARSET_ASSUME_UTF8_LOCALE)
+ #if defined(MPT_LOCALE_ASSUME_CHARSET)
if(charset == CharsetLocale)
{
- charset = CharsetUTF8;
+ charset = MPT_LOCALE_ASSUME_CHARSET;
}
#endif
- #if defined(MPT_CHARSET_CPP) || defined(MPT_CHARSET_CUSTOMUTF8)
- std::string out;
- switch(charset)
- {
- case CharsetLocale: out = String::ToLocale(src); break;
- case CharsetUTF8: out = String::ToUTF8(src); break;
- case CharsetASCII: out = String::ToAscii(src); break;
- case CharsetISO8859_1: out = String::ToISO_8859_1(src); break;
- case CharsetISO8859_15: out = String::To8bit(src, CharsetTableISO8859_15); break;
- case CharsetCP437: out = String::To8bit(src, CharsetTableCP437); break;
- case CharsetCP437AMS: out = String::To8bit(src, CharsetTableCP437AMS); break;
- case CharsetCP437AMS2: out = String::To8bit(src, CharsetTableCP437AMS2); break;
- case CharsetWindows1252: out = String::To8bit(src, CharsetTableWindows1252); break;
- }
- Tdststring result;
- std::copy(out.begin(), out.end(), std::back_inserter(result));
- return result;
- #elif defined(WIN32)
+ #if defined(MPT_CHARSET_WIN32)
const UINT codepage = CharsetToCodepage(charset);
int required_size = WideCharToMultiByte(codepage, 0, src.c_str(), -1, nullptr, 0, nullptr, nullptr);
if(required_size <= 0)
@@ -806,7 +803,7 @@
std::vector<CHAR> encoded_string(required_size);
WideCharToMultiByte(codepage, 0, src.c_str(), -1, &encoded_string[0], required_size, nullptr, nullptr);
return reinterpret_cast<const typename Tdststring::value_type*>(&encoded_string[0]);
- #else // !WIN32
+ #elif defined(MPT_CHARSET_ICONV)
iconv_t conv = iconv_t();
conv = iconv_open(CharsetToStringTranslit(charset), Charset_wchar_t());
if(!conv)
@@ -843,7 +840,24 @@
iconv_close(conv);
conv = iconv_t();
return reinterpret_cast<const typename Tdststring::value_type*>(&encoded_string[0]);
- #endif // WIN32
+ #else
+ std::string out;
+ switch(charset)
+ {
+ case CharsetLocale: out = String::ToLocale(src); break;
+ case CharsetUTF8: out = String::ToUTF8(src); break;
+ case CharsetASCII: out = String::ToAscii(src); break;
+ case CharsetISO8859_1: out = String::ToISO_8859_1(src); break;
+ case CharsetISO8859_15: out = String::To8bit(src, CharsetTableISO8859_15); break;
+ case CharsetCP437: out = String::To8bit(src, CharsetTableCP437); break;
+ case CharsetCP437AMS: out = String::To8bit(src, CharsetTableCP437AMS); break;
+ case CharsetCP437AMS2: out = String::To8bit(src, CharsetTableCP437AMS2); break;
+ case CharsetWindows1252: out = String::To8bit(src, CharsetTableWindows1252); break;
+ }
+ Tdststring result;
+ std::copy(out.begin(), out.end(), std::back_inserter(result));
+ return result;
+ #endif
}
@@ -861,30 +875,13 @@
if(charset == CharsetCP437AMS2) out = String::From8bit(in, CharsetTableCP437AMS2);
return out;
}
- #if defined(MPT_CHARSET_ASSUME_UTF8_LOCALE)
+ #if defined(MPT_LOCALE_ASSUME_CHARSET)
if(charset == CharsetLocale)
{
- charset = CharsetUTF8;
+ charset = MPT_LOCALE_ASSUME_CHARSET;
}
#endif
- #if defined(MPT_CHARSET_CPP) || defined(MPT_CHARSET_CUSTOMUTF8)
- std::string in;
- std::copy(src.begin(), src.end(), std::back_inserter(in));
- std::wstring out;
- switch(charset)
- {
- case CharsetLocale: out = String::FromLocale(in); break;
- case CharsetUTF8: out = String::FromUTF8(in); break;
- case CharsetASCII: out = String::FromAscii(in); break;
- case CharsetISO8859_1: out = String::FromISO_8859_1(in); break;
- case CharsetISO8859_15: out = String::From8bit(in, CharsetTableISO8859_15); break;
- case CharsetCP437: out = String::From8bit(in, CharsetTableCP437); break;
- case CharsetCP437AMS: out = String::From8bit(in, CharsetTableCP437AMS); break;
- case CharsetCP437AMS2: out = String::From8bit(in, CharsetTableCP437AMS2); break;
- case CharsetWindows1252: out = String::From8bit(in, CharsetTableWindows1252); break;
- }
- return out;
- #elif defined(WIN32)
+ #if defined(MPT_CHARSET_WIN32)
const UINT codepage = CharsetToCodepage(charset);
int required_size = MultiByteToWideChar(codepage, 0, reinterpret_cast<const char*>(src.c_str()), -1, nullptr, 0);
if(required_size <= 0)
@@ -894,7 +891,7 @@
std::vector<WCHAR> decoded_string(required_size);
MultiByteToWideChar(codepage, 0, reinterpret_cast<const char*>(src.c_str()), -1, &decoded_string[0], required_size);
return &decoded_string[0];
- #else // !WIN32
+ #elif defined(MPT_CHARSET_ICONV)
iconv_t conv = iconv_t();
conv = iconv_open(Charset_wchar_t(), CharsetToString(charset));
if(!conv)
@@ -935,7 +932,24 @@
iconv_close(conv);
conv = iconv_t();
return &wide_string[0];
- #endif // WIN32
+ #else
+ std::string in;
+ std::copy(src.begin(), src.end(), std::back_inserter(in));
+ std::wstring out;
+ switch(charset)
+ {
+ case CharsetLocale: out = String::FromLocale(in); break;
+ case CharsetUTF8: out = String::FromUTF8(in); break;
+ case CharsetASCII: out = String::FromAscii(in); break;
+ case CharsetISO8859_1: out = String::FromISO_8859_1(in); break;
+ case CharsetISO8859_15: out = String::From8bit(in, CharsetTableISO8859_15); break;
+ case CharsetCP437: out = String::From8bit(in, CharsetTableCP437); break;
+ case CharsetCP437AMS: out = String::From8bit(in, CharsetTableCP437AMS); break;
+ case CharsetCP437AMS2: out = String::From8bit(in, CharsetTableCP437AMS2); break;
+ case CharsetWindows1252: out = String::From8bit(in, CharsetTableWindows1252); break;
+ }
+ return out;
+ #endif
}
@@ -949,9 +963,7 @@
{
return Tdststring(reinterpret_cast<const typename Tdststring::value_type*>(&*src.begin()), reinterpret_cast<const typename Tdststring::value_type*>(&*src.end()));
}
- #if defined(MPT_CHARSET_CPP) || defined(MPT_CHARSET_CUSTOMUTF8) || defined(WIN32)
- return EncodeImpl<Tdststring>(to, DecodeImpl(from, src));
- #else // !WIN32
+ #if defined(MPT_CHARSET_ICONV)
if(to == CharsetCP437AMS || to == CharsetCP437AMS2 || from == CharsetCP437AMS || from == CharsetCP437AMS2)
{
return EncodeImpl<Tdststring>(to, DecodeImpl(from, src));
@@ -992,7 +1004,9 @@
iconv_close(conv);
conv = iconv_t();
return reinterpret_cast<const typename Tdststring::value_type*>(&dst_string[0]);
- #endif // WIN32
+ #else
+ return EncodeImpl<Tdststring>(to, DecodeImpl(from, src));
+ #endif
}
Modified: trunk/OpenMPT/common/version.cpp
===================================================================
--- trunk/OpenMPT/common/version.cpp 2014-02-28 14:47:09 UTC (rev 3795)
+++ trunk/OpenMPT/common/version.cpp 2014-02-28 16:04:29 UTC (rev 3796)
@@ -197,14 +197,14 @@
#else
retval += "*unknown";
#endif
- #if defined(WIN32)
+ #if defined(MPT_CHARSET_WIN32)
retval += " +WINAPI";
- #elif defined(MPT_CHARSET_CPP)
- retval += " +CODECVT";
- #elif defined(MPT_CHARSET_CUSTOMUTF8)
- retval += " +CUSTOMUTF8";
- #else
+ #elif defined(MPT_CHARSET_ICONV)
retval += " +ICONV";
+ #elif defined(MPT_CHARSET_CODECVTUTF8)
+ retval += " +CODECVTUTF8";
+ #elif defined(MPT_CHARSET_INTERNAL)
+ retval += " +INTERNALCHARSETS";
#endif
#if !defined(NO_ZLIB)
retval += " +ZLIB";
Modified: trunk/OpenMPT/libopenmpt/dox/dependencies.md
===================================================================
--- trunk/OpenMPT/libopenmpt/dox/dependencies.md 2014-02-28 14:47:09 UTC (rev 3795)
+++ trunk/OpenMPT/libopenmpt/dox/dependencies.md 2014-02-28 16:04:29 UTC (rev 3796)
@@ -16,10 +16,6 @@
* Required compilers to use libopenmpt:
* Any **C89** compatible compiler should work with the C API as long as a C99 compatible **stdint.h** is available.
* Any **C++03** compatible compiler should work with the C++ API.
- * Character set conversion requires one of:
- * **Win32**
- * **iconv**
- * a **C++11** compliant compiler
* **J2B** support requires a inflate (deflate decompression) implementation:
* **zlib**
* **miniz** can be used internally if no zlib is available.
@@ -48,6 +44,11 @@
### libopenmpt
+ * Character set conversion can use one of:
+ * **Win32**
+ * **iconv**
+ * **C++11** codecvt_utf8
+ instead of the internal conversion tables and functions.
* **MO3** support requires the closed-source **unmo3** library.
* **doxygen 1.8** or higher is required to build the documentation.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-03-01 00:21:25
|
Revision: 3801
http://sourceforge.net/p/modplug/code/3801
Author: saga-games
Date: 2014-03-01 00:21:15 +0000 (Sat, 01 Mar 2014)
Log Message:
-----------
[Imp] Since the envelope display is no longer limited to 32768 ticks, we can now effectively remove this limit.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/Modedit.cpp
trunk/OpenMPT/mptrack/View_ins.cpp
trunk/OpenMPT/soundlib/Snd_defs.h
Modified: trunk/OpenMPT/mptrack/Modedit.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Modedit.cpp 2014-02-28 23:46:47 UTC (rev 3800)
+++ trunk/OpenMPT/mptrack/Modedit.cpp 2014-03-01 00:21:15 UTC (rev 3801)
@@ -1040,7 +1040,7 @@
while ((dwPos < dwMemSize) && ((p[dwPos] < '0') || (p[dwPos] > '9'))) dwPos++;
if (dwPos >= dwMemSize) break;
int n2 = atoi(p+dwPos);
- if ((n1 < oldn) || (n1 > ENVELOPE_MAX_LENGTH)) n1 = oldn + 1;
+ if (n1 < oldn) n1 = oldn + 1;
env.Ticks[i] = (WORD)n1;
env.Values[i] = (BYTE)n2;
oldn = n1;
Modified: trunk/OpenMPT/mptrack/View_ins.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_ins.cpp 2014-02-28 23:46:47 UTC (rev 3800)
+++ trunk/OpenMPT/mptrack/View_ins.cpp 2014-03-01 00:21:15 UTC (rev 3801)
@@ -296,7 +296,7 @@
tickDiff = envelope->Ticks[nPoint];
int mintick = (nPoint) ? envelope->Ticks[nPoint - 1] : 0;
int maxtick = envelope->Ticks[nPoint + 1];
- if(nPoint + 1 == (int)envelope->nNodes || moveTail) maxtick = ENVELOPE_MAX_LENGTH;
+ if(nPoint + 1 == (int)envelope->nNodes || moveTail) maxtick = Util::MaxValueOfType(maxtick);
// Can't have multiple points on same tick
if(nPoint > 0 && mintick < maxtick - 1)
@@ -2492,11 +2492,6 @@
{
return false;
}
- // Limit envelope length
- if((envPoint == pEnv->nNodes - 1) && pEnv->Ticks[envPoint] + step > ENVELOPE_MAX_LENGTH)
- {
- return false;
- }
return true;
}
Modified: trunk/OpenMPT/soundlib/Snd_defs.h
===================================================================
--- trunk/OpenMPT/soundlib/Snd_defs.h 2014-02-28 23:46:47 UTC (rev 3800)
+++ trunk/OpenMPT/soundlib/Snd_defs.h 2014-03-01 00:21:15 UTC (rev 3801)
@@ -195,7 +195,6 @@
#define ENVELOPE_MID 32 // Vertical middle line
#define ENVELOPE_MAX 64 // Vertical max value of a point
#define MAX_ENVPOINTS 240 // Maximum length of each instrument envelope
-#define ENVELOPE_MAX_LENGTH 0x3FFF // Max envelope length in ticks. note: this value is only really required because too long envelopes won't be displayed properly in the instrument editor (win32 scrollbar issues)
// Flags of 'dF..' datafield in extended instrument properties.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2014-03-01 11:03:34
|
Revision: 3802
http://sourceforge.net/p/modplug/code/3802
Author: manxorist
Date: 2014-03-01 11:03:23 +0000 (Sat, 01 Mar 2014)
Log Message:
-----------
[Ref] Test: Split tracker and library test framework tools into separate header files.
[Mod] Test: Revert tracker test framework to r3782 .
Revision Links:
--------------
http://sourceforge.net/p/modplug/code/3782
Modified Paths:
--------------
trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj
trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters
trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj
trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj.filters
trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj
trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj.filters
trunk/OpenMPT/mptrack/mptrack_08.vcproj
trunk/OpenMPT/mptrack/mptrack_10.vcxproj
trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters
trunk/OpenMPT/test/test.cpp
Added Paths:
-----------
trunk/OpenMPT/test/TestTools.h
trunk/OpenMPT/test/TestToolsLib.h
trunk/OpenMPT/test/TestToolsTracker.h
Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj
===================================================================
--- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2014-03-01 00:21:15 UTC (rev 3801)
+++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2014-03-01 11:03:23 UTC (rev 3802)
@@ -242,6 +242,9 @@
<ClInclude Include="..\soundlib\WindowedFIR.h" />
<ClInclude Include="..\soundlib\XMTools.h" />
<ClInclude Include="..\test\test.h" />
+ <ClInclude Include="..\test\TestTools.h" />
+ <ClInclude Include="..\test\TestToolsLib.h" />
+ <ClInclude Include="..\test\TestToolsTracker.h" />
<ClInclude Include="libopenmpt.h" />
<ClInclude Include="libopenmpt.hpp" />
<ClInclude Include="libopenmpt_config.h" />
Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters
===================================================================
--- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters 2014-03-01 00:21:15 UTC (rev 3801)
+++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters 2014-03-01 11:03:23 UTC (rev 3802)
@@ -257,6 +257,15 @@
<ClInclude Include="..\soundlib\MixerInterface.h">
<Filter>Header Files\soundlib</Filter>
</ClInclude>
+ <ClInclude Include="..\test\TestTools.h">
+ <Filter>Header Files\test</Filter>
+ </ClInclude>
+ <ClInclude Include="..\test\TestToolsLib.h">
+ <Filter>Header Files\test</Filter>
+ </ClInclude>
+ <ClInclude Include="..\test\TestToolsTracker.h">
+ <Filter>Header Files\test</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\common\AudioCriticalSection.cpp">
Modified: trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj
===================================================================
--- trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj 2014-03-01 00:21:15 UTC (rev 3801)
+++ trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj 2014-03-01 11:03:23 UTC (rev 3802)
@@ -250,6 +250,9 @@
<ClInclude Include="..\soundlib\WindowedFIR.h" />
<ClInclude Include="..\soundlib\XMTools.h" />
<ClInclude Include="..\test\test.h" />
+ <ClInclude Include="..\test\TestTools.h" />
+ <ClInclude Include="..\test\TestToolsLib.h" />
+ <ClInclude Include="..\test\TestToolsTracker.h" />
<ClInclude Include="libopenmpt.h" />
<ClInclude Include="libopenmpt.hpp" />
<ClInclude Include="libopenmpt_config.h" />
Modified: trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj.filters
===================================================================
--- trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj.filters 2014-03-01 00:21:15 UTC (rev 3801)
+++ trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj.filters 2014-03-01 11:03:23 UTC (rev 3802)
@@ -263,6 +263,15 @@
<ClInclude Include="..\soundlib\MixerInterface.h">
<Filter>Header Files\soundlib</Filter>
</ClInclude>
+ <ClInclude Include="..\test\TestTools.h">
+ <Filter>Header Files\test</Filter>
+ </ClInclude>
+ <ClInclude Include="..\test\TestToolsLib.h">
+ <Filter>Header Files\test</Filter>
+ </ClInclude>
+ <ClInclude Include="..\test\TestToolsTracker.h">
+ <Filter>Header Files\test</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\common\AudioCriticalSection.cpp">
Modified: trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj
===================================================================
--- trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj 2014-03-01 00:21:15 UTC (rev 3801)
+++ trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj 2014-03-01 11:03:23 UTC (rev 3802)
@@ -246,6 +246,9 @@
<ClInclude Include="..\soundlib\WindowedFIR.h" />
<ClInclude Include="..\soundlib\XMTools.h" />
<ClInclude Include="..\test\test.h" />
+ <ClInclude Include="..\test\TestTools.h" />
+ <ClInclude Include="..\test\TestToolsLib.h" />
+ <ClInclude Include="..\test\TestToolsTracker.h" />
<ClInclude Include="libopenmpt.h" />
<ClInclude Include="libopenmpt.hpp" />
<ClInclude Include="libopenmpt_config.h" />
Modified: trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj.filters
===================================================================
--- trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj.filters 2014-03-01 00:21:15 UTC (rev 3801)
+++ trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj.filters 2014-03-01 11:03:23 UTC (rev 3802)
@@ -257,6 +257,15 @@
<ClInclude Include="..\soundlib\MixerInterface.h">
<Filter>Header Files\soundlib</Filter>
</ClInclude>
+ <ClInclude Include="..\test\TestTools.h">
+ <Filter>Header Files\test</Filter>
+ </ClInclude>
+ <ClInclude Include="..\test\TestToolsLib.h">
+ <Filter>Header Files\test</Filter>
+ </ClInclude>
+ <ClInclude Include="..\test\TestToolsTracker.h">
+ <Filter>Header Files\test</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\common\AudioCriticalSection.cpp">
Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj
===================================================================
--- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2014-03-01 00:21:15 UTC (rev 3801)
+++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2014-03-01 11:03:23 UTC (rev 3802)
@@ -1450,6 +1450,18 @@
RelativePath="..\test\test.h"
>
</File>
+ <File
+ RelativePath="..\test\TestTools.h"
+ >
+ </File>
+ <File
+ RelativePath="..\test\TestToolsLib.h"
+ >
+ </File>
+ <File
+ RelativePath="..\test\TestToolsTracker.h"
+ >
+ </File>
</Filter>
<Filter
Name="Module Loaders"
Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj
===================================================================
--- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2014-03-01 00:21:15 UTC (rev 3801)
+++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2014-03-01 11:03:23 UTC (rev 3802)
@@ -707,6 +707,9 @@
<ClInclude Include="..\soundlib\WindowedFIR.h" />
<ClInclude Include="..\soundlib\XMTools.h" />
<ClInclude Include="..\test\test.h" />
+ <ClInclude Include="..\test\TestTools.h" />
+ <ClInclude Include="..\test\TestToolsLib.h" />
+ <ClInclude Include="..\test\TestToolsTracker.h" />
<ClInclude Include="..\unarchiver\archive.h" />
<ClInclude Include="..\unarchiver\unarchiver.h" />
<ClInclude Include="..\unarchiver\ungzip.h" />
Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters
===================================================================
--- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2014-03-01 00:21:15 UTC (rev 3801)
+++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2014-03-01 11:03:23 UTC (rev 3802)
@@ -978,6 +978,15 @@
<ClInclude Include="..\soundlib\MixerInterface.h">
<Filter>Header Files\soundlib</Filter>
</ClInclude>
+ <ClInclude Include="..\test\TestToolsLib.h">
+ <Filter>test</Filter>
+ </ClInclude>
+ <ClInclude Include="..\test\TestToolsTracker.h">
+ <Filter>test</Filter>
+ </ClInclude>
+ <ClInclude Include="..\test\TestTools.h">
+ <Filter>test</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="res\bitmap1.bmp">
Added: trunk/OpenMPT/test/TestTools.h
===================================================================
--- trunk/OpenMPT/test/TestTools.h (rev 0)
+++ trunk/OpenMPT/test/TestTools.h 2014-03-01 11:03:23 UTC (rev 3802)
@@ -0,0 +1,5 @@
+
+#pragma once
+
+#include "TestToolsTracker.h"
+#include "TestToolsLib.h"
Property changes on: trunk/OpenMPT/test/TestTools.h
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/x-chdr
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/OpenMPT/test/TestToolsLib.h
===================================================================
--- trunk/OpenMPT/test/TestToolsLib.h (rev 0)
+++ trunk/OpenMPT/test/TestToolsLib.h 2014-03-01 11:03:23 UTC (rev 3802)
@@ -0,0 +1,191 @@
+
+#pragma once
+
+
+#ifdef ENABLE_TESTS
+#ifndef MODPLUG_TRACKER
+
+
+#include <memory>
+#include <iostream>
+
+
+namespace MptTest
+{
+
+
+static std::string remove_newlines(std::string str)
+{
+ return mpt::String::Replace(mpt::String::Replace(str, "\n", " "), "\r", " ");
+}
+
+static noinline void show_start(const char * const file, const int line, const char * const description)
+{
+ std::cout << "Test: " << file << "(" << line << "): " << remove_newlines(description) << ": ";
+}
+
+static noinline void MultiTestStart(const char * const file, const int line, const char * const description)
+{
+ show_start(file, line, description);
+ std::cout << "..." << std::endl;
+}
+
+static noinline void show_ok(const char * const file, const int line, const char * const description)
+{
+ MPT_UNREFERENCED_PARAMETER(file);
+ MPT_UNREFERENCED_PARAMETER(line);
+ MPT_UNREFERENCED_PARAMETER(description);
+ std::cout << "PASS" << std::endl;
+}
+
+static noinline void show_fail(const char * const file, const int line, const char * const description, bool exception = false, const char * const exception_text = nullptr)
+{
+ std::cout << "FAIL" << std::endl;
+ std::cout.flush();
+ if(!exception)
+ {
+ std::cerr << "FAIL: " << file << "(" << line << "): " << remove_newlines(description) << std::endl;
+ } else if(!exception_text || (exception_text && std::string(exception_text).empty()))
+ {
+ std::cerr << "FAIL: " << file << "(" << line << "): " << remove_newlines(description) << " EXCEPTION!" << std::endl;
+ } else
+ {
+ std::cerr << "FAIL: " << file << "(" << line << "): " << remove_newlines(description) << " EXCEPTION: " << exception_text << std::endl;
+ }
+ std::cerr.flush();
+}
+
+static int fail_count = 0;
+
+static noinline void CheckFailCountOrThrow()
+{
+ if(fail_count > 0)
+ {
+ throw std::runtime_error("Test failed.");
+ }
+}
+
+static noinline void ReportException(const char * const file, const int line, const char * const description)
+{
+ try
+ {
+ throw; // get the exception
+ } catch(std::exception & e)
+ {
+ show_fail(file, line, description, true, e.what());
+ throw; // rethrow
+ } catch(...)
+ {
+ show_fail(file, line, description, true);
+ throw; // rethrow
+ }
+}
+
+static noinline void TestFail(const char * const file, const int line, const char * const description)
+{
+ show_fail(file, line, description);
+ fail_count++;
+}
+
+static noinline void TestFailStop(const char * const file, const int line, const char * const description)
+{
+ show_fail(file, line, description);
+ fail_count++;
+ throw std::runtime_error(std::string("Test failed: ") + description);
+}
+
+#define MULTI_TEST_TRY try { \
+ fail_count = 0;
+#define MULTI_TEST_START MultiTestStart(THIS_FILE, __LINE__, description);
+#define MULTI_TEST_END show_start(THIS_FILE, __LINE__, description);
+#define MULTI_TEST_CATCH CheckFailCountOrThrow(); \
+ show_ok(THIS_FILE, __LINE__, description); \
+ } catch(...) { \
+ ReportException(THIS_FILE, __LINE__, description); \
+ }
+#define TEST_TRY try {
+#define TEST_CATCH } catch(...) { \
+ fail_count++; \
+ ReportException(file, line, description); \
+ throw; \
+ }
+#define TEST_START() show_start(file, line, description)
+#define TEST_OK() show_ok(file, line, description)
+#define TEST_FAIL() TestFail(file, line, description)
+#define TEST_FAIL_STOP() TestFailStop(file, line, description)
+
+
+template <typename Tx, typename Ty>
+noinline void VerifyEqualImpl(const Tx &x, const Ty &y, const char *const description, const char *const file, const int line)
+{
+ TEST_TRY
+ TEST_START();
+ if(x != y)
+ {
+ TEST_FAIL();
+ } else
+ {
+ TEST_OK();
+ }
+ TEST_CATCH
+}
+
+
+template <typename Tx, typename Ty>
+noinline void VerifyEqualNonContImpl(const Tx &x, const Ty &y, const char *const description, const char *const file, const int line)
+{
+ TEST_TRY
+ TEST_START();
+ if(x != y)
+ {
+ TEST_FAIL_STOP();
+ } else
+ {
+ TEST_OK();
+ }
+ TEST_CATCH
+}
+
+
+template <typename Tx, typename Ty>
+noinline void VerifyEqualQuietNonContImpl(const Tx &x, const Ty &y, const char *const description, const char *const file, const int line)
+{
+ TEST_TRY
+ if(x != y)
+ {
+ TEST_FAIL_STOP();
+ }
+ TEST_CATCH
+}
+
+
+//Verify that given parameters are 'equal'(show error message if not).
+//The exact meaning of equality is not specified; for now using operator!=.
+//The macro is active in both 'debug' and 'release' build.
+#define VERIFY_EQUAL(x,y) VerifyEqualImpl( (x) , (y) , #x " == " #y , THIS_FILE, __LINE__)
+
+
+// Like VERIFY_EQUAL, but throws exception if comparison fails.
+#define VERIFY_EQUAL_NONCONT(x,y) VerifyEqualNonContImpl( (x) , (y) , #x " == " #y , THIS_FILE, __LINE__)
+
+
+// Like VERIFY_EQUAL_NONCONT, but do not show message if test succeeds
+#define VERIFY_EQUAL_QUIET_NONCONT(x,y) VerifyEqualQuietNonContImpl( (x) , (y) , #x " == " #y , THIS_FILE, __LINE__)
+
+
+#define DO_TEST(func) \
+do{ \
+ const char * description = #func ; \
+ MULTI_TEST_TRY \
+ MULTI_TEST_START \
+ func(); \
+ MULTI_TEST_END \
+ MULTI_TEST_CATCH \
+}while(0)
+
+
+} // namespace MptTest
+
+
+#endif // !MODPLUG_TRACKER
+#endif // ENABLE_TESTS
Property changes on: trunk/OpenMPT/test/TestToolsLib.h
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/x-chdr
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/OpenMPT/test/TestToolsTracker.h
===================================================================
--- trunk/OpenMPT/test/TestToolsTracker.h (rev 0)
+++ trunk/OpenMPT/test/TestToolsTracker.h 2014-03-01 11:03:23 UTC (rev 3802)
@@ -0,0 +1,167 @@
+
+#pragma once
+
+
+#ifdef ENABLE_TESTS
+#ifdef MODPLUG_TRACKER
+
+
+namespace MptTest
+{
+
+
+static noinline void ReportError(const char * file, int line, const char * description, bool abort)
+//-------------------------------------------------------------------------------------------------
+{
+ std::string pos = std::string() + file + "(" + Stringify(line) + "):\n";
+ std::string message = pos + "Test failed: '" + description + "'";
+ if(IsDebuggerPresent())
+ {
+ message += "\n";
+ OutputDebugString(message.c_str());
+ } else
+ {
+ if(abort)
+ {
+ throw std::runtime_error(message);
+ } else
+ {
+ Reporting::Error(message.c_str(), "OpenMPT TestSuite");
+ }
+ }
+}
+
+static noinline void ReportExceptionError(const char * file, int line, const char * description, const char * exception_what)
+//---------------------------------------------------------------------------------------------------------------------------
+{
+ std::string pos = std::string() + file + "(" + Stringify(line) + "):\n";
+ std::string message;
+ if(exception_what)
+ {
+ message = pos + "Test '" + description + "' threw an exception, message:\n" + exception_what;
+ } else
+ {
+ message = pos + "Test '" + description + "' threw an unknown exception.";
+ }
+ if(IsDebuggerPresent())
+ {
+ message += "\n";
+ OutputDebugString(message.c_str());
+ } else
+ {
+ Reporting::Error(message.c_str(), "OpenMPT TestSuite");
+ }
+}
+
+static noinline void ReportException(const char * const file, const int line, const char * const description, bool rethrow)
+//-------------------------------------------------------------------------------------------------------------------------
+{
+ try
+ {
+ throw; // get the exception
+ } catch(std::exception &e)
+ {
+ ReportExceptionError(file, line, description, e.what());
+ if(rethrow)
+ {
+ throw;
+ }
+ } catch(...)
+ {
+ ReportExceptionError(file, line, description, nullptr);
+ if(rethrow)
+ {
+ throw;
+ }
+ }
+}
+
+#if defined(_MSC_VER) && defined(_M_IX86)
+// on x86, break directly using asm break interrupt instead of calling DebugBreak which breaks one stackframe deeper than we want
+#define MyDebugBreak() do { __asm { int 3 }; } while(0)
+#else
+#define MyDebugBreak() DebugBreak()
+#endif
+
+#define ReportExceptionAndBreak(file, line, description, rethrow) do { ReportException(file, line, description, rethrow); if(IsDebuggerPresent()) MyDebugBreak(); } while(0)
+#define ReportErrorAndBreak(file, line, description, progress) do { ReportError(file, line, description, progress); if(IsDebuggerPresent()) MyDebugBreak(); } while(0)
+
+#define MULTI_TEST_TRY try {
+#define MULTI_TEST_START
+#define MULTI_TEST_END
+#define MULTI_TEST_CATCH } catch(...) { ReportExceptionAndBreak(THIS_FILE, __LINE__, description, false); }
+#define TEST_TRY try {
+#define TEST_CATCH } catch(...) { ReportExceptionAndBreak(THIS_FILE, __LINE__, description, true); }
+#define TEST_START() do { } while(0)
+#define TEST_OK() do { MPT_UNREFERENCED_PARAMETER(description); } while(0)
+#define TEST_FAIL() ReportErrorAndBreak(THIS_FILE, __LINE__, description, false)
+#define TEST_FAIL_STOP() ReportErrorAndBreak(THIS_FILE, __LINE__, description, true)
+
+
+
+//Verify that given parameters are 'equal'(show error message if not).
+//The exact meaning of equality is not specified; for now using operator!=.
+//The macro is active in both 'debug' and 'release' build.
+#define VERIFY_EQUAL(x,y) \
+do{ \
+ const char * const description = #x " == " #y ; \
+ TEST_TRY \
+ TEST_START(); \
+ if((x) != (y)) \
+ { \
+ TEST_FAIL(); \
+ } else \
+ { \
+ TEST_OK(); \
+ } \
+ TEST_CATCH \
+}while(0)
+
+
+// Like VERIFY_EQUAL, but throws exception if comparison fails.
+#define VERIFY_EQUAL_NONCONT(x,y) \
+do{ \
+ const char * const description = #x " == " #y ; \
+ TEST_TRY \
+ TEST_START(); \
+ if((x) != (y)) \
+ { \
+ TEST_FAIL_STOP(); \
+ } else \
+ { \
+ TEST_OK(); \
+ } \
+ TEST_CATCH \
+}while(0)
+
+
+// Like VERIFY_EQUAL_NONCONT, but do not show message if test succeeds
+#define VERIFY_EQUAL_QUIET_NONCONT(x,y) \
+do{ \
+ const char * const description = #x " == " #y ; \
+ TEST_TRY \
+ if((x) != (y)) \
+ { \
+ TEST_FAIL_STOP(); \
+ } \
+ TEST_CATCH \
+}while(0)
+
+
+#define DO_TEST(func) \
+do{ \
+ const char * description = #func ; \
+ MULTI_TEST_TRY \
+ MULTI_TEST_START \
+ func(); \
+ MULTI_TEST_END \
+ MULTI_TEST_CATCH \
+}while(0)
+
+
+} // namespace MptTest
+
+
+#endif // MODPLUG_TRACKER
+#endif // ENABLE_TESTS
+
Property changes on: trunk/OpenMPT/test/TestToolsTracker.h
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/x-chdr
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/OpenMPT/test/test.cpp
===================================================================
--- trunk/OpenMPT/test/test.cpp 2014-03-01 00:21:15 UTC (rev 3801)
+++ trunk/OpenMPT/test/test.cpp 2014-03-01 11:03:23 UTC (rev 3802)
@@ -35,10 +35,6 @@
#include "../common/mptFstream.h"
#endif // !MODPLUG_TRACKER
#include <limits>
-#ifndef MODPLUG_TRACKER
-#include <memory>
-#include <iostream>
-#endif // !MODPLUG_TRACKER
#include <istream>
#include <ostream>
#include <sstream>
@@ -50,289 +46,26 @@
#endif
#endif
+#include "TestTools.h"
-namespace MptTest
-{
-
-
#ifdef THIS_FILE
#undef THIS_FILE
#endif
#ifdef _MSC_VER
-#define THIS_FILE "..\\test\\test.cpp" // __FILE__
+static const char * const THIS_FILE = "..\\test\\test.cpp"; // __FILE__
#else
-#define THIS_FILE "test/test.cpp" // __FILE__
+static const char * const THIS_FILE = "test/test.cpp"; // __FILE__
#endif
-#ifdef MODPLUG_TRACKER
-
-static noinline void ReportError(const char * file, int line, const char * description, bool abort)
-//-------------------------------------------------------------------------------------------------
+namespace MptTest
{
- std::string pos = std::string() + file + "(" + Stringify(line) + "):\n";
- std::string message = pos + "Test failed: '" + description + "'";
- if(IsDebuggerPresent())
- {
- message += "\n";
- OutputDebugString(message.c_str());
- } else
- {
- if(abort)
- {
- throw std::runtime_error(message);
- } else
- {
- Reporting::Error(message.c_str(), "OpenMPT TestSuite");
- }
- }
-}
-static noinline void ReportExceptionError(const char * file, int line, const char * description, const char * exception_what)
-//---------------------------------------------------------------------------------------------------------------------------
-{
- std::string pos = std::string() + file + "(" + Stringify(line) + "):\n";
- std::string message;
- if(exception_what)
- {
- message = pos + "Test '" + description + "' threw an exception, message:\n" + exception_what;
- } else
- {
- message = pos + "Test '" + description + "' threw an unknown exception.";
- }
- if(IsDebuggerPresent())
- {
- message += "\n";
- OutputDebugString(message.c_str());
- } else
- {
- Reporting::Error(message.c_str(), "OpenMPT TestSuite");
- }
-}
-static noinline void ReportException(const char * const file, const int line, const char * const description, bool rethrow)
-//-------------------------------------------------------------------------------------------------------------------------
-{
- try
- {
- throw; // get the exception
- } catch(std::exception &e)
- {
- ReportExceptionError(file, line, description, e.what());
- if(rethrow)
- {
- throw;
- }
- } catch(...)
- {
- ReportExceptionError(file, line, description, nullptr);
- if(rethrow)
- {
- throw;
- }
- }
-}
-#if defined(_MSC_VER) && defined(_M_IX86)
-// on x86, break directly using asm break interrupt instead of calling DebugBreak which breaks one stackframe deeper than we want
-#define MyDebugBreak() do { __asm { int 3 }; } while(0)
-#else
-#define MyDebugBreak() DebugBreak()
-#endif
-
-#define ReportExceptionAndBreak(file, line, description, rethrow) do { ReportException(file, line, description, rethrow); if(IsDebuggerPresent()) MyDebugBreak(); } while(0)
-#define ReportErrorAndBreak(file, line, description, progress) do { ReportError(file, line, description, progress); if(IsDebuggerPresent()) MyDebugBreak(); } while(0)
-
-#define MULTI_TEST_TRY try {
-#define MULTI_TEST_START
-#define MULTI_TEST_END
-#define MULTI_TEST_CATCH } catch(...) { ReportExceptionAndBreak(THIS_FILE, __LINE__, description, false); }
-#define TEST_TRY try {
-#define TEST_CATCH } catch(...) { ReportExceptionAndBreak(file, line, description, true); }
-#define TEST_START() do { } while(0)
-#define TEST_OK() do { MPT_UNREFERENCED_PARAMETER(description); } while(0)
-#define TEST_FAIL() ReportErrorAndBreak(file, line, description, false)
-#define TEST_FAIL_STOP() ReportErrorAndBreak(file, line, description, true)
-
-#else // !MODPLUG_TRACKER
-
-static std::string remove_newlines(std::string str)
-{
- return mpt::String::Replace(mpt::String::Replace(str, "\n", " "), "\r", " ");
-}
-
-static noinline void show_start(const char * const file, const int line, const char * const description)
-{
- std::cout << "Test: " << file << "(" << line << "): " << remove_newlines(description) << ": ";
-}
-
-static noinline void MultiTestStart(const char * const file, const int line, const char * const description)
-{
- show_start(file, line, description);
- std::cout << "..." << std::endl;
-}
-
-static noinline void show_ok(const char * const file, const int line, const char * const description)
-{
- MPT_UNREFERENCED_PARAMETER(file);
- MPT_UNREFERENCED_PARAMETER(line);
- MPT_UNREFERENCED_PARAMETER(description);
- std::cout << "PASS" << std::endl;
-}
-
-static noinline void show_fail(const char * const file, const int line, const char * const description, bool exception = false, const char * const exception_text = nullptr)
-{
- std::cout << "FAIL" << std::endl;
- std::cout.flush();
- if(!exception)
- {
- std::cerr << "FAIL: " << file << "(" << line << "): " << remove_newlines(description) << std::endl;
- } else if(!exception_text || (exception_text && std::string(exception_text).empty()))
- {
- std::cerr << "FAIL: " << file << "(" << line << "): " << remove_newlines(description) << " EXCEPTION!" << std::endl;
- } else
- {
- std::cerr << "FAIL: " << file << "(" << line << "): " << remove_newlines(description) << " EXCEPTION: " << exception_text << std::endl;
- }
- std::cerr.flush();
-}
-
-static int fail_count = 0;
-
-static noinline void CheckFailCountOrThrow()
-{
- if(fail_count > 0)
- {
- throw std::runtime_error("Test failed.");
- }
-}
-
-static noinline void ReportException(const char * const file, const int line, const char * const description)
-{
- try
- {
- throw; // get the exception
- } catch(std::exception & e)
- {
- show_fail(file, line, description, true, e.what());
- throw; // rethrow
- } catch(...)
- {
- show_fail(file, line, description, true);
- throw; // rethrow
- }
-}
-
-static noinline void TestFail(const char * const file, const int line, const char * const description)
-{
- show_fail(file, line, description);
- fail_count++;
-}
-
-static noinline void TestFailStop(const char * const file, const int line, const char * const description)
-{
- show_fail(file, line, description);
- fail_count++;
- throw std::runtime_error(std::string("Test failed: ") + description);
-}
-
-#define MULTI_TEST_TRY try { \
- fail_count = 0;
-#define MULTI_TEST_START MultiTestStart(THIS_FILE, __LINE__, description);
-#define MULTI_TEST_END show_start(THIS_FILE, __LINE__, description);
-#define MULTI_TEST_CATCH CheckFailCountOrThrow(); \
- show_ok(THIS_FILE, __LINE__, description); \
- } catch(...) { \
- ReportException(THIS_FILE, __LINE__, description); \
- }
-#define TEST_TRY try {
-#define TEST_CATCH } catch(...) { \
- fail_count++; \
- ReportException(file, line, description); \
- throw; \
- }
-#define TEST_START() show_start(file, line, description)
-#define TEST_OK() show_ok(file, line, description)
-#define TEST_FAIL() TestFail(file, line, description)
-#define TEST_FAIL_STOP() TestFailStop(file, line, description)
-
-#endif // MODPLUG_TRACKER
-
-
-template <typename Tx, typename Ty>
-noinline void VerifyEqualImpl(const Tx &x, const Ty &y, const char *const description, const char *const file, const int line)
-{
- TEST_TRY
- TEST_START();
- if(x != y)
- {
- TEST_FAIL();
- } else
- {
- TEST_OK();
- }
- TEST_CATCH
-}
-
-
-template <typename Tx, typename Ty>
-noinline void VerifyEqualNonContImpl(const Tx &x, const Ty &y, const char *const description, const char *const file, const int line)
-{
- TEST_TRY
- TEST_START();
- if(x != y)
- {
- TEST_FAIL_STOP();
- } else
- {
- TEST_OK();
- }
- TEST_CATCH
-}
-
-
-template <typename Tx, typename Ty>
-noinline void VerifyEqualQuietNonContImpl(const Tx &x, const Ty &y, const char *const description, const char *const file, const int line)
-{
- TEST_TRY
- if(x != y)
- {
- TEST_FAIL_STOP();
- }
- TEST_CATCH
-}
-
-
-//Verify that given parameters are 'equal'(show error message if not).
-//The exact meaning of equality is not specified; for now using operator!=.
-//The macro is active in both 'debug' and 'release' build.
-#define VERIFY_EQUAL(x,y) VerifyEqualImpl( (x) , (y) , #x " == " #y , THIS_FILE, __LINE__)
-
-
-// Like VERIFY_EQUAL, but throws exception if comparison fails.
-#define VERIFY_EQUAL_NONCONT(x,y) VerifyEqualNonContImpl( (x) , (y) , #x " == " #y , THIS_FILE, __LINE__)
-
-
-// Like VERIFY_EQUAL_NONCONT, but do not show message if test succeeds
-#define VERIFY_EQUAL_QUIET_NONCONT(x,y) VerifyEqualQuietNonContImpl( (x) , (y) , #x " == " #y , THIS_FILE, __LINE__)
-
-
-#define DO_TEST(func) \
-do{ \
- const char * description = #func ; \
- MULTI_TEST_TRY \
- MULTI_TEST_START \
- func(); \
- MULTI_TEST_END \
- MULTI_TEST_CATCH \
-}while(0)
-
-
-
-
static noinline void TestVersion();
static noinline void TestTypes();
static noinline void TestMisc();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2014-03-02 09:59:40
|
Revision: 3806
http://sourceforge.net/p/modplug/code/3806
Author: manxorist
Date: 2014-03-02 09:59:31 +0000 (Sun, 02 Mar 2014)
Log Message:
-----------
[Ref] Test: Rewrite test framework for libopenmpt in order to make the code more readable.
[Ref] Test: Add an currently disabled alternate C++11 version of the test framework for libopenmpt.
Modified Paths:
--------------
trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj
trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters
trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj
trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj.filters
trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj
trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj.filters
trunk/OpenMPT/mptrack/mptrack_08.vcproj
trunk/OpenMPT/mptrack/mptrack_10.vcxproj
trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters
trunk/OpenMPT/test/TestToolsLib.h
Added Paths:
-----------
trunk/OpenMPT/test/TestToolsLib.cpp
Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj
===================================================================
--- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2014-03-01 20:53:01 UTC (rev 3805)
+++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2014-03-02 09:59:31 UTC (rev 3806)
@@ -334,6 +334,7 @@
<ClCompile Include="..\soundlib\WindowedFIR.cpp" />
<ClCompile Include="..\soundlib\XMTools.cpp" />
<ClCompile Include="..\test\test.cpp" />
+ <ClCompile Include="..\test\TestToolsLib.cpp" />
<ClCompile Include="libopenmpt_c.cpp" />
<ClCompile Include="libopenmpt_cxx.cpp" />
<ClCompile Include="libopenmpt_ext.cpp" />
Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters
===================================================================
--- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters 2014-03-01 20:53:01 UTC (rev 3805)
+++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters 2014-03-02 09:59:31 UTC (rev 3806)
@@ -514,5 +514,8 @@
<ClCompile Include="..\common\Logging.cpp">
<Filter>Source Files\common</Filter>
</ClCompile>
+ <ClCompile Include="..\test\TestToolsLib.cpp">
+ <Filter>Source Files\test</Filter>
+ </ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
Modified: trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj
===================================================================
--- trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj 2014-03-01 20:53:01 UTC (rev 3805)
+++ trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj 2014-03-02 09:59:31 UTC (rev 3806)
@@ -344,6 +344,7 @@
<ClCompile Include="..\soundlib\WindowedFIR.cpp" />
<ClCompile Include="..\soundlib\XMTools.cpp" />
<ClCompile Include="..\test\test.cpp" />
+ <ClCompile Include="..\test\TestToolsLib.cpp" />
<ClCompile Include="libopenmpt_c.cpp" />
<ClCompile Include="libopenmpt_cxx.cpp" />
<ClCompile Include="libopenmpt_ext.cpp" />
Modified: trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj.filters
===================================================================
--- trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj.filters 2014-03-01 20:53:01 UTC (rev 3805)
+++ trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj.filters 2014-03-02 09:59:31 UTC (rev 3806)
@@ -520,5 +520,8 @@
<ClCompile Include="..\common\Logging.cpp">
<Filter>Source Files\common</Filter>
</ClCompile>
+ <ClCompile Include="..\test\TestToolsLib.cpp">
+ <Filter>Source Files\test</Filter>
+ </ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
Modified: trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj
===================================================================
--- trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj 2014-03-01 20:53:01 UTC (rev 3805)
+++ trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj 2014-03-02 09:59:31 UTC (rev 3806)
@@ -338,6 +338,7 @@
<ClCompile Include="..\soundlib\WindowedFIR.cpp" />
<ClCompile Include="..\soundlib\XMTools.cpp" />
<ClCompile Include="..\test\test.cpp" />
+ <ClCompile Include="..\test\TestToolsLib.cpp" />
<ClCompile Include="libopenmpt_c.cpp" />
<ClCompile Include="libopenmpt_cxx.cpp" />
<ClCompile Include="libopenmpt_ext.cpp" />
Modified: trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj.filters
===================================================================
--- trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj.filters 2014-03-01 20:53:01 UTC (rev 3805)
+++ trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj.filters 2014-03-02 09:59:31 UTC (rev 3806)
@@ -517,5 +517,8 @@
<ClCompile Include="..\common\Logging.cpp">
<Filter>Source Files\common</Filter>
</ClCompile>
+ <ClCompile Include="..\test\TestToolsLib.cpp">
+ <Filter>Source Files\test</Filter>
+ </ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj
===================================================================
--- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2014-03-01 20:53:01 UTC (rev 3805)
+++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2014-03-02 09:59:31 UTC (rev 3806)
@@ -1259,11 +1259,11 @@
>
</File>
<File
- RelativePath="..\common\svn_version_default\svn_version.h"
+ RelativePath=".\svn_version\svn_version.h"
>
</File>
<File
- RelativePath=".\svn_version\svn_version.h"
+ RelativePath="..\common\svn_version_default\svn_version.h"
>
</File>
<File
@@ -1455,6 +1455,10 @@
>
</File>
<File
+ RelativePath="..\test\TestToolsLib.cpp"
+ >
+ </File>
+ <File
RelativePath="..\test\TestToolsLib.h"
>
</File>
Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj
===================================================================
--- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2014-03-01 20:53:01 UTC (rev 3805)
+++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2014-03-02 09:59:31 UTC (rev 3806)
@@ -507,6 +507,7 @@
<ClCompile Include="..\soundlib\WindowedFIR.cpp" />
<ClCompile Include="..\soundlib\XMTools.cpp" />
<ClCompile Include="..\test\test.cpp" />
+ <ClCompile Include="..\test\TestToolsLib.cpp" />
<ClCompile Include="..\unarchiver\unarchiver.cpp" />
<ClCompile Include="..\unarchiver\ungzip.cpp" />
<ClCompile Include="..\unarchiver\unlha.cpp" />
Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters
===================================================================
--- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2014-03-01 20:53:01 UTC (rev 3805)
+++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2014-03-02 09:59:31 UTC (rev 3806)
@@ -502,6 +502,9 @@
<ClCompile Include="..\common\Logging.cpp">
<Filter>Source Files\common</Filter>
</ClCompile>
+ <ClCompile Include="..\test\TestToolsLib.cpp">
+ <Filter>test</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\soundlib\Loaders.h">
Added: trunk/OpenMPT/test/TestToolsLib.cpp
===================================================================
--- trunk/OpenMPT/test/TestToolsLib.cpp (rev 0)
+++ trunk/OpenMPT/test/TestToolsLib.cpp 2014-03-02 09:59:31 UTC (rev 3806)
@@ -0,0 +1,178 @@
+/*
+ * TestToolsLib.cpp
+ * ----------------
+ * Purpose: Unit test framework for libopenmpt.
+ * Notes : Currently somewhat unreadable :/
+ * Authors: OpenMPT Devs
+ * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
+ */
+
+
+#include "stdafx.h"
+#include "TestToolsLib.h"
+
+
+#ifdef ENABLE_TESTS
+#ifndef MODPLUG_TRACKER
+
+
+#include <exception>
+#include <iostream>
+
+
+namespace MptTest
+{
+
+
+int fail_count = 0;
+
+
+static std::string remove_newlines(std::string str)
+{
+ return mpt::String::Replace(mpt::String::Replace(str, "\n", " "), "\r", " ");
+}
+
+
+Context::Context(const char * file, int line)
+ : file(file)
+ , line(line)
+{
+ return;
+}
+
+
+Context::Context(const Context &c)
+ : file(c.file)
+ , line(c.line)
+{
+ return;
+}
+
+
+Test::Test(Fatality fatality, Verbosity verbosity, const char * const desc, const Context &context)
+ : fatality(fatality)
+ , verbosity(verbosity)
+ , desc(desc)
+ , context(context)
+{
+ return;
+}
+
+
+std::string Test::AsString() const
+{
+ return mpt::String::Print("Test: %1(%2): %3", context.file, context.line, remove_newlines(desc));
+}
+
+
+void Test::ShowStart() const
+{
+ switch(verbosity)
+ {
+ case VerbosityQuiet:
+ break;
+ case VerbosityNormal:
+ case VerbosityVerbose:
+ std::cout << AsString() << ": " << std::endl;
+ break;
+ }
+}
+
+
+void Test::ShowProgress(const char * text) const
+{
+ switch(verbosity)
+ {
+ case VerbosityQuiet:
+ break;
+ case VerbosityNormal:
+ case VerbosityVerbose:
+ std::cout << AsString() << ": " << text << std::endl;
+ break;
+ }
+}
+
+
+void Test::ShowPass() const
+{
+ switch(verbosity)
+ {
+ case VerbosityQuiet:
+ break;
+ case VerbosityNormal:
+ case VerbosityVerbose:
+ std::cout << AsString() << ": PASS" << std::endl;
+ break;
+ }
+}
+
+
+void Test::ShowFail(bool exception, const char * const text) const
+{
+ std::cout << AsString() << ": FAIL" << std::endl;
+ std::cout.flush();
+ if(!exception)
+ {
+ if(!text || (text && std::string(text).empty()))
+ {
+ std::cerr << "FAIL: " << AsString() << std::endl;
+ } else
+ {
+ std::cerr << "FAIL: " << AsString() << " : " << text << std::endl;
+ }
+ } else
+ {
+ if(!text || (text && std::string(text).empty()))
+ {
+ std::cerr << "FAIL: " << AsString() << " EXCEPTION!" << std::endl;
+ } else
+ {
+ std::cerr << "FAIL: " << AsString() << " EXCEPTION: " << text << std::endl;
+ }
+ }
+ std::cerr.flush();
+}
+
+
+void Test::ReportPassed()
+{
+ ShowPass();
+}
+
+
+void Test::ReportFailed()
+{
+ fail_count++;
+ ReportException();
+}
+
+
+void Test::ReportException()
+{
+ try
+ {
+ throw; // get the exception
+ } catch(TestFailed & e)
+ {
+ ShowFail(false, e.values.c_str());
+ if(fatality == FatalityStop)
+ {
+ throw; // rethrow
+ }
+ } catch(std::exception & e)
+ {
+ ShowFail(true, e.what());
+ throw; // rethrow
+ } catch(...)
+ {
+ ShowFail(true);
+ throw; // rethrow
+ }
+}
+
+
+} // namespace MptTest
+
+
+#endif // !MODPLUG_TRACKER
+#endif // ENABLE_TESTS
Property changes on: trunk/OpenMPT/test/TestToolsLib.cpp
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/x-c++src
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/OpenMPT/test/TestToolsLib.h
===================================================================
--- trunk/OpenMPT/test/TestToolsLib.h 2014-03-01 20:53:01 UTC (rev 3805)
+++ trunk/OpenMPT/test/TestToolsLib.h 2014-03-02 09:59:31 UTC (rev 3806)
@@ -15,181 +15,162 @@
#ifndef MODPLUG_TRACKER
-#include <memory>
-#include <iostream>
-
-
namespace MptTest
{
-static std::string remove_newlines(std::string str)
-{
- return mpt::String::Replace(mpt::String::Replace(str, "\n", " "), "\r", " ");
-}
+extern int fail_count;
-static noinline void show_start(const char * const file, const int line, const char * const description)
-{
- std::cout << "Test: " << file << "(" << line << "): " << remove_newlines(description) << ": ";
-}
-static noinline void MultiTestStart(const char * const file, const int line, const char * const description)
+enum Verbosity
{
- show_start(file, line, description);
- std::cout << "..." << std::endl;
-}
+ VerbosityQuiet,
+ VerbosityNormal,
+ VerbosityVerbose,
+};
-static noinline void show_ok(const char * const file, const int line, const char * const description)
+enum Fatality
{
- MPT_UNREFERENCED_PARAMETER(file);
- MPT_UNREFERENCED_PARAMETER(line);
- MPT_UNREFERENCED_PARAMETER(description);
- std::cout << "PASS" << std::endl;
-}
+ FatalityContinue,
+ FatalityStop
+};
-static noinline void show_fail(const char * const file, const int line, const char * const description, bool exception = false, const char * const exception_text = nullptr)
+
+struct Context
{
- std::cout << "FAIL" << std::endl;
- std::cout.flush();
- if(!exception)
- {
- std::cerr << "FAIL: " << file << "(" << line << "): " << remove_newlines(description) << std::endl;
- } else if(!exception_text || (exception_text && std::string(exception_text).empty()))
- {
- std::cerr << "FAIL: " << file << "(" << line << "): " << remove_newlines(description) << " EXCEPTION!" << std::endl;
- } else
- {
- std::cerr << "FAIL: " << file << "(" << line << "): " << remove_newlines(description) << " EXCEPTION: " << exception_text << std::endl;
- }
- std::cerr.flush();
-}
+public:
+ const char * const file;
+ const int line;
+public:
+ Context(const char * file, int line);
+ Context(const Context &c);
+};
-static int fail_count = 0;
+#define MPT_TEST_CONTEXT_CURRENT() (::MptTest::Context( __FILE__ , __LINE__ ))
-static noinline void CheckFailCountOrThrow()
-{
- if(fail_count > 0)
- {
- throw std::runtime_error("Test failed.");
- }
-}
-static noinline void ReportException(const char * const file, const int line, const char * const description)
+struct TestFailed
{
- try
- {
- throw; // get the exception
- } catch(std::exception & e)
- {
- show_fail(file, line, description, true, e.what());
- throw; // rethrow
- } catch(...)
- {
- show_fail(file, line, description, true);
- throw; // rethrow
- }
-}
+ std::string values;
+ TestFailed(const std::string &values) : values(values) { }
+ TestFailed() { }
+};
-static noinline void TestFail(const char * const file, const int line, const char * const description)
-{
- show_fail(file, line, description);
- fail_count++;
-}
-static noinline void TestFailStop(const char * const file, const int line, const char * const description)
+class Test
{
- show_fail(file, line, description);
- fail_count++;
- throw std::runtime_error(std::string("Test failed: ") + description);
-}
-#define MULTI_TEST_TRY try { \
- fail_count = 0;
-#define MULTI_TEST_START MultiTestStart(THIS_FILE, __LINE__, description);
-#define MULTI_TEST_END show_start(THIS_FILE, __LINE__, description);
-#define MULTI_TEST_CATCH CheckFailCountOrThrow(); \
- show_ok(THIS_FILE, __LINE__, description); \
- } catch(...) { \
- ReportException(THIS_FILE, __LINE__, description); \
- }
-#define TEST_TRY try {
-#define TEST_CATCH } catch(...) { \
- fail_count++; \
- ReportException(file, line, description); \
- throw; \
- }
-#define TEST_START() show_start(file, line, description)
-#define TEST_OK() show_ok(file, line, description)
-#define TEST_FAIL() TestFail(file, line, description)
-#define TEST_FAIL_STOP() TestFailStop(file, line, description)
+private:
+ Fatality const fatality;
+ Verbosity const verbosity;
+ const char * const desc;
+ Context const context;
-template <typename Tx, typename Ty>
-noinline void VerifyEqualImpl(const Tx &x, const Ty &y, const char *const description, const char *const file, const int line)
-{
- TEST_TRY
- TEST_START();
- if(x != y)
- {
- TEST_FAIL();
- } else
- {
- TEST_OK();
- }
- TEST_CATCH
-}
+public:
+ Test(Fatality fatality, Verbosity verbosity, const char * const desc, const Context &context);
-template <typename Tx, typename Ty>
-noinline void VerifyEqualNonContImpl(const Tx &x, const Ty &y, const char *const description, const char *const file, const int line)
-{
- TEST_TRY
- TEST_START();
- if(x != y)
+public:
+
+ std::string AsString() const;
+
+ void ShowStart() const;
+ void ShowProgress(const char * text) const;
+ void ShowPass() const;
+ void ShowFail(bool exception = false, const char * const text = nullptr) const;
+
+ void ReportPassed();
+ void ReportFailed();
+
+ void ReportException();
+
+public:
+
+#if 0 // C++11 version
+
+private:
+
+ template <typename Tx, typename Ty>
+ noinline void TypeCompareHelper(const Tx &x, const Ty &y)
{
- TEST_FAIL_STOP();
- } else
- {
- TEST_OK();
+ if(x != y)
+ {
+ //throw TestFailed(mpt::String::Print("%1 != %2", x, y));
+ throw TestFailed();
+ }
}
- TEST_CATCH
-}
+public:
-template <typename Tx, typename Ty>
-noinline void VerifyEqualQuietNonContImpl(const Tx &x, const Ty &y, const char *const description, const char *const file, const int line)
-{
- TEST_TRY
- if(x != y)
+ template <typename Tfx, typename Tfy>
+ noinline void operator () (const Tfx &fx, const Tfy &fy)
{
- TEST_FAIL_STOP();
+ ShowStart();
+ try
+ {
+ ShowProgress("Calculate x ...");
+ const auto x = fx();
+ ShowProgress("Calculate y ...");
+ const auto y = fy();
+ ShowProgress("Compare ...");
+ TypeCompareHelper(x, y);
+ ReportPassed();
+ } catch(...)
+ {
+ ReportFailed();
+ }
}
- TEST_CATCH
-}
+ #define VERIFY_EQUAL(x,y) ::MptTest::Test(::MptTest::FatalityContinue, ::MptTest::VerbosityNormal, #x " == " #y , MPT_TEST_CONTEXT_CURRENT() )( [&](){return (x) ;}, [&](){return (y) ;} )
+ #define VERIFY_EQUAL_NONCONT(x,y) ::MptTest::Test(::MptTest::FatalityStop, ::MptTest::VerbosityNormal, #x " == " #y , MPT_TEST_CONTEXT_CURRENT() )( [&](){return (x) ;}, [&](){return (y) ;} )
+ #define VERIFY_EQUAL_QUIET_NONCONT(x,y) ::MptTest::Test(::MptTest::FatalityStop, ::MptTest::VerbosityQuiet, #x " == " #y , MPT_TEST_CONTEXT_CURRENT() )( [&](){return (x) ;}, [&](){return (y) ;} )
-//Verify that given parameters are 'equal'(show error message if not).
-//The exact meaning of equality is not specified; for now using operator!=.
-//The macro is active in both 'debug' and 'release' build.
-#define VERIFY_EQUAL(x,y) VerifyEqualImpl( (x) , (y) , #x " == " #y , THIS_FILE, __LINE__)
+#else
+public:
-// Like VERIFY_EQUAL, but throws exception if comparison fails.
-#define VERIFY_EQUAL_NONCONT(x,y) VerifyEqualNonContImpl( (x) , (y) , #x " == " #y , THIS_FILE, __LINE__)
+ template <typename Tx, typename Ty>
+ noinline void operator () (const Tx &x, const Ty &y)
+ {
+ ShowStart();
+ try
+ {
+ if(x != y)
+ {
+ //throw TestFailed(mpt::String::Print("%1 != %2", x, y));
+ throw TestFailed();
+ }
+ ReportPassed();
+ } catch(...)
+ {
+ ReportFailed();
+ }
+ }
+ #define VERIFY_EQUAL(x,y) ::MptTest::Test(::MptTest::FatalityContinue, ::MptTest::VerbosityNormal, #x " == " #y , MPT_TEST_CONTEXT_CURRENT() )( (x) , (y) )
+ #define VERIFY_EQUAL_NONCONT(x,y) ::MptTest::Test(::MptTest::FatalityStop, ::MptTest::VerbosityNormal, #x " == " #y , MPT_TEST_CONTEXT_CURRENT() )( (x) , (y) )
+ #define VERIFY_EQUAL_QUIET_NONCONT(x,y) ::MptTest::Test(::MptTest::FatalityStop, ::MptTest::VerbosityQuiet, #x " == " #y , MPT_TEST_CONTEXT_CURRENT() )( (x) , (y) )
-// Like VERIFY_EQUAL_NONCONT, but do not show message if test succeeds
-#define VERIFY_EQUAL_QUIET_NONCONT(x,y) VerifyEqualQuietNonContImpl( (x) , (y) , #x " == " #y , THIS_FILE, __LINE__)
+#endif
+};
+
#define DO_TEST(func) \
do{ \
- const char * description = #func ; \
- MULTI_TEST_TRY \
- MULTI_TEST_START \
- func(); \
- MULTI_TEST_END \
- MULTI_TEST_CATCH \
+ ::MptTest::Test test(::MptTest::FatalityStop, ::MptTest::VerbosityNormal, #func , MPT_TEST_CONTEXT_CURRENT() ); \
+ try { \
+ test.ShowStart(); \
+ fail_count = 0; \
+ func(); \
+ if(fail_count > 0) { \
+ throw ::MptTest::TestFailed(); \
+ } \
+ test.ReportPassed(); \
+ } catch(...) { \
+ test.ReportException(); \
+ } \
}while(0)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-03-03 16:41:35
|
Revision: 3812
http://sourceforge.net/p/modplug/code/3812
Author: saga-games
Date: 2014-03-03 16:41:27 +0000 (Mon, 03 Mar 2014)
Log Message:
-----------
[Ref] GetLength operates on a copy of the CSoundFile state now. Makes handling some thingss easier.
[Imp] Improve sample sync on seek further based on these changes.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/Moddoc.cpp
trunk/OpenMPT/mptrack/View_smp.cpp
trunk/OpenMPT/soundlib/ModChannel.cpp
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/Sndfile.cpp
trunk/OpenMPT/soundlib/Sndfile.h
trunk/OpenMPT/soundlib/Sndmix.cpp
Modified: trunk/OpenMPT/mptrack/Moddoc.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Moddoc.cpp 2014-03-03 15:41:56 UTC (rev 3811)
+++ trunk/OpenMPT/mptrack/Moddoc.cpp 2014-03-03 16:41:27 UTC (rev 3812)
@@ -1102,7 +1102,7 @@
chn.nFadeOutVol = 0x10000;
}
- m_SndFile.NoteChange(nChn, note, false, true, true);
+ m_SndFile.NoteChange(&chn, note, false, true, true);
if (nVol >= 0) chn.nVolume = nVol;
// Handle sample looping.
@@ -1160,7 +1160,7 @@
} else
{
CriticalSection cs;
- m_SndFile.NoteChange(nChn, note);
+ m_SndFile.NoteChange(&m_SndFile.m_PlayState.Chn[nChn], note);
if (pause) m_SndFile.m_SongFlags.set(SONG_PAUSED);
}
return nChn;
@@ -1208,7 +1208,7 @@
// Could conflict with NNAs.
if(!pChn->dwFlags[mask] && pChn->nLength && (note == pChn->nNewNote || !note))
{
- m_SndFile.KeyOff(i);
+ m_SndFile.KeyOff(pChn);
if (!m_SndFile.m_nInstruments) pChn->dwFlags.reset(CHN_LOOP); // FIXME: If a sample with pingpong loop is playing backwards, stuff before the loop is played again!
if (fade) pChn->dwFlags.set(CHN_NOTEFADE);
if (note) break;
Modified: trunk/OpenMPT/mptrack/View_smp.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_smp.cpp 2014-03-03 15:41:56 UTC (rev 3811)
+++ trunk/OpenMPT/mptrack/View_smp.cpp 2014-03-03 16:41:27 UTC (rev 3812)
@@ -2414,8 +2414,9 @@
//----------------------------------------------
{
CSoundFile &sndFile = GetDocument()->GetrSoundFile();
- sndFile.KeyOff(noteChannel[note - NOTE_MIN]);
- sndFile.m_PlayState.Chn[noteChannel[note - NOTE_MIN]].dwFlags.set(CHN_NOTEFADE);
+ ModChannel &chn = sndFile.m_PlayState.Chn[noteChannel[note - NOTE_MIN]];
+ sndFile.KeyOff(&chn);
+ chn.dwFlags.set(CHN_NOTEFADE);
noteChannel[note - NOTE_MIN] = CHANNELINDEX_INVALID;
}
@@ -2951,7 +2952,7 @@
if(noteChannel[note - NOTE_MIN] != CHANNELINDEX_INVALID)
{
// Release sustain loop on key up
- pModDoc->GetrSoundFile().KeyOff(noteChannel[note - NOTE_MIN]);
+ pModDoc->GetrSoundFile().KeyOff(&GetDocument()->GetrSoundFile().m_PlayState.Chn[noteChannel[note - NOTE_MIN]]);
}
break;
case seNoteOffOnKeyUp:
Modified: trunk/OpenMPT/soundlib/ModChannel.cpp
===================================================================
--- trunk/OpenMPT/soundlib/ModChannel.cpp 2014-03-03 15:41:56 UTC (rev 3811)
+++ trunk/OpenMPT/soundlib/ModChannel.cpp 2014-03-03 16:41:27 UTC (rev 3812)
@@ -57,6 +57,7 @@
rightRamp = leftRamp = 0;
nVolume = 256;
nVibratoPos = nTremoloPos = nPanbrelloPos = 0;
+ nOldHiOffset = 0;
//-->Custom tuning related
m_ReCalculateFreqOnFirstTick = false;
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-03-03 15:41:56 UTC (rev 3811)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-03-03 16:41:27 UTC (rev 3812)
@@ -46,37 +46,23 @@
{
public:
+ CSoundFile::PlayState state;
struct ChnSettings
{
double patLoop;
ROWINDEX patLoopStart;
- UINT chnVol;
- ModCommand::PARAM oldGlbVolSlide;
- ModCommand::NOTE note;
- ModCommand::INSTR instr;
- ModCommand::PARAM oldParam;
- uint8 hiOffset;
BYTE vol;
ChnSettings()
{
patLoop = 0.0;
patLoopStart = 0;
- chnVol = 0;
- oldGlbVolSlide = 0;
- note = NOTE_NONE;
- instr = 0;
- oldParam = 0;
- hiOffset = 0;
vol = 0xFF;
}
};
+ std::vector<ChnSettings> chnSettings;
double elapsedTime;
- CSoundFile::samplecount_t renderedSamples;
- UINT musicSpeed, musicTempo;
- LONG glbVol;
- std::vector<ChnSettings> chnSettings;
protected:
const CSoundFile &sndFile;
@@ -85,20 +71,25 @@
GetLengthMemory(const CSoundFile &sf) : sndFile(sf)
{
+ state = sf.m_PlayState;
Reset();
};
void Reset()
{
elapsedTime = 0.0;
- renderedSamples = 0;
- musicSpeed = sndFile.m_nDefaultSpeed;
- musicTempo = sndFile.m_nDefaultTempo;
- glbVol = sndFile.m_nDefaultGlobalVolume;
+ state.m_lTotalSampleCount = 0;
+ state.m_nMusicSpeed = sndFile.m_nDefaultSpeed;
+ state.m_nMusicTempo = sndFile.m_nDefaultTempo;
+ state.m_nGlobalVolume = sndFile.m_nDefaultGlobalVolume;
chnSettings.assign(sndFile.GetNumChannels(), ChnSettings());
for(CHANNELINDEX chn = 0; chn < sndFile.GetNumChannels(); chn++)
{
- chnSettings[chn].chnVol = sndFile.ChnSettings[chn].nVolume;
+ state.Chn[chn].Reset(ModChannel::resetTotal, sndFile, chn);
+ state.Chn[chn].nOldHiOffset = 0;
+ state.Chn[chn].nOldGlobalVolSlide = 0;
+ state.Chn[chn].nOldChnVolSlide = 0;
+ state.Chn[chn].nNewNote = state.Chn[chn].nLastNote = NOTE_NONE;
}
}
};
@@ -122,22 +113,12 @@
retval.lastOrder = retval.endOrder = ORDERINDEX_INVALID;
retval.lastRow = retval.endRow = ROWINDEX_INVALID;
- ModChannel origChannels[CountOf(m_PlayState.Chn)];
- if(adjustMode & eAdjust)
- {
- for(CHANNELINDEX i = 0; i < CountOf(m_PlayState.Chn); i++)
- {
- origChannels[i] = m_PlayState.Chn[i];
- }
- }
-
// Are we trying to reach a certain pattern position?
const bool hasSearchTarget = target.mode != GetLengthTarget::NoTarget;
ROWINDEX nRow = 0, nNextRow = 0;
ROWINDEX nNextPatStartRow = 0; // FT2 E60 bug
ORDERINDEX nCurrentOrder = 0, nNextOrder = 0;
- PATTERNINDEX nPattern = Order[0];
GetLengthMemory memory(*this);
// Temporary visited rows vector (so that GetLength() won't interfere with the player code if the module is playing at the same time)
@@ -145,7 +126,7 @@
for (;;)
{
- UINT rowDelay = 0, tickDelay = 0;
+ uint32 rowDelay = 0, tickDelay = 0;
nRow = nNextRow;
nCurrentOrder = nNextOrder;
@@ -153,7 +134,7 @@
break;
// Check if pattern is valid
- nPattern = Order[nCurrentOrder];
+ PATTERNINDEX nPattern = Order[nCurrentOrder];
bool positionJumpOnThisRow = false;
bool patternBreakOnThisRow = false;
bool patternLoopEndedOnThisRow = false;
@@ -255,7 +236,7 @@
memory.chnSettings[chn].patLoop = memory.elapsedTime;
}
- ModChannel *pChn = m_PlayState.Chn;
+ ModChannel *pChn = memory.state.Chn;
ModCommand *p = Patterns[nPattern].GetRow(nRow);
ModCommand *nextRow = nullptr;
for(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); p++, pChn++, nChn++) if(!p->IsEmpty())
@@ -265,8 +246,13 @@
ModCommand::COMMAND command = p->command;
ModCommand::PARAM param = p->param;
ModCommand::NOTE note = p->note;
- if (p->instr) { memory.chnSettings[nChn].instr = p->instr; memory.chnSettings[nChn].note = NOTE_NONE; memory.chnSettings[nChn].vol = 0xFF; }
- if ((note >= NOTE_MIN) && (note <= NOTE_MAX)) memory.chnSettings[nChn].note = note;
+ if (p->instr)
+ {
+ pChn->nNewIns = p->instr;
+ pChn->nLastNote = NOTE_NONE;
+ memory.chnSettings[nChn].vol = 0xFF;
+ }
+ if (p->IsNote()) pChn->nLastNote = note;
if (p->volcmd == VOLCMD_VOLUME) { memory.chnSettings[nChn].vol = p->vol; }
switch(command)
{
@@ -326,14 +312,14 @@
// so it effectively counts down 65536 ticks with speed = 0 (song speed is a 16-bit variable in FT2)
if(GetType() == MOD_TYPE_XM && !param)
{
- memory.musicSpeed = uint16_max;
+ memory.state.m_nMusicSpeed = uint16_max;
}
#endif // MODPLUG_TRACKER
if (!param) break;
// 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 <= GetModSpecifications().speedMax) || GetType() == MOD_TYPE_MOD)
{
- memory.musicSpeed = param;
+ memory.state.m_nMusicSpeed = param;
}
break;
// Set Tempo
@@ -342,27 +328,27 @@
{
if (param) pChn->nOldTempo = (BYTE)param; else param = pChn->nOldTempo;
}
- if (param >= 0x20) memory.musicTempo = param; else
+ if (param >= 0x20) memory.state.m_nMusicTempo = param; else
{
// Tempo Slide
- uint32 tempoDiff = (param & 0x0F) * (memory.musicSpeed - 1);
+ uint32 tempoDiff = (param & 0x0F) * (memory.state.m_nMusicSpeed - 1);
if ((param & 0xF0) == 0x10)
{
- memory.musicTempo += tempoDiff;
+ memory.state.m_nMusicTempo += tempoDiff;
} else
{
- if(tempoDiff < memory.musicTempo)
- memory.musicTempo -= tempoDiff;
+ if(tempoDiff < memory.state.m_nMusicTempo)
+ memory.state.m_nMusicTempo -= tempoDiff;
else
- memory.musicTempo = 32;
+ memory.state.m_nMusicTempo = 32;
}
}
// -> CODE#0010
// -> DESC="add extended parameter mechanism to pattern effects"
if(IsCompatibleMode(TRK_ALLTRACKERS)) // clamp tempo correctly in compatible mode
- memory.musicTempo = CLAMP(memory.musicTempo, 32, 255);
+ memory.state.m_nMusicTempo = CLAMP(memory.state.m_nMusicTempo, 32, 255);
else
- memory.musicTempo = CLAMP(memory.musicTempo, GetModSpecifications().tempoMin, GetModSpecifications().tempoMax);
+ memory.state.m_nMusicTempo = CLAMP(memory.state.m_nMusicTempo, GetModSpecifications().tempoMin, GetModSpecifications().tempoMax);
// -! NEW_FEATURE#0010
break;
@@ -383,7 +369,7 @@
} else if((param & 0xF0) == 0xA0)
{
// High sample offset
- memory.chnSettings[nChn].hiOffset = param & 0x0F;
+ pChn->nOldHiOffset = param & 0x0F;
} else if((param & 0xF0) == 0xB0)
{
// Pattern Loop
@@ -430,7 +416,7 @@
case CMD_XFINEPORTAUPDOWN:
// ignore high offset in compatible mode
- if(((param & 0xF0) == 0xA0) && !IsCompatibleMode(TRK_FASTTRACKER2)) memory.chnSettings[nChn].hiOffset = param & 0x0F;
+ if(((param & 0xF0) == 0xA0) && !IsCompatibleMode(TRK_FASTTRACKER2)) pChn->nOldHiOffset = param & 0x0F;
break;
}
if ((adjustMode & eAdjust) == 0) continue;
@@ -471,7 +457,7 @@
// IT compatibility 16. FT2, ST3 and IT ignore out-of-range values
if(param <= 128)
{
- memory.glbVol = param << 1;
+ memory.state.m_nGlobalVolume = param << 1;
}
break;
// Global Volume Slide
@@ -479,59 +465,58 @@
if(IsCompatibleMode(TRK_IMPULSETRACKER | TRK_FASTTRACKER2))
{
// IT compatibility 16. Global volume slide params are stored per channel (FT2/IT)
- if (param) memory.chnSettings[nChn].oldGlbVolSlide = param; else param = memory.chnSettings[nChn].oldGlbVolSlide;
+ if (param) pChn->nOldGlobalVolSlide = param; else param = pChn->nOldGlobalVolSlide;
} else
{
- if (param) memory.chnSettings[0].oldGlbVolSlide = param; else param = memory.chnSettings[0].oldGlbVolSlide;
+ if (param) memory.state.Chn[0].nOldGlobalVolSlide = param; else param = memory.state.Chn[0].nOldGlobalVolSlide;
}
if (((param & 0x0F) == 0x0F) && (param & 0xF0))
{
param >>= 4;
if (!(GetType() & GLOBALVOL_7BIT_FORMATS)) param <<= 1;
- memory.glbVol += param << 1;
+ memory.state.m_nGlobalVolume += param << 1;
} else
if (((param & 0xF0) == 0xF0) && (param & 0x0F))
{
param = (param & 0x0F) << 1;
if (!(GetType() & GLOBALVOL_7BIT_FORMATS)) param <<= 1;
- memory.glbVol -= param;
+ memory.state.m_nGlobalVolume -= param;
} else
if (param & 0xF0)
{
param >>= 4;
param <<= 1;
if (!(GetType() & GLOBALVOL_7BIT_FORMATS)) param <<= 1;
- memory.glbVol += param * memory.musicSpeed;
+ memory.state.m_nGlobalVolume += param * (memory.state.m_nMusicSpeed - 1);
} else
{
param = (param & 0x0F) << 1;
if (!(GetType() & GLOBALVOL_7BIT_FORMATS)) param <<= 1;
- memory.glbVol -= param * memory.musicSpeed;
+ memory.state.m_nGlobalVolume -= param * (memory.state.m_nMusicSpeed - 1);
}
- memory.glbVol = CLAMP(memory.glbVol, 0, 256);
+ memory.state.m_nGlobalVolume = CLAMP(memory.state.m_nGlobalVolume, 0, 256);
break;
case CMD_CHANNELVOLUME:
- if (param <= 64) memory.chnSettings[nChn].chnVol = param;
+ if (param <= 64) pChn->nGlobalVol = param;
break;
case CMD_CHANNELVOLSLIDE:
- if (param) memory.chnSettings[nChn].oldParam = param; else param = memory.chnSettings[nChn].oldParam;
- pChn->nOldChnVolSlide = param;
+ if (param) pChn->nOldChnVolSlide = param; else param = pChn->nOldChnVolSlide;
if (((param & 0x0F) == 0x0F) && (param & 0xF0))
{
- param = (param >> 4) + memory.chnSettings[nChn].chnVol;
+ param = (param >> 4) + pChn->nGlobalVol;
} else
if (((param & 0xF0) == 0xF0) && (param & 0x0F))
{
- if (memory.chnSettings[nChn].chnVol > (UINT)(param & 0x0F)) param = memory.chnSettings[nChn].chnVol - (param & 0x0F);
+ if (pChn->nGlobalVol > (UINT)(param & 0x0F)) param = pChn->nGlobalVol - (param & 0x0F);
else param = 0;
} else
if (param & 0x0F)
{
- param = (param & 0x0F) * memory.musicSpeed;
- param = (memory.chnSettings[nChn].chnVol > param) ? memory.chnSettings[nChn].chnVol - param : 0;
- } else param = ((param & 0xF0) >> 4) * memory.musicSpeed + memory.chnSettings[nChn].chnVol;
+ param = (param & 0x0F) * (memory.state.m_nMusicSpeed - 1);
+ param = (pChn->nGlobalVol > param) ? pChn->nGlobalVol - param : 0;
+ } else param = ((param & 0xF0) >> 4) * (memory.state.m_nMusicSpeed - 1) + pChn->nGlobalVol;
param = MIN(param, 64);
- memory.chnSettings[nChn].chnVol = param;
+ pChn->nGlobalVol = param;
break;
}
}
@@ -545,7 +530,7 @@
}
// Interpret F00 effect in XM files as "stop song"
- if(GetType() == MOD_TYPE_XM && memory.musicSpeed == uint16_max)
+ if(GetType() == MOD_TYPE_XM && memory.state.m_nMusicSpeed == uint16_max)
{
break;
}
@@ -556,25 +541,35 @@
rowsPerBeat = Patterns[nPattern].GetRowsPerBeat();
}
- const uint32 tickDuration = GetTickDuration(memory.musicTempo, memory.musicSpeed, rowsPerBeat);
- const uint32 numTicks = (memory.musicSpeed + tickDelay) * MAX(rowDelay, 1);
+ const uint32 tickDuration = GetTickDuration(memory.state.m_nMusicTempo, memory.state.m_nMusicSpeed, rowsPerBeat);
+ const uint32 numTicks = (memory.state.m_nMusicSpeed + tickDelay) * MAX(rowDelay, 1);
const uint32 rowDuration = tickDuration * numTicks;
memory.elapsedTime += static_cast<double>(rowDuration) / static_cast<double>(m_MixerSettings.gdwMixingFreq);
- memory.renderedSamples += rowDuration;
+ memory.state.m_lTotalSampleCount += rowDuration;
if((adjustMode & eAdjustSamplePositions) == eAdjustSamplePositions)
{
+ const ModCommand::COMMAND forbiddenCommands[] = { CMD_PORTAMENTOUP, CMD_PORTAMENTODOWN, CMD_VOLUMESLIDE, CMD_VIBRATOVOL, CMD_TONEPORTAVOL, CMD_XFINEPORTAUPDOWN };
+ const ModCommand::VOLCMD forbiddenVolCommands[] = { VOLCMD_PORTAUP, VOLCMD_PORTADOWN, VOLCMD_TONEPORTAMENTO, VOLCMD_VOLSLIDEUP, VOLCMD_VOLSLIDEDOWN, VOLCMD_FINEVOLUP, VOLCMD_FINEVOLDOWN };
+
// Super experimental and dirty sample seeking
- pChn = m_PlayState.Chn;
+ pChn = memory.state.Chn;
p = Patterns[nPattern].GetRow(nRow);
for(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); p++, pChn++, nChn++)
{
+ if(ChnSettings[nChn].dwFlags[CHN_MUTE])
+ continue;
+
uint32 startTick = 0;
uint32 paramHi = p->param >> 4, paramLo = p->param & 0x0F;
- if(p->IsNote() && p->instr)
+ bool porta = p->command == CMD_TONEPORTAMENTO; // Volume column tone portamento can be crazy, and CMD_TONEPORTAVOL requires volume slides which we don't emulate right now.
+ bool stopNote = false;
+
+ if(p->IsNote())
{
- InstrumentChange(pChn, p->instr);
- NoteChange(nChn, p->note);
+ pChn->nNewNote = pChn->nLastNote;
+ InstrumentChange(pChn, pChn->nNewIns, porta);
+ NoteChange(pChn, p->note, porta);
pChn->nInc = GetChannelIncrement(pChn, pChn->nPeriod, 0);
if((p->command == CMD_MODCMDEX || p->command == CMD_S3MCMDEX) && (p->param & 0xF0) == 0xD0 && paramLo < numTicks)
@@ -583,33 +578,96 @@
} else if(p->command == CMD_DELAYCUT && paramHi < numTicks)
{
startTick = paramHi;
- } else if(p->command == CMD_OFFSET && p->IsNote())
- {
- // TODO: xParam not supported! (Note: xParam doesn't use hiOffset)
- pChn->nPos = (memory.chnSettings[nChn].hiOffset << 16) + (p->param << 8);
- } else if(p->volcmd == VOLCMD_OFFSET && p->IsNote())
- {
- pChn->nPos = (memory.chnSettings[nChn].hiOffset << 16) + (p->vol << 11);
}
}
+ if(p->command == CMD_OFFSET)
+ {
+ // TODO: xParam not supported! (Note: xParam doesn't use hiOffset)
+ if(p->param != 0) pChn->nOldOffset = p->param;
+ if(p->IsNote()) pChn->nPos = (pChn->nOldHiOffset << 16) + (pChn->nOldOffset << 8);
+ } else if(p->volcmd == VOLCMD_OFFSET)
+ {
+ if(p->vol != 0) pChn->nOldOffset = p->vol << 3;
+ if(p->IsNote()) pChn->nPos = (pChn->nOldHiOffset<< 16) + (pChn->nOldOffset << 8);
+ }
+
if(p->note == NOTE_KEYOFF || p->note == NOTE_NOTECUT || (p->note == NOTE_FADE && GetNumInstruments())
- || pChn->dwFlags[CHN_PINGPONGFLAG] // Ping-pong loops are not supported for now.
- || (p->command != CMD_NONE && // Sample stop commands.
- (((p->command == CMD_MODCMDEX || p->command == CMD_S3MCMDEX) && (p->param & 0xF0) == 0xC0 && paramLo < numTicks)
- || (p->command == CMD_DELAYCUT && paramHi != 0 && startTick + paramLo < numTicks)
- || p->command == CMD_TONEPORTAMENTO || p->command == CMD_TONEPORTAVOL || p->command == CMD_PORTAMENTOUP || p->command == CMD_PORTAMENTODOWN))
- || p->volcmd == VOLCMD_TONEPORTAMENTO || p->volcmd == VOLCMD_PORTAUP || p->volcmd == VOLCMD_PORTADOWN)
+ || ((p->command == CMD_MODCMDEX || p->command == CMD_S3MCMDEX) && (p->param & 0xF0) == 0xC0 && paramLo < numTicks)
+ || (p->command == CMD_DELAYCUT && paramLo != 0 && startTick + paramLo < numTicks))
{
- // Stop channel.
- pChn->nPeriod = 0;
- pChn->nInc = 0;
- pChn->nPos = pChn->nPosLo = 0;
+ stopNote = true;
}
- if(pChn->nInc != 0 && pChn->pModSample)
+
+ if(p->command == CMD_VOLUME)
{
+ pChn->nVolume = p->param * 4;
+ } else if(p->volcmd == VOLCMD_VOLUME)
+ {
+ pChn->nVolume = p->vol * 4;
+ }
+ if(p->command == CMD_PANNING8)
+ {
+ Panning(pChn, p->param);
+ } else if((p->command == CMD_MODCMDEX) || (p->command == CMD_S3MCMDEX) && (p->param & 0xF0) == 0x80)
+ {
+ Panning(pChn, ((p->param & 0x0F) * 256 + 8) / 15);
+ } else if(p->command == VOLCMD_PANNING)
+ {
+ pChn->nPan = p->vol * 4;
+ }
+
+ if(pChn->nInc != 0 && pChn->pModSample && !stopNote)
+ {
+ // Check if we don't want to emulate some effect and thus stop processing.
+ if(p->command != CMD_NONE)
+ {
+ for(size_t i = 0; i < CountOf(forbiddenCommands); i++)
+ {
+ if(p->command == forbiddenCommands[i])
+ {
+ stopNote = true;
+ break;
+ }
+ }
+ // Special case: Slides using extended commands
+ if(p->command == CMD_MODCMDEX)
+ {
+ switch(p->param & 0xF0)
+ case 0x10:
+ case 0x20:
+ case 0xA0:
+ case 0xB0:
+ stopNote = true;
+ break;
+ }
+ }
+
+ if(!stopNote && p->volcmd != VOLCMD_NONE)
+ {
+ for(size_t i = 0; i < CountOf(forbiddenVolCommands); i++)
+ {
+ if(p->volcmd == forbiddenVolCommands[i])
+ {
+ stopNote = true;
+ break;
+ }
+ }
+ }
+ }
+
+
+ if(pChn->nInc != 0 && pChn->pModSample && !stopNote)
+ {
// Increment playback position of sample and envelopes
for(uint32 i = 0; i < (numTicks - startTick); i++)
{
+ if(porta && i != startTick)
+ {
+ if(p->command == CMD_TONEPORTAMENTO) TonePortamento(pChn, p->param);
+ //else if(p->command == CMD_TONEPORTAVOL) TonePortamento(pChn, 0);
+ pChn->nInc = GetChannelIncrement(pChn, pChn->nPeriod, 0);
+ }
+
pChn->nPosLo += pChn->nInc * tickDuration;
pChn->nPos += (pChn->nPosLo >> 16);
pChn->nPosLo &= 0xFFFF;
@@ -620,18 +678,35 @@
if(pChn->pModSample->uFlags[CHN_SUSTAINLOOP | CHN_LOOP])
{
// Check if we exceeded the sample loop.
- while(pChn->nPos >= pChn->nLoopEnd)
+ if(pChn->dwFlags[CHN_PINGPONGFLAG] && pChn->nPos >= pChn->nLoopEnd)
{
- pChn->nPos -= (pChn->nLoopEnd - pChn->nLoopStart);
+ // Ping-pong loops are not supported for now.
+ stopNote = true;
+ } else
+ {
+ while(pChn->nPos >= pChn->nLoopEnd)
+ {
+ pChn->nPos -= (pChn->nLoopEnd - pChn->nLoopStart);
+ }
}
} else if(pChn->nPos >= pChn->nLength)
{
// Past sample end.
- pChn->nLeftVU = pChn->nRightVU = 0;
- pChn->nVolume = 0;
- pChn->pCurrentSample = nullptr;
+ stopNote = true;
}
}
+
+ if(stopNote)
+ {
+ // Stop channel.
+ pChn->nPeriod = 0;
+ pChn->nInc = 0;
+ pChn->nPos = pChn->nPosLo = 0;
+ pChn->nLeftVU = pChn->nRightVU = 0;
+ pChn->nVolume = 0;
+ pChn->pCurrentSample = nullptr;
+ pChn->nInc = 0;
+ }
}
}
@@ -674,36 +749,20 @@
if(retval.targetReached || target.mode == GetLengthTarget::NoTarget)
{
// Target found, or there is no target (i.e. play whole song)...
- m_PlayState.m_nGlobalVolume = memory.glbVol;
+ m_PlayState = memory.state;
m_PlayState.m_nFrameDelay = m_PlayState.m_nPatternDelay = 0;
- m_PlayState.m_lTotalSampleCount = memory.renderedSamples;
m_PlayState.m_bPositionChanged = true;
- if(IsCompatibleMode(TRK_IMPULSETRACKER | TRK_FASTTRACKER2))
- {
- // IT compatibility 16. Global volume slide params are stored per channel (FT2/IT)
- for(CHANNELINDEX n = 0; n < GetNumChannels(); n++)
- {
- m_PlayState.Chn[n].nOldGlobalVolSlide = memory.chnSettings[n].oldGlbVolSlide;
- }
- } else
- {
- m_PlayState.m_nOldGlbVolSlide = memory.chnSettings[0].oldGlbVolSlide;
- }
- m_PlayState.m_nMusicSpeed = memory.musicSpeed;
- m_PlayState.m_nMusicTempo = memory.musicTempo;
for(CHANNELINDEX n = 0; n < GetNumChannels(); n++)
{
- m_PlayState.Chn[n].nOldHiOffset = memory.chnSettings[n].hiOffset;
- m_PlayState.Chn[n].nGlobalVol = memory.chnSettings[n].chnVol;
- if(memory.chnSettings[n].note != NOTE_NONE)
+ if(memory.state.Chn[n].nLastNote != NOTE_NONE)
{
- m_PlayState.Chn[n].nNewNote = memory.chnSettings[n].note;
- if(ModCommand::IsNote(memory.chnSettings[n].note))
+ m_PlayState.Chn[n].nNewNote = memory.state.Chn[n].nLastNote;
+ if(ModCommand::IsNote(memory.state.Chn[n].nLastNote))
{
- m_PlayState.Chn[n].nLastNote = memory.chnSettings[n].note;
+ m_PlayState.Chn[n].nLastNote = memory.state.Chn[n].nLastNote;
}
}
- if(memory.chnSettings[n].instr) m_PlayState.Chn[n].nNewIns = memory.chnSettings[n].instr;
+ if(memory.state.Chn[n].nNewIns) m_PlayState.Chn[n].nNewIns = memory.state.Chn[n].nNewIns;
if(memory.chnSettings[n].vol != 0xFF)
{
if(memory.chnSettings[n].vol > 64) memory.chnSettings[n].vol = 64;
@@ -716,13 +775,9 @@
m_PlayState.m_nMusicSpeed = m_nDefaultSpeed;
m_PlayState.m_nMusicTempo = m_nDefaultTempo;
m_PlayState.m_nGlobalVolume = m_nDefaultGlobalVolume;
- for(CHANNELINDEX i = 0; i < CountOf(m_PlayState.Chn); i++)
- {
- m_PlayState.Chn[i] = origChannels[i];
- }
}
// When adjusting the playback status, we will also want to update the visited rows vector according to the current position.
- m_PlayState.visitedSongRows.Set(visitedRows);
+ visitedSongRows.Set(visitedRows);
}
return retval;
@@ -1076,11 +1131,10 @@
}
-void CSoundFile::NoteChange(CHANNELINDEX nChn, int note, bool bPorta, bool bResetEnv, bool bManual)
-//-------------------------------------------------------------------------------------------------
+void CSoundFile::NoteChange(ModChannel *pChn, int note, bool bPorta, bool bResetEnv, bool bManual) const
+//------------------------------------------------------------------------------------------------------
{
if (note < NOTE_MIN) return;
- ModChannel *pChn = &m_PlayState.Chn[nChn];
const ModSample *pSmp = pChn->pModSample;
const ModInstrument *pIns = pChn->pModInstrument;
@@ -1109,7 +1163,7 @@
// Key Off (+ Invalid Note for XM - TODO is this correct?)
if(note == NOTE_KEYOFF || !(GetType() & (MOD_TYPE_IT|MOD_TYPE_MPT)))
{
- KeyOff(nChn);
+ KeyOff(pChn);
}
else // Invalid Note -> Note Fade
{
@@ -1569,12 +1623,12 @@
{
// Cut
case DNA_NOTECUT:
- KeyOff(i);
+ KeyOff(p);
p->nVolume = 0;
break;
// Note Off
case DNA_NOTEOFF:
- KeyOff(i);
+ KeyOff(p);
break;
// Note Fade
case DNA_NOTEFADE:
@@ -1657,7 +1711,7 @@
switch(pChn->nNNA)
{
case NNA_NOTEOFF:
- KeyOff(n);
+ KeyOff(p);
break;
case NNA_NOTECUT:
p->nFadeOutVol = 0;
@@ -2142,7 +2196,7 @@
InstrumentChange(pChn, pChn->nNewIns, bPorta, false, (GetType() & (MOD_TYPE_XM|MOD_TYPE_MT2)) == 0);
pChn->nNewIns = 0;
}
- NoteChange(nChn, note, bPorta, (GetType() & (MOD_TYPE_XM|MOD_TYPE_MT2)) == 0);
+ NoteChange(pChn, note, bPorta, (GetType() & (MOD_TYPE_XM|MOD_TYPE_MT2)) == 0);
if ((bPorta) && (GetType() & (MOD_TYPE_XM|MOD_TYPE_MT2)) && (instr))
{
pChn->dwFlags.set(CHN_FASTVOLRAMP);
@@ -2538,7 +2592,7 @@
if(IsCompatibleMode(TRK_IMPULSETRACKER | TRK_FASTTRACKER2))
GlobalVolSlide(param, pChn->nOldGlobalVolSlide);
else
- GlobalVolSlide(param, m_PlayState.m_nOldGlbVolSlide);
+ GlobalVolSlide(param, m_PlayState.Chn[0].nOldGlobalVolSlide);
break;
// Set 8-bit Panning
@@ -2548,32 +2602,7 @@
{
break;
}
-
- if (!m_SongFlags[SONG_SURROUNDPAN])
- {
- pChn->dwFlags.reset(CHN_SURROUND);
- }
- if(!(GetType() & (MOD_TYPE_S3M | MOD_TYPE_DSM | MOD_TYPE_AMF | MOD_TYPE_MTM)))
- {
- // Real 8-bit panning
- pChn->nPan = param;
- } else
- {
- // 7-bit panning + surround
- if(param <= 0x80)
- {
- pChn->nPan = param << 1;
- } else if(param == 0xA4)
- {
- pChn->dwFlags.set(CHN_SURROUND);
- pChn->nPan = 0x80;
- }
- }
- pChn->dwFlags.set(CHN_FASTVOLRAMP);
- pChn->nRestorePanOnNewNote = 0;
- //IT compatibility 20. Set pan overrides random pan
- if(IsCompatibleMode(TRK_IMPULSETRACKER))
- pChn->nPanSwing = 0;
+ Panning(pChn, param);
break;
// Panning Slide
@@ -2625,14 +2654,14 @@
pChn->nVolume = 0;
}
}
- KeyOff(nChn);
+ KeyOff(pChn);
}
}
// This is how it's NOT supposed to sound...
else
{
if(m_SongFlags[SONG_FIRSTTICK])
- KeyOff(nChn);
+ KeyOff(pChn);
}
break;
@@ -2794,7 +2823,7 @@
}
// As long as the pattern loop is running, mark the looped rows as not visited yet
- m_PlayState.visitedSongRows.ResetPatternLoop(m_PlayState.m_nCurrentOrder, nPatLoopRow);
+ visitedSongRows.ResetPatternLoop(m_PlayState.m_nCurrentOrder, nPatLoopRow);
}
// Pattern Break / Position Jump only if no loop running
@@ -3273,8 +3302,8 @@
}
-void CSoundFile::Vibrato(ModChannel *p, UINT param)
-//-------------------------------------------------
+void CSoundFile::Vibrato(ModChannel *p, UINT param) const
+//-------------------------------------------------------
{
p->m_VibratoDepth = param % 16 / 15.0F;
//'New tuning'-thing: 0 - 1 <-> No depth - Full depth.
@@ -3286,8 +3315,8 @@
}
-void CSoundFile::FineVibrato(ModChannel *p, UINT param)
-//-----------------------------------------------------
+void CSoundFile::FineVibrato(ModChannel *p, UINT param) const
+//-----------------------------------------------------------
{
if (param & 0x0F) p->nVibratoDepth = param & 0x0F;
if (param & 0xF0) p->nVibratoSpeed = (param >> 4) & 0x0F;
@@ -3295,8 +3324,8 @@
}
-void CSoundFile::Panbrello(ModChannel *p, UINT param)
-//---------------------------------------------------
+void CSoundFile::Panbrello(ModChannel *p, UINT param) const
+//---------------------------------------------------------
{
if (param & 0x0F) p->nPanbrelloDepth = param & 0x0F;
if (param & 0xF0) p->nPanbrelloSpeed = (param >> 4) & 0x0F;
@@ -3304,6 +3333,37 @@
}
+void CSoundFile::Panning(ModChannel *pChn, UINT param) const
+//----------------------------------------------------------
+{
+ if (!m_SongFlags[SONG_SURROUNDPAN])
+ {
+ pChn->dwFlags.reset(CHN_SURROUND);
+ }
+ if(!(GetType() & (MOD_TYPE_S3M | MOD_TYPE_DSM | MOD_TYPE_AMF | MOD_TYPE_MTM)))
+ {
+ // Real 8-bit panning
+ pChn->nPan = param;
+ } else
+ {
+ // 7-bit panning + surround
+ if(param <= 0x80)
+ {
+ pChn->nPan = param << 1;
+ } else if(param == 0xA4)
+ {
+ pChn->dwFlags.set(CHN_SURROUND);
+ pChn->nPan = 0x80;
+ }
+ }
+ pChn->dwFlags.set(CHN_FASTVOLRAMP);
+ pChn->nRestorePanOnNewNote = 0;
+ //IT compatibility 20. Set pan overrides random pan
+ if(IsCompatibleMode(TRK_IMPULSETRACKER))
+ pChn->nPanSwing = 0;
+}
+
+
void CSoundFile::VolumeSlide(ModChannel *pChn, UINT param)
//--------------------------------------------------------
{
@@ -3506,8 +3566,8 @@
}
-void CSoundFile::Tremolo(ModChannel *pChn, UINT param)
-//----------------------------------------------------
+void CSoundFile::Tremolo(ModChannel *pChn, UINT param) const
+//----------------------------------------------------------
{
if (param & 0x0F) pChn->nTremoloDepth = (param & 0x0F) << 2;
if (param & 0xF0) pChn->nTremoloSpeed = (param >> 4) & 0x0F;
@@ -3707,7 +3767,7 @@
{
if (param == 1)
{
- KeyOff(i);
+ KeyOff(bkp);
} else if (param == 2)
{
bkp->dwFlags.set(CHN_NOTEFADE);
@@ -4445,7 +4505,7 @@
}
// IT compatibility: Really weird combination of envelopes and retrigger (see Storlek's q.it testcase)
// Test case: retrig.it
- NoteChange(nChn, note, IsCompatibleMode(TRK_IMPULSETRACKER), resetEnv);
+ NoteChange(&chn, note, IsCompatibleMode(TRK_IMPULSETRACKER), resetEnv);
if(m_nInstruments)
{
chn.rowCommand.note = note; // No retrig without note...
@@ -4551,10 +4611,9 @@
}
-void CSoundFile::KeyOff(CHANNELINDEX nChn)
-//----------------------------------------
+void CSoundFile::KeyOff(ModChannel *pChn) const
+//---------------------------------------------
{
- ModChannel *pChn = &m_PlayState.Chn[nChn];
const bool bKeyOn = !pChn->dwFlags[CHN_KEYOFF];
pChn->dwFlags.set(CHN_KEYOFF);
//if ((!pChn->pModInstrument) || (!(pChn->VolEnv.flags & CHN_VOLENV)))
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2014-03-03 15:41:56 UTC (rev 3811)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2014-03-03 16:41:27 UTC (rev 3812)
@@ -570,7 +570,7 @@
#ifdef MODPLUG_TRACKER
m_MIDIMapper(*this),
#endif
- m_PlayState(*this),
+ visitedSongRows(*this),
m_pCustomLog(nullptr)
#if MPT_COMPILER_MSVC
#pragma warning(default : 4355) // "'this' : used in base member initializer list"
@@ -719,7 +719,6 @@
m_nFreqFactor = m_nTempoFactor = 128;
#endif
m_PlayState.m_nGlobalVolume = MAX_GLOBAL_VOLUME;
- m_PlayState.m_nOldGlbVolSlide = 0;
InitializeGlobals();
Order.resize(1);
@@ -887,7 +886,7 @@
m_PlayState.m_nRow = 0;
RecalculateSamplesPerTick();
- m_PlayState.visitedSongRows.Initialize(true);
+ visitedSongRows.Initialize(true);
if ((m_nRestartPos >= Order.size()) || (Order[m_nRestartPos] >= Patterns.Size())) m_nRestartPos = 0;
@@ -1102,7 +1101,7 @@
m_PlayState.m_nSamplesToGlobalVolRampDest = 0;
m_PlayState.m_nGlobalVolumeRampAmount = 0;
- m_PlayState.visitedSongRows.Initialize(true);
+ visitedSongRows.Initialize(true);
}
m_SongFlags.reset(SONG_FADINGSONG | SONG_ENDREACHED);
for (nPattern = 0; nPattern < Order.size(); nPattern++)
@@ -2270,7 +2269,9 @@
m.param = mpt::saturate_cast<uint8>(param);
}
- if(sndFile.m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 22, 07, 09) && m.command == CMD_SPEED && m.param == 0)
+ if(sndFile.m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 22, 07, 09)
+ && sndFile.m_dwLastSavedWithVersion != MAKE_VERSION_NUMERIC(1, 22, 00, 00) // Ignore compatibility export
+ && m.command == CMD_SPEED && m.param == 0)
{
// OpenMPT can emulate FT2's F00 behaviour now.
m.command = CMD_NONE;
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2014-03-03 15:41:56 UTC (rev 3811)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2014-03-03 16:41:27 UTC (rev 3812)
@@ -462,7 +462,6 @@
uint32 m_nSamplesToGlobalVolRampDest, m_nGlobalVolumeRampAmount,
m_nGlobalVolumeDestination;
int32 m_lHighResRampingGlobalVolume;
- uint32 m_nOldGlbVolSlide;
public:
bool m_bPositionChanged; // Report to plugins that we jumped around in the module
@@ -473,16 +472,18 @@
ModChannel Chn[MAX_CHANNELS]; // Mixing channels... First m_nChannel channels are master channels (i.e. they are never NNA channels)!
protected:
- // For handling backwards jumps and stuff to prevent infinite loops when counting the mod length or rendering to wav.
- RowVisitor visitedSongRows;
bool m_bPatternTransitionOccurred;
public:
- PlayState(CSoundFile &owner) : visitedSongRows(owner) { }
+ PlayState &operator= (const PlayState &other) { memcpy(this, &other, sizeof(PlayState)); return *this; }
};
PlayState m_PlayState;
+protected:
+ // For handling backwards jumps and stuff to prevent infinite loops when counting the mod length or rendering to wav.
+ RowVisitor visitedSongRows;
+public:
#ifdef MODPLUG_TRACKER
std::bitset<MAX_BASECHANNELS> m_bChannelMuteTogglePending;
@@ -602,7 +603,7 @@
//specific order&row etc. Return value is in seconds.
GetLengthType GetLength(enmGetLengthResetMode adjustMode, GetLengthTarget target = GetLengthTarget());
- void InitializeVisitedRows() { m_PlayState.visitedSongRows.Initialize(true); }
+ void InitializeVisitedRows() { visitedSongRows.Initialize(true); }
public:
//Returns song length in seconds.
@@ -741,11 +742,11 @@
BOOL ProcessEffects();
CHANNELINDEX GetNNAChannel(CHANNELINDEX nChn) const;
void CheckNNA(CHANNELINDEX nChn, UINT instr, int note, bool forceCut);
- void NoteChange(CHANNELINDEX nChn, int note, bool bPorta = false, bool bResetEnv = true, bool bManual = false);
+ void NoteChange(ModChannel *pChn, int note, bool bPorta = false, bool bResetEnv = true, bool bManual = false) const;
void InstrumentChange(ModChannel *pChn, UINT instr, bool bPorta = false, bool bUpdVol = true, bool bResetEnv = true) const;
// Channel Effects
- void KeyOff(CHANNELINDEX nChn);
+ void KeyOff(ModChannel *pChn) const;
// Global Effects
void SetTempo(UINT param, bool setAsNonModcommand = false);
void SetSpeed(UINT param);
@@ -792,15 +793,16 @@
void ExtraFinePortamentoDown(ModChannel *pChn, UINT param);
void NoteSlide(ModChannel *pChn, UINT param, bool slideUp, bool retrig);
void TonePortamento(ModChannel *pChn, UINT param);
- void Vibrato(ModChannel *pChn, UINT param);
- void FineVibrato(ModChannel *pChn, UINT param);
+ void Vibrato(ModChannel *pChn, UINT param) const;
+ void FineVibrato(ModChannel *pChn, UINT param) const;
void VolumeSlide(ModChannel *pChn, UINT param);
void PanningSlide(ModChannel *pChn, UINT param, bool memory = true);
void ChannelVolSlide(ModChannel *pChn, UINT param);
void FineVolumeUp(ModChannel *pChn, UINT param, bool volCol);
void FineVolumeDown(ModChannel *pChn, UINT param, bool volCol);
- void Tremolo(ModChannel *pChn, UINT param);
- void Panbrello(ModChannel *pChn, UINT param);
+ void Tremolo(ModChannel *pChn, UINT param) const;
+ void Panbrello(ModChannel *pChn, UINT param) const;
+ void Panning(ModChannel *pChn, UINT param) const;
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, bool cutSample);
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2014-03-03 15:41:56 UTC (rev 3811)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2014-03-03 16:41:27 UTC (rev 3812)
@@ -426,7 +426,7 @@
if (m_PlayState.m_nCurrentOrder >= Order.size()
|| !Patterns.IsValidPat(Order[m_PlayState.m_nCurrentOrder]))
{
- m_PlayState.visitedSongRows.Initialize(true);
+ visitedSongRows.Initialize(true);
return FALSE;
}
@@ -460,7 +460,7 @@
// the pattern loop (editor flag, not to be confused with the pattern loop effect)
// flag is set - because in that case, the module would stop after the first pattern loop...
const bool overrideLoopCheck = (m_nRepeatCount != -1) && m_SongFlags[SONG_PATTERNLOOP];
- if(!overrideLoopCheck && m_PlayState.visitedSongRows.IsVisited(m_PlayState.m_nCurrentOrder, m_PlayState.m_nRow, true))
+ if(!overrideLoopCheck && visitedSongRows.IsVisited(m_PlayState.m_nCurrentOrder, m_PlayState.m_nRow, true))
{
if(m_nRepeatCount)
{
@@ -470,8 +470,8 @@
m_nRepeatCount--;
}
// Forget all but the current row.
- m_PlayState.visitedSongRows.Initialize(true);
- m_PlayState.visitedSongRows.Visit(m_PlayState.m_nCurrentOrder, m_PlayState.m_nRow);
+ visitedSongRows.Initialize(true);
+ visitedSongRows.Visit(m_PlayState.m_nCurrentOrder, m_PlayState.m_nRow);
} else
{
#ifdef MODPLUG_TRACKER
@@ -485,7 +485,7 @@
#endif // MODPLUG_TRACKER
{
// This is really the song's end!
- m_PlayState.visitedSongRows.Initialize(true);
+ visitedSongRows.Initialize(true);
return FALSE;
} else
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-03-03 16:44:54
|
Revision: 3813
http://sourceforge.net/p/modplug/code/3813
Author: saga-games
Date: 2014-03-03 16:44:47 +0000 (Mon, 03 Mar 2014)
Log Message:
-----------
[Ref] Remove pointless "Pow2xSmall" in serialization code.
[Fix] __readeflags() should use a 64-bit variable in 64-bit builds.
[Imp] Sample tab: Don't crash when trying to load soundtouch library that is not a suitable DLL (e.g. different bitness).
[Mod] Don't even execute CPUID when /noAssembly is specified.
Modified Paths:
--------------
trunk/OpenMPT/common/misc_util.cpp
trunk/OpenMPT/common/serialization_utils.cpp
trunk/OpenMPT/mptrack/Ctrl_smp.cpp
trunk/OpenMPT/mptrack/Mptrack.cpp
Modified: trunk/OpenMPT/common/misc_util.cpp
===================================================================
--- trunk/OpenMPT/common/misc_util.cpp 2014-03-03 16:41:27 UTC (rev 3812)
+++ trunk/OpenMPT/common/misc_util.cpp 2014-03-03 16:44:47 UTC (rev 3813)
@@ -269,10 +269,10 @@
static bool has_cpuid()
//---------------------
{
- const uint32 eflags_cpuid = 1<<21;
- uint32 old_eflags = __readeflags();
+ const size_t eflags_cpuid = 1 << 21;
+ size_t old_eflags = __readeflags();
__writeeflags(old_eflags ^ eflags_cpuid);
- bool result = ((__readeflags() ^ old_eflags) & eflags_cpuid) ? true : false;
+ bool result = ((__readeflags() ^ old_eflags) & eflags_cpuid) != 0;
__writeeflags(old_eflags);
return result;
}
@@ -286,7 +286,6 @@
if(has_cpuid())
{
-
cpuid_result VendorString = cpuid(0x00000000u);
cpuid_result StandardFeatureFlags = cpuid(0x00000001u);
@@ -297,22 +296,16 @@
if(VendorString.as_string() == "AuthenticAMD")
{
-
cpuid_result ExtendedVendorString = cpuid(0x80000000u);
if(ExtendedVendorString.a >= 0x80000001u)
{
-
cpuid_result ExtendedFeatureFlags = cpuid(0x80000001u);
if(ExtendedFeatureFlags.d & (1<<22)) ProcSupport |= PROCSUPPORT_AMD_MMXEXT;
if(ExtendedFeatureFlags.d & (1<<31)) ProcSupport |= PROCSUPPORT_AMD_3DNOW;
if(ExtendedFeatureFlags.d & (1<<30)) ProcSupport |= PROCSUPPORT_AMD_3DNOW2;
-
}
-
}
-
}
-
}
Modified: trunk/OpenMPT/common/serialization_utils.cpp
===================================================================
--- trunk/OpenMPT/common/serialization_utils.cpp 2014-03-03 16:41:27 UTC (rev 3812)
+++ trunk/OpenMPT/common/serialization_utils.cpp 2014-03-03 16:44:47 UTC (rev 3813)
@@ -144,17 +144,11 @@
}
-static const uint8 pow2xTable[] = {1, 2, 4, 8, 16, 32, 64, 128};
-
-// Returns 2^n. n must be within {0,...,7}.
-static inline uint8 Pow2xSmall(const uint8& exp) {ASSERT(exp <= 7); return pow2xTable[exp];}
-
-
void ReadAdaptive1248(std::istream& iStrm, uint64& val)
//-----------------------------------------------------
{
Binaryread<uint64>(iStrm, val, 1);
- uint8 bc = Pow2xSmall(static_cast<uint8>(val & 3));
+ uint8 bc = 1 << static_cast<uint8>(val & 3);
int byte = 1;
val &= 0xff;
while(bc > 1)
@@ -450,7 +444,7 @@
if(flags != s_DefaultFlagbyte)
{
WriteAdaptive1234(oStrm, 2); //Headersize - now it is 2.
- Binarywrite<uint8>(oStrm, HeaderId_FlagByte);
+ Binarywrite<uint8>(oStrm, HeaderId_FlagByte);
Binarywrite<uint8>(oStrm, flags);
}
else
@@ -631,7 +625,7 @@
if (Testbit(header, 5))
{
- Binaryread<uint8>(iStrm, tempU8);
+ Binaryread<uint8>(iStrm, tempU8);
iStrm.ignore(tempU8);
}
@@ -666,7 +660,7 @@
iStrm.ignore(size * (GetFlag(RwfRTwoBytesDescChar) ? 2 : 1));
}
- if(Testbit(flagbyte, 3))
+ if(Testbit(flagbyte, 3))
iStrm.ignore(5);
// Read entrycount
Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-03-03 16:41:27 UTC (rev 3812)
+++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-03-03 16:44:47 UTC (rev 3813)
@@ -1833,9 +1833,13 @@
HANDLE handleSt = NULL;
// Check whether the DLL file exists.
- if(PathFileExistsW((CTrackApp::GetAppDirPath() + MPT_PATHSTRING("OpenMPT_SoundTouch_f32.dll")).AsNative().c_str()) == TRUE)
+ HMODULE dllHandle = LoadLibraryW((CTrackApp::GetAppDirPath() + MPT_PATHSTRING("OpenMPT_SoundTouch_f32.dll")).AsNative().c_str());
+ if(dllHandle != NULL)
+ {
+ FreeLibrary(dllHandle);
handleSt = soundtouch_createInstance();
- if (handleSt == NULL)
+ }
+ if (handleSt == NULL)
{
MsgBox(IDS_SOUNDTOUCH_LOADFAILURE);
return -1;
Modified: trunk/OpenMPT/mptrack/Mptrack.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Mptrack.cpp 2014-03-03 16:41:27 UTC (rev 3812)
+++ trunk/OpenMPT/mptrack/Mptrack.cpp 2014-03-03 16:44:47 UTC (rev 3813)
@@ -299,34 +299,30 @@
//================================================
{
public:
- bool m_bNoDls, m_bSafeMode, m_bNoPlugins,
+ bool m_bNoDls, m_bNoPlugins, m_bNoAssembly,
m_bPortable, m_bNoSettingsOnNewVersion;
public:
CMPTCommandLineInfo()
{
- m_bNoDls = m_bSafeMode =
- m_bNoPlugins = m_bNoSettingsOnNewVersion = m_bPortable = false;
+ m_bNoDls = m_bNoPlugins = m_bNoAssembly =
+ m_bPortable = m_bNoSettingsOnNewVersion = false;
}
- virtual void ParseParam(LPCTSTR lpszParam, BOOL bFlag, BOOL bLast);
-};
-
-
-void CMPTCommandLineInfo::ParseParam(LPCTSTR lpszParam, BOOL bFlag, BOOL bLast)
-//-----------------------------------------------------------------------------
-{
- if ((lpszParam) && (bFlag))
+ virtual void ParseParam(LPCTSTR lpszParam, BOOL bFlag, BOOL bLast)
{
- if (!lstrcmpi(lpszParam, _T("nologo"))) { m_bShowSplash = FALSE; return; } else
- if (!lstrcmpi(lpszParam, _T("nodls"))) { m_bNoDls = true; return; } else
- if (!lstrcmpi(lpszParam, _T("noplugs"))) { m_bNoPlugins = true; return; } else
- if (!lstrcmpi(lpszParam, _T("portable"))) { m_bPortable = true; return; } else
- if (!lstrcmpi(lpszParam, _T("noSettingsOnNewVersion"))) { m_bNoSettingsOnNewVersion = true; return; }
- if (!lstrcmpi(lpszParam, _T("fullMemDump"))) { ExceptionHandler::fullMemDump = true; return; }
- if (!lstrcmpi(lpszParam, _T("noAssembly"))) { ProcSupport = 0; return; }
+ if ((lpszParam) && (bFlag))
+ {
+ if (!lstrcmpi(lpszParam, _T("nologo"))) { m_bShowSplash = FALSE; return; }
+ if (!lstrcmpi(lpszParam, _T("nodls"))) { m_bNoDls = true; return; }
+ if (!lstrcmpi(lpszParam, _T("noplugs"))) { m_bNoPlugins = true; return; }
+ if (!lstrcmpi(lpszParam, _T("portable"))) { m_bPortable = true; return; }
+ if (!lstrcmpi(lpszParam, _T("noSettingsOnNewVersion"))) { m_bNoSettingsOnNewVersion = true; return; }
+ if (!lstrcmpi(lpszParam, _T("fullMemDump"))) { ExceptionHandler::fullMemDump = true; return; }
+ if (!lstrcmpi(lpszParam, _T("noAssembly"))) { m_bNoAssembly = true; return; }
+ }
+ CCommandLineInfo::ParseParam(lpszParam, bFlag, bLast);
}
- CCommandLineInfo::ParseParam(lpszParam, bFlag, bLast);
-}
+};
/////////////////////////////////////////////////////////////////////////////
@@ -853,11 +849,6 @@
Log("OpenMPT Start");
- // Initialize Audio
-#ifdef ENABLE_ASM
- InitProcSupport();
-#endif
-
ASSERT(nullptr == m_pDocManager);
m_pDocManager = new CModDocManager();
@@ -867,6 +858,13 @@
CMPTCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
+#ifdef ENABLE_ASM
+ if(cmdInfo.m_bNoAssembly)
+ ProcSupport = 0;
+ else
+ InitProcSupport();
+#endif
+
m_pTrackerDirectories = new TrackerDirectories();
// Set up paths to store configuration in
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-03-03 16:46:35
|
Revision: 3814
http://sourceforge.net/p/modplug/code/3814
Author: saga-games
Date: 2014-03-03 16:46:26 +0000 (Mon, 03 Mar 2014)
Log Message:
-----------
[Ref] Silence a few 64-bit build warnings.
[Fix] Don't fail/assert in FrequencyToTranspose() if C5freq is 0.
[Mod] OpenMPT: Version is now 1.22.07.27
Modified Paths:
--------------
trunk/OpenMPT/common/versionNumber.h
trunk/OpenMPT/mptrack/SampleEditorDialogs.h
trunk/OpenMPT/mptrack/View_ins.cpp
trunk/OpenMPT/mptrack/View_tre.cpp
trunk/OpenMPT/mptrack/Vstplug.cpp
trunk/OpenMPT/soundlib/ModSample.cpp
Modified: trunk/OpenMPT/common/versionNumber.h
===================================================================
--- trunk/OpenMPT/common/versionNumber.h 2014-03-03 16:44:47 UTC (rev 3813)
+++ trunk/OpenMPT/common/versionNumber.h 2014-03-03 16:46:26 UTC (rev 3814)
@@ -17,7 +17,7 @@
#define VER_MAJORMAJOR 1
#define VER_MAJOR 22
#define VER_MINOR 07
-#define VER_MINORMINOR 26
+#define VER_MINORMINOR 27
//Version string. For example "1.17.02.28"
#define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR)
Modified: trunk/OpenMPT/mptrack/SampleEditorDialogs.h
===================================================================
--- trunk/OpenMPT/mptrack/SampleEditorDialogs.h 2014-03-03 16:44:47 UTC (rev 3813)
+++ trunk/OpenMPT/mptrack/SampleEditorDialogs.h 2014-03-03 16:46:26 UTC (rev 3814)
@@ -113,14 +113,14 @@
//==================================
{
public:
- int m_nSegments, m_nMaxSegments;
+ SmpLength m_nSegments, m_nMaxSegments;
protected:
CEdit m_EditSegments;
CSpinButtonCtrl m_SpinSegments;
public:
- CSampleGridDlg(CWnd *parent, int nSegments, int nMaxSegments) : CDialog(IDD_SAMPLE_GRID_SIZE, parent) { m_nSegments = nSegments; m_nMaxSegments = nMaxSegments; };
+ CSampleGridDlg(CWnd *parent, SmpLength nSegments, SmpLength nMaxSegments) : CDialog(IDD_SAMPLE_GRID_SIZE, parent) { m_nSegments = nSegments; m_nMaxSegments = nMaxSegments; };
protected:
virtual void DoDataExchange(CDataExchange* pDX);
Modified: trunk/OpenMPT/mptrack/View_ins.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_ins.cpp 2014-03-03 16:44:47 UTC (rev 3813)
+++ trunk/OpenMPT/mptrack/View_ins.cpp 2014-03-03 16:46:26 UTC (rev 3814)
@@ -2135,7 +2135,7 @@
CModDoc *modDoc = GetDocument();
if(modDoc != nullptr)
{
- modDoc->ProcessMIDI(midiData, m_nInstrument, modDoc->GetrSoundFile().GetInstrumentPlugin(m_nInstrument), kCtxViewInstruments);
+ modDoc->ProcessMIDI(static_cast<uint32>(midiData), m_nInstrument, modDoc->GetrSoundFile().GetInstrumentPlugin(m_nInstrument), kCtxViewInstruments);
return 1;
}
return 0;
@@ -2215,12 +2215,12 @@
}
if(wParam >= kcInstrumentStartNotes && wParam <= kcInstrumentEndNotes)
{
- PlayNote(wParam - kcInstrumentStartNotes + 1 + pMainFrm->GetBaseOctave() * 12);
+ PlayNote(static_cast<UINT>(wParam) - kcInstrumentStartNotes + 1 + pMainFrm->GetBaseOctave() * 12);
return wParam;
}
if(wParam >= kcInstrumentStartNoteStops && wParam <= kcInstrumentEndNoteStops)
{
- int note =wParam - kcInstrumentStartNoteStops + 1 + pMainFrm->GetBaseOctave() * 12;
+ UINT note = static_cast<UINT>(wParam) - kcInstrumentStartNoteStops + 1 + pMainFrm->GetBaseOctave() * 12;
m_baPlayingNote[note] = false;
pModDoc->NoteOff(note, false, m_nInstrument);
return wParam;
Modified: trunk/OpenMPT/mptrack/View_tre.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_tre.cpp 2014-03-03 16:44:47 UTC (rev 3813)
+++ trunk/OpenMPT/mptrack/View_tre.cpp 2014-03-03 16:46:26 UTC (rev 3814)
@@ -1386,7 +1386,7 @@
{
const DlsItem &item = *static_cast<const DlsItem *>(&modItem);
CMainFrame *pMainFrm = CMainFrame::GetMainFrame();
- size_t bank = item.GetBankIndex();
+ uint32 bank = item.GetBankIndex();
if ((bank < CTrackApp::gpDLSBanks.size()) && (CTrackApp::gpDLSBanks[bank]) && (pMainFrm))
{
CDLSBank *pDLSBank = CTrackApp::gpDLSBanks[bank];
@@ -1864,7 +1864,7 @@
{
lParam1 &= 0x7FFFFFFF;
lParam2 &= 0x7FFFFFFF;
- return lParam1 - lParam2;
+ return static_cast<int>(lParam1 - lParam2);
}
@@ -1887,7 +1887,7 @@
}
}
}
- return lParam1 - lParam2;
+ return static_cast<int>(lParam1 - lParam2);
}
Modified: trunk/OpenMPT/mptrack/Vstplug.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Vstplug.cpp 2014-03-03 16:44:47 UTC (rev 3813)
+++ trunk/OpenMPT/mptrack/Vstplug.cpp 2014-03-03 16:46:26 UTC (rev 3814)
@@ -214,7 +214,7 @@
CAbstractVstEditor *pVstEditor = pVstPlugin->GetEditor();
if (pVstEditor && pVstEditor->IsResizable())
{
- pVstEditor->SetSize(index, value);
+ pVstEditor->SetSize(index, static_cast<int>(value));
}
}
Log("VST plugin to host: Size Window\n");
@@ -587,7 +587,7 @@
if(fileSel->returnPath == nullptr || fileSel->sizeReturnPath == 0)
{
// Provide some memory for the return path.
- fileSel->sizeReturnPath = dir.length() + 1;
+ fileSel->sizeReturnPath = mpt::saturate_cast<VstInt32>(dir.length() + 1);
fileSel->returnPath = new char[fileSel->sizeReturnPath];
if(fileSel->returnPath == nullptr)
{
@@ -2051,37 +2051,37 @@
if(ProgramsAreChunks() && Dispatch(effIdentify, 0,0, nullptr, 0.0f) == 'NvEf')
{
void *p = nullptr;
- LONG nByteSize = 0;
// Try to get whole bank
- nByteSize = Dispatch(effGetChunk, 0,0, &p, 0);
+ uint32 nByteSize = mpt::saturate_cast<uint32>(Dispatch(effGetChunk, 0,0, &p, 0));
if (!p)
{
- nByteSize = Dispatch(effGetChunk, 1,0, &p, 0); // Getting bank failed, try to get just preset
+ nByteSize = mpt::saturate_cast<uint32>(Dispatch(effGetChunk, 1,0, &p, 0)); // Getting bank failed, try to get just preset
} else
{
m_pMixStruct->defaultProgram = GetCurrentProgram(); //we managed to get the bank, now we need to remember which program we're on.
}
if (p != nullptr)
{
- if ((m_pMixStruct->pPluginData) && (m_pMixStruct->nPluginDataSize >= (UINT)(nByteSize+4)))
+ LimitMax(nByteSize, Util::MaxValueOfType(nByteSize) - 4);
+ if ((m_pMixStruct->pPluginData) && (m_pMixStruct->nPluginDataSize >= nByteSize + 4))
{
- m_pMixStruct->nPluginDataSize = nByteSize+4;
+ m_pMixStruct->nPluginDataSize = nByteSize + 4;
} else
{
delete[] m_pMixStruct->pPluginData;
m_pMixStruct->nPluginDataSize = 0;
- m_pMixStruct->pPluginData = new char[nByteSize+4];
+ m_pMixStruct->pPluginData = new char[nByteSize + 4];
if (m_pMixStruct->pPluginData)
{
- m_pMixStruct->nPluginDataSize = nByteSize+4;
+ m_pMixStruct->nPluginDataSize = nByteSize + 4;
}
}
if (m_pMixStruct->pPluginData)
{
- *(ULONG *)m_pMixStruct->pPluginData = 'NvEf';
- memcpy(((BYTE*)m_pMixStruct->pPluginData)+4, p, nByteSize);
+ *(uint32 *)m_pMixStruct->pPluginData = 'NvEf';
+ memcpy(m_pMixStruct->pPluginData + 4, p, nByteSize);
return;
}
}
@@ -2136,12 +2136,12 @@
if ((nProgram>=0) && (nProgram < m_Effect.numPrograms))
{
// Bank
- Dispatch(effSetChunk, 0, m_pMixStruct->nPluginDataSize - 4, ((BYTE *)m_pMixStruct->pPluginData) + 4, 0);
+ Dispatch(effSetChunk, 0, m_pMixStruct->nPluginDataSize - 4, m_pMixStruct->pPluginData + 4, 0);
SetCurrentProgram(nProgram);
} else
{
// Program
- Dispatch(effSetChunk, 1, m_pMixStruct->nPluginDataSize - 4, ((BYTE *)m_pMixStruct->pPluginData) + 4, 0);
+ Dispatch(effSetChunk, 1, m_pMixStruct->nPluginDataSize - 4, m_pMixStruct->pPluginData + 4, 0);
}
} else
Modified: trunk/OpenMPT/soundlib/ModSample.cpp
===================================================================
--- trunk/OpenMPT/soundlib/ModSample.cpp 2014-03-03 16:44:47 UTC (rev 3813)
+++ trunk/OpenMPT/soundlib/ModSample.cpp 2014-03-03 16:46:26 UTC (rev 3814)
@@ -302,7 +302,11 @@
void ModSample::FrequencyToTranspose()
//------------------------------------
{
- int f2t = FrequencyToTranspose(nC5Speed);
+ int f2t;
+ if(nC5Speed)
+ f2t = FrequencyToTranspose(nC5Speed);
+ else
+ f2t = 0;
int transpose = f2t >> 7;
int finetune = f2t & 0x7F; //0x7F == 111 1111
if(finetune > 80) // XXX Why is this 80?
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2014-03-03 18:51:21
|
Revision: 3818
http://sourceforge.net/p/modplug/code/3818
Author: manxorist
Date: 2014-03-03 18:51:12 +0000 (Mon, 03 Mar 2014)
Log Message:
-----------
[Ref] sounddev: Split SoundDeviceThread.cpp from SoundDevice.cpp .
[Ref] sounddev: Rename SoundDevices.h to SoundDeviceThread.h .
Modified Paths:
--------------
trunk/OpenMPT/mptrack/mptrack_08.vcproj
trunk/OpenMPT/mptrack/mptrack_10.vcxproj
trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters
trunk/OpenMPT/sounddev/SoundDevice.cpp
trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp
trunk/OpenMPT/sounddev/SoundDeviceASIO.h
trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp
trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h
trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp
trunk/OpenMPT/sounddev/SoundDevicePortAudio.h
trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp
trunk/OpenMPT/sounddev/SoundDeviceWaveout.h
Added Paths:
-----------
trunk/OpenMPT/sounddev/SoundDeviceThread.cpp
trunk/OpenMPT/sounddev/SoundDeviceThread.h
Removed Paths:
-------------
trunk/OpenMPT/sounddev/SoundDevices.h
Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj
===================================================================
--- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2014-03-03 18:08:27 UTC (rev 3817)
+++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2014-03-03 18:51:12 UTC (rev 3818)
@@ -553,6 +553,10 @@
>
</File>
<File
+ RelativePath="..\sounddev\SoundDeviceThread.cpp"
+ >
+ </File>
+ <File
RelativePath="..\sounddev\SoundDeviceWaveout.cpp"
>
</File>
@@ -1215,7 +1219,7 @@
>
</File>
<File
- RelativePath="..\sounddev\SoundDevices.h"
+ RelativePath="..\sounddev\SoundDeviceThread.h"
>
</File>
<File
@@ -1259,11 +1263,11 @@
>
</File>
<File
- RelativePath=".\svn_version\svn_version.h"
+ RelativePath="..\common\svn_version_default\svn_version.h"
>
</File>
<File
- RelativePath="..\common\svn_version_default\svn_version.h"
+ RelativePath=".\svn_version\svn_version.h"
>
</File>
<File
Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj
===================================================================
--- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2014-03-03 18:08:27 UTC (rev 3817)
+++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2014-03-03 18:51:12 UTC (rev 3818)
@@ -457,6 +457,7 @@
<ClCompile Include="..\sounddev\SoundDeviceASIO.cpp" />
<ClCompile Include="..\sounddev\SoundDeviceDirectSound.cpp" />
<ClCompile Include="..\sounddev\SoundDevicePortAudio.cpp" />
+ <ClCompile Include="..\sounddev\SoundDeviceThread.cpp" />
<ClCompile Include="..\sounddev\SoundDeviceWaveout.cpp" />
<ClCompile Include="..\sounddsp\AGC.cpp" />
<ClCompile Include="..\sounddsp\DSP.cpp" />
@@ -656,7 +657,7 @@
<ClInclude Include="..\sounddev\SoundDeviceASIO.h" />
<ClInclude Include="..\sounddev\SoundDeviceDirectSound.h" />
<ClInclude Include="..\sounddev\SoundDevicePortAudio.h" />
- <ClInclude Include="..\sounddev\SoundDevices.h" />
+ <ClInclude Include="..\sounddev\SoundDeviceThread.h" />
<ClInclude Include="..\sounddev\SoundDeviceWaveout.h" />
<ClInclude Include="..\sounddsp\AGC.h" />
<ClInclude Include="..\sounddsp\DSP.h" />
Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters
===================================================================
--- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2014-03-03 18:08:27 UTC (rev 3817)
+++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2014-03-03 18:51:12 UTC (rev 3818)
@@ -505,6 +505,9 @@
<ClCompile Include="..\test\TestToolsLib.cpp">
<Filter>test</Filter>
</ClCompile>
+ <ClCompile Include="..\sounddev\SoundDeviceThread.cpp">
+ <Filter>Source Files\sounddev</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\soundlib\Loaders.h">
@@ -594,9 +597,6 @@
<ClInclude Include="..\sounddsp\Reverb.h">
<Filter>Header Files\sounddsp</Filter>
</ClInclude>
- <ClInclude Include="..\sounddev\SoundDevices.h">
- <Filter>Header Files\sounddev</Filter>
- </ClInclude>
<ClInclude Include="..\sounddev\SoundDevice.h">
<Filter>Header Files\sounddev</Filter>
</ClInclude>
@@ -990,6 +990,9 @@
<ClInclude Include="..\test\TestTools.h">
<Filter>test</Filter>
</ClInclude>
+ <ClInclude Include="..\sounddev\SoundDeviceThread.h">
+ <Filter>Header Files\sounddev</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="res\bitmap1.bmp">
Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevice.cpp 2014-03-03 18:08:27 UTC (rev 3817)
+++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2014-03-03 18:51:12 UTC (rev 3818)
@@ -12,7 +12,6 @@
#include "stdafx.h"
#include "SoundDevice.h"
-#include "SoundDevices.h"
#include "../common/misc_util.h"
#include "../common/StringFixer.h"
@@ -398,428 +397,6 @@
}
-CAudioThread::CAudioThread(CSoundDeviceWithThread &SoundDevice) : m_SoundDevice(SoundDevice)
-//------------------------------------------------------------------------------------------
-{
-
- m_HasXP = (mpt::Windows::GetWinNTVersion() >= mpt::Windows::VerWinXP);
-
- m_hKernel32DLL = NULL;
-
- pCreateWaitableTimer = nullptr;
- pSetWaitableTimer = nullptr;
- pCancelWaitableTimer = nullptr;
- m_hKernel32DLL = LoadLibrary(TEXT("kernel32.dll"));
- #if _WIN32_WINNT >= _WIN32_WINNT_WINXP
- m_HasXP = true;
- pCreateWaitableTimer = &CreateWaitableTimer;
- pSetWaitableTimer = &SetWaitableTimer;
- pCancelWaitableTimer = &CancelWaitableTimer;
- #else
- if(m_HasXP && m_hKernel32DLL)
- {
- pCreateWaitableTimer = (FCreateWaitableTimer)GetProcAddress(m_hKernel32DLL, "CreateWaitableTimerA");
- pSetWaitableTimer = (FSetWaitableTimer)GetProcAddress(m_hKernel32DLL, "SetWaitableTimer");
- pCancelWaitableTimer = (FCancelWaitableTimer)GetProcAddress(m_hKernel32DLL, "CancelWaitableTimer");
- if(!pCreateWaitableTimer || !pSetWaitableTimer || !pCancelWaitableTimer)
- {
- m_HasXP = false;
- }
- }
- #endif
-
- m_WakeupInterval = 0.0;
- m_hPlayThread = NULL;
- m_dwPlayThreadId = 0;
- m_hAudioWakeUp = NULL;
- m_hAudioThreadTerminateRequest = NULL;
- m_hAudioThreadGoneIdle = NULL;
- m_hHardwareWakeupEvent = INVALID_HANDLE_VALUE;
- m_AudioThreadActive = 0;
- m_hAudioWakeUp = CreateEvent(NULL, FALSE, FALSE, NULL);
- m_hAudioThreadTerminateRequest = CreateEvent(NULL, FALSE, FALSE, NULL);
- m_hAudioThreadGoneIdle = CreateEvent(NULL, TRUE, FALSE, NULL);
- m_hPlayThread = CreateThread(NULL, 0, AudioThreadWrapper, (LPVOID)this, 0, &m_dwPlayThreadId);
-}
-
-
-CAudioThread::~CAudioThread()
-//---------------------------
-{
- if(m_hPlayThread != NULL)
- {
- SetEvent(m_hAudioThreadTerminateRequest);
- WaitForSingleObject(m_hPlayThread, INFINITE);
- m_dwPlayThreadId = 0;
- m_hPlayThread = NULL;
- }
- if(m_hAudioThreadTerminateRequest)
- {
- CloseHandle(m_hAudioThreadTerminateRequest);
- m_hAudioThreadTerminateRequest = 0;
- }
- if(m_hAudioThreadGoneIdle != NULL)
- {
- CloseHandle(m_hAudioThreadGoneIdle);
- m_hAudioThreadGoneIdle = 0;
- }
- if(m_hAudioWakeUp != NULL)
- {
- CloseHandle(m_hAudioWakeUp);
- m_hAudioWakeUp = NULL;
- }
-
- pCreateWaitableTimer = nullptr;
- pSetWaitableTimer = nullptr;
- pCancelWaitableTimer = nullptr;
-
- if(m_hKernel32DLL)
- {
- FreeLibrary(m_hKernel32DLL);
- m_hKernel32DLL = NULL;
- }
-
-}
-
-
-CPriorityBooster::CPriorityBooster(bool boostPriority)
-//----------------------------------------------------
- : m_HasVista(false)
- , m_hAvRtDLL(NULL)
- , pAvSetMmThreadCharacteristics(nullptr)
- , pAvRevertMmThreadCharacteristics(nullptr)
- , m_BoostPriority(boostPriority)
- , task_idx(0)
- , hTask(NULL)
-{
-
- m_HasVista = (mpt::Windows::GetWinNTVersion() >= mpt::Windows::VerWinVista);
-
- if(m_HasVista)
- {
- m_hAvRtDLL = LoadLibrary(TEXT("avrt.dll"));
- if(m_hAvRtDLL && m_hAvRtDLL != INVALID_HANDLE_VALUE)
- {
- pAvSetMmThreadCharacteristics = (FAvSetMmThreadCharacteristics)GetProcAddress(m_hAvRtDLL, "AvSetMmThreadCharacteristicsA");
- pAvRevertMmThreadCharacteristics = (FAvRevertMmThreadCharacteristics)GetProcAddress(m_hAvRtDLL, "AvRevertMmThreadCharacteristics");
- }
- if(!pAvSetMmThreadCharacteristics || !pAvRevertMmThreadCharacteristics)
- {
- m_HasVista = false;
- }
- }
-
- #ifdef _DEBUG
- m_BoostPriority = false;
- #endif
-
- if(m_BoostPriority)
- {
- if(m_HasVista)
- {
- hTask = pAvSetMmThreadCharacteristics(TEXT("Pro Audio"), &task_idx);
- } else
- {
- SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
- }
- }
-
-}
-
-
-CPriorityBooster::~CPriorityBooster()
-//-----------------------------------
-{
-
- if(m_BoostPriority)
- {
- if(m_HasVista)
- {
- pAvRevertMmThreadCharacteristics(hTask);
- hTask = NULL;
- task_idx = 0;
- } else
- {
- SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL);
- }
- }
-
- pAvRevertMmThreadCharacteristics = nullptr;
- pAvSetMmThreadCharacteristics = nullptr;
-
- if(m_hAvRtDLL)
- {
- FreeLibrary(m_hAvRtDLL);
- m_hAvRtDLL = NULL;
- }
-
-}
-
-
-class CPeriodicWaker
-{
-private:
- CAudioThread &self;
-
- double sleepSeconds;
- long sleepMilliseconds;
- int64 sleep100Nanoseconds;
-
- Util::MultimediaClock clock_noxp;
-
- bool period_noxp_set;
- bool periodic_xp_timer;
-
- HANDLE sleepEvent;
-
-public:
-
- CPeriodicWaker(CAudioThread &self_, double sleepSeconds_) : self(self_), sleepSeconds(sleepSeconds_)
- //--------------------------------------------------------------------------------------------------
- {
-
- sleepMilliseconds = static_cast<long>(sleepSeconds * 1000.0);
- sleep100Nanoseconds = static_cast<int64>(sleepSeconds * 10000000.0);
- if(sleepMilliseconds < 1) sleepMilliseconds = 1;
- if(sleep100Nanoseconds < 1) sleep100Nanoseconds = 1;
-
- period_noxp_set = false;
- periodic_xp_timer = (sleep100Nanoseconds >= 10000); // can be represented as a millisecond period, otherwise use non-periodic timers which allow higher precision but might me slower because we have to set them again in each period
-
- sleepEvent = NULL;
-
- if(self.m_HasXP)
- {
- if(periodic_xp_timer)
- {
- sleepEvent = self.pCreateWaitableTimer(NULL, FALSE, NULL);
- LARGE_INTEGER dueTime;
- dueTime.QuadPart = 0 - sleep100Nanoseconds; // negative time means relative
- self.pSetWaitableTimer(sleepEvent, &dueTime, sleepMilliseconds, NULL, NULL, FALSE);
- } else
- {
- sleepEvent = self.pCreateWaitableTimer(NULL, TRUE, NULL);
- }
- } else
- {
- sleepEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
- clock_noxp.SetResolution(1); // increase resolution of multimedia timer
- period_noxp_set = true;
- }
-
- }
-
- long GetSleepMilliseconds() const
- //-------------------------------
- {
- return sleepMilliseconds;
- }
-
- HANDLE GetWakeupEvent() const
- //---------------------------
- {
- return sleepEvent;
- }
-
- void Retrigger()
- //--------------
- {
- if(self.m_HasXP)
- {
- if(!periodic_xp_timer)
- {
- LARGE_INTEGER dueTime;
- dueTime.QuadPart = 0 - sleep100Nanoseconds; // negative time means relative
- self.pSetWaitableTimer(sleepEvent, &dueTime, 0, NULL, NULL, FALSE);
- }
- } else
- {
- timeSetEvent(sleepMilliseconds, 1, (LPTIMECALLBACK)sleepEvent, NULL, TIME_ONESHOT | TIME_CALLBACK_EVENT_SET);
- }
- }
-
- CPeriodicWaker::~CPeriodicWaker()
- //-------------------------------
- {
- if(self.m_HasXP)
- {
- if(periodic_xp_timer)
- {
- self.pCancelWaitableTimer(sleepEvent);
- }
- CloseHandle(sleepEvent);
- sleepEvent = NULL;
- } else
- {
- if(period_noxp_set)
- {
- clock_noxp.SetResolution(0);
- period_noxp_set = false;
- }
- CloseHandle(sleepEvent);
- sleepEvent = NULL;
- }
- }
-
-};
-
-
-DWORD WINAPI CAudioThread::AudioThreadWrapper(LPVOID user)
-{
- return ((CAudioThread*)user)->AudioThread();
-}
-DWORD CAudioThread::AudioThread()
-//-------------------------------
-{
-
- bool terminate = false;
- while(!terminate)
- {
-
- bool idle = true;
- while(!terminate && idle)
- {
- HANDLE waithandles[2] = {m_hAudioThreadTerminateRequest, m_hAudioWakeUp};
- SetEvent(m_hAudioThreadGoneIdle);
- switch(WaitForMultipleObjects(2, waithandles, FALSE, INFINITE))
- {
- case WAIT_OBJECT_0:
- terminate = true;
- break;
- case WAIT_OBJECT_0+1:
- idle = false;
- break;
- }
- }
-
- if(!terminate)
- {
-
- CPriorityBooster priorityBooster(m_SoundDevice.m_Settings.BoostThreadPriority);
- CPeriodicWaker periodicWaker(*this, m_WakeupInterval);
-
- m_SoundDevice.StartFromSoundThread();
-
- while(!terminate && IsActive())
- {
-
- m_SoundDevice.FillAudioBufferLocked();
-
- periodicWaker.Retrigger();
-
- if(m_hHardwareWakeupEvent != INVALID_HANDLE_VALUE)
- {
- HANDLE waithandles[4] = {m_hAudioThreadTerminateRequest, m_hAudioWakeUp, m_hHardwareWakeupEvent, periodicWaker.GetWakeupEvent()};
- switch(WaitForMultipleObjects(4, waithandles, FALSE, periodicWaker.GetSleepMilliseconds()))
- {
- case WAIT_OBJECT_0:
- terminate = true;
- break;
- }
- } else
- {
- HANDLE waithandles[3] = {m_hAudioThreadTerminateRequest, m_hAudioWakeUp, periodicWaker.GetWakeupEvent()};
- switch(WaitForMultipleObjects(3, waithandles, FALSE, periodicWaker.GetSleepMilliseconds()))
- {
- case WAIT_OBJECT_0:
- terminate = true;
- break;
- }
- }
-
- }
-
- m_SoundDevice.StopFromSoundThread();
-
- }
-
- }
-
- SetEvent(m_hAudioThreadGoneIdle);
-
- return 0;
-
-}
-
-
-void CAudioThread::SetWakeupEvent(HANDLE ev)
-//------------------------------------------
-{
- m_hHardwareWakeupEvent = ev;
-}
-
-
-void CAudioThread::SetWakeupInterval(double seconds)
-//--------------------------------------------------
-{
- m_WakeupInterval = seconds;
-}
-
-
-void CAudioThread::Activate()
-//---------------------------
-{
- if(InterlockedExchangeAdd(&m_AudioThreadActive, 0))
- {
- ALWAYS_ASSERT(false);
- return;
- }
- ResetEvent(m_hAudioThreadGoneIdle);
- InterlockedExchange(&m_AudioThreadActive, 1);
- SetEvent(m_hAudioWakeUp);
-}
-
-
-void CAudioThread::Deactivate()
-//-----------------------------
-{
- if(!InterlockedExchangeAdd(&m_AudioThreadActive, 0))
- {
- ALWAYS_ASSERT(false);
- return;
- }
- InterlockedExchange(&m_AudioThreadActive, 0);
- WaitForSingleObject(m_hAudioThreadGoneIdle, INFINITE);
-}
-
-
-void CSoundDeviceWithThread::FillAudioBufferLocked()
-//--------------------------------------------------
-{
- SourceFillAudioBufferLocked();
-}
-
-
-void CSoundDeviceWithThread::SetWakeupEvent(HANDLE ev)
-//----------------------------------------------------
-{
- m_AudioThread.SetWakeupEvent(ev);
-}
-
-
-void CSoundDeviceWithThread::SetWakeupInterval(double seconds)
-//------------------------------------------------------------
-{
- m_AudioThread.SetWakeupInterval(seconds);
-}
-
-
-bool CSoundDeviceWithThread::InternalStart()
-//------------------------------------------
-{
- m_AudioThread.Activate();
- return true;
-}
-
-
-void CSoundDeviceWithThread::InternalStop()
-//-----------------------------------------
-{
- m_AudioThread.Deactivate();
-}
-
-
-
///////////////////////////////////////////////////////////////////////////////////////
//
// Global Functions
Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2014-03-03 18:08:27 UTC (rev 3817)
+++ trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2014-03-03 18:51:12 UTC (rev 3818)
@@ -12,7 +12,6 @@
#include "stdafx.h"
#include "SoundDevice.h"
-#include "SoundDevices.h"
#include "SoundDeviceASIO.h"
Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceASIO.h 2014-03-03 18:08:27 UTC (rev 3817)
+++ trunk/OpenMPT/sounddev/SoundDeviceASIO.h 2014-03-03 18:51:12 UTC (rev 3818)
@@ -11,7 +11,7 @@
#pragma once
-#include "SoundDevices.h"
+#include "SoundDevice.h"
#include "../common/FlagSet.h"
Modified: trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2014-03-03 18:08:27 UTC (rev 3817)
+++ trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2014-03-03 18:51:12 UTC (rev 3818)
@@ -12,7 +12,7 @@
#include "stdafx.h"
#include "SoundDevice.h"
-#include "SoundDevices.h"
+#include "SoundDeviceThread.h"
#include "SoundDeviceDirectSound.h"
Modified: trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h 2014-03-03 18:08:27 UTC (rev 3817)
+++ trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h 2014-03-03 18:51:12 UTC (rev 3818)
@@ -11,7 +11,8 @@
#pragma once
-#include "SoundDevices.h"
+#include "SoundDevice.h"
+#include "SoundDeviceThread.h"
#ifndef NO_DSOUND
#include <dsound.h>
Modified: trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2014-03-03 18:08:27 UTC (rev 3817)
+++ trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2014-03-03 18:51:12 UTC (rev 3818)
@@ -12,7 +12,6 @@
#include "stdafx.h"
#include "SoundDevice.h"
-#include "SoundDevices.h"
#include "SoundDevicePortAudio.h"
Modified: trunk/OpenMPT/sounddev/SoundDevicePortAudio.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevicePortAudio.h 2014-03-03 18:08:27 UTC (rev 3817)
+++ trunk/OpenMPT/sounddev/SoundDevicePortAudio.h 2014-03-03 18:51:12 UTC (rev 3818)
@@ -10,7 +10,7 @@
#pragma once
-#include "SoundDevices.h"
+#include "SoundDevice.h"
#ifndef NO_PORTAUDIO
#include "portaudio/include/portaudio.h"
Copied: trunk/OpenMPT/sounddev/SoundDeviceThread.cpp (from rev 3817, trunk/OpenMPT/sounddev/SoundDevice.cpp)
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceThread.cpp (rev 0)
+++ trunk/OpenMPT/sounddev/SoundDeviceThread.cpp 2014-03-03 18:51:12 UTC (rev 3818)
@@ -0,0 +1,442 @@
+/*
+ * SoundDeviceThread.cpp
+ * ---------------------
+ * Purpose: Sound device threading driver helpers.
+ * Notes : (currently none)
+ * Authors: Olivier Lapicque
+ * OpenMPT Devs
+ * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
+ */
+
+
+#include "stdafx.h"
+
+#include "SoundDevice.h"
+#include "SoundDeviceThread.h"
+
+#include "../common/misc_util.h"
+
+#include <algorithm>
+#include <iterator>
+
+
+CAudioThread::CAudioThread(CSoundDeviceWithThread &SoundDevice) : m_SoundDevice(SoundDevice)
+//------------------------------------------------------------------------------------------
+{
+
+ m_HasXP = (mpt::Windows::GetWinNTVersion() >= mpt::Windows::VerWinXP);
+
+ m_hKernel32DLL = NULL;
+
+ pCreateWaitableTimer = nullptr;
+ pSetWaitableTimer = nullptr;
+ pCancelWaitableTimer = nullptr;
+ m_hKernel32DLL = LoadLibrary(TEXT("kernel32.dll"));
+ #if _WIN32_WINNT >= _WIN32_WINNT_WINXP
+ m_HasXP = true;
+ pCreateWaitableTimer = &CreateWaitableTimer;
+ pSetWaitableTimer = &SetWaitableTimer;
+ pCancelWaitableTimer = &CancelWaitableTimer;
+ #else
+ if(m_HasXP && m_hKernel32DLL)
+ {
+ pCreateWaitableTimer = (FCreateWaitableTimer)GetProcAddress(m_hKernel32DLL, "CreateWaitableTimerA");
+ pSetWaitableTimer = (FSetWaitableTimer)GetProcAddress(m_hKernel32DLL, "SetWaitableTimer");
+ pCancelWaitableTimer = (FCancelWaitableTimer)GetProcAddress(m_hKernel32DLL, "CancelWaitableTimer");
+ if(!pCreateWaitableTimer || !pSetWaitableTimer || !pCancelWaitableTimer)
+ {
+ m_HasXP = false;
+ }
+ }
+ #endif
+
+ m_WakeupInterval = 0.0;
+ m_hPlayThread = NULL;
+ m_dwPlayThreadId = 0;
+ m_hAudioWakeUp = NULL;
+ m_hAudioThreadTerminateRequest = NULL;
+ m_hAudioThreadGoneIdle = NULL;
+ m_hHardwareWakeupEvent = INVALID_HANDLE_VALUE;
+ m_AudioThreadActive = 0;
+ m_hAudioWakeUp = CreateEvent(NULL, FALSE, FALSE, NULL);
+ m_hAudioThreadTerminateRequest = CreateEvent(NULL, FALSE, FALSE, NULL);
+ m_hAudioThreadGoneIdle = CreateEvent(NULL, TRUE, FALSE, NULL);
+ m_hPlayThread = CreateThread(NULL, 0, AudioThreadWrapper, (LPVOID)this, 0, &m_dwPlayThreadId);
+}
+
+
+CAudioThread::~CAudioThread()
+//---------------------------
+{
+ if(m_hPlayThread != NULL)
+ {
+ SetEvent(m_hAudioThreadTerminateRequest);
+ WaitForSingleObject(m_hPlayThread, INFINITE);
+ m_dwPlayThreadId = 0;
+ m_hPlayThread = NULL;
+ }
+ if(m_hAudioThreadTerminateRequest)
+ {
+ CloseHandle(m_hAudioThreadTerminateRequest);
+ m_hAudioThreadTerminateRequest = 0;
+ }
+ if(m_hAudioThreadGoneIdle != NULL)
+ {
+ CloseHandle(m_hAudioThreadGoneIdle);
+ m_hAudioThreadGoneIdle = 0;
+ }
+ if(m_hAudioWakeUp != NULL)
+ {
+ CloseHandle(m_hAudioWakeUp);
+ m_hAudioWakeUp = NULL;
+ }
+
+ pCreateWaitableTimer = nullptr;
+ pSetWaitableTimer = nullptr;
+ pCancelWaitableTimer = nullptr;
+
+ if(m_hKernel32DLL)
+ {
+ FreeLibrary(m_hKernel32DLL);
+ m_hKernel32DLL = NULL;
+ }
+
+}
+
+
+CPriorityBooster::CPriorityBooster(bool boostPriority)
+//----------------------------------------------------
+ : m_HasVista(false)
+ , m_hAvRtDLL(NULL)
+ , pAvSetMmThreadCharacteristics(nullptr)
+ , pAvRevertMmThreadCharacteristics(nullptr)
+ , m_BoostPriority(boostPriority)
+ , task_idx(0)
+ , hTask(NULL)
+{
+
+ m_HasVista = (mpt::Windows::GetWinNTVersion() >= mpt::Windows::VerWinVista);
+
+ if(m_HasVista)
+ {
+ m_hAvRtDLL = LoadLibrary(TEXT("avrt.dll"));
+ if(m_hAvRtDLL && m_hAvRtDLL != INVALID_HANDLE_VALUE)
+ {
+ pAvSetMmThreadCharacteristics = (FAvSetMmThreadCharacteristics)GetProcAddress(m_hAvRtDLL, "AvSetMmThreadCharacteristicsA");
+ pAvRevertMmThreadCharacteristics = (FAvRevertMmThreadCharacteristics)GetProcAddress(m_hAvRtDLL, "AvRevertMmThreadCharacteristics");
+ }
+ if(!pAvSetMmThreadCharacteristics || !pAvRevertMmThreadCharacteristics)
+ {
+ m_HasVista = false;
+ }
+ }
+
+ #ifdef _DEBUG
+ m_BoostPriority = false;
+ #endif
+
+ if(m_BoostPriority)
+ {
+ if(m_HasVista)
+ {
+ hTask = pAvSetMmThreadCharacteristics(TEXT("Pro Audio"), &task_idx);
+ } else
+ {
+ SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
+ }
+ }
+
+}
+
+
+CPriorityBooster::~CPriorityBooster()
+//-----------------------------------
+{
+
+ if(m_BoostPriority)
+ {
+ if(m_HasVista)
+ {
+ pAvRevertMmThreadCharacteristics(hTask);
+ hTask = NULL;
+ task_idx = 0;
+ } else
+ {
+ SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL);
+ }
+ }
+
+ pAvRevertMmThreadCharacteristics = nullptr;
+ pAvSetMmThreadCharacteristics = nullptr;
+
+ if(m_hAvRtDLL)
+ {
+ FreeLibrary(m_hAvRtDLL);
+ m_hAvRtDLL = NULL;
+ }
+
+}
+
+
+class CPeriodicWaker
+{
+private:
+ CAudioThread &self;
+
+ double sleepSeconds;
+ long sleepMilliseconds;
+ int64 sleep100Nanoseconds;
+
+ Util::MultimediaClock clock_noxp;
+
+ bool period_noxp_set;
+ bool periodic_xp_timer;
+
+ HANDLE sleepEvent;
+
+public:
+
+ CPeriodicWaker(CAudioThread &self_, double sleepSeconds_) : self(self_), sleepSeconds(sleepSeconds_)
+ //--------------------------------------------------------------------------------------------------
+ {
+
+ sleepMilliseconds = static_cast<long>(sleepSeconds * 1000.0);
+ sleep100Nanoseconds = static_cast<int64>(sleepSeconds * 10000000.0);
+ if(sleepMilliseconds < 1) sleepMilliseconds = 1;
+ if(sleep100Nanoseconds < 1) sleep100Nanoseconds = 1;
+
+ period_noxp_set = false;
+ periodic_xp_timer = (sleep100Nanoseconds >= 10000); // can be represented as a millisecond period, otherwise use non-periodic timers which allow higher precision but might me slower because we have to set them again in each period
+
+ sleepEvent = NULL;
+
+ if(self.m_HasXP)
+ {
+ if(periodic_xp_timer)
+ {
+ sleepEvent = self.pCreateWaitableTimer(NULL, FALSE, NULL);
+ LARGE_INTEGER dueTime;
+ dueTime.QuadPart = 0 - sleep100Nanoseconds; // negative time means relative
+ self.pSetWaitableTimer(sleepEvent, &dueTime, sleepMilliseconds, NULL, NULL, FALSE);
+ } else
+ {
+ sleepEvent = self.pCreateWaitableTimer(NULL, TRUE, NULL);
+ }
+ } else
+ {
+ sleepEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ clock_noxp.SetResolution(1); // increase resolution of multimedia timer
+ period_noxp_set = true;
+ }
+
+ }
+
+ long GetSleepMilliseconds() const
+ //-------------------------------
+ {
+ return sleepMilliseconds;
+ }
+
+ HANDLE GetWakeupEvent() const
+ //---------------------------
+ {
+ return sleepEvent;
+ }
+
+ void Retrigger()
+ //--------------
+ {
+ if(self.m_HasXP)
+ {
+ if(!periodic_xp_timer)
+ {
+ LARGE_INTEGER dueTime;
+ dueTime.QuadPart = 0 - sleep100Nanoseconds; // negative time means relative
+ self.pSetWaitableTimer(sleepEvent, &dueTime, 0, NULL, NULL, FALSE);
+ }
+ } else
+ {
+ timeSetEvent(sleepMilliseconds, 1, (LPTIMECALLBACK)sleepEvent, NULL, TIME_ONESHOT | TIME_CALLBACK_EVENT_SET);
+ }
+ }
+
+ CPeriodicWaker::~CPeriodicWaker()
+ //-------------------------------
+ {
+ if(self.m_HasXP)
+ {
+ if(periodic_xp_timer)
+ {
+ self.pCancelWaitableTimer(sleepEvent);
+ }
+ CloseHandle(sleepEvent);
+ sleepEvent = NULL;
+ } else
+ {
+ if(period_noxp_set)
+ {
+ clock_noxp.SetResolution(0);
+ period_noxp_set = false;
+ }
+ CloseHandle(sleepEvent);
+ sleepEvent = NULL;
+ }
+ }
+
+};
+
+
+DWORD WINAPI CAudioThread::AudioThreadWrapper(LPVOID user)
+{
+ return ((CAudioThread*)user)->AudioThread();
+}
+DWORD CAudioThread::AudioThread()
+//-------------------------------
+{
+
+ bool terminate = false;
+ while(!terminate)
+ {
+
+ bool idle = true;
+ while(!terminate && idle)
+ {
+ HANDLE waithandles[2] = {m_hAudioThreadTerminateRequest, m_hAudioWakeUp};
+ SetEvent(m_hAudioThreadGoneIdle);
+ switch(WaitForMultipleObjects(2, waithandles, FALSE, INFINITE))
+ {
+ case WAIT_OBJECT_0:
+ terminate = true;
+ break;
+ case WAIT_OBJECT_0+1:
+ idle = false;
+ break;
+ }
+ }
+
+ if(!terminate)
+ {
+
+ CPriorityBooster priorityBooster(m_SoundDevice.m_Settings.BoostThreadPriority);
+ CPeriodicWaker periodicWaker(*this, m_WakeupInterval);
+
+ m_SoundDevice.StartFromSoundThread();
+
+ while(!terminate && IsActive())
+ {
+
+ m_SoundDevice.FillAudioBufferLocked();
+
+ periodicWaker.Retrigger();
+
+ if(m_hHardwareWakeupEvent != INVALID_HANDLE_VALUE)
+ {
+ HANDLE waithandles[4] = {m_hAudioThreadTerminateRequest, m_hAudioWakeUp, m_hHardwareWakeupEvent, periodicWaker.GetWakeupEvent()};
+ switch(WaitForMultipleObjects(4, waithandles, FALSE, periodicWaker.GetSleepMilliseconds()))
+ {
+ case WAIT_OBJECT_0:
+ terminate = true;
+ break;
+ }
+ } else
+ {
+ HANDLE waithandles[3] = {m_hAudioThreadTerminateRequest, m_hAudioWakeUp, periodicWaker.GetWakeupEvent()};
+ switch(WaitForMultipleObjects(3, waithandles, FALSE, periodicWaker.GetSleepMilliseconds()))
+ {
+ case WAIT_OBJECT_0:
+ terminate = true;
+ break;
+ }
+ }
+
+ }
+
+ m_SoundDevice.StopFromSoundThread();
+
+ }
+
+ }
+
+ SetEvent(m_hAudioThreadGoneIdle);
+
+ return 0;
+
+}
+
+
+void CAudioThread::SetWakeupEvent(HANDLE ev)
+//------------------------------------------
+{
+ m_hHardwareWakeupEvent = ev;
+}
+
+
+void CAudioThread::SetWakeupInterval(double seconds)
+//--------------------------------------------------
+{
+ m_WakeupInterval = seconds;
+}
+
+
+void CAudioThread::Activate()
+//---------------------------
+{
+ if(InterlockedExchangeAdd(&m_AudioThreadActive, 0))
+ {
+ ALWAYS_ASSERT(false);
+ return;
+ }
+ ResetEvent(m_hAudioThreadGoneIdle);
+ InterlockedExchange(&m_AudioThreadActive, 1);
+ SetEvent(m_hAudioWakeUp);
+}
+
+
+void CAudioThread::Deactivate()
+//-----------------------------
+{
+ if(!InterlockedExchangeAdd(&m_AudioThreadActive, 0))
+ {
+ ALWAYS_ASSERT(false);
+ return;
+ }
+ InterlockedExchange(&m_AudioThreadActive, 0);
+ WaitForSingleObject(m_hAudioThreadGoneIdle, INFINITE);
+}
+
+
+void CSoundDeviceWithThread::FillAudioBufferLocked()
+//--------------------------------------------------
+{
+ SourceFillAudioBufferLocked();
+}
+
+
+void CSoundDeviceWithThread::SetWakeupEvent(HANDLE ev)
+//----------------------------------------------------
+{
+ m_AudioThread.SetWakeupEvent(ev);
+}
+
+
+void CSoundDeviceWithThread::SetWakeupInterval(double seconds)
+//------------------------------------------------------------
+{
+ m_AudioThread.SetWakeupInterval(seconds);
+}
+
+
+bool CSoundDeviceWithThread::InternalStart()
+//------------------------------------------
+{
+ m_AudioThread.Activate();
+ return true;
+}
+
+
+void CSoundDeviceWithThread::InternalStop()
+//-----------------------------------------
+{
+ m_AudioThread.Deactivate();
+}
+
Copied: trunk/OpenMPT/sounddev/SoundDeviceThread.h (from rev 3817, trunk/OpenMPT/sounddev/SoundDevices.h)
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceThread.h (rev 0)
+++ trunk/OpenMPT/sounddev/SoundDeviceThread.h 2014-03-03 18:51:12 UTC (rev 3818)
@@ -0,0 +1,93 @@
+/*
+ * SoundDeviceThread.h
+ * -------------------
+ * Purpose: Sound device threading driver helpers.
+ * Notes : (currently none)
+ * Authors: Olivier Lapicque
+ * OpenMPT Devs
+ * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
+ */
+
+
+#pragma once
+
+#include "SoundDevice.h"
+
+
+class CSoundDeviceWithThread;
+
+
+class CPriorityBooster
+{
+private:
+ typedef HANDLE (WINAPI *FAvSetMmThreadCharacteristics)(LPCTSTR, LPDWORD);
+ typedef BOOL (WINAPI *FAvRevertMmThreadCharacteristics)(HANDLE);
+private:
+ bool m_HasVista;
+ HMODULE m_hAvRtDLL;
+ FAvSetMmThreadCharacteristics pAvSetMmThreadCharacteristics;
+ FAvRevertMmThreadCharacteristics pAvRevertMmThreadCharacteristics;
+ bool m_BoostPriority;
+ DWORD task_idx;
+ HANDLE hTask;
+public:
+ CPriorityBooster(bool boostPriority);
+ ~CPriorityBooster();
+};
+
+
+class CAudioThread
+{
+ friend class CPeriodicWaker;
+private:
+ CSoundDeviceWithThread & m_SoundDevice;
+
+ bool m_HasXP;
+ HMODULE m_hKernel32DLL;
+ typedef HANDLE (WINAPI *FCreateWaitableTimer)(LPSECURITY_ATTRIBUTES, BOOL, LPCTSTR);
+ typedef BOOL (WINAPI *FSetWaitableTimer)(HANDLE, const LARGE_INTEGER *, LONG, PTIMERAPCROUTINE, LPVOID, BOOL);
+ typedef BOOL (WINAPI *FCancelWaitableTimer)(HANDLE);
+ FCreateWaitableTimer pCreateWaitableTimer;
+ FSetWaitableTimer pSetWaitableTimer;
+ FCancelWaitableTimer pCancelWaitableTimer;
+
+ double m_WakeupInterval;
+ HANDLE m_hAudioWakeUp;
+ HANDLE m_hPlayThread;
+ HANDLE m_hAudioThreadTerminateRequest;
+ HANDLE m_hAudioThreadGoneIdle;
+ HANDLE m_hHardwareWakeupEvent;
+ DWORD m_dwPlayThreadId;
+ LONG m_AudioThreadActive;
+ static DWORD WINAPI AudioThreadWrapper(LPVOID user);
+ DWORD AudioThread();
+ bool IsActive() { return InterlockedExchangeAdd(&m_AudioThreadActive, 0)?true:false; }
+public:
+ CAudioThread(CSoundDeviceWithThread &SoundDevice);
+ ~CAudioThread();
+ void Activate();
+ void Deactivate();
+ void SetWakeupEvent(HANDLE ev);
+ void SetWakeupInterval(double seconds);
+};
+
+
+class CSoundDeviceWithThread : public ISoundDevice
+{
+ friend class CAudioThread;
+protected:
+ CAudioThread m_AudioThread;
+private:
+ void FillAudioBufferLocked();
+protected:
+ void SetWakeupEvent(HANDLE ev);
+ void SetWakeupInterval(double seconds);
+public:
+ CSoundDeviceWithThread(SoundDeviceID id, const std::wstring &internalID) : ISoundDevice(id, internalID), m_AudioThread(*this) {}
+ virtual ~CSoundDeviceWithThread() {}
+ bool InternalStart();
+ void InternalStop();
+ virtual void StartFromSoundThread() = 0;
+ virtual void StopFromSoundThread() = 0;
+};
+
Modified: trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp 2014-03-03 18:08:27 UTC (rev 3817)
+++ trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp 2014-03-03 18:51:12 UTC (rev 3818)
@@ -12,7 +12,7 @@
#include "stdafx.h"
#include "SoundDevice.h"
-#include "SoundDevices.h"
+#include "SoundDeviceThread.h"
#include "SoundDeviceWaveout.h"
Modified: trunk/OpenMPT/sounddev/SoundDeviceWaveout.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceWaveout.h 2014-03-03 18:08:27 UTC (rev 3817)
+++ trunk/OpenMPT/sounddev/SoundDeviceWaveout.h 2014-03-03 18:51:12 UTC (rev 3818)
@@ -11,7 +11,8 @@
#pragma once
-#include "SoundDevices.h"
+#include "SoundDevice.h"
+#include "SoundDeviceThread.h"
#include <MMSystem.h>
Deleted: trunk/OpenMPT/sounddev/SoundDevices.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevices.h 2014-03-03 18:08:27 UTC (rev 3817)
+++ trunk/OpenMPT/sounddev/SoundDevices.h 2014-03-03 18:51:12 UTC (rev 3818)
@@ -1,93 +0,0 @@
-/*
- * SoundDevices.h
- * --------------
- * Purpose: Sound device driver helpers.
- * Notes : (currently none)
- * Authors: Olivier Lapicque
- * OpenMPT Devs
- * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
- */
-
-
-#pragma once
-
-#include "SoundDevice.h"
-
-
-class CSoundDeviceWithThread;
-
-
-class CPriorityBooster
-{
-private:
- typedef HANDLE (WINAPI *FAvSetMmThreadCharacteristics)(LPCTSTR, LPDWORD);
- typedef BOOL (WINAPI *FAvRevertMmThreadCharacteristics)(HANDLE);
-private:
- bool m_HasVista;
- HMODULE m_hAvRtDLL;
- FAvSetMmThreadCharacteristics pAvSetMmThreadCharacteristics;
- FAvRevertMmThreadCharacteristics pAvRevertMmThreadCharacteristics;
- bool m_BoostPriority;
- DWORD task_idx;
- HANDLE hTask;
-public:
- CPriorityBooster(bool boostPriority);
- ~CPriorityBooster();
-};
-
-
-class CAudioThread
-{
- friend class CPeriodicWaker;
-private:
- CSoundDeviceWithThread & m_SoundDevice;
-
- bool m_HasXP;
- HMODULE m_hKernel32DLL;
- typedef HANDLE (WINAPI *FCreateWaitableTimer)(LPSECURITY_ATTRIBUTES, BOOL, LPCTSTR);
- typedef BOOL (WINAPI *FSetWaitableTimer)(HANDLE, const LARGE_INTEGER *, LONG, PTIMERAPCROUTINE, LPVOID, BOOL);
- typedef BOOL (WINAPI *FCancelWaitableTimer)(HANDLE);
- FCreateWaitableTimer pCreateWaitableTimer;
- FSetWaitableTimer pSetWaitableTimer;
- FCancelWaitableTimer pCancelWaitableTimer;
-
- double m_WakeupInterval;
- HANDLE m_hAudioWakeUp;
- HANDLE m_hPlayThread;
- HANDLE m_hAudioThreadTerminateRequest;
- HANDLE m_hAudioThreadGoneIdle;
- HANDLE m_hHardwareWakeupEvent;
- DWORD m_dwPlayThreadId;
- LONG m_AudioThreadActive;
- static DWORD WINAPI AudioThreadWrapper(LPVOID user);
- DWORD AudioThread();
- bool IsActive() { return InterlockedExchangeAdd(&m_AudioThreadActive, 0)?true:false; }
-public:
- CAudioThread(CSoundDeviceWithThread &SoundDevice);
- ~CAudioThread();
- void Activate();
- void Deactivate();
- void SetWakeupEvent(HANDLE ev);
- void SetWakeupInterval(double seconds);
-};
-
-
-class CSoundDeviceWithThread : public ISoundDevice
-{
- friend class CAudioThread;
-protected:
- CAudioThread m_AudioThread;
-private:
- void FillAudioBufferLocked();
-protected:
- void SetWakeupEvent(HANDLE ev);
- void SetWakeupInterval(double seconds);
-public:
- CSoundDeviceWithThread(SoundDeviceID id, const std::wstring &internalID) : ISoundDevice(id, internalID), m_AudioThread(*this) {}
- virtual ~CSoundDeviceWithThread() {}
- bool InternalStart();
- void InternalStop();
- virtual void StartFromSoundThread() = 0;
- virtual void StopFromSoundThread() = 0;
-};
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-03-03 21:02:34
|
Revision: 3819
http://sourceforge.net/p/modplug/code/3819
Author: saga-games
Date: 2014-03-03 21:02:26 +0000 (Mon, 03 Mar 2014)
Log Message:
-----------
[Fix] Tentative fix for samples not playing completely in sample preview while song is playing (http://bugs.openmpt.org/view.php?id=209) - we check the available virtual channels backwards now, which should minimize the risk of a clash with a legit virtual channel (and is faster). This seems to improve things a lot, but I don't understand why.
[Fix] VSTi arpeggio continued in case of NNA=continue.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/Moddoc.cpp
trunk/OpenMPT/soundlib/Snd_fx.cpp
Modified: trunk/OpenMPT/mptrack/Moddoc.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Moddoc.cpp 2014-03-03 18:51:12 UTC (rev 3818)
+++ trunk/OpenMPT/mptrack/Moddoc.cpp 2014-03-03 21:02:26 UTC (rev 3819)
@@ -1077,14 +1077,13 @@
// reset channel properties; in theory the chan is completely unused anyway.
chn.Reset(ModChannel::resetTotal, m_SndFile, CHANNELINDEX_INVALID);
chn.nMasterChn = 0; // remove NNA association
- chn.nNewNote = static_cast<uint8>(note);
+ chn.nNewNote = chn.nLastNote = static_cast<uint8>(note);
if (nins)
{
// Set instrument
chn.ResetEnvelopes();
m_SndFile.InstrumentChange(&chn, nins);
- chn.nFadeOutVol = 0x10000; // Needed for XM files, as the nRowInstr check in NoteChange() will fail.
} else if ((nsmp) && (nsmp < MAX_SAMPLES)) // Or set sample
{
ModSample &sample = m_SndFile.GetSample(nsmp);
@@ -1097,10 +1096,10 @@
chn.nLoopEnd = sample.nLoopEnd;
chn.dwFlags = static_cast<ChannelFlags>(sample.uFlags) & (CHN_SAMPLEFLAGS & ~CHN_MUTE);
chn.nPan = 128;
- if (sample.uFlags & CHN_PANNING) chn.nPan = sample.nPan;
+ if (sample.uFlags[CHN_PANNING]) chn.nPan = sample.nPan;
chn.nInsVol = sample.nGlobalVol;
- chn.nFadeOutVol = 0x10000;
}
+ chn.nFadeOutVol = 0x10000;
m_SndFile.NoteChange(&chn, note, false, true, true);
if (nVol >= 0) chn.nVolume = nVol;
@@ -2666,7 +2665,7 @@
{
CHANNELINDEX nStoppedChannel = CHANNELINDEX_INVALID;
// Search for available channel
- for(CHANNELINDEX j = m_SndFile.m_nChannels; j < MAX_CHANNELS; j++)
+ for(CHANNELINDEX j = MAX_CHANNELS - 1; j >= m_SndFile.m_nChannels; j--)
{
const ModChannel &chn = m_SndFile.m_PlayState.Chn[j];
if(!chn.nLength)
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-03-03 18:51:12 UTC (rev 3818)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-03-03 21:02:26 UTC (rev 3819)
@@ -1520,6 +1520,7 @@
chn.dwFlags.reset(CHN_VIBRATO | CHN_TREMOLO | CHN_PANBRELLO | CHN_MUTE | CHN_PORTAMENTO);
chn.nMasterChn = nChn + 1;
chn.nCommand = CMD_NONE;
+ chn.rowCommand.Clear();
// Cut the note
chn.nFadeOutVol = 0;
chn.dwFlags.set(CHN_NOTEFADE | CHN_FASTVOLRAMP);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2014-03-06 12:00:43
|
Revision: 3828
http://sourceforge.net/p/modplug/code/3828
Author: manxorist
Date: 2014-03-06 12:00:31 +0000 (Thu, 06 Mar 2014)
Log Message:
-----------
[Ref] Ban locale-dependent strings in libopenmpt and make mpt::CharsetLocale, mpt::ToLocale and mpt::PathString unavailable in non-test libopenmpt builds by making them conditional on MPT_WITH_CHARSET_LOCALE an MPT_WITH_PATHSTRING .
Modified Paths:
--------------
trunk/OpenMPT/common/BuildSettings.h
trunk/OpenMPT/common/Logging.cpp
trunk/OpenMPT/common/mptFstream.h
trunk/OpenMPT/common/mptPathString.cpp
trunk/OpenMPT/common/mptPathString.h
trunk/OpenMPT/common/mptString.cpp
trunk/OpenMPT/common/mptString.h
trunk/OpenMPT/soundlib/Sndfile.cpp
Modified: trunk/OpenMPT/common/BuildSettings.h
===================================================================
--- trunk/OpenMPT/common/BuildSettings.h 2014-03-05 15:36:12 UTC (rev 3827)
+++ trunk/OpenMPT/common/BuildSettings.h 2014-03-06 12:00:31 UTC (rev 3828)
@@ -261,8 +261,20 @@
#define MPT_CHARSET_INTERNAL
#endif
+#if defined(MODPLUG_TRACKER) && !defined(MPT_WITH_PATHSTRING)
+#define MPT_WITH_PATHSTRING // Tracker requires PathString
+#endif
+#if !defined(MODPLUG_NO_FILESAVE) && !defined(MPT_WITH_PATHSTRING)
+#define MPT_WITH_PATHSTRING // file saving requires PathString
+#endif
+#if defined(MPT_WITH_PATHSTRING) && !defined(MPT_WITH_CHARSET_LOCALE)
+#define MPT_WITH_CHARSET_LOCALE // PathString requires locale charset
+#endif
+
+
+
#if MPT_COMPILER_MSVC
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
@@ -319,3 +331,4 @@
#define _SCL_SECURE_NO_WARNINGS
#endif
#endif
+
Modified: trunk/OpenMPT/common/Logging.cpp
===================================================================
--- trunk/OpenMPT/common/Logging.cpp 2014-03-05 15:36:12 UTC (rev 3827)
+++ trunk/OpenMPT/common/Logging.cpp 2014-03-06 12:00:31 UTC (rev 3828)
@@ -137,7 +137,11 @@
std::clog
<< "openmpt: "
<< context.file << "(" << context.line << ")" << ": "
+#if defined(MPT_WITH_CHARSET_LOCALE)
<< mpt::ToLocale(message)
+#else
+ << mpt::To(mpt::CharsetUTF8, message)
+#endif
<< " [" << context.function << "]"
<< std::endl;
#endif // MODPLUG_TRACKER
@@ -153,7 +157,11 @@
vsnprintf(message, LOGBUF_SIZE, format, va);
message[LOGBUF_SIZE - 1] = '\0';
va_end(va);
+#if defined(MPT_WITH_CHARSET_LOCALE)
DoLog(context, mpt::ToWide(mpt::CharsetLocale, message));
+#else
+ DoLog(context, mpt::ToWide(mpt::CharsetUTF8, message));
+#endif
}
@@ -169,7 +177,11 @@
void Logger::operator () (const std::string &text)
//------------------------------------------------
{
+#if defined(MPT_WITH_CHARSET_LOCALE)
DoLog(context, mpt::ToWide(mpt::CharsetLocale, text));
+#else
+ DoLog(context, mpt::ToWide(mpt::CharsetUTF8, text));
+#endif
}
void Logger::operator () (const std::wstring &text)
Modified: trunk/OpenMPT/common/mptFstream.h
===================================================================
--- trunk/OpenMPT/common/mptFstream.h 2014-03-05 15:36:12 UTC (rev 3827)
+++ trunk/OpenMPT/common/mptFstream.h 2014-03-06 12:00:31 UTC (rev 3828)
@@ -14,6 +14,8 @@
#include "../common/mptString.h"
#include "../common/mptPathString.h"
+#if defined(MPT_WITH_PATHSTRING)
+
namespace mpt
{
@@ -192,3 +194,6 @@
#undef MPT_FSTREAM_OPEN
} // namespace mpt
+
+#endif // MPT_WITH_PATHSTRING
+
Modified: trunk/OpenMPT/common/mptPathString.cpp
===================================================================
--- trunk/OpenMPT/common/mptPathString.cpp 2014-03-05 15:36:12 UTC (rev 3827)
+++ trunk/OpenMPT/common/mptPathString.cpp 2014-03-06 12:00:31 UTC (rev 3828)
@@ -11,6 +11,8 @@
#include "mptPathString.h"
+#if defined(MPT_WITH_PATHSTRING)
+
#if defined(MODPLUG_TRACKER)
namespace mpt
@@ -185,7 +187,11 @@
//-----------------------------------------------------------------
{
#if defined(WIN32)
- return _wfopen(filename.AsNative().c_str(), mode ? mpt::ToWide(mpt::CharsetLocale, mode).c_str() : nullptr);
+ #if defined(MPT_WITH_CHARSET_LOCALE)
+ return _wfopen(filename.AsNative().c_str(), mode ? mpt::ToWide(mpt::CharsetLocale, mode).c_str() : nullptr);
+ #else
+ return _wfopen(filename.AsNative().c_str(), mode ? mpt::ToWide(mpt::CharsetUTF8, mode).c_str() : nullptr);
+ #endif
#else // !WIN32
return fopen(filename.AsNative().c_str(), mode);
#endif // WIN32
@@ -197,7 +203,11 @@
#if defined(WIN32)
return _wfopen(filename.AsNative().c_str(), mode);
#else // !WIN32
- return fopen(filename.AsNative().c_str(), mode ? mpt::ToLocale(mode).c_str() : nullptr);
+ #if defined(MPT_WITH_CHARSET_LOCALE)
+ return fopen(filename.AsNative().c_str(), mode ? mpt::ToLocale(mode).c_str() : nullptr);
+ #else
+ return fopen(filename.AsNative().c_str(), mode ? mpt::To(mpt::CharsetUTF8, mode).c_str() : nullptr);
+ #endif
#endif // WIN32
}
@@ -296,3 +306,6 @@
#endif
#endif // MODPLUG_TRACKER
+
+#endif // MPT_WITH_PATHSTRING
+
Modified: trunk/OpenMPT/common/mptPathString.h
===================================================================
--- trunk/OpenMPT/common/mptPathString.h 2014-03-05 15:36:12 UTC (rev 3827)
+++ trunk/OpenMPT/common/mptPathString.h 2014-03-06 12:00:31 UTC (rev 3828)
@@ -13,6 +13,8 @@
#include <cstdio>
#include <stdio.h>
+#if defined(MPT_WITH_PATHSTRING)
+
//#define MPT_DEPRECATED_PATH
#define MPT_DEPRECATED_PATH MPT_DEPRECATED
@@ -134,10 +136,14 @@
#if defined(WIN32)
// conversions
+#if defined(MPT_WITH_CHARSET_LOCALE)
MPT_DEPRECATED_PATH std::string ToLocale() const { return mpt::ToLocale(path); }
+#endif
std::string ToUTF8() const { return mpt::To(mpt::CharsetUTF8, path); }
std::wstring ToWide() const { return path; }
+#if defined(MPT_WITH_CHARSET_LOCALE)
MPT_DEPRECATED_PATH static PathString FromLocale(const std::string &path) { return PathString(mpt::ToWide(mpt::CharsetLocale, path)); }
+#endif
static PathString FromUTF8(const std::string &path) { return PathString(mpt::ToWide(mpt::CharsetUTF8, path)); }
static PathString FromWide(const std::wstring &path) { return PathString(path); }
RawPathString AsNative() const { return path; }
@@ -157,6 +163,7 @@
#else // !WIN32
// conversions
+#if defined(MPT_WITH_CHARSET_LOCALE)
std::string ToLocale() const { return path; }
std::string ToUTF8() const { return mpt::To(mpt::CharsetUTF8, mpt::CharsetLocale, path); }
std::wstring ToWide() const { return mpt::ToWide(mpt::CharsetLocale, path); }
@@ -165,12 +172,22 @@
static PathString FromWide(const std::wstring &path) { return PathString(mpt::To(mpt::CharsetLocale, path)); }
RawPathString AsNative() const { return path; }
static PathString FromNative(const RawPathString &path) { return PathString(path); }
+#else
+ std::string ToUTF8() const { return path; }
+ std::wstring ToWide() const { return mpt::ToWide(mpt::CharsetUTF8, path); }
+ static PathString FromUTF8(const std::string &path) { return path; }
+ static PathString FromWide(const std::wstring &path) { return PathString(mpt::To(mpt::CharsetUTF8, path)); }
+ RawPathString AsNative() const { return path; }
+ static PathString FromNative(const RawPathString &path) { return PathString(path); }
+#endif
#endif // WIN32
};
+#if defined(MPT_WITH_CHARSET_LOCALE)
MPT_DEPRECATED_PATH static inline std::string ToString(const mpt::PathString & x) { return mpt::ToLocale(x.ToWide()); }
+#endif
static inline std::wstring ToWString(const mpt::PathString & x) { return x.ToWide(); }
} // namespace mpt
@@ -220,3 +237,6 @@
#endif
#endif // MODPLUG_TRACKER
+
+#endif // MPT_WITH_PATHSTRING
+
Modified: trunk/OpenMPT/common/mptString.cpp
===================================================================
--- trunk/OpenMPT/common/mptString.cpp 2014-03-05 15:36:12 UTC (rev 3827)
+++ trunk/OpenMPT/common/mptString.cpp 2014-03-06 12:00:31 UTC (rev 3828)
@@ -348,6 +348,8 @@
return res;
}
+#if defined(MPT_WITH_CHARSET_LOCALE)
+
static std::wstring LocaleDecode(const std::string &str, const std::locale & locale, wchar_t replacement = L'\uFFFD')
//-------------------------------------------------------------------------------------------------------------------
{
@@ -498,6 +500,8 @@
return String::ToAscii(str, replacement); // fallback
}
+#endif
+
#endif // MPT_CHARSET_CODECVTUTF8 || MPT_CHARSET_INTERNAL
#if defined(MPT_CHARSET_CODECVTUTF8)
@@ -687,7 +691,9 @@
{
switch(charset)
{
+#if defined(MPT_WITH_CHARSET_LOCALE)
case CharsetLocale: return CP_ACP; break;
+#endif
case CharsetUTF8: return CP_UTF8; break;
case CharsetASCII: return 20127; break;
case CharsetISO8859_1: return 28591; break;
@@ -708,7 +714,9 @@
{
switch(charset)
{
+#if defined(MPT_WITH_CHARSET_LOCALE)
case CharsetLocale: return ""; break; // "char" breaks with glibc when no locale is set
+#endif
case CharsetUTF8: return "UTF-8"; break;
case CharsetASCII: return "ASCII"; break;
case CharsetISO8859_1: return "ISO-8859-1"; break;
@@ -725,7 +733,9 @@
{
switch(charset)
{
+#if defined(MPT_WITH_CHARSET_LOCALE)
case CharsetLocale: return "//TRANSLIT"; break; // "char" breaks with glibc when no locale is set
+#endif
case CharsetUTF8: return "UTF-8//TRANSLIT"; break;
case CharsetASCII: return "ASCII//TRANSLIT"; break;
case CharsetISO8859_1: return "ISO-8859-1//TRANSLIT"; break;
@@ -787,12 +797,14 @@
std::copy(out.begin(), out.end(), std::back_inserter(result));
return result;
}
+#if defined(MPT_WITH_CHARSET_LOCALE)
#if defined(MPT_LOCALE_ASSUME_CHARSET)
if(charset == CharsetLocale)
{
charset = MPT_LOCALE_ASSUME_CHARSET;
}
#endif
+#endif
#if defined(MPT_CHARSET_WIN32)
const UINT codepage = CharsetToCodepage(charset);
int required_size = WideCharToMultiByte(codepage, 0, src.c_str(), -1, nullptr, 0, nullptr, nullptr);
@@ -844,7 +856,9 @@
std::string out;
switch(charset)
{
+#if defined(MPT_WITH_CHARSET_LOCALE)
case CharsetLocale: out = String::ToLocale(src); break;
+#endif
case CharsetUTF8: out = String::ToUTF8(src); break;
case CharsetASCII: out = String::ToAscii(src); break;
case CharsetISO8859_1: out = String::ToISO_8859_1(src); break;
@@ -875,12 +889,14 @@
if(charset == CharsetCP437AMS2) out = String::From8bit(in, CharsetTableCP437AMS2);
return out;
}
+#if defined(MPT_WITH_CHARSET_LOCALE)
#if defined(MPT_LOCALE_ASSUME_CHARSET)
if(charset == CharsetLocale)
{
charset = MPT_LOCALE_ASSUME_CHARSET;
}
#endif
+#endif
#if defined(MPT_CHARSET_WIN32)
const UINT codepage = CharsetToCodepage(charset);
int required_size = MultiByteToWideChar(codepage, 0, reinterpret_cast<const char*>(src.c_str()), -1, nullptr, 0);
@@ -938,7 +954,9 @@
std::wstring out;
switch(charset)
{
+#if defined(MPT_WITH_CHARSET_LOCALE)
case CharsetLocale: out = String::FromLocale(in); break;
+#endif
case CharsetUTF8: out = String::FromUTF8(in); break;
case CharsetASCII: out = String::FromAscii(in); break;
case CharsetISO8859_1: out = String::FromISO_8859_1(in); break;
@@ -1018,6 +1036,7 @@
return String::DecodeImpl(from, str);
}
+#if defined(MPT_WITH_CHARSET_LOCALE)
std::string ToLocale(const std::wstring &str)
{
return String::EncodeImpl<std::string>(CharsetLocale, str);
@@ -1026,6 +1045,7 @@
{
return String::ConvertImpl<std::string>(CharsetLocale, from, str);
}
+#endif
std::string To(Charset to, const std::wstring &str)
{
@@ -1115,10 +1135,17 @@
return o.str();
}
+#if defined(MPT_WITH_CHARSET_LOCALE)
std::string ToString(const std::wstring & x) { return mpt::ToLocale(x); }
std::string ToString(const wchar_t * const & x) { return mpt::ToLocale(x); };
std::string ToString(const char & x) { return std::string(1, x); }
std::string ToString(const wchar_t & x) { return mpt::ToLocale(std::wstring(1, x)); }
+#else
+std::string ToString(const std::wstring & x) { return mpt::To(mpt::CharsetUTF8, x); }
+std::string ToString(const wchar_t * const & x) { return mpt::To(mpt::CharsetUTF8, x); };
+std::string ToString(const char & x) { return std::string(1, x); }
+std::string ToString(const wchar_t & x) { return mpt::To(mpt::CharsetUTF8, std::wstring(1, x)); }
+#endif
std::string ToString(const bool & x) { return ToStringHelper(x); }
std::string ToString(const signed char & x) { return ToStringHelper(x); }
std::string ToString(const unsigned char & x) { return ToStringHelper(x); }
@@ -1134,10 +1161,17 @@
std::string ToString(const double & x) { return ToStringHelper(x); }
std::string ToString(const long double & x) { return ToStringHelper(x); }
+#if defined(MPT_WITH_CHARSET_LOCALE)
std::wstring ToWString(const std::string & x) { return mpt::ToWide(mpt::CharsetLocale, x); }
std::wstring ToWString(const char * const & x) { return mpt::ToWide(mpt::CharsetLocale, x); }
std::wstring ToWString(const char & x) { return mpt::ToWide(mpt::CharsetLocale, std::string(1, x)); }
std::wstring ToWString(const wchar_t & x) { return std::wstring(1, x); }
+#else
+std::wstring ToWString(const std::string & x) { return mpt::ToWide(mpt::CharsetUTF8, x); }
+std::wstring ToWString(const char * const & x) { return mpt::ToWide(mpt::CharsetUTF8, x); }
+std::wstring ToWString(const char & x) { return mpt::ToWide(mpt::CharsetUTF8, std::string(1, x)); }
+std::wstring ToWString(const wchar_t & x) { return std::wstring(1, x); }
+#endif
std::wstring ToWString(const bool & x) { return ToWStringHelper(x); }
std::wstring ToWString(const signed char & x) { return ToWStringHelper(x); }
std::wstring ToWString(const unsigned char & x) { return ToWStringHelper(x); }
Modified: trunk/OpenMPT/common/mptString.h
===================================================================
--- trunk/OpenMPT/common/mptString.h 2014-03-05 15:36:12 UTC (rev 3827)
+++ trunk/OpenMPT/common/mptString.h 2014-03-06 12:00:31 UTC (rev 3828)
@@ -160,7 +160,9 @@
enum Charset {
+#if defined(MPT_WITH_CHARSET_LOCALE)
CharsetLocale, // CP_ACP on windows, current C locale otherwise
+#endif
CharsetUTF8,
@@ -184,6 +186,7 @@
static inline std::wstring ToWide(const std::wstring &str) { return str; }
std::wstring ToWide(Charset from, const std::string &str);
+#if defined(MPT_WITH_CHARSET_LOCALE)
// Convert to locale-encoded string.
// On Windows, CP_ACP is used,
// otherwise, the global "C" locale is used.
@@ -194,6 +197,7 @@
// destination charset will be replaced by some replacement character or string.
std::string ToLocale(const std::wstring &str);
std::string ToLocale(Charset from, const std::string &str);
+#endif
// Convert to a string encoded in the 'to'-specified character set.
// If str does not contain any invalid characters,
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2014-03-05 15:36:12 UTC (rev 3827)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2014-03-06 12:00:31 UTC (rev 3828)
@@ -2370,10 +2370,14 @@
// Convert ANSI plugin path names to UTF-8 (irrelevant in probably 99% of all cases anyway, I think I've never seen a VST plugin with a non-ASCII file name)
for(PLUGINDEX i = 0; i < MAX_MIXPLUGINS; i++)
{
+#if defined(MPT_WITH_CHARSET_LOCALE)
const std::string name = mpt::To(mpt::CharsetUTF8, mpt::CharsetLocale, m_MixPlugins[i].Info.szLibraryName);
+#else
+ const std::string name = mpt::To(mpt::CharsetUTF8, mpt::CharsetWindows1252, m_MixPlugins[i].Info.szLibraryName);
+#endif
mpt::String::Copy(m_MixPlugins[i].Info.szLibraryName, name);
}
}
Patterns.ForEachModCommand(UpgradePatternData(*this));
-}
\ No newline at end of file
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2014-03-06 13:19:40
|
Revision: 3831
http://sourceforge.net/p/modplug/code/3831
Author: manxorist
Date: 2014-03-06 13:19:32 +0000 (Thu, 06 Mar 2014)
Log Message:
-----------
[Fix] build: Mixed revision working copies result in svnversion returning a string that contains a ':'. This confuses the Makefile and would be rather tricky to escape, just replace it with a '-'.
Modified Paths:
--------------
trunk/OpenMPT/Makefile
trunk/OpenMPT/common/svn_version_svnversion/svn_version.h
Modified: trunk/OpenMPT/Makefile
===================================================================
--- trunk/OpenMPT/Makefile 2014-03-06 13:02:11 UTC (rev 3830)
+++ trunk/OpenMPT/Makefile 2014-03-06 13:19:32 UTC (rev 3831)
@@ -361,7 +361,7 @@
SVN_INFO:=$(shell svn info . > /dev/null 2>&1 ; echo $$? )
ifeq ($(SVN_INFO),0)
# in svn checkout
-BUILD_SVNVERSION := $(shell svnversion -n . )
+BUILD_SVNVERSION := $(shell svnversion -n . | tr ':' '-' )
CPPFLAGS += -Icommon/svn_version_svnversion -D BUILD_SVNVERSION=\"$(BUILD_SVNVERSION)\"
DIST_OPENMPT_VERSION:=r$(BUILD_SVNVERSION)
DIST_LIBOPENMPT_VERSION:=$(LIBOPENMPT_VERSION_MAJOR).$(LIBOPENMPT_VERSION_MINOR).$(BUILD_SVNVERSION)
Modified: trunk/OpenMPT/common/svn_version_svnversion/svn_version.h
===================================================================
--- trunk/OpenMPT/common/svn_version_svnversion/svn_version.h 2014-03-06 13:02:11 UTC (rev 3830)
+++ trunk/OpenMPT/common/svn_version_svnversion/svn_version.h 2014-03-06 13:19:32 UTC (rev 3831)
@@ -44,6 +44,10 @@
{
svnversion = svnversion.substr(svnversion.find(":") + 1);
}
+ if(svnversion.find("-") != std::string::npos)
+ {
+ svnversion = svnversion.substr(svnversion.find("-") + 1);
+ }
if(svnversion.find("M") != std::string::npos)
{
svnversion = svnversion.substr(0, svnversion.find("M"));
@@ -73,6 +77,10 @@
{
return true;
}
+ if(svnversion.find("-") != std::string::npos)
+ {
+ return true;
+ }
if(svnversion.find("S") != std::string::npos)
{
return true;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-03-06 22:10:07
|
Revision: 3835
http://sourceforge.net/p/modplug/code/3835
Author: saga-games
Date: 2014-03-06 22:10:01 +0000 (Thu, 06 Mar 2014)
Log Message:
-----------
[Mod] If "no loud samples" is enabled, make the treeview preview as loud as it would be in the currently active module's sample editor.
[Fix] STM Loader: Imported volume commands were slightly off when there was another command next to them.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/MainFrm.cpp
trunk/OpenMPT/soundlib/Load_stm.cpp
Modified: trunk/OpenMPT/mptrack/MainFrm.cpp
===================================================================
--- trunk/OpenMPT/mptrack/MainFrm.cpp 2014-03-06 17:22:30 UTC (rev 3834)
+++ trunk/OpenMPT/mptrack/MainFrm.cpp 2014-03-06 22:10:01 UTC (rev 3835)
@@ -1567,12 +1567,21 @@
void CMainFrame::InitPreview()
//----------------------------
{
+ const CModDoc *activeDoc = GetActiveDoc();
m_WaveFile.Destroy();
m_WaveFile.Create(FileReader());
// Avoid global volume ramping when trying samples in the treeview.
m_WaveFile.m_nDefaultGlobalVolume = m_WaveFile.m_PlayState.m_nGlobalVolume = MAX_GLOBAL_VOLUME;
- m_WaveFile.SetMixLevels(mixLevels_117RC3);
- m_WaveFile.m_nSamplePreAmp = static_cast<uint32>(m_WaveFile.GetPlayConfig().getNormalSamplePreAmp());
+ if(activeDoc != nullptr && (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_NOEXTRALOUD))
+ {
+ m_WaveFile.SetMixLevels(activeDoc->GetrSoundFile().GetMixLevels());
+ m_WaveFile.m_nSamplePreAmp = activeDoc->GetrSoundFile().m_nSamplePreAmp;
+ } else
+ {
+ // Preview at 0dB
+ m_WaveFile.SetMixLevels(mixLevels_117RC3);
+ m_WaveFile.m_nSamplePreAmp = static_cast<uint32>(m_WaveFile.GetPlayConfig().getNormalSamplePreAmp());
+ }
m_WaveFile.m_nDefaultTempo = 125;
m_WaveFile.m_nDefaultSpeed = 6;
m_WaveFile.m_nType = MOD_TYPE_MPT;
Modified: trunk/OpenMPT/soundlib/Load_stm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_stm.cpp 2014-03-06 17:22:30 UTC (rev 3834)
+++ trunk/OpenMPT/soundlib/Load_stm.cpp 2014-03-06 22:10:01 UTC (rev 3835)
@@ -222,7 +222,7 @@
m->instr = 0;
}
- int8 vol = (entry.insvol & 0x07) | (entry.volcmd >> 1);
+ int8 vol = (entry.insvol & 0x07) | ((entry.volcmd & 0xF0) >> 1);
if(vol <= 64)
{
m->volcmd = VOLCMD_VOLUME;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2014-03-07 11:43:29
|
Revision: 3837
http://sourceforge.net/p/modplug/code/3837
Author: manxorist
Date: 2014-03-07 11:43:17 +0000 (Fri, 07 Mar 2014)
Log Message:
-----------
[Ref] DSP: Replace WIN32 types in reverb.
[Ref] Replace BOOL with bool in CSoundFile::InitPlayer.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/MainFrm.cpp
trunk/OpenMPT/mptrack/Mod2wave.cpp
trunk/OpenMPT/sounddsp/AGC.cpp
trunk/OpenMPT/sounddsp/AGC.h
trunk/OpenMPT/sounddsp/DSP.cpp
trunk/OpenMPT/sounddsp/DSP.h
trunk/OpenMPT/sounddsp/EQ.cpp
trunk/OpenMPT/sounddsp/EQ.h
trunk/OpenMPT/sounddsp/Reverb.cpp
trunk/OpenMPT/sounddsp/Reverb.h
trunk/OpenMPT/soundlib/Sndfile.cpp
trunk/OpenMPT/soundlib/Sndfile.h
trunk/OpenMPT/soundlib/Sndmix.cpp
Modified: trunk/OpenMPT/mptrack/MainFrm.cpp
===================================================================
--- trunk/OpenMPT/mptrack/MainFrm.cpp 2014-03-07 02:32:49 UTC (rev 3836)
+++ trunk/OpenMPT/mptrack/MainFrm.cpp 2014-03-07 11:43:17 UTC (rev 3837)
@@ -1029,7 +1029,7 @@
sndFile.SetEQGains(TrackerSettings::Instance().m_EqSettings.Gains, MAX_EQ_BANDS, TrackerSettings::Instance().m_EqSettings.Freqs, reset?TRUE:FALSE);
#endif
sndFile.SetDspEffects(TrackerSettings::Instance().MixerDSPMask);
- sndFile.InitPlayer(reset?TRUE:FALSE);
+ sndFile.InitPlayer(reset);
}
@@ -1044,7 +1044,7 @@
sndFile.SetMixerSettings(TrackerSettings::Instance().GetMixerSettings());
sndFile.SetResamplerSettings(TrackerSettings::Instance().GetResamplerSettings());
UpdateDspEffects(sndFile, false); // reset done in next line
- sndFile.InitPlayer(reset?TRUE:FALSE);
+ sndFile.InitPlayer(reset);
}
@@ -1332,7 +1332,7 @@
if(!bPatLoop && bPaused) sndFile.m_SongFlags.set(SONG_PAUSED);
sndFile.SetRepeatCount((TrackerSettings::Instance().gbLoopSong) ? -1 : 0);
- sndFile.InitPlayer(TRUE);
+ sndFile.InitPlayer(true);
sndFile.ResumePlugins();
m_wndToolBar.SetCurrentSong(m_pSndFile);
@@ -1430,7 +1430,7 @@
SetPlaybackSoundFile(pSndFile);
- m_pSndFile->InitPlayer(TRUE);
+ m_pSndFile->InitPlayer(true);
if(!StartPlayback())
{
Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Mod2wave.cpp 2014-03-07 02:32:49 UTC (rev 3836)
+++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2014-03-07 11:43:17 UTC (rev 3837)
@@ -1020,7 +1020,7 @@
m_SndFile.ResetChannels();
m_SndFile.SetMixerSettings(mixersettings);
m_SndFile.SetResamplerSettings(TrackerSettings::Instance().GetResamplerSettings());
- m_SndFile.InitPlayer(TRUE);
+ m_SndFile.InitPlayer(true);
if(!m_dwFileLimit) m_dwFileLimit = Util::MaxValueOfType(m_dwFileLimit) >> 10;
m_dwFileLimit <<= 10;
Modified: trunk/OpenMPT/sounddsp/AGC.cpp
===================================================================
--- trunk/OpenMPT/sounddsp/AGC.cpp 2014-03-07 02:32:49 UTC (rev 3836)
+++ trunk/OpenMPT/sounddsp/AGC.cpp 2014-03-07 11:43:17 UTC (rev 3837)
@@ -120,7 +120,7 @@
}
-void CAGC::Initialize(BOOL bReset, DWORD MixingFreq)
+void CAGC::Initialize(bool bReset, DWORD MixingFreq)
//--------------------------------------------------
{
if(bReset)
Modified: trunk/OpenMPT/sounddsp/AGC.h
===================================================================
--- trunk/OpenMPT/sounddsp/AGC.h 2014-03-07 02:32:49 UTC (rev 3836)
+++ trunk/OpenMPT/sounddsp/AGC.h 2014-03-07 11:43:17 UTC (rev 3837)
@@ -23,7 +23,7 @@
UINT m_Timeout;
public:
CAGC();
- void Initialize(BOOL bReset, DWORD MixingFreq);
+ void Initialize(bool bReset, DWORD MixingFreq);
public:
void Process(int *MixSoundBuffer, int *RearSoundBuffer, int count, UINT nChannels);
void Adjust(UINT oldVol, UINT newVol);
Modified: trunk/OpenMPT/sounddsp/DSP.cpp
===================================================================
--- trunk/OpenMPT/sounddsp/DSP.cpp 2014-03-07 02:32:49 UTC (rev 3836)
+++ trunk/OpenMPT/sounddsp/DSP.cpp 2014-03-07 11:43:17 UTC (rev 3837)
@@ -158,7 +158,7 @@
}
-void CDSP::Initialize(BOOL bReset, DWORD MixingFreq, DWORD DSPMask)
+void CDSP::Initialize(bool bReset, DWORD MixingFreq, DWORD DSPMask)
//-----------------------------------------------------------------
{
if (!m_Settings.m_nProLogicDelay) m_Settings.m_nProLogicDelay = 20;
Modified: trunk/OpenMPT/sounddsp/DSP.h
===================================================================
--- trunk/OpenMPT/sounddsp/DSP.h 2014-03-07 02:32:49 UTC (rev 3836)
+++ trunk/OpenMPT/sounddsp/DSP.h 2014-03-07 11:43:17 UTC (rev 3837)
@@ -83,7 +83,7 @@
BOOL SetXBassParameters(UINT nDepth, UINT nRange);
// [Surround level 0(quiet)-100(heavy)] [delay in ms, usually 5-40ms]
BOOL SetSurroundParameters(UINT nDepth, UINT nDelay);
- void Initialize(BOOL bReset, DWORD MixingFreq, DWORD DSPMask);
+ void Initialize(bool bReset, DWORD MixingFreq, DWORD DSPMask);
void Process(int * MixSoundBuffer, int * MixRearBuffer, int count, UINT nChannels, DWORD DSPMask);
private:
void ProcessStereoSurround(int * MixSoundBuffer, int count);
Modified: trunk/OpenMPT/sounddsp/EQ.cpp
===================================================================
--- trunk/OpenMPT/sounddsp/EQ.cpp 2014-03-07 02:32:49 UTC (rev 3836)
+++ trunk/OpenMPT/sounddsp/EQ.cpp 2014-03-07 11:43:17 UTC (rev 3837)
@@ -397,7 +397,7 @@
}
-void CEQ::Initialize(BOOL bReset, DWORD MixingFreq)
+void CEQ::Initialize(bool bReset, DWORD MixingFreq)
//-------------------------------------------------
{
float32 fMixingFreq = (float32)MixingFreq;
@@ -406,7 +406,7 @@
{
float32 k, k2, r, f;
float32 v0, v1;
- BOOL b = bReset;
+ bool b = bReset;
f = gEQ[band].CenterFrequency / fMixingFreq;
if (f > 0.45f) gEQ[band].Gain = 1;
@@ -509,11 +509,11 @@
gEQ[i+MAX_EQ_BANDS].bEnable = false;
}
}
- Initialize(bReset, MixingFreq);
+ Initialize(bReset?true:false, MixingFreq);
}
-void CQuadEQ::Initialize(BOOL bReset, DWORD MixingFreq)
+void CQuadEQ::Initialize(bool bReset, DWORD MixingFreq)
//-----------------------------------------------------
{
front.Initialize(bReset, MixingFreq);
Modified: trunk/OpenMPT/sounddsp/EQ.h
===================================================================
--- trunk/OpenMPT/sounddsp/EQ.h 2014-03-07 02:32:49 UTC (rev 3836)
+++ trunk/OpenMPT/sounddsp/EQ.h 2014-03-07 11:43:17 UTC (rev 3837)
@@ -39,7 +39,7 @@
public:
CEQ();
public:
- void Initialize(BOOL bReset, DWORD MixingFreq);
+ void Initialize(bool bReset, DWORD MixingFreq);
void ProcessStereo(int *pbuffer, float *MixFloatBuffer, UINT nCount);
void ProcessMono(int *pbuffer, float *MixFloatBuffer, UINT nCount);
void SetEQGains(const UINT *pGains, UINT nGains, const UINT *pFreqs, BOOL bReset, DWORD MixingFreq);
@@ -55,7 +55,7 @@
CEQ rear;
float EQTempFloatBuffer[MIXBUFFERSIZE * 2];
public:
- void Initialize(BOOL bReset, DWORD MixingFreq);
+ void Initialize(bool bReset, DWORD MixingFreq);
void Process(int *frontBuffer, int *rearBuffer, UINT nCount, UINT nChannels);
void SetEQGains(const UINT *pGains, UINT nGains, const UINT *pFreqs, BOOL bReset, DWORD MixingFreq);
};
Modified: trunk/OpenMPT/sounddsp/Reverb.cpp
===================================================================
--- trunk/OpenMPT/sounddsp/Reverb.cpp 2014-03-07 02:32:49 UTC (rev 3836)
+++ trunk/OpenMPT/sounddsp/Reverb.cpp 2014-03-07 11:43:17 UTC (rev 3837)
@@ -18,7 +18,7 @@
#pragma warning(disable:4725) // Pentium fdiv bug
#pragma warning(disable:4731) // ebp modified
-extern void StereoFill(int *pBuffer, UINT nSamples, mixsample_t &lpROfs, mixsample_t &lpLOfs);
+extern void StereoFill(int *pBuffer, uint32 nSamples, mixsample_t &lpROfs, mixsample_t &lpLOfs);
@@ -67,19 +67,19 @@
// Misc functions
-static LONG OnePoleLowPassCoef(LONG scale, float g, float F_c, float F_s);
-static LONG mBToLinear(LONG scale, LONG value_mB);
-static float mBToLinear(LONG value_mB);
+static int32 OnePoleLowPassCoef(int32 scale, float g, float F_c, float F_s);
+static int32 mBToLinear(int32 scale, int32 value_mB);
+static float mBToLinear(int32 value_mB);
struct SNDMIX_REVERB_PROPERTIES
{
- LONG lRoom; // [-10000, 0] default: -10000 mB
- LONG lRoomHF; // [-10000, 0] default: 0 mB
+ int32 lRoom; // [-10000, 0] default: -10000 mB
+ int32 lRoomHF; // [-10000, 0] default: 0 mB
float flDecayTime; // [0.1, 20.0] default: 1.0 s
float flDecayHFRatio; // [0.1, 2.0] default: 0.5
- LONG lReflections; // [-10000, 1000] default: -10000 mB
+ int32 lReflections; // [-10000, 1000] default: -10000 mB
float flReflectionsDelay; // [0.0, 0.3] default: 0.02 s
- LONG lReverb; // [-10000, 2000] default: -10000 mB
+ int32 lReverb; // [-10000, 2000] default: -10000 mB
float flReverbDelay; // [0.0, 0.1] default: 0.04 s
float flDiffusion; // [0.0, 100.0] default: 100.0 %
float flDensity; // [0.0, 100.0] default: 100.0 %
@@ -126,7 +126,7 @@
{{ SNDMIX_REVERB_PRESET_UNDERWATER }, "Underwater"},
};
-const char *GetReverbPresetName(UINT nPreset)
+const char *GetReverbPresetName(uint32 nPreset)
{
return (nPreset < NUM_REVERBTYPES) ? gRvbPresets[nPreset].lpszName : NULL;
}
@@ -138,8 +138,8 @@
typedef struct _REFLECTIONPRESET
{
- LONG lDelayFactor;
- SHORT sGainLL, sGainRR, sGainLR, sGainRL;
+ int32 lDelayFactor;
+ int16 sGainLL, sGainRR, sGainLR, sGainRL;
} REFLECTIONPRESET, *PREFLECTIONPRESET;
const REFLECTIONPRESET gReflectionsPreset[ENVIRONMENT_NUMREFLECTIONS] =
@@ -162,18 +162,18 @@
inline long ftol(float f) { return ((long)(f)); }
-static VOID I3dl2_to_Generic(
+static void I3dl2_to_Generic(
const SNDMIX_REVERB_PROPERTIES *pReverb,
PENVIRONMENTREVERB pRvb,
float flOutputFreq,
- LONG lMinRefDelay,
- LONG lMaxRefDelay,
- LONG lMinRvbDelay,
- LONG lMaxRvbDelay,
- LONG lTankLength)
+ int32 lMinRefDelay,
+ int32 lMaxRefDelay,
+ int32 lMinRvbDelay,
+ int32 lMaxRvbDelay,
+ int32 lTankLength)
{
float flDelayFactor, flDelayFactorHF, flDecayTimeHF;
- LONG lDensity, lTailDiffusion;
+ int32 lDensity, lTailDiffusion;
// Common parameters
pRvb->ReverbLevel = pReverb->lReverb;
@@ -181,7 +181,7 @@
pRvb->RoomHF = pReverb->lRoomHF;
// HACK: Somewhat normalize the reverb output level
- LONG lMaxLevel = (pRvb->ReverbLevel > pRvb->ReflectionsLevel) ? pRvb->ReverbLevel : pRvb->ReflectionsLevel;
+ int32 lMaxLevel = (pRvb->ReverbLevel > pRvb->ReflectionsLevel) ? pRvb->ReverbLevel : pRvb->ReflectionsLevel;
if (lMaxLevel < -600)
{
lMaxLevel += 600;
@@ -201,9 +201,9 @@
// Verify reflections and reverb delay parameters
float flRefDelay = pReverb->flReflectionsDelay;
if (flRefDelay > 0.100f) flRefDelay = 0.100f;
- LONG lReverbDelay = ftol(pReverb->flReverbDelay * flOutputFreq);
- LONG lReflectionsDelay = ftol(flRefDelay * flOutputFreq);
- LONG lReverbDecayTime = ftol(pReverb->flDecayTime * flOutputFreq);
+ int32 lReverbDelay = ftol(pReverb->flReverbDelay * flOutputFreq);
+ int32 lReflectionsDelay = ftol(flRefDelay * flOutputFreq);
+ int32 lReverbDecayTime = ftol(pReverb->flDecayTime * flOutputFreq);
if (lReflectionsDelay < lMinRefDelay)
{
lReverbDelay -= (lMinRefDelay - lReflectionsDelay);
@@ -228,7 +228,7 @@
pRvb->ReverbDelay = lReverbDelay;
pRvb->ReverbDecaySamples = lReverbDecayTime;
// Setup individual reflections delay and gains
- for (UINT iRef=0; iRef<ENVIRONMENT_NUMREFLECTIONS; iRef++)
+ for (uint32 iRef=0; iRef<ENVIRONMENT_NUMREFLECTIONS; iRef++)
{
PENVIRONMENTREFLECTION pRef = &pRvb->Reflections[iRef];
pRef->Delay = lReflectionsDelay + (gReflectionsPreset[iRef].lDelayFactor * lReverbDelay + 50)/100;
@@ -259,8 +259,8 @@
gnRvbROfsVol = 0;
// Clear out all reverb state
- g_bLastInPresent = FALSE;
- g_bLastOutPresent = FALSE;
+ g_bLastInPresent = false;
+ g_bLastOutPresent = false;
g_nLastRvbIn_xl = g_nLastRvbIn_xr = 0;
g_nLastRvbIn_yl = g_nLastRvbIn_yr = 0;
g_nLastRvbOut_xl = g_nLastRvbOut_xr = 0;
@@ -278,8 +278,8 @@
}
-void CReverb::Initialize(BOOL bReset, DWORD MixingFreq)
-//-----------------------------------------------------
+void CReverb::Initialize(bool bReset, uint32 MixingFreq)
+//------------------------------------------------------
{
if (m_Settings.m_nReverbType >= NUM_REVERBTYPES) m_Settings.m_nReverbType = 0;
static PSNDMIX_REVERB_PROPERTIES spCurrentPreset = NULL;
@@ -305,17 +305,17 @@
gnReverbDecaySamples = rvb.ReverbDecaySamples;
// Room attenuation at high frequencies
- LONG nRoomLP;
+ int32 nRoomLP;
nRoomLP = OnePoleLowPassCoef(32768, mBToLinear(rvb.RoomHF), 5000, flOutputFrequency);
- g_RefDelay.nCoeffs[0] = (SHORT)nRoomLP;
- g_RefDelay.nCoeffs[1] = (SHORT)nRoomLP;
+ g_RefDelay.nCoeffs[0] = (int16)nRoomLP;
+ g_RefDelay.nCoeffs[1] = (int16)nRoomLP;
// Pre-Diffusion factor (for both reflections and late reverb)
- g_RefDelay.nPreDifCoeffs[0] = (SHORT)(rvb.PreDiffusion*2);
- g_RefDelay.nPreDifCoeffs[1] = (SHORT)(rvb.PreDiffusion*2);
+ g_RefDelay.nPreDifCoeffs[0] = (int16)(rvb.PreDiffusion*2);
+ g_RefDelay.nPreDifCoeffs[1] = (int16)(rvb.PreDiffusion*2);
// Setup individual reflections delay and gains
- for (UINT iRef=0; iRef<8; iRef++)
+ for (uint32 iRef=0; iRef<8; iRef++)
{
PSWRVBREFLECTION pRef = &g_RefDelay.Reflections[iRef];
pRef->DelayDest = rvb.Reflections[iRef].Delay;
@@ -328,7 +328,7 @@
g_LateReverb.nReverbDelay = rvb.ReverbDelay;
// Reflections Master Gain
- ULONG lReflectionsGain = 0;
+ uint32 lReflectionsGain = 0;
if (rvb.ReflectionsLevel > -9000)
{
lReflectionsGain = mBToLinear(32768, rvb.ReflectionsLevel);
@@ -336,7 +336,7 @@
g_RefDelay.lMasterGain = lReflectionsGain;
// Late reverb master gain
- ULONG lReverbGain = 0;
+ uint32 lReverbGain = 0;
if (rvb.ReverbLevel > -9000)
{
lReverbGain = mBToLinear(32768, rvb.ReverbLevel);
@@ -344,38 +344,38 @@
g_LateReverb.lMasterGain = lReverbGain;
// Late reverb diffusion
- ULONG nTailDiffusion = rvb.TankDiffusion;
+ uint32 nTailDiffusion = rvb.TankDiffusion;
if (nTailDiffusion > 0x7f00) nTailDiffusion = 0x7f00;
- g_LateReverb.nDifCoeffs[0] = (SHORT)nTailDiffusion;
- g_LateReverb.nDifCoeffs[1] = (SHORT)nTailDiffusion;
- g_LateReverb.nDifCoeffs[2] = (SHORT)nTailDiffusion;
- g_LateReverb.nDifCoeffs[3] = (SHORT)nTailDiffusion;
+ g_LateReverb.nDifCoeffs[0] = (int16)nTailDiffusion;
+ g_LateReverb.nDifCoeffs[1] = (int16)nTailDiffusion;
+ g_LateReverb.nDifCoeffs[2] = (int16)nTailDiffusion;
+ g_LateReverb.nDifCoeffs[3] = (int16)nTailDiffusion;
g_LateReverb.Dif2InGains[0] = 0x7000;
g_LateReverb.Dif2InGains[1] = 0x1000;
g_LateReverb.Dif2InGains[2] = 0x1000;
g_LateReverb.Dif2InGains[3] = 0x7000;
// Late reverb decay time
- LONG nReverbDecay = rvb.ReverbDecay;
+ int32 nReverbDecay = rvb.ReverbDecay;
if (nReverbDecay < 0) nReverbDecay = 0;
if (nReverbDecay > 0x7ff0) nReverbDecay = 0x7ff0;
- g_LateReverb.nDecayDC[0] = (SHORT)nReverbDecay;
+ g_LateReverb.nDecayDC[0] = (int16)nReverbDecay;
g_LateReverb.nDecayDC[1] = 0;
g_LateReverb.nDecayDC[2] = 0;
- g_LateReverb.nDecayDC[3] = (SHORT)nReverbDecay;
+ g_LateReverb.nDecayDC[3] = (int16)nReverbDecay;
// Late Reverb Decay HF
float fReverbDamping = rvb.flReverbDamping * rvb.flReverbDamping;
- LONG nDampingLowPass;
+ int32 nDampingLowPass;
nDampingLowPass = OnePoleLowPassCoef(32768, fReverbDamping, 5000, flOutputFrequency);
if (nDampingLowPass < 0x100) nDampingLowPass = 0x100;
if (nDampingLowPass >= 0x7f00) nDampingLowPass = 0x7f00;
- g_LateReverb.nDecayLP[0] = (SHORT)nDampingLowPass;
+ g_LateReverb.nDecayLP[0] = (int16)nDampingLowPass;
g_LateReverb.nDecayLP[1] = 0;
g_LateReverb.nDecayLP[2] = 0;
- g_LateReverb.nDecayLP[3] = (SHORT)nDampingLowPass;
+ g_LateReverb.nDecayLP[3] = (int16)nDampingLowPass;
}
if (bReset)
{
@@ -391,11 +391,11 @@
// [Reverb level 0(quiet)-100(loud)], [type = REVERBTYPE_XXXX]
-bool CReverb::SetReverbParameters(UINT nDepth, UINT nType)
-//--------------------------------------------------------
+bool CReverb::SetReverbParameters(uint32 nDepth, uint32 nType)
+//------------------------------------------------------------
{
if (nDepth > 100) nDepth = 100;
- UINT gain = (nDepth * 16) / 100;
+ uint32 gain = (nDepth * 16) / 100;
if (gain > 16) gain = 16;
if (gain < 1) gain = 1;
m_Settings.m_nReverbDepth = gain;
@@ -404,8 +404,8 @@
}
-int *CReverb::GetReverbSendBuffer(UINT nSamples)
-//----------------------------------------------
+int *CReverb::GetReverbSendBuffer(uint32 nSamples)
+//------------------------------------------------
{
if(!gnReverbSend)
{ // and we did not clear the buffer yet, do it now because we will get new data
@@ -417,8 +417,8 @@
// Reverb
-void CReverb::Process(int *MixSoundBuffer, UINT nSamples)
-//-------------------------------------------------------
+void CReverb::Process(int *MixSoundBuffer, uint32 nSamples)
+//---------------------------------------------------------
{
if(!(GetProcSupport() & PROCSUPPORT_MMX)) return;
if((!gnReverbSend) && (!gnReverbSamples))
@@ -430,23 +430,23 @@
StereoFill(MixReverbBuffer, nSamples, gnRvbROfsVol, gnRvbLOfsVol);
}
- UINT nIn, nOut;
+ uint32 nIn, nOut;
// Dynamically adjust reverb master gains
- LONG lMasterGain;
+ int32 lMasterGain;
lMasterGain = ((g_RefDelay.lMasterGain * m_Settings.m_nReverbDepth) >> 4);
if (lMasterGain > 0x7fff) lMasterGain = 0x7fff;
- g_RefDelay.ReflectionsGain[0] = (SHORT)lMasterGain;
- g_RefDelay.ReflectionsGain[1] = (SHORT)lMasterGain;
+ g_RefDelay.ReflectionsGain[0] = (int16)lMasterGain;
+ g_RefDelay.ReflectionsGain[1] = (int16)lMasterGain;
lMasterGain = ((g_LateReverb.lMasterGain * m_Settings.m_nReverbDepth) >> 4);
if (lMasterGain > 0x10000) lMasterGain = 0x10000;
- g_LateReverb.RvbOutGains[0] = (SHORT)((lMasterGain+0x7f) >> 3); // l->l
- g_LateReverb.RvbOutGains[1] = (SHORT)((lMasterGain+0xff) >> 4); // r->l
- g_LateReverb.RvbOutGains[2] = (SHORT)((lMasterGain+0xff) >> 4); // l->r
- g_LateReverb.RvbOutGains[3] = (SHORT)((lMasterGain+0x7f) >> 3); // r->r
+ g_LateReverb.RvbOutGains[0] = (int16)((lMasterGain+0x7f) >> 3); // l->l
+ g_LateReverb.RvbOutGains[1] = (int16)((lMasterGain+0xff) >> 4); // r->l
+ g_LateReverb.RvbOutGains[2] = (int16)((lMasterGain+0xff) >> 4); // l->r
+ g_LateReverb.RvbOutGains[3] = (int16)((lMasterGain+0x7f) >> 3); // r->r
// Process Dry/Wet Mix
- LONG lMaxRvbGain = (g_RefDelay.lMasterGain > g_LateReverb.lMasterGain) ? g_RefDelay.lMasterGain : g_LateReverb.lMasterGain;
+ int32 lMaxRvbGain = (g_RefDelay.lMasterGain > g_LateReverb.lMasterGain) ? g_RefDelay.lMasterGain : g_LateReverb.lMasterGain;
if (lMaxRvbGain > 32768) lMaxRvbGain = 32768;
- LONG lDryVol = (36 - m_Settings.m_nReverbDepth)>>1;
+ int32 lDryVol = (36 - m_Settings.m_nReverbDepth)>>1;
if (lDryVol < 8) lDryVol = 8;
if (lDryVol > 16) lDryVol = 16;
lDryVol = 16 - (((16-lDryVol) * lMaxRvbGain) >> 15);
@@ -459,15 +459,15 @@
if (nIn > 0) MMX_ProcessPreDelay(&g_RefDelay, MixReverbBuffer, nIn);
// Process Reverb Reflections and Late Reverberation
int *pRvbOut = MixReverbBuffer;
- UINT nRvbSamples = nOut, nCount = 0;
+ uint32 nRvbSamples = nOut, nCount = 0;
while (nRvbSamples > 0)
{
- UINT nPosRef = g_RefDelay.nRefOutPos & SNDMIX_REVERB_DELAY_MASK;
- UINT nPosRvb = (nPosRef - g_LateReverb.nReverbDelay) & SNDMIX_REVERB_DELAY_MASK;
- UINT nmax1 = (SNDMIX_REVERB_DELAY_MASK+1) - nPosRef;
- UINT nmax2 = (SNDMIX_REVERB_DELAY_MASK+1) - nPosRvb;
+ uint32 nPosRef = g_RefDelay.nRefOutPos & SNDMIX_REVERB_DELAY_MASK;
+ uint32 nPosRvb = (nPosRef - g_LateReverb.nReverbDelay) & SNDMIX_REVERB_DELAY_MASK;
+ uint32 nmax1 = (SNDMIX_REVERB_DELAY_MASK+1) - nPosRef;
+ uint32 nmax2 = (SNDMIX_REVERB_DELAY_MASK+1) - nPosRvb;
nmax1 = (nmax1 < nmax2) ? nmax1 : nmax2;
- UINT n = nRvbSamples;
+ uint32 n = nRvbSamples;
if (n > nmax1) n = nmax1;
if (n > 64) n = 64;
// Reflections output + late reverb delay
@@ -497,10 +497,10 @@
}
-VOID CReverb::X86_ReverbDryMix(int *pDry, int *pWet, int lDryVol, UINT nSamples)
-//------------------------------------------------------------------------------
+void CReverb::X86_ReverbDryMix(int *pDry, int *pWet, int lDryVol, uint32 nSamples)
+//--------------------------------------------------------------------------------
{
- for (UINT i=0; i<nSamples; i++)
+ for (uint32 i=0; i<nSamples; i++)
{
pDry[i*2] += (pWet[i*2]>>4) * lDryVol;
pDry[i*2+1] += (pWet[i*2+1]>>4) * lDryVol;
@@ -508,13 +508,13 @@
}
-UINT CReverb::X86_ReverbProcessPreFiltering2x(int *pWet, UINT nSamples)
-//---------------------------------------------------------------------
+uint32 CReverb::X86_ReverbProcessPreFiltering2x(int *pWet, uint32 nSamples)
+//-------------------------------------------------------------------------
{
- UINT nOutSamples = 0;
+ uint32 nOutSamples = 0;
int lowpass = g_RefDelay.nCoeffs[0];
int y1_l = g_nLastRvbIn_yl, y1_r = g_nLastRvbIn_yr;
- UINT n = nSamples;
+ uint32 n = nSamples;
if (g_bLastInPresent)
{
@@ -529,17 +529,17 @@
pWet+=2;
n--;
nOutSamples = 1;
- g_bLastInPresent = FALSE;
+ g_bLastInPresent = false;
}
if (n & 1)
{
n--;
g_nLastRvbIn_xl = pWet[n*2];
g_nLastRvbIn_xr = pWet[n*2+1];
- g_bLastInPresent = TRUE;
+ g_bLastInPresent = true;
}
n >>= 1;
- for (UINT i=0; i<n; i++)
+ for (uint32 i=0; i<n; i++)
{
int x1_l = pWet[i*4];
int x2_l = pWet[i*4+2];
@@ -558,13 +558,13 @@
}
-UINT CReverb::X86_ReverbProcessPreFiltering1x(int *pWet, UINT nSamples)
-//---------------------------------------------------------------------
+uint32 CReverb::X86_ReverbProcessPreFiltering1x(int *pWet, uint32 nSamples)
+//-------------------------------------------------------------------------
{
int lowpass = g_RefDelay.nCoeffs[0];
int y1_l = g_nLastRvbIn_yl, y1_r = g_nLastRvbIn_yr;
- for (UINT i=0; i<nSamples; i++)
+ for (uint32 i=0; i<nSamples; i++)
{
int x_l = pWet[i*2] >> 12;
int x_r = pWet[i*2+1] >> 12;
@@ -579,10 +579,10 @@
}
-VOID CReverb::X86_ReverbProcessPostFiltering2x(const int *pRvb, int *pDry, UINT nSamples)
-//---------------------------------------------------------------------------------------
+void CReverb::X86_ReverbProcessPostFiltering2x(const int *pRvb, int *pDry, uint32 nSamples)
+//-----------------------------------------------------------------------------------------
{
- UINT n0 = nSamples, n;
+ uint32 n0 = nSamples, n;
int x1_l = g_nLastRvbOut_xl, x1_r = g_nLastRvbOut_xr;
if (g_bLastOutPresent)
@@ -591,10 +591,10 @@
pDry[1] += x1_r;
pDry += 2;
n0--;
- g_bLastOutPresent = FALSE;
+ g_bLastOutPresent = false;
}
n = n0 >> 1;
- for (UINT i=0; i<n; i++)
+ for (uint32 i=0; i<n; i++)
{
int x_l = pRvb[i*2], x_r = pRvb[i*2+1];
pDry[i*4] += (x_l + x1_l)>>1;
@@ -611,7 +611,7 @@
pDry[n*4+1] += (x_r + x1_r)>>1;
x1_l = x_l;
x1_r = x_r;
- g_bLastOutPresent = TRUE;
+ g_bLastOutPresent = true;
}
g_nLastRvbOut_xl = x1_l;
g_nLastRvbOut_xr = x1_r;
@@ -621,8 +621,8 @@
#define DCR_AMOUNT 9
// Stereo Add + DC removal
-VOID CReverb::MMX_ReverbProcessPostFiltering1x(const int *pRvb, int *pDry, UINT nSamples)
-//---------------------------------------------------------------------------------------
+void CReverb::MMX_ReverbProcessPostFiltering1x(const int *pRvb, int *pDry, uint32 nSamples)
+//-----------------------------------------------------------------------------------------
{
__int64 nDCRRvb_X1 = gnDCRRvb_X1;
__int64 nDCRRvb_Y1 = gnDCRRvb_Y1;
@@ -659,8 +659,8 @@
}
-VOID CReverb::MMX_ReverbDCRemoval(int *pBuffer, UINT nSamples)
-//------------------------------------------------------------
+void CReverb::MMX_ReverbDCRemoval(int *pBuffer, uint32 nSamples)
+//--------------------------------------------------------------
{
__int64 nDCRRvb_X1 = gnDCRRvb_X1;
__int64 nDCRRvb_Y1 = gnDCRRvb_Y1;
@@ -702,8 +702,8 @@
// 3. Insert the result in the reflections delay buffer
//
-VOID CReverb::MMX_ProcessPreDelay(PSWRVBREFDELAY pPreDelay, const int *pIn, UINT nSamples)
-//----------------------------------------------------------------------------------------
+void CReverb::MMX_ProcessPreDelay(PSWRVBREFDELAY pPreDelay, const int *pIn, uint32 nSamples)
+//------------------------------------------------------------------------------------------
{
_asm {
mov eax, pPreDelay
@@ -776,8 +776,8 @@
} DUMMYREFARRAY, *PDUMMYREFARRAY;
-VOID CReverb::MMX_ProcessReflections(PSWRVBREFDELAY pPreDelay, short int *pRefOut, int *pOut, UINT nSamples)
-//----------------------------------------------------------------------------------------------------------
+void CReverb::MMX_ProcessReflections(PSWRVBREFDELAY pPreDelay, short int *pRefOut, int *pOut, uint32 nSamples)
+//------------------------------------------------------------------------------------------------------------
{
_asm {
// First stage
@@ -902,8 +902,8 @@
// Late reverberation (with SW reflections)
//
-VOID CReverb::MMX_ProcessLateReverb(PSWLATEREVERB pReverb, short int *pRefOut, int *pMixOut, UINT nSamples)
-//---------------------------------------------------------------------------------------------------------
+void CReverb::MMX_ProcessLateReverb(PSWLATEREVERB pReverb, short int *pRefOut, int *pMixOut, uint32 nSamples)
+//-----------------------------------------------------------------------------------------------------------
{
_asm {
push ebp
@@ -1012,12 +1012,12 @@
// (1-gcos(w)-sqrt(2g(1-cos w) - g2(1-(cos w)^2))) / (1-g)
-static LONG OnePoleLowPassCoef(LONG scale, float g, float F_c, float F_s)
-//----------------------------------------------------------------
+static int32 OnePoleLowPassCoef(int32 scale, float g, float F_c, float F_s)
+//-------------------------------------------------------------------------
{
float cosw; // cos(2*PI*Fc/Fs)
float scale_over_1mg; // scale / (1.0f - g);
- LONG result;
+ int32 result;
if (g > 0.999999f) return 0;
_asm {
@@ -1066,7 +1066,7 @@
}
-static LONG mBToLinear(LONG scale, LONG value_mB)
+static int32 mBToLinear(int32 scale, int32 value_mB)
{
// factor = log2(10)/(100*20)
const float _factor = 3.321928094887362304f / (100.0f * 20.0f);
@@ -1093,7 +1093,7 @@
}
-static float mBToLinear(LONG value_mB)
+static float mBToLinear(int32 value_mB)
{
// factor = log2(10)/(100*20)
const float _factor = 3.321928094887362304f / (100.0f * 20.0f);
Modified: trunk/OpenMPT/sounddsp/Reverb.h
===================================================================
--- trunk/OpenMPT/sounddsp/Reverb.h 2014-03-07 02:32:49 UTC (rev 3836)
+++ trunk/OpenMPT/sounddsp/Reverb.h 2014-03-07 11:43:17 UTC (rev 3837)
@@ -25,22 +25,22 @@
typedef struct _SWRVBREFLECTION
{
- ULONG Delay, DelayDest;
- SHORT Gains[4]; // g_ll, g_rl, g_lr, g_rr
+ uint32 Delay, DelayDest;
+ int16 Gains[4]; // g_ll, g_rl, g_lr, g_rr
} SWRVBREFLECTION, *PSWRVBREFLECTION;
typedef struct _SWRVBREFDELAY
{
- ULONG nDelayPos, nPreDifPos, nRefOutPos;
- LONG lMasterGain; // reflections linear master gain
- SHORT nCoeffs[2]; // room low-pass coefficients
- SHORT History[2]; // room low-pass history
- SHORT nPreDifCoeffs[2]; // prediffusion coefficients
- SHORT ReflectionsGain[2]; // master reflections gain
+ uint32 nDelayPos, nPreDifPos, nRefOutPos;
+ int32 lMasterGain; // reflections linear master gain
+ int16 nCoeffs[2]; // room low-pass coefficients
+ int16 History[2]; // room low-pass history
+ int16 nPreDifCoeffs[2]; // prediffusion coefficients
+ int16 ReflectionsGain[2]; // master reflections gain
SWRVBREFLECTION Reflections[8]; // Up to 8 SW Reflections
- short int RefDelayBuffer[(SNDMIX_REFLECTIONS_DELAY_MASK+1)*2]; // reflections delay buffer
- short int PreDifBuffer[(SNDMIX_PREDIFFUSION_DELAY_MASK+1)*2]; // pre-diffusion
- short int RefOut[(SNDMIX_REVERB_DELAY_MASK+1)*2]; // stereo output of reflections
+ int16 RefDelayBuffer[(SNDMIX_REFLECTIONS_DELAY_MASK+1)*2]; // reflections delay buffer
+ int16 PreDifBuffer[(SNDMIX_PREDIFFUSION_DELAY_MASK+1)*2]; // pre-diffusion
+ int16 RefOut[(SNDMIX_REVERB_DELAY_MASK+1)*2]; // stereo output of reflections
} SWRVBREFDELAY, *PSWRVBREFDELAY;
@@ -67,42 +67,42 @@
typedef struct _SWLATEREVERB
{
- ULONG nReverbDelay; // Reverb delay (in samples)
- ULONG nDelayPos; // Delay line position
- SHORT nDifCoeffs[4]; // Reverb diffusion
- SHORT nDecayDC[4]; // Reverb DC decay
- SHORT nDecayLP[4]; // Reverb HF decay
- SHORT LPHistory[4]; // Low-pass history
- SHORT Dif2InGains[4]; // 2nd diffuser input gains
- SHORT RvbOutGains[4]; // 4x2 Reverb output gains
- LONG lMasterGain; // late reverb master gain
- LONG lDummyAlign;
+ uint32 nReverbDelay; // Reverb delay (in samples)
+ uint32 nDelayPos; // Delay line position
+ int16 nDifCoeffs[4]; // Reverb diffusion
+ int16 nDecayDC[4]; // Reverb DC decay
+ int16 nDecayLP[4]; // Reverb HF decay
+ int16 LPHistory[4]; // Low-pass history
+ int16 Dif2InGains[4]; // 2nd diffuser input gains
+ int16 RvbOutGains[4]; // 4x2 Reverb output gains
+ int32 lMasterGain; // late reverb master gain
+ int32 lDummyAlign;
// Tank Delay lines
- short int Diffusion1[(RVBDLY_MASK+1)*2]; // {dif1_l, dif1_r}
- short int Diffusion2[(RVBDLY_MASK+1)*2]; // {dif2_l, dif2_r}
- short int Delay1[(RVBDLY_MASK+1)*2]; // {dly1_l, dly1_r}
- short int Delay2[(RVBDLY_MASK+1)*2]; // {dly2_l, dly2_r}
+ int16 Diffusion1[(RVBDLY_MASK+1)*2]; // {dif1_l, dif1_r}
+ int16 Diffusion2[(RVBDLY_MASK+1)*2]; // {dif2_l, dif2_r}
+ int16 Delay1[(RVBDLY_MASK+1)*2]; // {dly1_l, dly1_r}
+ int16 Delay2[(RVBDLY_MASK+1)*2]; // {dly2_l, dly2_r}
} SWLATEREVERB, *PSWLATEREVERB;
#define ENVIRONMENT_NUMREFLECTIONS 8
typedef struct _ENVIRONMENTREFLECTION
{
- SHORT GainLL, GainRR, GainLR, GainRL; // +/- 32K scale
- ULONG Delay; // In samples
+ int16 GainLL, GainRR, GainLR, GainRL; // +/- 32K scale
+ uint32 Delay; // In samples
} ENVIRONMENTREFLECTION, *PENVIRONMENTREFLECTION;
typedef struct _ENVIRONMENTREVERB
{
- LONG ReverbLevel; // Late reverb gain (mB)
- LONG ReflectionsLevel; // Master reflections gain (mB)
- LONG RoomHF; // Room gain HF (mB)
- ULONG ReverbDecay; // Reverb tank decay (0-7fff scale)
- LONG PreDiffusion; // Reverb pre-diffusion amount (+/- 32K scale)
- LONG TankDiffusion; // Reverb tank diffusion (+/- 32K scale)
- ULONG ReverbDelay; // Reverb delay (in samples)
- float flReverbDamping; // HF tank gain [0.0, 1.0]
- LONG ReverbDecaySamples;// Reverb decay time (in samples)
+ int32 ReverbLevel; // Late reverb gain (mB)
+ int32 ReflectionsLevel; // Master reflections gain (mB)
+ int32 RoomHF; // Room gain HF (mB)
+ uint32 ReverbDecay; // Reverb tank decay (0-7fff scale)
+ int32 PreDiffusion; // Reverb pre-diffusion amount (+/- 32K scale)
+ int32 TankDiffusion; // Reverb tank diffusion (+/- 32K scale)
+ uint32 ReverbDelay; // Reverb delay (in samples)
+ float flReverbDamping; // HF tank gain [0.0, 1.0]
+ int32 ReverbDecaySamples;// Reverb decay time (in samples)
ENVIRONMENTREFLECTION Reflections[ENVIRONMENT_NUMREFLECTIONS];
} ENVIRONMENTREVERB, *PENVIRONMENTREVERB;
@@ -112,8 +112,8 @@
//===================
{
public:
- UINT m_nReverbDepth;
- UINT m_nReverbType;
+ uint32 m_nReverbDepth;
+ uint32 m_nReverbType;
public:
CReverbSettings();
};
@@ -134,14 +134,14 @@
private:
- UINT gnReverbSend;
+ uint32 gnReverbSend;
- UINT gnReverbSamples;
- UINT gnReverbDecaySamples;
+ uint32 gnReverbSamples;
+ uint32 gnReverbDecaySamples;
// Internal reverb state
- BOOL g_bLastInPresent;
- BOOL g_bLastOutPresent;
+ bool g_bLastInPresent;
+ bool g_bLastOutPresent;
int g_nLastRvbIn_xl;
int g_nLastRvbIn_xr;
int g_nLastRvbIn_yl;
@@ -158,31 +158,31 @@
public:
CReverb();
public:
- void Initialize(BOOL bReset, DWORD MixingFreq);
+ void Initialize(bool bReset, uint32 MixingFreq);
// can be called multiple times or never (if no data is sent to reverb)
- int *GetReverbSendBuffer(UINT nSamples);
+ int *GetReverbSendBuffer(uint32 nSamples);
// call once after all data has been sent.
- void Process(int *MixSoundBuffer, UINT nSamples);
+ void Process(int *MixSoundBuffer, uint32 nSamples);
// [Reverb level 0(quiet)-100(loud)], [REVERBTYPE_XXXX]
- bool SetReverbParameters(UINT nDepth, UINT nType);
+ bool SetReverbParameters(uint32 nDepth, uint32 nType);
private:
void Shutdown();
// Pre/Post resampling and filtering
- UINT X86_ReverbProcessPreFiltering1x(int *pWet, UINT nSamples);
- UINT X86_ReverbProcessPreFiltering2x(int *pWet, UINT nSamples);
- VOID MMX_ReverbProcessPostFiltering1x(const int *pRvb, int *pDry, UINT nSamples);
- VOID X86_ReverbProcessPostFiltering2x(const int *pRvb, int *pDry, UINT nSamples);
- VOID MMX_ReverbDCRemoval(int *pBuffer, UINT nSamples);
- VOID X86_ReverbDryMix(int *pDry, int *pWet, int lDryVol, UINT nSamples);
+ uint32 X86_ReverbProcessPreFiltering1x(int *pWet, uint32 nSamples);
+ uint32 X86_ReverbProcessPreFiltering2x(int *pWet, uint32 nSamples);
+ void MMX_ReverbProcessPostFiltering1x(const int *pRvb, int *pDry, uint32 nSamples);
+ void X86_ReverbProcessPostFiltering2x(const int *pRvb, int *pDry, uint32 nSamples);
+ void MMX_ReverbDCRemoval(int *pBuffer, uint32 nSamples);
+ void X86_ReverbDryMix(int *pDry, int *pWet, int lDryVol, uint32 nSamples);
// Process pre-diffusion and pre-delay
- VOID MMX_ProcessPreDelay(PSWRVBREFDELAY pPreDelay, const int *pIn, UINT nSamples);
+ void MMX_ProcessPreDelay(PSWRVBREFDELAY pPreDelay, const int *pIn, uint32 nSamples);
// Process reflections
- VOID MMX_ProcessReflections(PSWRVBREFDELAY pPreDelay, short int *pRefOut, int *pMixOut, UINT nSamples);
+ void MMX_ProcessReflections(PSWRVBREFDELAY pPreDelay, short int *pRefOut, int *pMixOut, uint32 nSamples);
// Process Late Reverb (SW Reflections): stereo reflections output, 32-bit reverb output, SW reverb gain
- VOID MMX_ProcessLateReverb(PSWLATEREVERB pReverb, short int *pRefOut, int *pMixOut, UINT nSamples);
+ void MMX_ProcessLateReverb(PSWLATEREVERB pReverb, short int *pRefOut, int *pMixOut, uint32 nSamples);
};
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2014-03-07 02:32:49 UTC (rev 3836)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2014-03-07 11:43:17 UTC (rev 3837)
@@ -1033,7 +1033,7 @@
#endif
#endif
m_MixerSettings.DSPMask = DSPMask;
- InitPlayer(FALSE);
+ InitPlayer(false);
}
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2014-03-07 02:32:49 UTC (rev 3836)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2014-03-07 11:43:17 UTC (rev 3837)
@@ -730,7 +730,7 @@
// Mixer Config
void SetMixerSettings(const MixerSettings &mixersettings);
void SetResamplerSettings(const CResamplerSettings &resamplersettings);
- void InitPlayer(BOOL bReset=FALSE);
+ void InitPlayer(bool bReset=false);
void SetDspEffects(DWORD DSPMask);
DWORD GetSampleRate() { return m_MixerSettings.gdwMixingFreq; }
#ifndef NO_EQ
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2014-03-07 02:32:49 UTC (rev 3836)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2014-03-07 11:43:17 UTC (rev 3837)
@@ -79,7 +79,7 @@
(mixersettings.MixerFlags != m_MixerSettings.MixerFlags))
reset = true;
m_MixerSettings = mixersettings;
- InitPlayer(reset?TRUE:FALSE);
+ InitPlayer(reset);
}
@@ -91,7 +91,7 @@
}
-void CSoundFile::InitPlayer(BOOL bReset)
+void CSoundFile::InitPlayer(bool bReset)
//--------------------------------------
{
if(bReset)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2014-03-07 11:55:02
|
Revision: 3838
http://sourceforge.net/p/modplug/code/3838
Author: manxorist
Date: 2014-03-07 11:54:51 +0000 (Fri, 07 Mar 2014)
Log Message:
-----------
[Ref] Kill ULONG and SHORT win32 types in soundlib/ .
Modified Paths:
--------------
trunk/OpenMPT/common/typedefs.h
trunk/OpenMPT/soundlib/Dlsbank.cpp
trunk/OpenMPT/soundlib/Dlsbank.h
trunk/OpenMPT/soundlib/Load_med.cpp
trunk/OpenMPT/soundlib/SampleFormats.cpp
trunk/OpenMPT/soundlib/plugins/DmoToVst.cpp
Modified: trunk/OpenMPT/common/typedefs.h
===================================================================
--- trunk/OpenMPT/common/typedefs.h 2014-03-07 11:43:17 UTC (rev 3837)
+++ trunk/OpenMPT/common/typedefs.h 2014-03-07 11:54:51 UTC (rev 3838)
@@ -411,10 +411,8 @@
typedef std::uint16_t WORD;
typedef std::uint32_t DWORD;
typedef std::int8_t CHAR;
-typedef std::int16_t SHORT;
typedef std::int32_t LONG;
typedef std::uint32_t UINT;
-typedef std::uint32_t ULONG;
typedef BYTE * LPBYTE;
// for BOOL
Modified: trunk/OpenMPT/soundlib/Dlsbank.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Dlsbank.cpp 2014-03-07 11:43:17 UTC (rev 3837)
+++ trunk/OpenMPT/soundlib/Dlsbank.cpp 2014-03-07 11:54:51 UTC (rev 3838)
@@ -263,7 +263,7 @@
DWORD len;
DWORD cbSize;
WORD usUnityNote;
- SHORT sFineTune;
+ int16 sFineTune;
LONG lAttenuation;
DWORD fulOptions;
DWORD cSampleLoops;
@@ -1488,8 +1488,8 @@
// returns 12*128*(log2(freq/8363)+midiftune/100)
-static int DlsFreqToTranspose(ULONG freq, int nMidiFTune)
-//-------------------------------------------------------
+static int DlsFreqToTranspose(uint32 freq, int nMidiFTune)
+//--------------------------------------------------------
{
#ifdef ENABLE_X86
const float _f1_8363 = 1.0f / 8363.0f;
Modified: trunk/OpenMPT/soundlib/Dlsbank.h
===================================================================
--- trunk/OpenMPT/soundlib/Dlsbank.h 2014-03-07 11:43:17 UTC (rev 3837)
+++ trunk/OpenMPT/soundlib/Dlsbank.h 2014-03-07 11:54:51 UTC (rev 3838)
@@ -37,7 +37,7 @@
WORD uPercEnv;
WORD usVolume; // 0..256
WORD fuOptions; // flags + key group
- SHORT sFineTune; // 1..100
+ int16 sFineTune; // 1..100
BYTE uKeyMin;
BYTE uKeyMax;
BYTE uUnityNote;
Modified: trunk/OpenMPT/soundlib/Load_med.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_med.cpp 2014-03-07 11:43:17 UTC (rev 3837)
+++ trunk/OpenMPT/soundlib/Load_med.cpp 2014-03-07 11:54:51 UTC (rev 3838)
@@ -121,8 +121,8 @@
// 3: g723_24
BYTE commonflags; // flags common to all packtypes (none defined so far)
BYTE packerflags; // flags for the specific packtype
- ULONG leftchlen; // packed length of left channel in bytes
- ULONG rightchlen; // packed length of right channel in bytes (ONLY PRESENT IN STEREO SAMPLES)
+ uint32 leftchlen; // packed length of left channel in bytes
+ uint32 rightchlen; // packed length of right channel in bytes (ONLY PRESENT IN STEREO SAMPLES)
BYTE SampleData[1]; // Sample Data
} MMDSAMPLEHEADER;
@@ -228,7 +228,7 @@
STATIC_ASSERT(sizeof(MMD1BLOCKINFO) == 36);
-// A set of play sequences is stored as an array of ULONG files offsets
+// A set of play sequences is stored as an array of uint32 files offsets
// Each offset points to the play sequence itself.
typedef struct PACKED tagMMD2PLAYSEQ
{
Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp
===================================================================
--- trunk/OpenMPT/soundlib/SampleFormats.cpp 2014-03-07 11:43:17 UTC (rev 3837)
+++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2014-03-07 11:54:51 UTC (rev 3838)
@@ -549,14 +549,14 @@
DWORD loopend; // end loop position in the wavesample
WORD freq; // Rate at which the wavesample has been sampled
DWORD low_freq, high_freq, root_freq; // check note.h for the correspondance.
- SHORT finetune; // fine tune. -512 to +512, EXCLUDING 0 cause it is a multiplier. 512 is one octave off, and 1 is a neutral value
+ int16 finetune; // fine tune. -512 to +512, EXCLUDING 0 cause it is a multiplier. 512 is one octave off, and 1 is a neutral value
BYTE balance; // Balance: 0-15. 0=full left, 15 = full right
BYTE env_rate[6]; // attack rates
BYTE env_volume[6]; // attack volumes
BYTE tremolo_sweep, tremolo_rate, tremolo_depth;
BYTE vibrato_sweep, vibrato_rate, vibrato_depth;
BYTE flags;
- SHORT scale_frequency;
+ int16 scale_frequency;
WORD scale_factor;
BYTE reserved[36];
} GF1SAMPLEHEADER;
Modified: trunk/OpenMPT/soundlib/plugins/DmoToVst.cpp
===================================================================
--- trunk/OpenMPT/soundlib/plugins/DmoToVst.cpp 2014-03-07 11:43:17 UTC (rev 3837)
+++ trunk/OpenMPT/soundlib/plugins/DmoToVst.cpp 2014-03-07 11:54:51 UTC (rev 3838)
@@ -30,7 +30,7 @@
IMediaObjectInPlace *m_pMediaProcess;
IMediaParamInfo *m_pParamInfo;
IMediaParams *m_pMediaParams;
- ULONG m_nSamplesPerSec;
+ uint32 m_nSamplesPerSec;
AEffect m_Effect;
REFERENCE_TIME m_DataTime;
int16 *m_pMixBuffer;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2014-03-07 12:22:53
|
Revision: 3839
http://sourceforge.net/p/modplug/code/3839
Author: manxorist
Date: 2014-03-07 12:22:43 +0000 (Fri, 07 Mar 2014)
Log Message:
-----------
[Ref] Kill win32 TRUE, FALSE and BOOL and replace them with c++ true, false and bool in soundlib/ and sounddsp/ .
Modified Paths:
--------------
trunk/OpenMPT/common/typedefs.h
trunk/OpenMPT/mptrack/Mpdlgs.cpp
trunk/OpenMPT/sounddsp/AGC.cpp
trunk/OpenMPT/sounddsp/DSP.cpp
trunk/OpenMPT/sounddsp/DSP.h
trunk/OpenMPT/sounddsp/EQ.cpp
trunk/OpenMPT/sounddsp/EQ.h
trunk/OpenMPT/soundlib/Dlsbank.cpp
trunk/OpenMPT/soundlib/Dlsbank.h
trunk/OpenMPT/soundlib/Load_it.cpp
trunk/OpenMPT/soundlib/Load_itp.cpp
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/Sndfile.cpp
trunk/OpenMPT/soundlib/Sndfile.h
trunk/OpenMPT/soundlib/Sndmix.cpp
Modified: trunk/OpenMPT/common/typedefs.h
===================================================================
--- trunk/OpenMPT/common/typedefs.h 2014-03-07 11:54:51 UTC (rev 3838)
+++ trunk/OpenMPT/common/typedefs.h 2014-03-07 12:22:43 UTC (rev 3839)
@@ -406,7 +406,6 @@
// openmpt assumes these type have exact WIN32 semantics
-typedef std::int32_t BOOL;
typedef std::uint8_t BYTE;
typedef std::uint16_t WORD;
typedef std::uint32_t DWORD;
@@ -415,10 +414,6 @@
typedef std::uint32_t UINT;
typedef BYTE * LPBYTE;
-// for BOOL
-#define TRUE (1)
-#define FALSE (0)
-
#endif // !WIN32
Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2014-03-07 11:54:51 UTC (rev 3838)
+++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2014-03-07 12:22:43 UTC (rev 3839)
@@ -1456,7 +1456,7 @@
#ifndef NO_EQ
CriticalSection cs;
if(CMainFrame::GetMainFrame()->GetSoundFilePlaying())
- CMainFrame::GetMainFrame()->GetSoundFilePlaying()->SetEQGains( m_pEqPreset->Gains, MAX_EQ_BANDS, m_pEqPreset->Freqs, bReset);
+ CMainFrame::GetMainFrame()->GetSoundFilePlaying()->SetEQGains( m_pEqPreset->Gains, MAX_EQ_BANDS, m_pEqPreset->Freqs, bReset?true:false);
#endif
}
Modified: trunk/OpenMPT/sounddsp/AGC.cpp
===================================================================
--- trunk/OpenMPT/sounddsp/AGC.cpp 2014-03-07 11:54:51 UTC (rev 3838)
+++ trunk/OpenMPT/sounddsp/AGC.cpp 2014-03-07 12:22:43 UTC (rev 3839)
@@ -85,7 +85,7 @@
CAGC::CAGC()
//----------
{
- Initialize(TRUE, 44100);
+ Initialize(true, 44100);
}
Modified: trunk/OpenMPT/sounddsp/DSP.cpp
===================================================================
--- trunk/OpenMPT/sounddsp/DSP.cpp 2014-03-07 11:54:51 UTC (rev 3838)
+++ trunk/OpenMPT/sounddsp/DSP.cpp 2014-03-07 12:22:43 UTC (rev 3839)
@@ -31,10 +31,10 @@
// DSP Effects internal state
-extern VOID X86_InitMixBuffer(int *pBuffer, UINT nSamples);
+extern void X86_InitMixBuffer(int *pBuffer, UINT nSamples);
-static VOID X86_StereoDCRemoval(int *, UINT count, LONG *nDCRFlt_Y1l, LONG *nDCRFlt_X1l, LONG *nDCRFlt_Y1r, LONG *nDCRFlt_X1r);
-static VOID X86_MonoDCRemoval(int *, UINT count, LONG *nDCRFlt_Y1l, LONG *nDCRFlt_X1l);
+static void X86_StereoDCRemoval(int *, UINT count, LONG *nDCRFlt_Y1l, LONG *nDCRFlt_X1l, LONG *nDCRFlt_Y1r, LONG *nDCRFlt_X1r);
+static void X86_MonoDCRemoval(int *, UINT count, LONG *nDCRFlt_Y1l, LONG *nDCRFlt_X1l);
///////////////////////////////////////////////////////////////////////////////////
//
@@ -44,7 +44,7 @@
#define PI 3.14159265358979323f
static inline float Sgn(float x) { return (x >= 0) ? 1.0f : -1.0f; }
-static VOID ShelfEQ(LONG scale,
+static void ShelfEQ(LONG scale,
LONG *outA1, LONG *outB0, LONG *outB1,
LONG F_c, LONG F_s, float gainDC, float gainFT, float gainPI)
{
@@ -390,7 +390,7 @@
#define DCR_AMOUNT 9
-static VOID X86_StereoDCRemoval(int *pBuffer, UINT nSamples, LONG *nDCRFlt_Y1l, LONG *nDCRFlt_X1l, LONG *nDCRFlt_Y1r, LONG *nDCRFlt_X1r)
+static void X86_StereoDCRemoval(int *pBuffer, UINT nSamples, LONG *nDCRFlt_Y1l, LONG *nDCRFlt_X1l, LONG *nDCRFlt_Y1r, LONG *nDCRFlt_X1r)
{
int y1l=*nDCRFlt_Y1l, x1l=*nDCRFlt_X1l;
int y1r=*nDCRFlt_Y1r, x1r=*nDCRFlt_X1r;
@@ -436,7 +436,7 @@
}
-static VOID X86_MonoDCRemoval(int *pBuffer, UINT nSamples, LONG *nDCRFlt_Y1l, LONG *nDCRFlt_X1l)
+static void X86_MonoDCRemoval(int *pBuffer, UINT nSamples, LONG *nDCRFlt_Y1l, LONG *nDCRFlt_X1l)
{
int y1l=*nDCRFlt_Y1l, x1l=*nDCRFlt_X1l;
_asm {
@@ -476,7 +476,7 @@
// Clean DSP Effects interface
// [XBass level 0(quiet)-100(loud)], [cutoff in Hz 20-100]
-BOOL CDSP::SetXBassParameters(UINT nDepth, UINT nRange)
+bool CDSP::SetXBassParameters(UINT nDepth, UINT nRange)
//-----------------------------------------------------
{
if (nDepth > 100) nDepth = 100;
@@ -487,12 +487,12 @@
if (range > 5) range -= 5; else range = 0;
if (nRange > 16) nRange = 16;
m_Settings.m_nXBassRange = 21 - range; // filter average on 0.5-1.6ms
- return TRUE;
+ return true;
}
// [Surround level 0(quiet)-100(heavy)] [delay in ms, usually 5-50ms]
-BOOL CDSP::SetSurroundParameters(UINT nDepth, UINT nDelay)
+bool CDSP::SetSurroundParameters(UINT nDepth, UINT nDelay)
//--------------------------------------------------------
{
UINT gain = (nDepth * 16) / 100;
@@ -502,7 +502,7 @@
if (nDelay < 4) nDelay = 4;
if (nDelay > 50) nDelay = 50;
m_Settings.m_nProLogicDelay = nDelay;
- return TRUE;
+ return true;
}
Modified: trunk/OpenMPT/sounddsp/DSP.h
===================================================================
--- trunk/OpenMPT/sounddsp/DSP.h 2014-03-07 11:54:51 UTC (rev 3838)
+++ trunk/OpenMPT/sounddsp/DSP.h 2014-03-07 12:22:43 UTC (rev 3839)
@@ -80,9 +80,9 @@
public:
void SetSettings(const CDSPSettings &settings) { m_Settings = settings; }
// [XBass level 0(quiet)-100(loud)], [cutoff in Hz 10-100]
- BOOL SetXBassParameters(UINT nDepth, UINT nRange);
+ bool SetXBassParameters(UINT nDepth, UINT nRange);
// [Surround level 0(quiet)-100(heavy)] [delay in ms, usually 5-40ms]
- BOOL SetSurroundParameters(UINT nDepth, UINT nDelay);
+ bool SetSurroundParameters(UINT nDepth, UINT nDelay);
void Initialize(bool bReset, DWORD MixingFreq, DWORD DSPMask);
void Process(int * MixSoundBuffer, int * MixRearBuffer, int count, UINT nChannels, DWORD DSPMask);
private:
Modified: trunk/OpenMPT/sounddsp/EQ.cpp
===================================================================
--- trunk/OpenMPT/sounddsp/EQ.cpp 2014-03-07 11:54:51 UTC (rev 3838)
+++ trunk/OpenMPT/sounddsp/EQ.cpp 2014-03-07 12:22:43 UTC (rev 3839)
@@ -479,7 +479,7 @@
}
-void CEQ::SetEQGains(const UINT *pGains, UINT nGains, const UINT *pFreqs, BOOL bReset, DWORD MixingFreq)
+void CEQ::SetEQGains(const UINT *pGains, UINT nGains, const UINT *pFreqs, bool bReset, DWORD MixingFreq)
//------------------------------------------------------------------------------------------------------
{
for (UINT i=0; i<MAX_EQ_BANDS; i++)
@@ -509,7 +509,7 @@
gEQ[i+MAX_EQ_BANDS].bEnable = false;
}
}
- Initialize(bReset?true:false, MixingFreq);
+ Initialize(bReset, MixingFreq);
}
@@ -520,7 +520,7 @@
rear.Initialize(bReset, MixingFreq);
}
-void CQuadEQ::SetEQGains(const UINT *pGains, UINT nGains, const UINT *pFreqs, BOOL bReset, DWORD MixingFreq)
+void CQuadEQ::SetEQGains(const UINT *pGains, UINT nGains, const UINT *pFreqs, bool bReset, DWORD MixingFreq)
//----------------------------------------------------------------------------------------------------------
{
front.SetEQGains(pGains, nGains, pFreqs, bReset, MixingFreq);
Modified: trunk/OpenMPT/sounddsp/EQ.h
===================================================================
--- trunk/OpenMPT/sounddsp/EQ.h 2014-03-07 11:54:51 UTC (rev 3838)
+++ trunk/OpenMPT/sounddsp/EQ.h 2014-03-07 12:22:43 UTC (rev 3839)
@@ -42,7 +42,7 @@
void Initialize(bool bReset, DWORD MixingFreq);
void ProcessStereo(int *pbuffer, float *MixFloatBuffer, UINT nCount);
void ProcessMono(int *pbuffer, float *MixFloatBuffer, UINT nCount);
- void SetEQGains(const UINT *pGains, UINT nGains, const UINT *pFreqs, BOOL bReset, DWORD MixingFreq);
+ void SetEQGains(const UINT *pGains, UINT nGains, const UINT *pFreqs, bool bReset, DWORD MixingFreq);
};
@@ -57,6 +57,6 @@
public:
void Initialize(bool bReset, DWORD MixingFreq);
void Process(int *frontBuffer, int *rearBuffer, UINT nCount, UINT nChannels);
- void SetEQGains(const UINT *pGains, UINT nGains, const UINT *pFreqs, BOOL bReset, DWORD MixingFreq);
+ void SetEQGains(const UINT *pGains, UINT nGains, const UINT *pFreqs, bool bReset, DWORD MixingFreq);
};
Modified: trunk/OpenMPT/soundlib/Dlsbank.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Dlsbank.cpp 2014-03-07 11:54:51 UTC (rev 3838)
+++ trunk/OpenMPT/soundlib/Dlsbank.cpp 2014-03-07 12:22:43 UTC (rev 3839)
@@ -500,13 +500,13 @@
}
-BOOL CDLSBank::IsDLSBank(const mpt::PathString &filename)
+bool CDLSBank::IsDLSBank(const mpt::PathString &filename)
//-------------------------------------------------------
{
RIFFCHUNKID riff;
FILE *f;
- if(filename.empty()) return FALSE;
- if((f = mpt_fopen(filename, "rb")) == NULL) return FALSE;
+ if(filename.empty()) return false;
+ if((f = mpt_fopen(filename, "rb")) == NULL) return false;
MemsetZero(riff);
fread(&riff, sizeof(RIFFCHUNKID), 1, f);
// Check for embedded DLS sections
@@ -544,7 +544,7 @@
///////////////////////////////////////////////////////////////
// Find an instrument based on the given parameters
-DLSINSTRUMENT *CDLSBank::FindInstrument(BOOL bDrum, UINT nBank, DWORD dwProgram, DWORD dwKey, UINT *pInsNo)
+DLSINSTRUMENT *CDLSBank::FindInstrument(bool bDrum, UINT nBank, DWORD dwProgram, DWORD dwKey, UINT *pInsNo)
//---------------------------------------------------------------------------------------------------------
{
if ((!m_pInstruments) || (!m_nInstruments)) return NULL;
@@ -592,11 +592,11 @@
///////////////////////////////////////////////////////////////
// Update DLS instrument definition from an IFF chunk
-BOOL CDLSBank::UpdateInstrumentDefinition(DLSINSTRUMENT *pDlsIns, void *pvchunk, DWORD dwMaxLen)
+bool CDLSBank::UpdateInstrumentDefinition(DLSINSTRUMENT *pDlsIns, void *pvchunk, DWORD dwMaxLen)
//----------------------------------------------------------------------------------------------
{
IFFCHUNK *pchunk = (IFFCHUNK *)pvchunk;
- if ((!pchunk->len) || (pchunk->len+8 > dwMaxLen)) return FALSE;
+ if ((!pchunk->len) || (pchunk->len+8 > dwMaxLen)) return false;
if (pchunk->id == IFFID_LIST)
{
LISTCHUNK *plist = (LISTCHUNK *)pchunk;
@@ -799,18 +799,18 @@
#endif
}
}
- return TRUE;
+ return true;
}
///////////////////////////////////////////////////////////////
// Converts SF2 chunks to DLS
-BOOL CDLSBank::UpdateSF2PresetData(void *pvsf2, void *pvchunk, DWORD dwMaxLen)
+bool CDLSBank::UpdateSF2PresetData(void *pvsf2, void *pvchunk, DWORD dwMaxLen)
//----------------------------------------------------------------------------
{
SF2LOADERINFO *psf2 = (SF2LOADERINFO *)pvsf2;
IFFCHUNK *pchunk = (IFFCHUNK *)pvchunk;
- if ((!pchunk->len) || (pchunk->len+8 > dwMaxLen)) return FALSE;
+ if ((!pchunk->len) || (pchunk->len+8 > dwMaxLen)) return false;
switch(pchunk->id)
{
case IFFID_phdr:
@@ -951,18 +951,18 @@
}
#endif
}
- return TRUE;
+ return true;
}
// Convert all instruments to the DLS format
-BOOL CDLSBank::ConvertSF2ToDLS(void *pvsf2info)
+bool CDLSBank::ConvertSF2ToDLS(void *pvsf2info)
//---------------------------------------------
{
SF2LOADERINFO *psf2;
DLSINSTRUMENT *pDlsIns;
- if ((!m_pInstruments) || (!m_pSamplesEx)) return FALSE;
+ if ((!m_pInstruments) || (!m_pSamplesEx)) return false;
psf2 = (SF2LOADERINFO *)pvsf2info;
pDlsIns = m_pInstruments;
for (UINT nIns=0; nIns<m_nInstruments; nIns++, pDlsIns++)
@@ -1131,14 +1131,14 @@
//Log("\n");
}
}
- return TRUE;
+ return true;
}
///////////////////////////////////////////////////////////////
// Open: opens a DLS bank
-BOOL CDLSBank::Open(const mpt::PathString &filename)
+bool CDLSBank::Open(const mpt::PathString &filename)
//--------------------------------------------------
{
SF2LOADERINFO sf2info;
@@ -1147,17 +1147,17 @@
DWORD dwMemPos, dwMemLength;
UINT nInsDef;
- if(filename.empty()) return FALSE;
+ if(filename.empty()) return false;
m_szFileName = filename;
lpMemFile = NULL;
// Memory-Mapped file
CMappedFile MapFile;
- if (!MapFile.Open(filename)) return FALSE;
+ if (!MapFile.Open(filename)) return false;
dwMemLength = MapFile.GetLength();
if (dwMemLength >= 256) lpMemFile = (const BYTE *)MapFile.Lock();
if (!lpMemFile)
{
- return FALSE;
+ return false;
}
#ifdef DLSBANK_LOG
@@ -1202,7 +1202,7 @@
#ifdef DLSBANK_LOG
Log("Invalid DLS bank!\n");
#endif
- return FALSE;
+ return false;
}
memset(&sf2info, 0, sizeof(sf2info));
m_nType = (priff->id_DLS == IFFID_sfbk) ? SOUNDBANK_TYPE_SF2 : SOUNDBANK_TYPE_DLS;
@@ -1380,7 +1380,7 @@
#ifdef DLSBANK_LOG
Log("DLS bank closed\n");
#endif
- return TRUE;
+ return true;
}
////////////////////////////////////////////////////////////////////////////////////////
@@ -1404,22 +1404,22 @@
}
-BOOL CDLSBank::FreeWaveForm(LPBYTE p)
+bool CDLSBank::FreeWaveForm(LPBYTE p)
//-----------------------------------
{
if (p) free(p);
- return TRUE;
+ return true;
}
-BOOL CDLSBank::ExtractWaveForm(UINT nIns, UINT nRgn, LPBYTE *ppWave, DWORD *pLen)
+bool CDLSBank::ExtractWaveForm(UINT nIns, UINT nRgn, LPBYTE *ppWave, DWORD *pLen)
//-------------------------------------------------------------------------------
{
DLSINSTRUMENT *pDlsIns;
DWORD dwOffset;
UINT nWaveLink;
FILE *f;
- BOOL bOk = FALSE;
+ bool bOk = false;
if ((!ppWave) || (!pLen) || (!m_pInstruments) || (nIns >= m_nInstruments)
|| (!m_dwWavePoolOffset) || (!m_pWaveForms))
@@ -1427,7 +1427,7 @@
#ifdef DLSBANK_LOG
Log("ExtractWaveForm(%d) failed: m_nInstruments=%d m_dwWavePoolOffset=%d m_pWaveForms=0x%08X\n", nIns, m_nInstruments, m_dwWavePoolOffset, m_pWaveForms);
#endif
- return FALSE;
+ return false;
}
*ppWave = NULL;
*pLen = 0;
@@ -1437,7 +1437,7 @@
#ifdef DLSBANK_LOG
Log("invalid waveform region: nIns=%d nRgn=%d pSmp->nRegions=%d\n", nIns, nRgn, pSmp->nRegions);
#endif
- return FALSE;
+ return false;
}
nWaveLink = pDlsIns->Regions[nRgn].nWaveLink;
if (nWaveLink >= m_nWaveForms)
@@ -1445,10 +1445,10 @@
#ifdef DLSBANK_LOG
Log("Invalid wavelink id: nWaveLink=%d nWaveForms=%d\n", nWaveLink, m_nWaveForms);
#endif
- return FALSE;
+ return false;
}
dwOffset = m_pWaveForms[nWaveLink] + m_dwWavePoolOffset;
- if((f = mpt_fopen(m_szFileName, "rb")) == NULL) return FALSE;
+ if((f = mpt_fopen(m_szFileName, "rb")) == NULL) return false;
if (fseek(f, dwOffset, SEEK_SET) == 0)
{
if (m_nType & SOUNDBANK_TYPE_SF2)
@@ -1460,7 +1460,7 @@
*pLen = m_pSamplesEx[nWaveLink].dwLen;
*ppWave = (LPBYTE)calloc(1, *pLen + 8);
fread((*ppWave), 1, *pLen, f);
- bOk = TRUE;
+ bOk = true;
}
}
} else
@@ -1476,7 +1476,7 @@
{
memcpy((*ppWave), &chunk, 12);
fread((*ppWave)+12, 1, *pLen-12, f);
- bOk = TRUE;
+ bOk = true;
}
}
}
@@ -1517,20 +1517,20 @@
}
-BOOL CDLSBank::ExtractSample(CSoundFile &sndFile, SAMPLEINDEX nSample, UINT nIns, UINT nRgn, int transpose)
+bool CDLSBank::ExtractSample(CSoundFile &sndFile, SAMPLEINDEX nSample, UINT nIns, UINT nRgn, int transpose)
//---------------------------------------------------------------------------------------------------------
{
DLSINSTRUMENT *pDlsIns;
LPBYTE pWaveForm = NULL;
DWORD dwLen = 0;
- BOOL bOk, bWaveForm;
+ bool bOk, bWaveForm;
- if ((!m_pInstruments) || (nIns >= m_nInstruments)) return FALSE;
+ if ((!m_pInstruments) || (nIns >= m_nInstruments)) return false;
pDlsIns = &m_pInstruments[nIns];
- if (nRgn >= pDlsIns->nRegions) return FALSE;
- if (!ExtractWaveForm(nIns, nRgn, &pWaveForm, &dwLen)) return FALSE;
- if ((!pWaveForm) || (dwLen < 16)) return FALSE;
- bOk = FALSE;
+ if (nRgn >= pDlsIns->nRegions) return false;
+ if (!ExtractWaveForm(nIns, nRgn, &pWaveForm, &dwLen)) return false;
+ if ((!pWaveForm) || (dwLen < 16)) return false;
+ bOk = false;
FileReader wsmpChunk;
if (m_nType & SOUNDBANK_TYPE_SF2)
@@ -1561,7 +1561,7 @@
SampleIO::signedPCM)
.ReadSample(sample, chunk);
}
- bWaveForm = (sample.pSample) ? TRUE : FALSE;
+ bWaveForm = (sample.pSample) ? true : false;
} else
{
FileReader file(pWaveForm, dwLen);
@@ -1654,14 +1654,14 @@
if (pDlsIns->szName[0]) memcpy(sndFile.m_szNames[nSample], pDlsIns->szName, MAX_SAMPLENAME - 1);
sample.Convert(MOD_TYPE_IT, sndFile.GetType());
sample.PrecomputeLoops(sndFile, false);
- bOk = TRUE;
+ bOk = true;
}
FreeWaveForm(pWaveForm);
return bOk;
}
-BOOL CDLSBank::ExtractInstrument(CSoundFile &sndFile, INSTRUMENTINDEX nInstr, UINT nIns, UINT nDrumRgn)
+bool CDLSBank::ExtractInstrument(CSoundFile &sndFile, INSTRUMENTINDEX nInstr, UINT nIns, UINT nDrumRgn)
//-----------------------------------------------------------------------------------------------------
{
BYTE RgnToSmp[DLSMAXREGIONS];
@@ -1670,17 +1670,17 @@
UINT nRgnMin, nRgnMax, nEnv;
SAMPLEINDEX nSample;
- if ((!m_pInstruments) || (nIns >= m_nInstruments)) return FALSE;
+ if ((!m_pInstruments) || (nIns >= m_nInstruments)) return false;
pDlsIns = &m_pInstruments[nIns];
if (pDlsIns->ulBank & F_INSTRUMENT_DRUMS)
{
- if (nDrumRgn >= pDlsIns->nRegions) return FALSE;
+ if (nDrumRgn >= pDlsIns->nRegions) return false;
nRgnMin = nDrumRgn;
nRgnMax = nDrumRgn+1;
nEnv = pDlsIns->Regions[nDrumRgn].uPercEnv;
} else
{
- if (!pDlsIns->nRegions) return FALSE;
+ if (!pDlsIns->nRegions) return false;
nRgnMin = 0;
nRgnMax = pDlsIns->nRegions;
nEnv = pDlsIns->nMelodicEnv;
@@ -1703,7 +1703,7 @@
pIns = new (std::nothrow) ModInstrument();
if(pIns == nullptr)
{
- return FALSE;
+ return false;
}
if (sndFile.Instruments[nInstr])
@@ -1764,12 +1764,12 @@
// Extract Samples
for (UINT nRgn=nRgnMin; nRgn<nRgnMax; nRgn++)
{
- BOOL bDupRgn;
+ bool bDupRgn;
UINT nSmp;
DLSREGION *pRgn = &pDlsIns->Regions[nRgn];
// Elimitate Duplicate Regions
nSmp = 0;
- bDupRgn = FALSE;
+ bDupRgn = false;
for (UINT iDup=nRgnMin; iDup<nRgn; iDup++)
{
DLSREGION *pRgn2 = &pDlsIns->Regions[iDup];
@@ -1779,7 +1779,7 @@
|| ((pRgn2->uKeyMin == pRgn->uKeyMin)
&& (pRgn2->uKeyMax == pRgn->uKeyMax)))
{
- bDupRgn = TRUE;
+ bDupRgn = true;
nSmp = RgnToSmp[iDup];
break;
}
@@ -1951,7 +1951,7 @@
pIns->VolEnv.nNodes = 4;
}
}
- return TRUE;
+ return true;
}
Modified: trunk/OpenMPT/soundlib/Dlsbank.h
===================================================================
--- trunk/OpenMPT/soundlib/Dlsbank.h 2014-03-07 11:54:51 UTC (rev 3838)
+++ trunk/OpenMPT/soundlib/Dlsbank.h 2014-03-07 12:22:43 UTC (rev 3839)
@@ -129,12 +129,12 @@
CDLSBank();
virtual ~CDLSBank();
void Destroy();
- static BOOL IsDLSBank(const mpt::PathString &filename);
+ static bool IsDLSBank(const mpt::PathString &filename);
static DWORD MakeMelodicCode(UINT bank, UINT instr) { return ((bank << 16) | (instr));}
static DWORD MakeDrumCode(UINT rgn, UINT instr) { return (0x80000000 | (rgn << 16) | (instr));}
public:
- BOOL Open(const mpt::PathString &filename);
+ bool Open(const mpt::PathString &filename);
mpt::PathString GetFileName() const { return m_szFileName; }
UINT GetBankType() const { return m_nType; }
UINT GetBankInfo(SOUNDBANKINFO *pBankInfo=NULL) const { if (pBankInfo) *pBankInfo = m_BankInfo; return m_nType; }
@@ -143,19 +143,19 @@
UINT GetNumInstruments() const { return m_nInstruments; }
UINT GetNumSamples() const { return m_nWaveForms; }
DLSINSTRUMENT *GetInstrument(UINT iIns) { return (m_pInstruments) ? &m_pInstruments[iIns] : NULL; }
- DLSINSTRUMENT *FindInstrument(BOOL bDrum, UINT nBank=0xFF, DWORD dwProgram=0xFF, DWORD dwKey=0xFF, UINT *pInsNo=NULL);
+ DLSINSTRUMENT *FindInstrument(bool bDrum, UINT nBank=0xFF, DWORD dwProgram=0xFF, DWORD dwKey=0xFF, UINT *pInsNo=NULL);
UINT GetRegionFromKey(UINT nIns, UINT nKey);
- BOOL FreeWaveForm(LPBYTE p);
- BOOL ExtractWaveForm(UINT nIns, UINT nRgn, LPBYTE *ppWave, DWORD *pLen);
- BOOL ExtractSample(CSoundFile &sndFile, SAMPLEINDEX nSample, UINT nIns, UINT nRgn, int transpose=0);
- BOOL ExtractInstrument(CSoundFile &sndFile, INSTRUMENTINDEX nInstr, UINT nIns, UINT nDrumRgn);
+ bool FreeWaveForm(LPBYTE p);
+ bool ExtractWaveForm(UINT nIns, UINT nRgn, LPBYTE *ppWave, DWORD *pLen);
+ bool ExtractSample(CSoundFile &sndFile, SAMPLEINDEX nSample, UINT nIns, UINT nRgn, int transpose=0);
+ bool ExtractInstrument(CSoundFile &sndFile, INSTRUMENTINDEX nInstr, UINT nIns, UINT nDrumRgn);
const CHAR *GetRegionName(UINT nIns, UINT nRgn) const;
// Internal Loader Functions
protected:
- BOOL UpdateInstrumentDefinition(DLSINSTRUMENT *pDlsIns, void *pchunk, DWORD dwMaxLen);
- BOOL UpdateSF2PresetData(void *psf2info, void *pchunk, DWORD dwMaxLen);
- BOOL ConvertSF2ToDLS(void *psf2info);
+ bool UpdateInstrumentDefinition(DLSINSTRUMENT *pDlsIns, void *pchunk, DWORD dwMaxLen);
+ bool UpdateSF2PresetData(void *psf2info, void *pchunk, DWORD dwMaxLen);
+ bool ConvertSF2ToDLS(void *psf2info);
public:
// DLS Unit conversion
Modified: trunk/OpenMPT/soundlib/Load_it.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_it.cpp 2014-03-07 11:54:51 UTC (rev 3838)
+++ trunk/OpenMPT/soundlib/Load_it.cpp 2014-03-07 12:22:43 UTC (rev 3839)
@@ -1251,7 +1251,7 @@
// Mix Plugins. Just calculate the size of this extra block for now.
if(!compatibilityExport)
{
- dwExtra += SaveMixPlugins(NULL, TRUE);
+ dwExtra += SaveMixPlugins(NULL, true);
}
// Edit History. Just calculate the size of this extra block for now.
@@ -1321,7 +1321,7 @@
// Writing mix plugins info
if(!compatibilityExport)
{
- SaveMixPlugins(f, FALSE);
+ SaveMixPlugins(f, false);
}
// Writing song message
@@ -1687,7 +1687,7 @@
#ifndef MODPLUG_NO_FILESAVE
-UINT CSoundFile::SaveMixPlugins(FILE *f, BOOL bUpdate)
+UINT CSoundFile::SaveMixPlugins(FILE *f, bool bUpdate)
//----------------------------------------------------
{
uint32 chinfo[MAX_BASECHANNELS];
Modified: trunk/OpenMPT/soundlib/Load_itp.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_itp.cpp 2014-03-07 11:54:51 UTC (rev 3838)
+++ trunk/OpenMPT/soundlib/Load_itp.cpp 2014-03-07 12:22:43 UTC (rev 3839)
@@ -397,11 +397,11 @@
// Song mix plugins
// mix plugins data length
- id = SaveMixPlugins(NULL, TRUE);
+ id = SaveMixPlugins(NULL, true);
fwrite(&id, 1, sizeof(id), f);
// mix plugins data
- SaveMixPlugins(f, FALSE);
+ SaveMixPlugins(f, false);
// Song midi config
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-03-07 11:54:51 UTC (rev 3838)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-03-07 12:22:43 UTC (rev 3839)
@@ -1765,7 +1765,7 @@
}
-BOOL CSoundFile::ProcessEffects()
+bool CSoundFile::ProcessEffects()
//-------------------------------
{
ModChannel *pChn = m_PlayState.Chn;
@@ -1776,7 +1776,7 @@
// ScreamTracker 2 only updates effects on every 16th tick.
if((m_PlayState.m_nTickCount & 0x0F) != 0 && GetType() == MOD_TYPE_STM)
{
- return TRUE;
+ return true;
}
// -> CODE#0010
@@ -2889,7 +2889,7 @@
}
}
- return TRUE;
+ return true;
}
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2014-03-07 11:54:51 UTC (rev 3838)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2014-03-07 12:22:43 UTC (rev 3839)
@@ -704,12 +704,12 @@
#ifdef MODPLUG_TRACKER
-BOOL CSoundFile::Create(FileReader file, ModLoadingFlags loadFlags, CModDoc *pModDoc)
+bool CSoundFile::Create(FileReader file, ModLoadingFlags loadFlags, CModDoc *pModDoc)
//-----------------------------------------------------------------------------------
{
m_pModDoc = pModDoc;
#else
-BOOL CSoundFile::Create(FileReader file, ModLoadingFlags loadFlags)
+bool CSoundFile::Create(FileReader file, ModLoadingFlags loadFlags)
//-----------------------------------------------------------------
{
#endif // MODPLUG_TRACKER
@@ -973,14 +973,14 @@
const ORDERINDEX nMinLength = std::min(CacheSize, GetModSpecifications().ordersMax);
if (Order.GetLength() < nMinLength)
Order.resize(nMinLength);
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
-BOOL CSoundFile::Destroy()
+bool CSoundFile::Destroy()
//------------------------
{
for(CHANNELINDEX i = 0; i < MAX_CHANNELS; i++)
@@ -1016,7 +1016,7 @@
m_nType = MOD_TYPE_NONE;
m_ContainerType = MOD_CONTAINERTYPE_NONE;
m_nChannels = m_nSamples = m_nInstruments = 0;
- return TRUE;
+ return true;
}
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2014-03-07 11:54:51 UTC (rev 3838)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2014-03-07 12:22:43 UTC (rev 3839)
@@ -546,12 +546,12 @@
// Get parent CModDoc. Can be nullptr if previewing from tree view, and is always nullptr if we're not actually compiling OpenMPT.
CModDoc *GetpModDoc() const { return m_pModDoc; }
- BOOL Create(FileReader file, ModLoadingFlags loadFlags = loadCompleteModule, CModDoc *pModDoc = nullptr);
+ bool Create(FileReader file, ModLoadingFlags loadFlags = loadCompleteModule, CModDoc *pModDoc = nullptr);
#else
- BOOL Create(FileReader file, ModLoadingFlags loadFlags);
+ bool Create(FileReader file, ModLoadingFlags loadFlags);
#endif // MODPLUG_TRACKER
- BOOL Destroy();
+ bool Destroy();
MODTYPE GetType() const { return m_nType; }
bool TypeIsIT_MPT() const { return (m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT)) != 0; }
bool TypeIsIT_MPT_XM() const { return (m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT | MOD_TYPE_XM)) != 0; }
@@ -678,7 +678,7 @@
bool SaveMod(const mpt::PathString &filename) const;
bool SaveIT(const mpt::PathString &filename, bool compatibilityExport = false);
bool SaveITProject(const mpt::PathString &filename); // -> CODE#0023 -> DESC="IT project files (.itp)" -! NEW_FEATURE#0023
- UINT SaveMixPlugins(FILE *f=NULL, BOOL bUpdate=TRUE);
+ UINT SaveMixPlugins(FILE *f=NULL, bool bUpdate=true);
void WriteInstrumentPropertyForAllInstruments(uint32 code, int16 size, FILE* f, UINT nInstruments) const;
void SaveExtendedInstrumentProperties(UINT nInstruments, FILE* f) const;
void SaveExtendedSongProperties(FILE* f) const;
@@ -715,7 +715,7 @@
private:
void CreateStereoMix(int count);
public:
- BOOL FadeSong(UINT msec);
+ bool FadeSong(UINT msec);
private:
void ProcessDSP(std::size_t countChunk);
void ProcessPlugins(UINT nCount);
@@ -734,12 +734,12 @@
void SetDspEffects(DWORD DSPMask);
DWORD GetSampleRate() { return m_MixerSettings.gdwMixingFreq; }
#ifndef NO_EQ
- void SetEQGains(const UINT *pGains, UINT nBands, const UINT *pFreqs=NULL, BOOL bReset=FALSE) { m_EQ.SetEQGains(pGains, nBands, pFreqs, bReset, m_MixerSettings.gdwMixingFreq); } // 0=-12dB, 32=+12dB
+ void SetEQGains(const UINT *pGains, UINT nBands, const UINT *pFreqs=NULL, bool bReset=false) { m_EQ.SetEQGains(pGains, nBands, pFreqs, bReset, m_MixerSettings.gdwMixingFreq); } // 0=-12dB, 32=+12dB
#endif // NO_EQ
public:
- BOOL ReadNote();
- BOOL ProcessRow();
- BOOL ProcessEffects();
+ bool ReadNote();
+ bool ProcessRow();
+ bool ProcessEffects();
CHANNELINDEX GetNNAChannel(CHANNELINDEX nChn) const;
void CheckNNA(CHANNELINDEX nChn, UINT instr, int note, bool forceCut);
void NoteChange(ModChannel *pChn, int note, bool bPorta = false, bool bResetEnv = true, bool bManual = false) const;
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2014-03-07 11:54:51 UTC (rev 3838)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2014-03-07 12:22:43 UTC (rev 3839)
@@ -116,11 +116,11 @@
}
-BOOL CSoundFile::FadeSong(UINT msec)
+bool CSoundFile::FadeSong(UINT msec)
//----------------------------------
{
samplecount_t nsamples = Util::muldiv(msec, m_MixerSettings.gdwMixingFreq, 1000);
- if (nsamples <= 0) return FALSE;
+ if (nsamples <= 0) return false;
if (nsamples > 0x100000) nsamples = 0x100000;
m_PlayState.m_nBufferCount = nsamples;
int32 nRampLength = static_cast<int32>(m_PlayState.m_nBufferCount);
@@ -137,7 +137,7 @@
pramp->nRampLength = nRampLength;
pramp->dwFlags.set(CHN_VOLUMERAMP);
}
- return TRUE;
+ return true;
}
@@ -314,7 +314,7 @@
/////////////////////////////////////////////////////////////////////////////
// Handles navigation/effects
-BOOL CSoundFile::ProcessRow()
+bool CSoundFile::ProcessRow()
//---------------------------
{
while(++m_PlayState.m_nTickCount >= GetNumTicksOnCurrentRow())
@@ -350,7 +350,7 @@
if ((m_PlayState.m_nPattern == Order.GetInvalidPatIndex()) || (m_PlayState.m_nCurrentOrder >= Order.size()))
{
- //if (!m_nRepeatCount) return FALSE;
+ //if (!m_nRepeatCount) return false;
ORDERINDEX nRestartPosOverride = m_nRestartPos;
if(!m_nRestartPos && m_PlayState.m_nCurrentOrder <= Order.size() && m_PlayState.m_nCurrentOrder > 0)
@@ -427,7 +427,7 @@
|| !Patterns.IsValidPat(Order[m_PlayState.m_nCurrentOrder]))
{
visitedSongRows.Initialize(true);
- return FALSE;
+ return false;
}
} else
@@ -446,12 +446,12 @@
m_PlayState.m_nNextOrder = m_PlayState.m_nCurrentOrder;
#ifdef MODPLUG_TRACKER
- if ((m_nMaxOrderPosition) && (m_PlayState.m_nCurrentOrder >= m_nMaxOrderPosition)) return FALSE;
+ if ((m_nMaxOrderPosition) && (m_PlayState.m_nCurrentOrder >= m_nMaxOrderPosition)) return false;
#endif // MODPLUG_TRACKER
}
// Weird stuff?
- if (!Patterns.IsValidPat(m_PlayState.m_nPattern)) return FALSE;
+ if (!Patterns.IsValidPat(m_PlayState.m_nPattern)) return false;
// Should never happen
if (m_PlayState.m_nRow >= Patterns[m_PlayState.m_nPattern].GetNumRows()) m_PlayState.m_nRow = 0;
@@ -486,7 +486,7 @@
{
// This is really the song's end!
visitedSongRows.Initialize(true);
- return FALSE;
+ return false;
} else
{
// Ok, this is really dirty, but we have to update the visited rows vector...
@@ -1647,7 +1647,7 @@
////////////////////////////////////////////////////////////////////////////////////////////
// Handles envelopes & mixer setup
-BOOL CSoundFile::ReadNote()
+bool CSoundFile::ReadNote()
//-------------------------
{
#ifdef MODPLUG_TRACKER
@@ -1661,10 +1661,10 @@
#endif // MODPLUG_TRACKER
{
if(!ProcessRow())
- return FALSE;
+ return false;
}
////////////////////////////////////////////////////////////////////////////////////
- if (!m_PlayState.m_nMusicTempo) return FALSE;
+ if (!m_PlayState.m_nMusicTempo) return false;
m_PlayState.m_nSamplesPerTick = GetTickDuration(m_PlayState.m_nMusicTempo, m_PlayState.m_nMusicSpeed, m_PlayState.m_nCurrentRowsPerBeat);
m_PlayState.m_nBufferCount = m_PlayState.m_nSamplesPerTick;
@@ -2084,7 +2084,7 @@
}
}
}
- return TRUE;
+ return true;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2014-03-07 13:08:55
|
Revision: 3842
http://sourceforge.net/p/modplug/code/3842
Author: manxorist
Date: 2014-03-07 13:08:48 +0000 (Fri, 07 Mar 2014)
Log Message:
-----------
[Ref] Remove CHAR in soundlib.
Modified Paths:
--------------
trunk/OpenMPT/common/typedefs.h
trunk/OpenMPT/soundlib/Dlsbank.cpp
trunk/OpenMPT/soundlib/Dlsbank.h
trunk/OpenMPT/soundlib/Load_med.cpp
trunk/OpenMPT/soundlib/Load_mt2.cpp
trunk/OpenMPT/soundlib/SampleFormats.cpp
trunk/OpenMPT/soundlib/Sndfile.cpp
Modified: trunk/OpenMPT/common/typedefs.h
===================================================================
--- trunk/OpenMPT/common/typedefs.h 2014-03-07 12:46:56 UTC (rev 3841)
+++ trunk/OpenMPT/common/typedefs.h 2014-03-07 13:08:48 UTC (rev 3842)
@@ -409,7 +409,6 @@
typedef std::uint8_t BYTE;
typedef std::uint16_t WORD;
typedef std::uint32_t DWORD;
-typedef std::int8_t CHAR;
typedef std::int32_t LONG;
typedef std::uint32_t UINT;
typedef BYTE * LPBYTE;
Modified: trunk/OpenMPT/soundlib/Dlsbank.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Dlsbank.cpp 2014-03-07 12:46:56 UTC (rev 3841)
+++ trunk/OpenMPT/soundlib/Dlsbank.cpp 2014-03-07 13:08:48 UTC (rev 3842)
@@ -319,7 +319,7 @@
typedef struct PACKED SFPRESETHEADER
{
- CHAR achPresetName[20];
+ char achPresetName[20];
WORD wPreset;
WORD wBank;
WORD wPresetBagNdx;
@@ -348,7 +348,7 @@
typedef struct PACKED SFINST
{
- CHAR achInstName[20];
+ char achInstName[20];
WORD wInstBagNdx;
} SFINST;
@@ -372,14 +372,14 @@
typedef struct PACKED SFSAMPLE
{
- CHAR achSampleName[20];
+ char achSampleName[20];
DWORD dwStart;
DWORD dwEnd;
DWORD dwStartloop;
DWORD dwEndloop;
DWORD dwSampleRate;
BYTE byOriginalPitch;
- CHAR chPitchCorrection;
+ char chPitchCorrection;
WORD wSampleLink;
WORD sfSampleType;
} SFSAMPLE;
@@ -791,7 +791,7 @@
#if 0
default:
{
- CHAR sid[5];
+ char sid[5];
memcpy(sid, &pchunk->id, 4);
sid[4] = 0;
Log(" \"%s\": %d bytes\n", (DWORD)sid, pchunk->len);
@@ -944,7 +944,7 @@
#ifdef DLSINSTR_LOG
default:
{
- CHAR sdbg[5];
+ char sdbg[5];
memcpy(sdbg, &pchunk->id, 4);
sdbg[4] = 0;
Log("Unsupported SF2 chunk: %s (%d bytes)\n", sdbg, pchunk->len);
@@ -1339,7 +1339,7 @@
#ifdef DLSBANK_LOG
default:
{
- CHAR sdbg[5];
+ char sdbg[5];
memcpy(sdbg, &pchunk->id, 4);
sdbg[4] = 0;
Log("Unsupported chunk: %s (%d bytes)\n", sdbg, pchunk->len);
@@ -1631,8 +1631,8 @@
int nBaseTune = DlsFreqToTranspose(
sample.nC5Speed,
sFineTune+(60 + transpose - usUnityNote)*100);
- sample.nFineTune = (CHAR)(nBaseTune & 0x7F);
- sample.RelativeTone = (CHAR)(nBaseTune >> 7);
+ sample.nFineTune = (int8)(nBaseTune & 0x7F);
+ sample.RelativeTone = (int8)(nBaseTune >> 7);
sample.TransposeToFrequency();
if (lVolume > 256) lVolume = 256;
if (lVolume < 16) lVolume = 16;
@@ -1713,7 +1713,7 @@
// Initializes Instrument
if (pDlsIns->ulBank & F_INSTRUMENT_DRUMS)
{
- CHAR s[64] = "";
+ char s[64] = "";
UINT key = pDlsIns->Regions[nDrumRgn].uKeyMin;
if ((key >= 24) && (key <= 84)) lstrcpy(s, szMidiPercussionNames[key-24]);
if (pDlsIns->szName[0])
@@ -1955,7 +1955,7 @@
}
-const CHAR *CDLSBank::GetRegionName(UINT nIns, UINT nRgn) const
+const char *CDLSBank::GetRegionName(UINT nIns, UINT nRgn) const
//-------------------------------------------------------------
{
DLSINSTRUMENT *pDlsIns;
Modified: trunk/OpenMPT/soundlib/Dlsbank.h
===================================================================
--- trunk/OpenMPT/soundlib/Dlsbank.h 2014-03-07 12:46:56 UTC (rev 3841)
+++ trunk/OpenMPT/soundlib/Dlsbank.h 2014-03-07 13:08:48 UTC (rev 3842)
@@ -66,7 +66,7 @@
DWORD ulBank, ulInstrument;
UINT nRegions, nMelodicEnv;
DLSREGION Regions[DLSMAXREGIONS];
- CHAR szName[32];
+ char szName[32];
// SF2 stuff (DO NOT USE! -> used internally by the SF2 loader)
WORD wPresetBagNdx, wPresetBagNum;
} DLSINSTRUMENT;
@@ -75,13 +75,13 @@
typedef struct PACKED DLSSAMPLEEX
{
- CHAR szName[20];
+ char szName[20];
DWORD dwLen;
DWORD dwStartloop;
DWORD dwEndloop;
DWORD dwSampleRate;
BYTE byOriginalPitch;
- CHAR chPitchCorrection;
+ char chPitchCorrection;
} DLSSAMPLEEX;
STATIC_ASSERT(sizeof(DLSSAMPLEEX) == 38);
@@ -100,12 +100,12 @@
typedef struct SOUNDBANKINFO
{
- CHAR szBankName[256];
- CHAR szCopyRight[256];
- CHAR szComments[512];
- CHAR szEngineer[256];
- CHAR szSoftware[256]; // ISFT: Software
- CHAR szDescription[256]; // ISBJ: Subject
+ char szBankName[256];
+ char szCopyRight[256];
+ char szComments[512];
+ char szEngineer[256];
+ char szSoftware[256]; // ISFT: Software
+ char szDescription[256]; // ISBJ: Subject
} SOUNDBANKINFO;
@@ -149,7 +149,7 @@
bool ExtractWaveForm(UINT nIns, UINT nRgn, LPBYTE *ppWave, DWORD *pLen);
bool ExtractSample(CSoundFile &sndFile, SAMPLEINDEX nSample, UINT nIns, UINT nRgn, int transpose=0);
bool ExtractInstrument(CSoundFile &sndFile, INSTRUMENTINDEX nInstr, UINT nIns, UINT nDrumRgn);
- const CHAR *GetRegionName(UINT nIns, UINT nRgn) const;
+ const char *GetRegionName(UINT nIns, UINT nRgn) const;
// Internal Loader Functions
protected:
Modified: trunk/OpenMPT/soundlib/Load_med.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_med.cpp 2014-03-07 12:46:56 UTC (rev 3841)
+++ trunk/OpenMPT/soundlib/Load_med.cpp 2014-03-07 13:08:48 UTC (rev 3842)
@@ -509,7 +509,7 @@
const MMD0EXP *pmex;
DWORD dwBlockArr, dwSmplArr, dwExpData, wNumBlocks;
DWORD *pdwTable;
- CHAR version;
+ int8 version;
UINT deftempo;
int playtransp = 0;
Modified: trunk/OpenMPT/soundlib/Load_mt2.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-03-07 12:46:56 UTC (rev 3841)
+++ trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-03-07 13:08:48 UTC (rev 3842)
@@ -290,7 +290,7 @@
dwMemPos += 8;
if (dwMemPos + dwLen > dwMemLength) return true;
#ifdef MT2DEBUG
- CHAR s[5];
+ char s[5];
memcpy(s, &dwId, 4);
s[4] = 0;
Log("pos=0x%04X: %s: %d bytes\n", dwMemPos-8, s, dwLen);
Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp
===================================================================
--- trunk/OpenMPT/soundlib/SampleFormats.cpp 2014-03-07 12:46:56 UTC (rev 3841)
+++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2014-03-07 13:08:48 UTC (rev 3842)
@@ -513,9 +513,9 @@
typedef struct PACKED GF1PATCHFILEHEADER
{
char magic[8]; // "GF1PATCH"
- CHAR version[4]; // "100", or "110"
- CHAR id[10]; // "ID#000002"
- CHAR copyright[60]; // Copyright
+ char version[4]; // "100", or "110"
+ char id[10]; // "ID#000002"
+ char copyright[60]; // Copyright
BYTE instrum; // Number of instruments in patch
BYTE voices; // Number of voices, usually 14
BYTE channels; // Number of wav channels that can be played concurently to the patch
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2014-03-07 12:46:56 UTC (rev 3841)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2014-03-07 13:08:48 UTC (rev 3842)
@@ -456,8 +456,8 @@
GET_MPTHEADER_array_member( PitchEnv.Values , uint8 , PiE[ , MAX_ENVPOINTS )
GET_MPTHEADER_array_member( NoteMap , uint8 , NM[. , 128 )
GET_MPTHEADER_array_member( Keyboard , uint16 , K[.. , 128 )
-GET_MPTHEADER_array_member( name , CHAR , n[.. , 32 )
-GET_MPTHEADER_array_member( filename , CHAR , fn[. , 12 )
+GET_MPTHEADER_array_member( name , char , n[.. , 32 )
+GET_MPTHEADER_array_member( filename , char , fn[. , 12 )
GET_MPTHEADER_sized_member( nMixPlug , uint8 , MiP. )
GET_MPTHEADER_sized_member( nVolRampUp , uint16 , VR.. )
GET_MPTHEADER_sized_member( nResampling , UINT , R... )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2014-03-07 14:16:09
|
Revision: 3843
http://sourceforge.net/p/modplug/code/3843
Author: manxorist
Date: 2014-03-07 14:16:01 +0000 (Fri, 07 Mar 2014)
Log Message:
-----------
[Ref] Remove 3 superflous includes of misc_util.h .
Modified Paths:
--------------
trunk/OpenMPT/common/serialization_utils.h
trunk/OpenMPT/common/version.cpp
trunk/OpenMPT/soundlib/tuning.cpp
trunk/OpenMPT/soundlib/tuningbase.h
Modified: trunk/OpenMPT/common/serialization_utils.h
===================================================================
--- trunk/OpenMPT/common/serialization_utils.h 2014-03-07 13:08:48 UTC (rev 3842)
+++ trunk/OpenMPT/common/serialization_utils.h 2014-03-07 14:16:01 UTC (rev 3843)
@@ -10,18 +10,22 @@
#pragma once
+#include <algorithm>
+#include <bitset>
+#include <istream>
+#include <limits>
+#include <sstream>
#include <string>
-#include <sstream>
+#include <ostream>
#include <vector>
-#include <bitset>
-#include "../common/misc_util.h"
+
+#include <string.h>
+
#include "../common/typedefs.h"
-#include <limits>
+
#ifdef HAS_TYPE_TRAITS
#include <type_traits>
#endif
-#include <algorithm>
-#include <string.h>
namespace srlztn //SeRiaLiZaTioN
{
Modified: trunk/OpenMPT/common/version.cpp
===================================================================
--- trunk/OpenMPT/common/version.cpp 2014-03-07 13:08:48 UTC (rev 3842)
+++ trunk/OpenMPT/common/version.cpp 2014-03-07 14:16:01 UTC (rev 3843)
@@ -16,8 +16,6 @@
#include <cstdlib>
-#include "misc_util.h"
-
#include "versionNumber.h"
#include "svn_version.h"
Modified: trunk/OpenMPT/soundlib/tuning.cpp
===================================================================
--- trunk/OpenMPT/soundlib/tuning.cpp 2014-03-07 13:08:48 UTC (rev 3842)
+++ trunk/OpenMPT/soundlib/tuning.cpp 2014-03-07 14:16:01 UTC (rev 3843)
@@ -15,6 +15,7 @@
#ifdef MODPLUG_TRACKER
#include "../mptrack/Reporting.h"
#endif
+#include "../common/misc_util.h"
#include <string>
typedef CTuningRTI::RATIOTYPE RATIOTYPE;
Modified: trunk/OpenMPT/soundlib/tuningbase.h
===================================================================
--- trunk/OpenMPT/soundlib/tuningbase.h 2014-03-07 13:08:48 UTC (rev 3842)
+++ trunk/OpenMPT/soundlib/tuningbase.h 2014-03-07 14:16:01 UTC (rev 3843)
@@ -18,7 +18,6 @@
#include <ostream>
#include <map>
#include <limits>
-#include "../common/misc_util.h"
#include "../common/typedefs.h"
namespace srlztn {class Ssb;}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|