mednafen-support resampler enable

This commit is contained in:
zeromus 2012-11-13 19:12:06 +00:00
parent 7bdd93d14d
commit cb8578b488
3 changed files with 35 additions and 5 deletions

View File

@ -4,6 +4,12 @@
//make sure this file gets included by everything //make sure this file gets included by everything
//configurations related to headlessness shall be in here //configurations related to headlessness shall be in here
#ifdef LIBMEDNAHAWK
#define HEADLESS
#define WANT_RESAMPLER
#define WANT_PSF
#endif
#ifdef HEADLESS #ifdef HEADLESS
#else #else
@ -16,6 +22,7 @@
#define WANT_REWIND #define WANT_REWIND
#define WANT_DEARCHIVE #define WANT_DEARCHIVE
#define WANT_IPS #define WANT_IPS
#define WANT_RESAMPLER
//features you may want to consider -D in a headless library's makefile //features you may want to consider -D in a headless library's makefile
#define WANT_PSF #define WANT_PSF

View File

@ -73,7 +73,7 @@
<ClCompile> <ClCompile>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.;..;..\src;..\include;..\zlib123;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>.;..;..\src;..\include;..\zlib123;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WANT_PSF;HEADLESS;WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>LIBMEDNAHAWK;WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild> <MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@ -96,7 +96,7 @@
<ClCompile> <ClCompile>
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions> <AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
<AdditionalIncludeDirectories>.;..;..\src;..\include;..\zlib123;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>.;..;..\src;..\include;..\zlib123;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WANT_PSF;HEADLESS;WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>LIBMEDNAHAWK;WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<StructMemberAlignment>1Byte</StructMemberAlignment> <StructMemberAlignment>1Byte</StructMemberAlignment>
<PrecompiledHeader> <PrecompiledHeader>
@ -126,7 +126,7 @@
<Optimization>Full</Optimization> <Optimization>Full</Optimization>
<WholeProgramOptimization>false</WholeProgramOptimization> <WholeProgramOptimization>false</WholeProgramOptimization>
<AdditionalIncludeDirectories>.;..;..\src;..\include;..\zlib123;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>.;..;..\src;..\include;..\zlib123;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WANT_PSF;HEADLESS;WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>LIBMEDNAHAWK;WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<StructMemberAlignment>1Byte</StructMemberAlignment> <StructMemberAlignment>1Byte</StructMemberAlignment>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet> <EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>

View File

@ -45,7 +45,10 @@
#include "qtrecord.h" #include "qtrecord.h"
#include "md5.h" #include "md5.h"
#include "clamp.h" #include "clamp.h"
#ifdef WANT_RESAMPLER
#include "Fir_Resampler.h" #include "Fir_Resampler.h"
#endif
#include "string/escape.h" #include "string/escape.h"
@ -171,7 +174,6 @@ MDFNGI *MDFNGameInfo = NULL;
static QTRecord *qtrecorder = NULL; static QTRecord *qtrecorder = NULL;
static WAVRecord *wavrecorder = NULL; static WAVRecord *wavrecorder = NULL;
#endif #endif
static Fir_Resampler<16> ff_resampler;
static double LastSoundMultiplier; static double LastSoundMultiplier;
static bool FFDiscard = FALSE; // TODO: Setting to discard sound samples instead of increasing pitch static bool FFDiscard = FALSE; // TODO: Setting to discard sound samples instead of increasing pitch
@ -182,6 +184,8 @@ static double last_sound_rate;
static bool PrevInterlaced; static bool PrevInterlaced;
static Deinterlacer deint; static Deinterlacer deint;
static std::vector<int16> SoundBufPristine;
static std::vector<CDIF *> CDInterfaces; // FIXME: Cleanup on error out. static std::vector<CDIF *> CDInterfaces; // FIXME: Cleanup on error out.
#ifdef WANT_AVDUMP #ifdef WANT_AVDUMP
@ -1194,8 +1198,9 @@ void MDFNI_Kill(void)
MDFN_KillSettings(); MDFN_KillSettings();
} }
#ifdef WANT_RESAMPLER
static double multiplier_save, volume_save; static double multiplier_save, volume_save;
static std::vector<int16> SoundBufPristine; static Fir_Resampler<16> ff_resampler;
static void ProcessAudio(EmulateSpecStruct *espec) static void ProcessAudio(EmulateSpecStruct *espec)
{ {
@ -1355,6 +1360,20 @@ static void ProcessAudio(EmulateSpecStruct *espec)
espec->SoundBufSize = espec->SoundBufSizeALMS + SoundBufSize; espec->SoundBufSize = espec->SoundBufSizeALMS + SoundBufSize;
} // end to: if(espec->SoundBuf && espec->SoundBufSize) } // end to: if(espec->SoundBuf && espec->SoundBufSize)
} }
#else
static void ProcessAudio(EmulateSpecStruct *espec)
{
if(espec->SoundBuf && espec->SoundBufSize)
{
int16 *const SoundBuf = espec->SoundBuf + espec->SoundBufSizeALMS * MDFNGameInfo->soundchan;
int32 SoundBufSize = espec->SoundBufSize - espec->SoundBufSizeALMS;
const int32 SoundBufMaxSize = espec->SoundBufMaxSize - espec->SoundBufSizeALMS;
espec->SoundBufSize = espec->SoundBufSizeALMS + SoundBufSize;
} // end to: if(espec->SoundBuf && espec->SoundBufSize)
}
#endif
#ifndef HEADLESS #ifndef HEADLESS
void MDFN_MidSync(EmulateSpecStruct *espec) void MDFN_MidSync(EmulateSpecStruct *espec)
@ -1377,8 +1396,10 @@ void MDFN_MidSync(EmulateSpecStruct *espec)
void MDFNI_Emulate(EmulateSpecStruct *espec) void MDFNI_Emulate(EmulateSpecStruct *espec)
{ {
#ifdef WANT_RESAMPLER
multiplier_save = 1; multiplier_save = 1;
volume_save = 1; volume_save = 1;
#endif
// Initialize some espec member data to zero, to catch some types of bugs. // Initialize some espec member data to zero, to catch some types of bugs.
espec->DisplayRect.x = 0; espec->DisplayRect.x = 0;
@ -1405,7 +1426,9 @@ void MDFNI_Emulate(EmulateSpecStruct *espec)
espec->SoundFormatChanged = true; espec->SoundFormatChanged = true;
last_sound_rate = espec->SoundRate; last_sound_rate = espec->SoundRate;
#ifdef WANT_RESAMPLER
ff_resampler.buffer_size((espec->SoundRate / 2) * 2); ff_resampler.buffer_size((espec->SoundRate / 2) * 2);
#endif
} }
#ifdef WANT_AVDUMP #ifdef WANT_AVDUMP