Commit d7c26374 authored by bbbradsmith's avatar bbbradsmith
Browse files

Much nicer sounding alternative to Hatari's strange polarized lowpass filter

parent f605173e
......@@ -60,6 +60,7 @@ unsigned int video_config = 0;
int CHANGE_RATE = 0, CHANGEAV_TIMING = 0;
float FRAMERATE = 50.0, SAMPLERATE = 44100.0;
extern bool UseNonPolarizedLowPassFilter;
bool hatari_fastfdc = true;
bool hatari_borders = true;
char hatari_frameskips[2];
......@@ -115,6 +116,18 @@ void retro_set_environment(retro_environment_t cb)
},
"true"
},
// Audio
{
"hatari_polarized_filter",
"Polarized audio filter",
"Uses hatari's polarized lowpass filters on audio to simulate distortion",
{
{ "false", "disabled" },
{ "true", "enabled" },
{ NULL, NULL },
},
"false"
},
// Video
{
"hatari_video_hires",
......@@ -212,6 +225,16 @@ static void update_variables(void)
ConfigureParams.DiskImage.FastFloppy = hatari_fastfdc;
}
// Audio
var.key = "hatari_polarized_filter";
var.value = NULL;
UseNonPolarizedLowPassFilter = true;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
if(strcmp(var.value, "true") == 0)
UseNonPolarizedLowPassFilter = false;
}
// Video
var.key = "hatari_video_hires";
var.value = NULL;
......
......@@ -221,6 +221,9 @@ Uint8 SoundRegs[ 14 ];
int YmVolumeMixing = YM_TABLE_MIXING;
bool UseLowPassFilter = false;
#ifdef __LIBRETRO__
bool UseNonPolarizedLowPassFilter = true;
#endif
bool bEnvelopeFreqFlag; /* Cleared each frame for YM saving */
......@@ -381,7 +384,18 @@ static ymsample PWMaliasFilter(ymsample x0)
return y0;
}
#ifdef __LIBRETRO__
// A more "normal" alternative to the lowpass filters above,
// which affects rising and falling waves the same way rather than unequally.
// Removes a lot of unpleasant distortion.
static ymsample NonPolarizedLowPassFilter(ymsample x0)
{
static yms32 y0 = 0, x1 = 0;
y0 = (3*(x0 + x1) + (y0<<1)) >> 3;
x1 = x0;
return y0;
}
#endif
/*--------------------------------------------------------------*/
/* Build the volume conversion table used to simulate the */
......@@ -972,6 +986,11 @@ static ymsample YM2149_NextSample(void)
if ( envPos >= (3*32) << 24 ) /* blocks 0, 1 and 2 were used (envPos 0 to 95) */
envPos -= (2*32) << 24; /* replay/loop blocks 1 and 2 (envPos 32 to 95) */
#ifdef __LIBRETRO__
if ( UseNonPolarizedLowPassFilter )
return NonPolarizedLowPassFilter(sample);
#endif
/* Apply low pass filter ? */
if ( UseLowPassFilter )
return LowPassFilter(sample);
......@@ -1041,6 +1060,11 @@ static ymsample YM2149_NextSample(void)
if ( envPos >= (3*32) << 24 ) /* blocks 0, 1 and 2 were used (envPos 0 to 95) */
envPos -= (2*32) << 24; /* replay/loop blocks 1 and 2 (envPos 32 to 95) */
#ifdef __LIBRETRO__
if ( UseNonPolarizedLowPassFilter )
return NonPolarizedLowPassFilter(sample);
#endif
/* Apply low pass filter ? */
if ( UseLowPassFilter )
return LowPassFilter(sample);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment