summaryrefslogtreecommitdiff
path: root/sounddsp
diff options
context:
space:
mode:
authorJames Cowgill <jcowgill@debian.org>2018-12-23 22:09:29 +0000
committerJames Cowgill <jcowgill@debian.org>2018-12-23 22:09:29 +0000
commitfa977e826b34fe2fcfeb253f50d8def6127068b6 (patch)
treed0e1cd7cdc903a5c858d2339ec4a359c6b7a9903 /sounddsp
parentdb8e0c1070c79653be541929205e7b7004d43663 (diff)
New upstream version 0.4.0
Diffstat (limited to 'sounddsp')
-rw-r--r--sounddsp/AGC.cpp1
-rw-r--r--sounddsp/AGC.h2
-rw-r--r--sounddsp/DSP.cpp7
-rw-r--r--sounddsp/DSP.h2
-rw-r--r--sounddsp/EQ.cpp13
-rw-r--r--sounddsp/EQ.h2
-rw-r--r--sounddsp/Reverb.cpp97
-rw-r--r--sounddsp/Reverb.h40
8 files changed, 68 insertions, 96 deletions
diff --git a/sounddsp/AGC.cpp b/sounddsp/AGC.cpp
index 5051c57..fac3408 100644
--- a/sounddsp/AGC.cpp
+++ b/sounddsp/AGC.cpp
@@ -10,7 +10,6 @@
#include "stdafx.h"
-#include "../soundlib/Sndfile.h"
#include "../sounddsp/AGC.h"
diff --git a/sounddsp/AGC.h b/sounddsp/AGC.h
index 4c50ea6..f9537a0 100644
--- a/sounddsp/AGC.h
+++ b/sounddsp/AGC.h
@@ -10,6 +10,8 @@
#pragma once
+#include "BuildSettings.h"
+
OPENMPT_NAMESPACE_BEGIN
diff --git a/sounddsp/DSP.cpp b/sounddsp/DSP.cpp
index b9103c3..228236d 100644
--- a/sounddsp/DSP.cpp
+++ b/sounddsp/DSP.cpp
@@ -10,7 +10,6 @@
#include "stdafx.h"
-#include "../soundlib/Sndfile.h"
#include "../sounddsp/DSP.h"
#include <math.h>
@@ -72,9 +71,9 @@ static void ShelfEQ(int32 scale,
b1 = ((beta1 + rho*beta0) * quad);
a1 = - ((rho + alpha) * quad);
- outA1 = Util::Round<int32>(a1 * scale);
- outB0 = Util::Round<int32>(b0 * scale);
- outB1 = Util::Round<int32>(b1 * scale);
+ outA1 = mpt::saturate_round<int32>(a1 * scale);
+ outB0 = mpt::saturate_round<int32>(b0 * scale);
+ outB1 = mpt::saturate_round<int32>(b1 * scale);
}
diff --git a/sounddsp/DSP.h b/sounddsp/DSP.h
index 0b9361d..982ba6a 100644
--- a/sounddsp/DSP.h
+++ b/sounddsp/DSP.h
@@ -11,6 +11,8 @@
#pragma once
+#include "BuildSettings.h"
+
OPENMPT_NAMESPACE_BEGIN
diff --git a/sounddsp/EQ.cpp b/sounddsp/EQ.cpp
index 9a998d5..1b39297 100644
--- a/sounddsp/EQ.cpp
+++ b/sounddsp/EQ.cpp
@@ -10,7 +10,6 @@
#include "stdafx.h"
-#include "../soundlib/Sndfile.h"
#include "../soundlib/MixerLoops.h"
#include "../sounddsp/EQ.h"
@@ -201,7 +200,7 @@ mainloop:
#endif // ENABLE_X86_AMD
-#ifdef ENABLE_SSE
+#if defined(ENABLE_X86) && defined(ENABLE_SSE)
static void SSE_StereoEQ(EQBANDSTRUCT *pbl, EQBANDSTRUCT *pbr, float32 *pbuffer, UINT nCount)
{
@@ -294,7 +293,7 @@ done:;
}
}
-#endif // ENABLE_SSE
+#endif // ENABLE_X86 && ENABLE_SSE
#if MPT_COMPILER_MSVC
#pragma warning(pop)
@@ -333,7 +332,7 @@ void CEQ::ProcessMono(int *pbuffer, float *MixFloatBuffer, UINT nCount)
void CEQ::ProcessStereo(int *pbuffer, float *MixFloatBuffer, UINT nCount)
{
-#ifdef ENABLE_SSE
+#if defined(ENABLE_X86) && defined(ENABLE_SSE)
if(GetProcSupport() & PROCSUPPORT_SSE)
{
@@ -354,7 +353,7 @@ void CEQ::ProcessStereo(int *pbuffer, float *MixFloatBuffer, UINT nCount)
} else
-#endif // ENABLE_SSE
+#endif // ENABLE_X86 && ENABLE_SSE
#ifdef ENABLE_X86_AMD
@@ -395,10 +394,6 @@ void CEQ::ProcessStereo(int *pbuffer, float *MixFloatBuffer, UINT nCount)
CEQ::CEQ()
{
- #if defined(ENABLE_SSE) || defined(ENABLE_X86_AMD)
- MPT_ASSERT_ALWAYS(((uintptr_t)&(gEQ[0])) % 4 == 0);
- MPT_ASSERT_ALWAYS(((uintptr_t)&(gEQ[1])) % 4 == 0);
- #endif // ENABLE_SSE || ENABLE_X86_AMD
memcpy(gEQ, gEQDefaults, sizeof(gEQ));
}
diff --git a/sounddsp/EQ.h b/sounddsp/EQ.h
index 0fd073a..229681d 100644
--- a/sounddsp/EQ.h
+++ b/sounddsp/EQ.h
@@ -11,6 +11,8 @@
#pragma once
+#include "BuildSettings.h"
+
#include "../soundlib/Mixer.h" // For MIXBUFFERSIZE
OPENMPT_NAMESPACE_BEGIN
diff --git a/sounddsp/Reverb.cpp b/sounddsp/Reverb.cpp
index ce7817f..c6d4ba1 100644
--- a/sounddsp/Reverb.cpp
+++ b/sounddsp/Reverb.cpp
@@ -55,38 +55,11 @@ static MPT_FORCEINLINE void Store64SSE(int32 *dst, __m128i src) { return _mm_sto
static MPT_FORCEINLINE void Store64SSE(LR16 *dst, __m128i src) { return _mm_storel_epi64(reinterpret_cast<__m128i *>(dst), src); }
#endif
-CReverbSettings::CReverbSettings()
-{
- m_nReverbType = 0;
- m_nReverbDepth = 8; // 50%
-}
-
CReverb::CReverb()
{
- m_currentPreset = nullptr;
-
// Shared reverb state
InitMixBuffer(MixReverbBuffer, static_cast<uint32>(mpt::size(MixReverbBuffer)));
- gnRvbROfsVol = 0;
- gnRvbLOfsVol = 0;
-
- gnReverbSend = 0;
-
- gnReverbSamples = 0;
- gnReverbDecaySamples = 0;
-
- // Internal reverb state
- g_bLastInPresent = 0;
- g_bLastOutPresent = 0;
- g_nLastRvbIn_xl = 0;
- g_nLastRvbIn_xr = 0;
- g_nLastRvbIn_yl = 0;
- g_nLastRvbIn_yr = 0;
- g_nLastRvbOut_xl = 0;
- g_nLastRvbOut_xr = 0;
- MemsetZero(gnDCRRvb_Y1);
- MemsetZero(gnDCRRvb_X1);
// Reverb mix buffers
MemsetZero(g_RefDelay);
@@ -102,7 +75,7 @@ static int32 OnePoleLowPassCoef(int32 scale, float g, float F_c, float F_s)
g *= g;
double scale_over_1mg = scale / (1.0 - g);
double cosw = std::cos(2.0 * M_PI * F_c / F_s);
- return Util::Round<int32>((1.0 - (std::sqrt((g + g) * (1.0 - cosw) - g * g * (1.0 - cosw * cosw)) + g * cosw)) * scale_over_1mg);
+ return mpt::saturate_round<int32>((1.0 - (std::sqrt((g + g) * (1.0 - cosw) - g * g * (1.0 - cosw * cosw)) + g * cosw)) * scale_over_1mg);
}
static float mBToLinear(int32 value_mB)
@@ -116,7 +89,7 @@ static float mBToLinear(int32 value_mB)
static int32 mBToLinear(int32 scale, int32 value_mB)
{
- return Util::Round<int32>(mBToLinear(value_mB) * scale);
+ return mpt::saturate_round<int32>(mBToLinear(value_mB) * scale);
}
@@ -137,46 +110,46 @@ struct SNDMIX_REVERB_PROPERTIES
struct SNDMIX_RVBPRESET
{
SNDMIX_REVERB_PROPERTIES Preset;
- const char *name;
+ const MPT_UCHAR_TYPE *name;
};
-static SNDMIX_RVBPRESET gRvbPresets[NUM_REVERBTYPES] =
+static const SNDMIX_RVBPRESET gRvbPresets[NUM_REVERBTYPES] =
{
- {{ SNDMIX_REVERB_PRESET_PLATE }, "GM Plate"},
- {{ SNDMIX_REVERB_PRESET_SMALLROOM }, "GM Small Room"},
- {{ SNDMIX_REVERB_PRESET_MEDIUMROOM }, "GM Medium Room"},
- {{ SNDMIX_REVERB_PRESET_LARGEROOM }, "GM Large Room"},
- {{ SNDMIX_REVERB_PRESET_MEDIUMHALL }, "GM Medium Hall"},
- {{ SNDMIX_REVERB_PRESET_LARGEHALL }, "GM Large Hall"},
- {{ SNDMIX_REVERB_PRESET_GENERIC }, "Generic"},
- {{ SNDMIX_REVERB_PRESET_PADDEDCELL }, "Padded Cell"},
- {{ SNDMIX_REVERB_PRESET_ROOM }, "Room"},
- {{ SNDMIX_REVERB_PRESET_BATHROOM }, "Bathroom"},
- {{ SNDMIX_REVERB_PRESET_LIVINGROOM }, "Living Room"},
- {{ SNDMIX_REVERB_PRESET_STONEROOM }, "Stone Room"},
- {{ SNDMIX_REVERB_PRESET_AUDITORIUM }, "Auditorium"},
- {{ SNDMIX_REVERB_PRESET_CONCERTHALL }, "Concert Hall"},
- {{ SNDMIX_REVERB_PRESET_CAVE }, "Cave"},
- {{ SNDMIX_REVERB_PRESET_ARENA }, "Arena"},
- {{ SNDMIX_REVERB_PRESET_HANGAR }, "Hangar"},
- {{ SNDMIX_REVERB_PRESET_CARPETEDHALLWAY }, "Carpeted Hallway"},
- {{ SNDMIX_REVERB_PRESET_HALLWAY }, "Hallway"},
- {{ SNDMIX_REVERB_PRESET_STONECORRIDOR }, "Stone Corridor"},
- {{ SNDMIX_REVERB_PRESET_ALLEY }, "Alley"},
- {{ SNDMIX_REVERB_PRESET_FOREST }, "Forest"},
- {{ SNDMIX_REVERB_PRESET_CITY }, "City"},
- {{ SNDMIX_REVERB_PRESET_MOUNTAINS }, "Mountains"},
- {{ SNDMIX_REVERB_PRESET_QUARRY }, "Quarry"},
- {{ SNDMIX_REVERB_PRESET_PLAIN }, "Plain"},
- {{ SNDMIX_REVERB_PRESET_PARKINGLOT }, "Parking Lot"},
- {{ SNDMIX_REVERB_PRESET_SEWERPIPE }, "Sewer Pipe"},
- {{ SNDMIX_REVERB_PRESET_UNDERWATER }, "Underwater"},
+ {{ SNDMIX_REVERB_PRESET_PLATE }, UL_("GM Plate")},
+ {{ SNDMIX_REVERB_PRESET_SMALLROOM }, UL_("GM Small Room")},
+ {{ SNDMIX_REVERB_PRESET_MEDIUMROOM }, UL_("GM Medium Room")},
+ {{ SNDMIX_REVERB_PRESET_LARGEROOM }, UL_("GM Large Room")},
+ {{ SNDMIX_REVERB_PRESET_MEDIUMHALL }, UL_("GM Medium Hall")},
+ {{ SNDMIX_REVERB_PRESET_LARGEHALL }, UL_("GM Large Hall")},
+ {{ SNDMIX_REVERB_PRESET_GENERIC }, UL_("Generic")},
+ {{ SNDMIX_REVERB_PRESET_PADDEDCELL }, UL_("Padded Cell")},
+ {{ SNDMIX_REVERB_PRESET_ROOM }, UL_("Room")},
+ {{ SNDMIX_REVERB_PRESET_BATHROOM }, UL_("Bathroom")},
+ {{ SNDMIX_REVERB_PRESET_LIVINGROOM }, UL_("Living Room")},
+ {{ SNDMIX_REVERB_PRESET_STONEROOM }, UL_("Stone Room")},
+ {{ SNDMIX_REVERB_PRESET_AUDITORIUM }, UL_("Auditorium")},
+ {{ SNDMIX_REVERB_PRESET_CONCERTHALL }, UL_("Concert Hall")},
+ {{ SNDMIX_REVERB_PRESET_CAVE }, UL_("Cave")},
+ {{ SNDMIX_REVERB_PRESET_ARENA }, UL_("Arena")},
+ {{ SNDMIX_REVERB_PRESET_HANGAR }, UL_("Hangar")},
+ {{ SNDMIX_REVERB_PRESET_CARPETEDHALLWAY }, UL_("Carpeted Hallway")},
+ {{ SNDMIX_REVERB_PRESET_HALLWAY }, UL_("Hallway")},
+ {{ SNDMIX_REVERB_PRESET_STONECORRIDOR }, UL_("Stone Corridor")},
+ {{ SNDMIX_REVERB_PRESET_ALLEY }, UL_("Alley")},
+ {{ SNDMIX_REVERB_PRESET_FOREST }, UL_("Forest")},
+ {{ SNDMIX_REVERB_PRESET_CITY }, UL_("City")},
+ {{ SNDMIX_REVERB_PRESET_MOUNTAINS }, UL_("Mountains")},
+ {{ SNDMIX_REVERB_PRESET_QUARRY }, UL_("Quarry")},
+ {{ SNDMIX_REVERB_PRESET_PLAIN }, UL_("Plain")},
+ {{ SNDMIX_REVERB_PRESET_PARKINGLOT }, UL_("Parking Lot")},
+ {{ SNDMIX_REVERB_PRESET_SEWERPIPE }, UL_("Sewer Pipe")},
+ {{ SNDMIX_REVERB_PRESET_UNDERWATER }, UL_("Underwater")},
};
-const char *GetReverbPresetName(uint32 nPreset)
+mpt::ustring GetReverbPresetName(uint32 nPreset)
{
- return (nPreset < NUM_REVERBTYPES) ? gRvbPresets[nPreset].name : nullptr;
+ return (nPreset < NUM_REVERBTYPES) ? mpt::ustring(gRvbPresets[nPreset].name) : mpt::ustring();
}
//////////////////////////////////////////////////////////////////////////
diff --git a/sounddsp/Reverb.h b/sounddsp/Reverb.h
index 1b4c08d..8a777ea 100644
--- a/sounddsp/Reverb.h
+++ b/sounddsp/Reverb.h
@@ -10,6 +10,8 @@
#pragma once
+#include "BuildSettings.h"
+
#ifndef NO_REVERB
#include "../soundlib/Mixer.h" // For MIXBUFFERSIZE
@@ -21,7 +23,7 @@ OPENMPT_NAMESPACE_BEGIN
#define NUM_REVERBTYPES 29
-const char *GetReverbPresetName(uint32 nPreset);
+mpt::ustring GetReverbPresetName(uint32 nPreset);
/////////////////////////////////////////////////////////////////////////////
//
@@ -128,10 +130,8 @@ struct EnvironmentReverb
class CReverbSettings
{
public:
- uint32 m_nReverbDepth;
- uint32 m_nReverbType;
-public:
- CReverbSettings();
+ uint32 m_nReverbDepth = 8; // 50%
+ uint32 m_nReverbType = 0;
};
@@ -144,27 +144,27 @@ public:
private:
mixsample_t MixReverbBuffer[MIXBUFFERSIZE * 2];
public:
- mixsample_t gnRvbROfsVol, gnRvbLOfsVol;
+ mixsample_t gnRvbROfsVol = 0, gnRvbLOfsVol = 0;
private:
- const SNDMIX_REVERB_PROPERTIES *m_currentPreset;
+ const SNDMIX_REVERB_PROPERTIES *m_currentPreset = nullptr;
- uint32 gnReverbSend;
+ uint32 gnReverbSend = 0;
- uint32 gnReverbSamples;
- uint32 gnReverbDecaySamples;
+ uint32 gnReverbSamples = 0;
+ uint32 gnReverbDecaySamples = 0;
// Internal reverb state
- bool g_bLastInPresent;
- bool g_bLastOutPresent;
- int g_nLastRvbIn_xl;
- int g_nLastRvbIn_xr;
- int g_nLastRvbIn_yl;
- int g_nLastRvbIn_yr;
- int g_nLastRvbOut_xl;
- int g_nLastRvbOut_xr;
- int32 gnDCRRvb_Y1[2];
- int32 gnDCRRvb_X1[2];
+ bool g_bLastInPresent = 0;
+ bool g_bLastOutPresent = 0;
+ int g_nLastRvbIn_xl = 0;
+ int g_nLastRvbIn_xr = 0;
+ int g_nLastRvbIn_yl = 0;
+ int g_nLastRvbIn_yr = 0;
+ int g_nLastRvbOut_xl = 0;
+ int g_nLastRvbOut_xr = 0;
+ int32 gnDCRRvb_Y1[2] = { 0, 0 };
+ int32 gnDCRRvb_X1[2] = { 0, 0 };
// Reverb mix buffers
SWRvbRefDelay g_RefDelay;