added configurable lowpass filter

This commit is contained in:
ekeeke31 2009-08-11 08:18:46 +00:00
parent c0179e7ed4
commit 8834abaa74
8 changed files with 96 additions and 60 deletions

View File

@ -21,9 +21,8 @@
#include "shared.h" #include "shared.h"
#define TYPE_AR 0x01 #define TYPE_PRO1 0x12
#define TYPE_PRO1 0x02 #define TYPE_PRO2 0x22
#define TYPE_PRO2 0x03
static struct static struct
{ {

View File

@ -71,6 +71,7 @@ void config_default(void)
config.hq_fm = 1; config.hq_fm = 1;
config.psgBoostNoise = 0; config.psgBoostNoise = 0;
config.filter = 1; config.filter = 1;
config.lp_range = 50;
config.low_freq = 880; config.low_freq = 880;
config.high_freq = 5000; config.high_freq = 5000;
config.lg = 1.0; config.lg = 1.0;

View File

@ -36,8 +36,9 @@ typedef struct
int32 psg_preamp; int32 psg_preamp;
int32 fm_preamp; int32 fm_preamp;
uint8 filter; uint8 filter;
uint16 low_freq; int16 lp_range;
uint16 high_freq; int16 low_freq;
int16 high_freq;
float lg; float lg;
float mg; float mg;
float hg; float hg;

View File

@ -36,7 +36,6 @@
void legal () void legal ()
{ {
int ypos = 56; int ypos = 56;
gxClearScreen((GXColor)BLACK); gxClearScreen((GXColor)BLACK);
FONT_writeCenter ("DISCLAIMER",22,0,640,ypos,(GXColor)WHITE); FONT_writeCenter ("DISCLAIMER",22,0,640,ypos,(GXColor)WHITE);

View File

@ -224,11 +224,11 @@ static gui_item items_audio[10] =
{NULL,NULL,"PSG Volume: 2.50", "Adjust SN76489 output level", 52,132,276,48}, {NULL,NULL,"PSG Volume: 2.50", "Adjust SN76489 output level", 52,132,276,48},
{NULL,NULL,"FM Volume: 1.00", "Adjust YM2612 output level", 52,132,276,48}, {NULL,NULL,"FM Volume: 1.00", "Adjust YM2612 output level", 52,132,276,48},
{NULL,NULL,"Filtering: 3-BAND EQ", "Setup Audio filtering", 52,132,276,48}, {NULL,NULL,"Filtering: 3-BAND EQ", "Setup Audio filtering", 52,132,276,48},
{NULL,NULL,"Low Freq: 200 Hz", "Adjust EQ Low Band Frequency", 52,132,276,48},
{NULL,NULL,"High Freq: 20000 Hz","Adjust EQ High Band Frequency",52,132,276,48},
{NULL,NULL,"Low Gain: 1.00", "Adjust EQ Low Band Gain", 52,132,276,48}, {NULL,NULL,"Low Gain: 1.00", "Adjust EQ Low Band Gain", 52,132,276,48},
{NULL,NULL,"Middle Gain: 1.00", "Adjust EQ Middle Band Gain", 52,132,276,48}, {NULL,NULL,"Mid Gain: 1.00", "Adjust EQ Middle Band Gain", 52,132,276,48},
{NULL,NULL,"High Gain: 1.00", "Adjust EQ High BandGain", 52,132,276,48}, {NULL,NULL,"High Gain: 1.00", "Adjust EQ High BandGain", 52,132,276,48},
{NULL,NULL,"Low Freq: 200 Hz", "Adjust EQ Low Band Frequency", 52,132,276,48},
{NULL,NULL,"High Freq: 20000 Hz", "Adjust EQ High Band Frequency",52,132,276,48}
}; };
/* System options menu */ /* System options menu */
@ -700,8 +700,8 @@ static void soundmenu ()
int ret, quit = 0; int ret, quit = 0;
gui_menu *m = &menu_audio; gui_menu *m = &menu_audio;
gui_item *items = m->items; gui_item *items = m->items;
float psg_volume = (double)config.psg_preamp/100.0; float psg_volume = (float)config.psg_preamp/100.0;
float fm_volume = (double)config.fm_preamp/100.0; float fm_volume = (float)config.fm_preamp/100.0;
sprintf (items[0].text, "High-Quality FM: %s", config.hq_fm ? "ON":"OFF"); sprintf (items[0].text, "High-Quality FM: %s", config.hq_fm ? "ON":"OFF");
sprintf (items[1].text, "PSG Noise Boost: %s", config.psgBoostNoise ? "ON":"OFF"); sprintf (items[1].text, "PSG Noise Boost: %s", config.psgBoostNoise ? "ON":"OFF");
@ -710,18 +710,29 @@ static void soundmenu ()
if (config.filter == 2) sprintf (items[4].text, "Filtering: 3-BAND EQ"); if (config.filter == 2) sprintf (items[4].text, "Filtering: 3-BAND EQ");
else if (config.filter == 1) sprintf (items[4].text, "Filtering: LOW PASS"); else if (config.filter == 1) sprintf (items[4].text, "Filtering: LOW PASS");
else sprintf (items[4].text, "Filtering: OFF"); else sprintf (items[4].text, "Filtering: OFF");
sprintf (items[5].text, "Low Freq: %d", config.low_freq); if (config.filter == 2)
sprintf (items[6].text, "High Freq: %d", config.high_freq); {
sprintf (items[7].text, "Low Gain: %1.2f", config.lg); sprintf (items[5].text, "Low Gain: %1.2f", config.lg);
sprintf (items[8].text, "Middle Gain: %1.2f", config.mg); strcpy (items[5].comment, "Adjust EQ Low Band Gain");
sprintf (items[9].text, "High Gain: %1.2f", config.hg); sprintf (items[6].text, "Middle Gain: %1.2f", config.mg);
sprintf (items[7].text, "High Gain: %1.2f", config.hg);
sprintf (items[8].text, "Low Freq: %d", config.low_freq);
sprintf (items[9].text, "High Freq: %d", config.high_freq);
}
else if (config.filter == 1)
{
sprintf (items[5].text, "Low-Pass Rate: %d %%", config.lp_range);
strcpy (items[5].comment, "Adjust Low Pass filter");
}
GUI_InitMenu(m); GUI_InitMenu(m);
if (config.filter < 2) if (config.filter == 1)
m->max_items = 5; m->max_items = 6;
else else if (config.filter == 2)
m->max_items = 10; m->max_items = 10;
else
m->max_items = 5;
GUI_SlideMenuTitle(m,strlen("Audio ")); GUI_SlideMenuTitle(m,strlen("Audio "));
@ -761,7 +772,7 @@ static void soundmenu ()
case 3: case 3:
GUI_OptionBox(m,0,"FM Volume",(void *)&fm_volume,0.01,0.0,5.0,0); GUI_OptionBox(m,0,"FM Volume",(void *)&fm_volume,0.01,0.0,5.0,0);
sprintf (items[3].text, "FM Volume: %1.2f", (double)config.fm_preamp/100.0); sprintf (items[3].text, "FM Volume: %1.2f", fm_volume);
config.fm_preamp = (int)(fm_volume * 100.0); config.fm_preamp = (int)(fm_volume * 100.0);
break; break;
@ -769,56 +780,71 @@ static void soundmenu ()
config.filter ++; config.filter ++;
if (config.filter > 2) config.filter = 0; if (config.filter > 2) config.filter = 0;
if (config.filter == 2) if (config.filter == 2)
sprintf (items[4].text, "Filtering: 3-BAND EQ");
else if (config.filter == 1)
sprintf (items[4].text, "Filtering: LOW PASS");
else
sprintf (items[4].text, "Filtering: OFF");
if (config.filter < 2)
{ {
/* reset menu selection */ m->max_items = 10;
m->offset = 1; sprintf (items[4].text, "Filtering: 3-BAND EQ");
m->selected = 3; sprintf (items[5].text, "Low Gain: %1.2f", config.lg);
m->max_items = 5; strcpy (items[5].comment, "Adjust EQ Low Band Gain");
sprintf (items[6].text, "Middle Gain: %1.2f", config.mg);
sprintf (items[7].text, "High Gain: %1.2f", config.hg);
sprintf (items[8].text, "Low Freq: %d", config.low_freq);
sprintf (items[9].text, "High Freq: %d", config.high_freq);
}
else if (config.filter == 1)
{
m->max_items = 6;
sprintf (items[4].text, "Filtering: LOW PASS");
sprintf (items[5].text, "Low-Pass Rate: %d %%", config.lp_range);
strcpy (items[5].comment, "Adjust Low Pass filter");
} }
else else
{ {
/* enable items */ sprintf (items[4].text, "Filtering: OFF");
m->max_items = 10; m->max_items = 5;
m->offset = 1;
m->selected = 3;
}
/* intialize EQ */ /* reintialize EQ */
audio_set_equalizer();
break;
case 5:
if (config.filter == 1)
{
GUI_OptionBox(m,0,"Low-Pass Rate",(void *)&config.lp_range,1,0,100,1);
sprintf (items[5].text, "Low-Pass Rate: %d %%", config.lp_range);
}
else
{
GUI_OptionBox(m,0,"Low Gain",(void *)&config.lg,0.01,0.0,2.0,0);
sprintf (items[5].text, "Low Gain: %1.2f", config.lg);
audio_set_equalizer(); audio_set_equalizer();
} }
break; break;
case 5:
GUI_OptionBox(m,0,"Low Frequency",(void *)&config.low_freq,10,0,config.high_freq,1);
sprintf (items[5].text, "Low Freq: %d", config.low_freq);
audio_set_equalizer();
break;
case 6: case 6:
GUI_OptionBox(m,0,"High Frequency",(void *)&config.high_freq,100,config.low_freq,30000,1); GUI_OptionBox(m,0,"Middle Gain",(void *)&config.mg,0.01,0.0,2.0,0);
sprintf (items[6].text, "High Freq: %d", config.high_freq); sprintf (items[6].text, "Middle Gain: %1.2f", config.mg);
audio_set_equalizer(); audio_set_equalizer();
break; break;
case 7: case 7:
GUI_OptionBox(m,0,"Low Gain",(void *)&config.lg,0.01,0.0,2.0,0); GUI_OptionBox(m,0,"High Gain",(void *)&config.hg,0.01,0.0,2.0,0);
sprintf (items[7].text, "Low Gain: %1.2f", config.lg); sprintf (items[7].text, "High Gain: %1.2f", config.hg);
audio_set_equalizer(); audio_set_equalizer();
break; break;
case 8: case 8:
GUI_OptionBox(m,0,"Middle Gain",(void *)&config.mg,0.01,0.0,2.0,0); GUI_OptionBox(m,0,"Low Frequency",(void *)&config.low_freq,10,0,config.high_freq,1);
sprintf (items[8].text, "Middle Gain: %1.2f", config.mg); sprintf (items[8].text, "Low Freq: %d", config.low_freq);
audio_set_equalizer(); audio_set_equalizer();
break; break;
case 9: case 9:
GUI_OptionBox(m,0,"High Gain",(void *)&config.hg,0.01,0.0,2.0,0); GUI_OptionBox(m,0,"High Frequency",(void *)&config.high_freq,100,config.low_freq,30000,1);
sprintf (items[9].text, "High Gain: %1.2f", config.hg); sprintf (items[9].text, "High Freq: %d", config.high_freq);
audio_set_equalizer(); audio_set_equalizer();
break; break;

View File

@ -33,9 +33,9 @@
#define SK_UPMEM "/genplus/sk2chip.bin" #define SK_UPMEM "/genplus/sk2chip.bin"
#ifdef HW_RVL #ifdef HW_RVL
#define VERSION "version 1.4.0W" #define VERSION "version 1.3.XW"
#else #else
#define VERSION "version 1.4.0G" #define VERSION "version 1.3.XG"
#endif #endif
/* globals */ /* globals */

View File

@ -54,14 +54,19 @@ void audio_set_equalizer(void)
/**************************************************************** /****************************************************************
* AUDIO stream update * AUDIO stream update
****************************************************************/ ****************************************************************/
static int ll, rr; static int llp,rrp;
void audio_update (int size) void audio_update (int size)
{ {
int i; int i, l, r;
int l, r; int ll = llp;
int psg_preamp = config.psg_preamp; int rr = rrp;
int fm_preamp = config.fm_preamp;
int filter = config.filter; int psg_preamp = config.psg_preamp;
int fm_preamp = config.fm_preamp;
int filter = config.filter;
uint32 factora = (config.lp_range << 16) / 100;
uint32 factorb = 0x10000 - factora;
int16 *fm[2] = {snd.fm.buffer[0],snd.fm.buffer[1]}; int16 *fm[2] = {snd.fm.buffer[0],snd.fm.buffer[1]};
int16 *psg = snd.psg.buffer; int16 *psg = snd.psg.buffer;
@ -97,10 +102,10 @@ void audio_update (int size)
if (filter & 1) if (filter & 1)
{ {
/* single-pole low-pass filter (6 dB/octave) */ /* single-pole low-pass filter (6 dB/octave) */
l = (ll + l) >> 1; ll = (ll>>16)*factorb + l*factora;
r = (rr + r) >> 1; rr = (rr>>16)*factorb + r*factora;
ll = l; l = ll >> 16;
rr = r; r = rr >> 16;
} }
else if (filter & 2) else if (filter & 2)
{ {
@ -124,6 +129,10 @@ void audio_update (int size)
*sb++ = l; *sb++ = l;
#endif #endif
} }
/* save delayed samples */
llp = ll;
rrp = rr;
} }
/**************************************************************** /****************************************************************

View File

@ -85,6 +85,7 @@ extern uint32 count_z80;
extern uint32 line_z80; extern uint32 line_z80;
extern int32 current_z80; extern int32 current_z80;
extern uint8 system_hw; extern uint8 system_hw;
extern uint32 count_z80;
/* Function prototypes */ /* Function prototypes */
extern int audio_init (int rate); extern int audio_init (int rate);