sound, add FM filtering

This commit is contained in:
kub 2022-04-14 17:32:40 +00:00
parent 21e0cd52e6
commit 68a950875c
13 changed files with 73 additions and 854 deletions

View file

@ -122,8 +122,7 @@ SRCS_COMMON += $(R)pico/carthw/svp/stub_arm.S
SRCS_COMMON += $(R)pico/carthw/svp/compiler.c
endif
# sound
SRCS_COMMON += $(R)pico/sound/sound.c
SRCS_COMMON += $(R)pico/sound/resampler.c # $(R)pico/sound/blipper.c
SRCS_COMMON += $(R)pico/sound/sound.c $(R)pico/sound/resampler.c
SRCS_COMMON += $(R)pico/sound/sn76496.c $(R)pico/sound/ym2612.c
SRCS_COMMON += $(R)pico/sound/emu2413/emu2413.c
ifneq "$(ARCH)$(asm_mix)" "arm1"

View file

@ -275,7 +275,7 @@ static int custom_read(menu_entry *me, const char *var, const char *val)
case MA_OPT_SOUND_QUALITY:
if (strcasecmp(var, "Sound Quality") != 0) return 0;
PicoIn.sndRate = strtoul(val, &tmp, 10);
if (PicoIn.sndRate < 8000 || PicoIn.sndRate > 53267) {
if (PicoIn.sndRate < 8000 || PicoIn.sndRate > 54000) {
if (strncasecmp(tmp, "native", 6) == 0) {
tmp += 6;
PicoIn.sndRate = 53000;

View file

@ -57,7 +57,7 @@ int pico_inp_mode;
int flip_after_sync;
int engineState = PGS_Menu;
static short __attribute__((aligned(4))) sndBuffer[2*53267/50];
static short __attribute__((aligned(4))) sndBuffer[2*54000/50];
/* tmp buff to reduce stack usage for plats with small stack */
static char static_buff[512];

View file

@ -446,9 +446,13 @@ static int menu_loop_keyconfig(int id, int keys)
// ------------ MD options menu ------------
static const char h_fmfilter[] = "improves sound quality but is noticeably slower\n"
"best option if native rate isn't working";
static menu_entry e_menu_md_options[] =
{
mee_enum ("Renderer", MA_OPT_RENDERER, currentConfig.renderer, renderer_names),
mee_onoff_h ("FM filtering", MA_OPT_FM_FILTER, PicoIn.opt, POPT_EN_FM_FILTER, h_fmfilter),
mee_end,
};
@ -618,23 +622,24 @@ static int menu_loop_adv_options(int id, int keys)
static int sndrate_prevnext(int rate, int dir)
{
static const int rates[] = { 8000, 11025, 16000, 22050, 44100, 53000 };
int rate_count = sizeof(rates)/sizeof(rates[0]);
int i;
for (i = 0; i < 6; i++)
for (i = 0; i < rate_count; i++)
if (rates[i] == rate) break;
i += dir ? 1 : -1;
if (i > 5) {
if (i >= rate_count) {
if (!(PicoIn.opt & POPT_EN_STEREO)) {
PicoIn.opt |= POPT_EN_STEREO;
return rates[0];
}
return rates[5];
return rates[rate_count-1];
}
if (i < 0) {
if (PicoIn.opt & POPT_EN_STEREO) {
PicoIn.opt &= ~POPT_EN_STEREO;
return rates[5];
return rates[rate_count-1];
}
return rates[0];
}
@ -676,8 +681,8 @@ static const char *mgn_opt_alpha(int id, int *offs)
return static_buff;
}
static const char h_quality[] = "native is the FM sound chip rate (53267/52781 Hz),\n"
"select this for the best FM sound quality";
static const char h_quality[] = "native is the Megadrive sound chip rate (~53000),\n"
"best quality, but might not work on some devices";
static const char h_lowpass[] = "Low pass filter for sound closer to real hardware";
static menu_entry e_menu_snd_options[] =

View file

@ -44,6 +44,7 @@ typedef enum
MA_OPT_AUTOLOAD_SAVE,
MA_OPT_SOUND_FILTER,
MA_OPT_SOUND_ALPHA,
MA_OPT_FM_FILTER,
MA_OPT2_GAMMA,
MA_OPT2_A_SN_GAMMA,
MA_OPT2_DBLBUFF, /* giz */