|
From: <sag...@us...> - 2014-02-03 17:43:40
|
Revision: 3638
http://sourceforge.net/p/modplug/code/3638
Author: saga-games
Date: 2014-02-03 17:43:32 +0000 (Mon, 03 Feb 2014)
Log Message:
-----------
[Mod] XM compatibility: FT2 uses square root pan law. Let's use it in compatible play mode.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Sndmix.cpp
trunk/OpenMPT/soundlib/SoundFilePlayConfig.cpp
trunk/OpenMPT/soundlib/SoundFilePlayConfig.h
trunk/OpenMPT/soundlib/Tables.cpp
trunk/OpenMPT/soundlib/Tables.h
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2014-02-03 17:00:01 UTC (rev 3637)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2014-02-03 17:43:32 UTC (rev 3638)
@@ -1931,6 +1931,17 @@
pChn->newLeftVol = (realvol * (256 - pan)) >> 8;
pChn->newRightVol = (realvol * 128) >> 8;
}
+ } else if(GetType() == MOD_TYPE_XM && m_PlayConfig.getEmulateQuirks())
+ {
+ // FT2 uses square root panning. There is a 257-entry LUT for this,
+ // but FT2's internal panning ranges from 0 to 255 only, meaning that
+ // you can never truly achieve 100% right panning in FT2, only 100% left.
+ // Test case: FT2PanLaw.xm
+ LimitMax(pan, 255);
+ const int panL = pan > 0 ? XMPanningTable[256 - pan] : 65536;
+ const int panR = XMPanningTable[pan];
+ pChn->newLeftVol = (realvol * panL) >> 16;
+ pChn->newRightVol = (realvol * panR) >> 16;
} else
{
pChn->newLeftVol = (realvol * (256 - pan)) >> 8;
Modified: trunk/OpenMPT/soundlib/SoundFilePlayConfig.cpp
===================================================================
--- trunk/OpenMPT/soundlib/SoundFilePlayConfig.cpp 2014-02-03 17:00:01 UTC (rev 3637)
+++ trunk/OpenMPT/soundlib/SoundFilePlayConfig.cpp 2014-02-03 17:43:32 UTC (rev 3638)
@@ -43,6 +43,7 @@
setNormalVSTiVol(100.0);
setNormalGlobalVol(128.0);
setExtraSampleAttenuation(MIXING_ATTENUATION);
+ setEmulateQuirks(false);
break;
// Ericus' version gives us floats in [-0.06;0.06] and requires attenuation to
@@ -59,6 +60,7 @@
setNormalVSTiVol(100.0);
setNormalGlobalVol(128.0);
setExtraSampleAttenuation(MIXING_ATTENUATION);
+ setEmulateQuirks(false);
break;
// 117RC2 gives us floats in [-1.0; 1.0] and hopefully plays VSTis at
@@ -76,6 +78,7 @@
setNormalVSTiVol(100.0);
setNormalGlobalVol(128.0);
setExtraSampleAttenuation(MIXING_ATTENUATION);
+ setEmulateQuirks(false);
break;
// 117RC3 ignores the horrible global, system-specific pre-amp,
@@ -94,6 +97,7 @@
setNormalVSTiVol(128.0);
setNormalGlobalVol(256.0);
setExtraSampleAttenuation(0);
+ setEmulateQuirks(false);
break;
// A mixmode that is intended to be compatible to legacy trackers (IT/FT2/etc).
@@ -111,166 +115,10 @@
setNormalVSTiVol(256.0);
setNormalGlobalVol(256.0);
setExtraSampleAttenuation(1);
+ setEmulateQuirks(true);
break;
}
return;
}
-
-
-
-//getters and setters.
-bool CSoundFilePlayConfig::getGlobalVolumeAppliesToMaster() const
-//---------------------------------------------------------------
-{
- return m_globalVolumeAppliesToMaster;
-}
-
-
-void CSoundFilePlayConfig::setGlobalVolumeAppliesToMaster(bool inGlobalVolumeAppliesToMaster)
-//-------------------------------------------------------------------------------------------
-{
- m_globalVolumeAppliesToMaster=inGlobalVolumeAppliesToMaster;
-}
-
-float CSoundFilePlayConfig::getVSTiGainFactor() const
-//---------------------------------------------------
-{
- return m_VSTiVolume;
-}
-
-float CSoundFilePlayConfig::getVSTiVolume() const
-//-----------------------------------------------
-{
- return m_VSTiVolume;
-}
-
-void CSoundFilePlayConfig::setVSTiVolume(float inVSTiVolume)
-//-----------------------------------------------------------
-{
- m_VSTiVolume = inVSTiVolume;
-}
-
-float CSoundFilePlayConfig::getVSTiAttenuation() const
-//----------------------------------------------------
-{
- return m_VSTiAttenuation;
-}
-
-void CSoundFilePlayConfig::setVSTiAttenuation(float inVSTiAttenuation)
-//---------------------------------------------------------------------
-{
- m_VSTiAttenuation = inVSTiAttenuation;
-}
-
-float CSoundFilePlayConfig::getIntToFloat() const
-//-----------------------------------------------
-{
- return m_IntToFloat;
-}
-
-void CSoundFilePlayConfig::setIntToFloat(float inIntToFloat)
-//-----------------------------------------------------------
-{
- m_IntToFloat = inIntToFloat;
-}
-
-
-float CSoundFilePlayConfig::getFloatToInt() const
-//-----------------------------------------------
-{
- return m_FloatToInt;
-}
-
-
-void CSoundFilePlayConfig::setFloatToInt(float inFloatToInt)
-//-----------------------------------------------------------
-{
- m_FloatToInt = inFloatToInt;
-}
-
-bool CSoundFilePlayConfig::getUseGlobalPreAmp() const
-//---------------------------------------------------
-{
- return m_ignorePreAmp;
-}
-
-void CSoundFilePlayConfig::setUseGlobalPreAmp(bool inUseGlobalPreAmp)
-//-------------------------------------------------------------------
-{
- m_ignorePreAmp = inUseGlobalPreAmp;
-}
-
-
-forcePanningMode CSoundFilePlayConfig::getForcePanningMode() const
-//----------------------------------------------------------------
-{
- return m_forceSoftPanning;
-}
-
-void CSoundFilePlayConfig::setForcePanningMode(forcePanningMode inForceSoftPanning)
-//---------------------------------------------------------------------------------
-{
- m_forceSoftPanning = inForceSoftPanning;
-}
-
-void CSoundFilePlayConfig::setDisplayDBValues(bool in)
-//----------------------------------------------------
-{
- m_displayDBValues = in;
-}
-
-void CSoundFilePlayConfig::setNormalSamplePreAmp(double in)
-//---------------------------------------------------------
-{
- m_normalSamplePreAmp = in;
-}
-
-void CSoundFilePlayConfig::setNormalVSTiVol(double in)
-//----------------------------------------------------
-{
- m_normalVSTiVol = in;
-}
-
-void CSoundFilePlayConfig::setNormalGlobalVol(double in)
-//------------------------------------------------------
-{
- m_normalGlobalVol = in;
-}
-
-bool CSoundFilePlayConfig::getDisplayDBValues() const
-//---------------------------------------------------
-{
- return m_displayDBValues;
-}
-
-double CSoundFilePlayConfig::getNormalSamplePreAmp() const
-//--------------------------------------------------------
-{
- return m_normalSamplePreAmp;
-}
-
-double CSoundFilePlayConfig::getNormalVSTiVol() const
-//---------------------------------------------------
-{
- return m_normalVSTiVol;
-}
-
-double CSoundFilePlayConfig::getNormalGlobalVol() const
-//-----------------------------------------------------
-{
- return m_normalGlobalVol;
-}
-
-void CSoundFilePlayConfig::setExtraSampleAttenuation(int attn)
-//------------------------------------------------------------
-{
- m_extraAttenuation = attn;
-}
-
-int CSoundFilePlayConfig::getExtraSampleAttenuation() const
-//---------------------------------------------------------
-{
- return m_extraAttenuation;
-}
Modified: trunk/OpenMPT/soundlib/SoundFilePlayConfig.h
===================================================================
--- trunk/OpenMPT/soundlib/SoundFilePlayConfig.h 2014-02-03 17:00:01 UTC (rev 3637)
+++ trunk/OpenMPT/soundlib/SoundFilePlayConfig.h 2014-02-03 17:43:32 UTC (rev 3638)
@@ -49,48 +49,50 @@
void SetMixLevels(int mixLevelType);
//getters/setters
- float getIntToFloat() const;
- void setIntToFloat(float);
- float getFloatToInt() const;
- void setFloatToInt(float);
+ bool getGlobalVolumeAppliesToMaster() const { return m_globalVolumeAppliesToMaster; }
+ void setGlobalVolumeAppliesToMaster(bool inGlobalVolumeAppliesToMaster) { m_globalVolumeAppliesToMaster=inGlobalVolumeAppliesToMaster; }
+ // user-controllable VSTi gain factor.
+ float getVSTiVolume() const { return m_VSTiVolume; }
+ void setVSTiVolume(float inVSTiVolume) { m_VSTiVolume = inVSTiVolume; }
+
// default VSTi gain factor, different depending on the MPT version we're "emulating"
- void setVSTiAttenuation(float);
- float getVSTiAttenuation() const;
+ float getVSTiAttenuation() const { return m_VSTiAttenuation; }
+ void setVSTiAttenuation(float inVSTiAttenuation) { m_VSTiAttenuation = inVSTiAttenuation; }
- // user-controllable VSTi gain factor.
- void setVSTiVolume(float);
- float getVSTiVolume() const;
+ float getIntToFloat() const { return m_IntToFloat; }
+ void setIntToFloat(float inIntToFloat) { m_IntToFloat = inIntToFloat; }
- void setGlobalVolumeAppliesToMaster(bool);
- bool getGlobalVolumeAppliesToMaster() const;
-
- void setUseGlobalPreAmp(bool);
- bool getUseGlobalPreAmp() const;
+ float getFloatToInt() const { return m_FloatToInt; }
+ void setFloatToInt(float inFloatToInt) { m_FloatToInt = inFloatToInt; }
- void setForcePanningMode(forcePanningMode);
- forcePanningMode getForcePanningMode() const;
+ bool getUseGlobalPreAmp() const { return m_ignorePreAmp; }
+ void setUseGlobalPreAmp(bool inUseGlobalPreAmp) { m_ignorePreAmp = inUseGlobalPreAmp; }
- void setDisplayDBValues(bool);
- bool getDisplayDBValues() const;
+ forcePanningMode getForcePanningMode() const { return m_forceSoftPanning; }
+ void setForcePanningMode(forcePanningMode inForceSoftPanning) { m_forceSoftPanning = inForceSoftPanning; }
+ bool getDisplayDBValues() const { return m_displayDBValues; }
+ void setDisplayDBValues(bool in) { m_displayDBValues = in; }
+
+ // Values at which volumes are unchanged
+ double getNormalSamplePreAmp() const { return m_normalSamplePreAmp; }
+ void setNormalSamplePreAmp(double in) { m_normalSamplePreAmp = in; }
+ double getNormalVSTiVol() const { return m_normalVSTiVol; }
+ void setNormalVSTiVol(double in) { m_normalVSTiVol = in; }
+ double getNormalGlobalVol() const { return m_normalGlobalVol; }
+ void setNormalGlobalVol(double in) { m_normalGlobalVol = in; }
+
// Extra sample attenuation in bits
- void setExtraSampleAttenuation(int);
- int getExtraSampleAttenuation() const;
+ int getExtraSampleAttenuation() const { return m_extraAttenuation; }
+ void setExtraSampleAttenuation(int attn) { m_extraAttenuation = attn; }
- //Values at which volumes are unchanged
- double getNormalSamplePreAmp() const;
- double getNormalVSTiVol() const;
- double getNormalGlobalVol() const;
- void setNormalSamplePreAmp(double);
- void setNormalVSTiVol(double);
- void setNormalGlobalVol(double);
+ // True if format-specific mixing quirks should be emulated.
+ bool getEmulateQuirks() const { return m_emualteQuirks; }
+ void setEmulateQuirks(bool emulate) { m_emualteQuirks = emulate; }
-private:
+protected:
-//calculated internally (getters only):
- float getVSTiGainFactor() const;
-
float m_IntToFloat;
float m_FloatToInt;
float m_VSTiAttenuation;
@@ -100,11 +102,11 @@
double m_normalVSTiVol;
double m_normalGlobalVol;
+ int m_extraAttenuation;
+ forcePanningMode m_forceSoftPanning;
bool m_globalVolumeAppliesToMaster;
bool m_ignorePreAmp;
- forcePanningMode m_forceSoftPanning;
bool m_displayDBValues;
-
- int m_extraAttenuation;
+ bool m_emualteQuirks;
};
Modified: trunk/OpenMPT/soundlib/Tables.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Tables.cpp 2014-02-03 17:00:01 UTC (rev 3637)
+++ trunk/OpenMPT/soundlib/Tables.cpp 2014-02-03 17:43:32 UTC (rev 3638)
@@ -675,7 +675,7 @@
// LUT for 2 * damping factor
-const float ITResonanceTable[128] =
+const float ITResonanceTable[128] =
{
1.0000000000000000f, 0.9786446094512940f, 0.9577452540397644f, 0.9372922182083130f,
0.9172759056091309f, 0.8976871371269226f, 0.8785166740417481f, 0.8597555756568909f,
@@ -712,6 +712,29 @@
};
+// FT2's square root panning law LUT.
+// Formula to generate this table: round(65536 * sqrt(n / 256))
+const uint16 XMPanningTable[256] =
+{
+ 0, 4096, 5793, 7094, 8192, 9159, 10033, 10837, 11585, 12288, 12953, 13585, 14189, 14768, 15326, 15864,
+ 16384, 16888, 17378, 17854, 18318, 18770, 19212, 19644, 20066, 20480, 20886, 21283, 21674, 22058, 22435, 22806,
+ 23170, 23530, 23884, 24232, 24576, 24915, 25249, 25580, 25905, 26227, 26545, 26859, 27170, 27477, 27780, 28081,
+ 28378, 28672, 28963, 29251, 29537, 29819, 30099, 30377, 30652, 30924, 31194, 31462, 31727, 31991, 32252, 32511,
+ 32768, 33023, 33276, 33527, 33776, 34024, 34270, 34514, 34756, 34996, 35235, 35472, 35708, 35942, 36175, 36406,
+ 36636, 36864, 37091, 37316, 37540, 37763, 37985, 38205, 38424, 38642, 38858, 39073, 39287, 39500, 39712, 39923,
+ 40132, 40341, 40548, 40755, 40960, 41164, 41368, 41570, 41771, 41972, 42171, 42369, 42567, 42763, 42959, 43154,
+ 43348, 43541, 43733, 43925, 44115, 44305, 44494, 44682, 44869, 45056, 45242, 45427, 45611, 45795, 45977, 46160,
+ 46341, 46522, 46702, 46881, 47059, 47237, 47415, 47591, 47767, 47942, 48117, 48291, 48465, 48637, 48809, 48981,
+ 49152, 49322, 49492, 49661, 49830, 49998, 50166, 50332, 50499, 50665, 50830, 50995, 51159, 51323, 51486, 51649,
+ 51811, 51972, 52134, 52294, 52454, 52614, 52773, 52932, 53090, 53248, 53405, 53562, 53719, 53874, 54030, 54185,
+ 54340, 54494, 54647, 54801, 54954, 55106, 55258, 55410, 55561, 55712, 55862, 56012, 56162, 56311, 56459, 56608,
+ 56756, 56903, 57051, 57198, 57344, 57490, 57636, 57781, 57926, 58071, 58215, 58359, 58503, 58646, 58789, 58931,
+ 59073, 59215, 59357, 59498, 59639, 59779, 59919, 60059, 60199, 60338, 60477, 60615, 60753, 60891, 61029, 61166,
+ 61303, 61440, 61576, 61712, 61848, 61984, 62119, 62254, 62388, 62523, 62657, 62790, 62924, 63057, 63190, 63323,
+ 63455, 63587, 63719, 63850, 63982, 64113, 64243, 64374, 64504, 64634, 64763, 64893, 65022, 65151, 65279, 65408,
+};
+
+
// Reversed sinc coefficients for 4x256 taps polyphase FIR resampling filter
const int16 CResampler::FastSincTable[256*4] =
{ // Cubic Spline
Modified: trunk/OpenMPT/soundlib/Tables.h
===================================================================
--- trunk/OpenMPT/soundlib/Tables.h 2014-02-03 17:00:01 UTC (rev 3637)
+++ trunk/OpenMPT/soundlib/Tables.h 2014-02-03 17:43:32 UTC (rev 3638)
@@ -33,3 +33,4 @@
extern const uint32 LinearSlideUpTable[256];
extern const uint32 LinearSlideDownTable[256];
extern const float ITResonanceTable[128];
+extern const uint16 XMPanningTable[256];
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|