mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
sound, add FM filtering
This commit is contained in:
parent
21e0cd52e6
commit
68a950875c
13 changed files with 73 additions and 854 deletions
|
@ -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"
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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[] =
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -1640,6 +1640,15 @@ static void update_variables(bool first_run)
|
|||
PicoIn.opt &= ~POPT_EN_FM_DAC;
|
||||
}
|
||||
|
||||
var.value = NULL;
|
||||
var.key = "picodrive_fm_filter";
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
|
||||
if (strcmp(var.value, "on") == 0)
|
||||
PicoIn.opt |= POPT_EN_FM_FILTER;
|
||||
else
|
||||
PicoIn.opt &= ~POPT_EN_FM_FILTER;
|
||||
}
|
||||
|
||||
old_snd_filter = PicoIn.opt & POPT_EN_SNDFILTER;
|
||||
var.value = NULL;
|
||||
var.key = "picodrive_audio_filter";
|
||||
|
|
|
@ -207,7 +207,7 @@ struct retro_core_option_v2_definition option_defs_us[] = {
|
|||
"picodrive_sound_rate",
|
||||
"Audio Sample Rate (Hz)",
|
||||
"Sample Rate (Hz)",
|
||||
"Higher values increase sound quality. Lower values may increase performance. Native is the FM sound chip rate, either 53267 Hz for NTSC or 52781 Hz for PAL. Select this if you want the most accurate audio.",
|
||||
"Higher values increase sound quality. Lower values may increase performance. Native is the Megadrive sound chip rate (~53000). Select this if you want the most accurate audio.",
|
||||
NULL,
|
||||
"audio",
|
||||
{
|
||||
|
@ -220,6 +220,20 @@ struct retro_core_option_v2_definition option_defs_us[] = {
|
|||
},
|
||||
"44100"
|
||||
},
|
||||
{
|
||||
"picodrive_fm_filter",
|
||||
"FM filtering",
|
||||
NULL,
|
||||
"Enable filtering for Mega Drive FM sound at non-native bitrates. Sound output will improve, at the price of being noticeably slower",
|
||||
NULL,
|
||||
"audio",
|
||||
{
|
||||
{ "off", "disabled" },
|
||||
{ "on", "enabled" },
|
||||
{ NULL, NULL },
|
||||
},
|
||||
"off"
|
||||
},
|
||||
{
|
||||
"picodrive_smsfm",
|
||||
"Master System FM Sound Unit",
|
||||
|
|
|
@ -398,7 +398,7 @@ static void vidResetMode(void)
|
|||
#define SOUND_BLOCK_SIZE_PAL (1764*2)
|
||||
#define SOUND_BLOCK_COUNT 8
|
||||
|
||||
static short __attribute__((aligned(4))) sndBuffer[SOUND_BLOCK_SIZE_PAL*SOUND_BLOCK_COUNT + 44100/50*2];
|
||||
static short __attribute__((aligned(4))) sndBuffer[SOUND_BLOCK_SIZE_PAL*SOUND_BLOCK_COUNT + 54000/50*2];
|
||||
static short *snd_playptr = NULL, *sndBuffer_endptr = NULL;
|
||||
static int samples_made = 0, samples_done = 0, samples_block = 0;
|
||||
static int sound_thread_exit = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue