mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-04 23:07:46 -04:00
Merge from libretro/master:46902e0 for repo synchronization
This commit is contained in:
parent
9d1ecde692
commit
61d76999d7
74 changed files with 14043 additions and 2094 deletions
|
@ -26,6 +26,73 @@ short cdda_out_buffer[2*1152];
|
|||
// sn76496
|
||||
extern int *sn76496_regs;
|
||||
|
||||
// Low pass filter 'previous' samples
|
||||
static int32_t lpf_lp;
|
||||
static int32_t lpf_rp;
|
||||
|
||||
static void low_pass_filter_stereo(int *buf32, int length)
|
||||
{
|
||||
int samples = length;
|
||||
int *out32 = buf32;
|
||||
// Restore previous samples
|
||||
int32_t lpf_l = lpf_lp;
|
||||
int32_t lpf_r = lpf_rp;
|
||||
|
||||
// Single-pole low-pass filter (6 dB/octave)
|
||||
int32_t factor_a = PicoIn.sndFilterRange;
|
||||
int32_t factor_b = 0x10000 - factor_a;
|
||||
|
||||
do
|
||||
{
|
||||
// Apply low-pass filter
|
||||
lpf_l = (lpf_l * factor_a) + (out32[0] * factor_b);
|
||||
lpf_r = (lpf_r * factor_a) + (out32[1] * factor_b);
|
||||
|
||||
// 16.16 fixed point
|
||||
lpf_l >>= 16;
|
||||
lpf_r >>= 16;
|
||||
|
||||
// Update sound buffer
|
||||
*out32++ = lpf_l;
|
||||
*out32++ = lpf_r;
|
||||
}
|
||||
while (--samples);
|
||||
|
||||
// Save last samples for next frame
|
||||
lpf_lp = lpf_l;
|
||||
lpf_rp = lpf_r;
|
||||
}
|
||||
|
||||
static void low_pass_filter_mono(int *buf32, int length)
|
||||
{
|
||||
int samples = length;
|
||||
int *out32 = buf32;
|
||||
// Restore previous sample
|
||||
int32_t lpf_l = lpf_lp;
|
||||
|
||||
// Single-pole low-pass filter (6 dB/octave)
|
||||
int32_t factor_a = PicoIn.sndFilterRange;
|
||||
int32_t factor_b = 0x10000 - factor_a;
|
||||
|
||||
do
|
||||
{
|
||||
// Apply low-pass filter
|
||||
lpf_l = (lpf_l * factor_a) + (out32[0] * factor_b);
|
||||
|
||||
// 16.16 fixed point
|
||||
lpf_l >>= 16;
|
||||
|
||||
// Update sound buffer
|
||||
*out32++ = lpf_l;
|
||||
}
|
||||
while (--samples);
|
||||
|
||||
// Save last sample for next frame
|
||||
lpf_lp = lpf_l;
|
||||
}
|
||||
|
||||
void (*low_pass_filter)(int *buf32, int length) = low_pass_filter_stereo;
|
||||
|
||||
// ym2413
|
||||
#define YM2413_CLK 3579545
|
||||
OPLL old_opll;
|
||||
|
@ -51,6 +118,11 @@ PICO_INTERNAL void PsndReset(void)
|
|||
// PsndRerate calls YM2612Init, which also resets
|
||||
PsndRerate(0);
|
||||
timers_reset();
|
||||
|
||||
// Reset low pass filter
|
||||
lpf_lp = 0;
|
||||
lpf_rp = 0;
|
||||
|
||||
mix_reset();
|
||||
}
|
||||
|
||||
|
@ -107,6 +179,9 @@ void PsndRerate(int preserve_state)
|
|||
// set mixer
|
||||
PsndMix_32_to_16l = (PicoIn.opt & POPT_EN_STEREO) ? mix_32_to_16l_stereo : mix_32_to_16_mono;
|
||||
|
||||
// set low pass filter
|
||||
low_pass_filter = (PicoIn.opt & POPT_EN_STEREO) ? low_pass_filter_stereo : low_pass_filter_mono;
|
||||
|
||||
if (PicoIn.AHW & PAHW_PICO)
|
||||
PicoReratePico();
|
||||
}
|
||||
|
@ -388,6 +463,11 @@ static int PsndRender(int offset, int length)
|
|||
if ((PicoIn.AHW & PAHW_32X) && (PicoIn.opt & POPT_EN_PWM))
|
||||
p32x_pwm_update(buf32, length-offset, stereo);
|
||||
|
||||
// Apply low pass filter, if required
|
||||
if (PicoIn.sndFilter == 1) {
|
||||
low_pass_filter(buf32, length);
|
||||
}
|
||||
|
||||
// convert + limit to normal 16bit output
|
||||
PsndMix_32_to_16l(PicoIn.sndOut+(offset<<stereo), buf32, length-offset);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue