mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 07:17:45 -04:00
sound, add native rate mode, change resampling
This commit is contained in:
parent
d26d4c2965
commit
882f697ad4
11 changed files with 90 additions and 167 deletions
|
@ -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 > 44100)
|
||||
if (PicoIn.sndRate < 8000 || PicoIn.sndRate > 53267)
|
||||
PicoIn.sndRate = 22050;
|
||||
if (*tmp == 'H' || *tmp == 'h') tmp++;
|
||||
if (*tmp == 'Z' || *tmp == 'z') tmp++;
|
||||
|
|
|
@ -57,7 +57,7 @@ int pico_inp_mode;
|
|||
int flip_after_sync;
|
||||
int engineState = PGS_Menu;
|
||||
|
||||
static short __attribute__((aligned(4))) sndBuffer[2*44100/50];
|
||||
static short __attribute__((aligned(4))) sndBuffer[2*53267/50];
|
||||
|
||||
/* tmp buff to reduce stack usage for plats with small stack */
|
||||
static char static_buff[512];
|
||||
|
@ -1328,6 +1328,9 @@ void emu_sound_start(void)
|
|||
{
|
||||
PicoIn.sndOut = NULL;
|
||||
|
||||
// auto-select rate?
|
||||
if (PicoIn.sndRate > 52000)
|
||||
PicoIn.sndRate = YM2612_NATIVE_RATE();
|
||||
if (currentConfig.EmuOpt & EOPT_EN_SOUND)
|
||||
{
|
||||
int is_stereo = (PicoIn.opt & POPT_EN_STEREO) ? 1 : 0;
|
||||
|
|
|
@ -595,24 +595,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 };
|
||||
static const int rates[] = { 8000, 11025, 16000, 22050, 44100, 53000 };
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 5; i++)
|
||||
for (i = 0; i < 6; i++)
|
||||
if (rates[i] == rate) break;
|
||||
|
||||
i += dir ? 1 : -1;
|
||||
if (i > 4) {
|
||||
if (i > 5) {
|
||||
if (!(PicoIn.opt & POPT_EN_STEREO)) {
|
||||
PicoIn.opt |= POPT_EN_STEREO;
|
||||
return rates[0];
|
||||
}
|
||||
return rates[4];
|
||||
return rates[5];
|
||||
}
|
||||
if (i < 0) {
|
||||
if (PicoIn.opt & POPT_EN_STEREO) {
|
||||
PicoIn.opt &= ~POPT_EN_STEREO;
|
||||
return rates[4];
|
||||
return rates[5];
|
||||
}
|
||||
return rates[0];
|
||||
}
|
||||
|
@ -630,7 +630,9 @@ static const char *mgn_opt_sound(int id, int *offs)
|
|||
const char *str2;
|
||||
*offs = -8;
|
||||
str2 = (PicoIn.opt & POPT_EN_STEREO) ? "stereo" : "mono";
|
||||
sprintf(static_buff, "%5iHz %s", PicoIn.sndRate, str2);
|
||||
if (PicoIn.sndRate > 52000)
|
||||
sprintf(static_buff, "native %s\n", str2);
|
||||
else sprintf(static_buff, "%5iHz %s", PicoIn.sndRate, str2);
|
||||
return static_buff;
|
||||
}
|
||||
|
||||
|
@ -652,12 +654,14 @@ 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_lowpass[] = "Low pass filter for sound closer to real hardware";
|
||||
|
||||
static menu_entry e_menu_snd_options[] =
|
||||
{
|
||||
mee_onoff ("Enable sound", MA_OPT_ENABLE_SOUND, currentConfig.EmuOpt, EOPT_EN_SOUND),
|
||||
mee_cust ("Sound Quality", MA_OPT_SOUND_QUALITY, mh_opt_snd, mgn_opt_sound),
|
||||
mee_cust_h ("Sound Quality", MA_OPT_SOUND_QUALITY, mh_opt_snd, mgn_opt_sound, h_quality),
|
||||
mee_onoff_h ("Sound filter", MA_OPT_SOUND_FILTER, PicoIn.opt, POPT_EN_SNDFILTER, h_lowpass),
|
||||
mee_cust ("Filter strength", MA_OPT_SOUND_ALPHA, mh_opt_alpha, mgn_opt_alpha),
|
||||
mee_end,
|
||||
|
@ -667,6 +671,8 @@ static int menu_loop_snd_options(int id, int keys)
|
|||
{
|
||||
static int sel = 0;
|
||||
|
||||
if (PicoIn.sndRate > 52000)
|
||||
PicoIn.sndRate = 53000;
|
||||
me_loop(e_menu_snd_options, &sel);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -731,7 +731,7 @@ void pemu_sound_start(void)
|
|||
}
|
||||
}
|
||||
|
||||
static const int sound_rates[] = { 44100, 32000, 22050, 16000, 11025, 8000 };
|
||||
static const int sound_rates[] = { 53000, 44100, 32000, 22050, 16000, 11025, 8000 };
|
||||
|
||||
void pemu_sound_stop(void)
|
||||
{
|
||||
|
|
|
@ -1316,6 +1316,8 @@ bool retro_load_game(const struct retro_game_info *info)
|
|||
PicoIn.writeSound = snd_write;
|
||||
memset(sndBuffer, 0, sizeof(sndBuffer));
|
||||
PicoIn.sndOut = sndBuffer;
|
||||
if (PicoIn.sndRate > 52000)
|
||||
PicoIn.sndRate = YM2612_NATIVE_RATE();
|
||||
PsndRerate(0);
|
||||
|
||||
apply_renderer();
|
||||
|
@ -1566,7 +1568,9 @@ static void update_variables(bool first_run)
|
|||
{
|
||||
PicoDetectRegion();
|
||||
PicoLoopPrepare();
|
||||
PsndRerate(1);
|
||||
if (PicoIn.sndRate > 52000)
|
||||
PicoIn.sndRate = YM2612_NATIVE_RATE();
|
||||
PsndRerate(!first_run);
|
||||
}
|
||||
|
||||
old_vout_aspect = vout_aspect;
|
||||
|
@ -1687,10 +1691,12 @@ static void update_variables(bool first_run)
|
|||
var.key = "picodrive_sound_rate";
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
|
||||
new_sound_rate = atoi(var.value);
|
||||
if (!strcmp(var.value, "native"))
|
||||
new_sound_rate = YM2612_NATIVE_RATE();
|
||||
if (new_sound_rate != PicoIn.sndRate) {
|
||||
/* Update the sound rate */
|
||||
PicoIn.sndRate = new_sound_rate;
|
||||
PsndRerate(1);
|
||||
PsndRerate(!first_run);
|
||||
struct retro_system_av_info av_info;
|
||||
retro_get_system_av_info(&av_info);
|
||||
environ_cb(RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO, &av_info);
|
||||
|
|
|
@ -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.",
|
||||
"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.",
|
||||
NULL,
|
||||
"audio",
|
||||
{
|
||||
|
@ -215,6 +215,7 @@ struct retro_core_option_v2_definition option_defs_us[] = {
|
|||
{ "22050", NULL },
|
||||
{ "32000", NULL },
|
||||
{ "44100", NULL },
|
||||
{ "native", NULL },
|
||||
{ NULL, NULL },
|
||||
},
|
||||
"44100"
|
||||
|
|
|
@ -487,6 +487,8 @@ void pemu_sound_start(void)
|
|||
}
|
||||
}
|
||||
|
||||
if (PicoIn.sndRate > 52000)
|
||||
PicoIn.sndRate = YM2612_NATIVE_RATE();
|
||||
ret = POPT_EN_FM|POPT_EN_PSG|POPT_EN_STEREO;
|
||||
if (PicoIn.sndRate != PsndRate_old || (PicoIn.opt&ret) != (PicoOpt_old&ret) || Pico.m.pal != pal_old) {
|
||||
PsndRerate(Pico.m.frame_count ? 1 : 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue