forked from len0rd/rockbox
Added Balance setting
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1744 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
bfe55a4a09
commit
b3bda03db0
6 changed files with 69 additions and 37 deletions
|
|
@ -152,6 +152,7 @@ void init(void)
|
|||
mpeg_init( global_settings.volume,
|
||||
global_settings.bass,
|
||||
global_settings.treble,
|
||||
global_settings.balance,
|
||||
global_settings.loudness,
|
||||
global_settings.bass_boost,
|
||||
global_settings.avc );
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ struct user_settings global_settings;
|
|||
|
||||
static unsigned short last_checksum = 0;
|
||||
|
||||
#define CONFIG_BLOCK_VERSION 0
|
||||
#define CONFIG_BLOCK_VERSION 1
|
||||
#define CONFIG_BLOCK_SIZE 44
|
||||
|
||||
/********************************************
|
||||
|
|
@ -339,12 +339,12 @@ void settings_reset(void) {
|
|||
DEBUGF( "settings_reset()\n" );
|
||||
|
||||
global_settings.volume = mpeg_sound_default(SOUND_VOLUME);
|
||||
global_settings.balance = DEFAULT_BALANCE_SETTING;
|
||||
global_settings.balance = mpeg_sound_default(SOUND_BALANCE);
|
||||
global_settings.bass = mpeg_sound_default(SOUND_BASS);
|
||||
global_settings.treble = mpeg_sound_default(SOUND_TREBLE);
|
||||
global_settings.loudness = DEFAULT_LOUDNESS_SETTING;
|
||||
global_settings.bass_boost = DEFAULT_BASS_BOOST_SETTING;
|
||||
global_settings.avc = DEFAULT_AVC_SETTING;
|
||||
global_settings.loudness = mpeg_sound_default(SOUND_LOUDNESS);
|
||||
global_settings.bass_boost = mpeg_sound_default(SOUND_SUPERBASS);
|
||||
global_settings.avc = mpeg_sound_default(SOUND_AVC);
|
||||
global_settings.contrast = DEFAULT_CONTRAST_SETTING;
|
||||
global_settings.poweroff = DEFAULT_POWEROFF_SETTING;
|
||||
global_settings.backlight = DEFAULT_BACKLIGHT_SETTING;
|
||||
|
|
|
|||
|
|
@ -97,13 +97,6 @@ extern struct user_settings global_settings;
|
|||
|
||||
/* system defines */
|
||||
|
||||
#define DEFAULT_VOLUME_SETTING 70/2
|
||||
#define DEFAULT_BALANCE_SETTING 50
|
||||
#define DEFAULT_BASS_SETTING 50/2
|
||||
#define DEFAULT_TREBLE_SETTING 50/2
|
||||
#define DEFAULT_LOUDNESS_SETTING 0
|
||||
#define DEFAULT_BASS_BOOST_SETTING 0
|
||||
#define DEFAULT_AVC_SETTING 0
|
||||
#ifdef HAVE_LCD_CHARCELLS
|
||||
#define MAX_CONTRAST_SETTING 31
|
||||
#define DEFAULT_CONTRAST_SETTING 30
|
||||
|
|
|
|||
|
|
@ -105,6 +105,10 @@ void set_sound(char* string,
|
|||
break;
|
||||
}
|
||||
mpeg_sound_set(setting, *variable);
|
||||
#ifdef HAVE_MAS3507D
|
||||
if(setting == SOUND_BALANCE)
|
||||
mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
|
||||
#endif
|
||||
}
|
||||
lcd_stop_scroll();
|
||||
}
|
||||
|
|
@ -114,6 +118,11 @@ static void volume(void)
|
|||
set_sound("Volume", &global_settings.volume, SOUND_VOLUME);
|
||||
}
|
||||
|
||||
static void balance(void)
|
||||
{
|
||||
set_sound("Balance", &global_settings.balance, SOUND_BALANCE);
|
||||
}
|
||||
|
||||
static void bass(void)
|
||||
{
|
||||
set_sound("Bass", &global_settings.bass, SOUND_BASS);
|
||||
|
|
@ -150,6 +159,7 @@ void sound_menu(void)
|
|||
{ "Volume", volume },
|
||||
{ "Bass", bass },
|
||||
{ "Treble", treble },
|
||||
{ "Balance", balance },
|
||||
#ifdef HAVE_MAS3587F
|
||||
{ "Loudness", loudness },
|
||||
{ "Bass Boost", bass_boost },
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ static char *units[] =
|
|||
"%", /* Volume */
|
||||
"dB", /* Bass */
|
||||
"dB", /* Treble */
|
||||
"", /* Balance */
|
||||
"%", /* Balance */
|
||||
"dB", /* Loudness */
|
||||
"%" /* Bass boost */
|
||||
};
|
||||
|
|
@ -79,7 +79,7 @@ static int minval[] =
|
|||
0, /* Volume */
|
||||
0, /* Bass */
|
||||
0, /* Treble */
|
||||
0, /* Balance */
|
||||
-50, /* Balance */
|
||||
0, /* Loudness */
|
||||
0 /* Bass boost */
|
||||
};
|
||||
|
|
@ -94,7 +94,7 @@ static int maxval[] =
|
|||
30, /* Bass */
|
||||
30, /* Treble */
|
||||
#endif
|
||||
100, /* Balance */
|
||||
50, /* Balance */
|
||||
17, /* Loudness */
|
||||
10 /* Bass boost */
|
||||
};
|
||||
|
|
@ -109,7 +109,7 @@ static int defaultval[] =
|
|||
15+7, /* Bass */
|
||||
15+7, /* Treble */
|
||||
#endif
|
||||
50, /* Balance */
|
||||
0, /* Balance */
|
||||
0, /* Loudness */
|
||||
0 /* Bass boost */
|
||||
};
|
||||
|
|
@ -1266,7 +1266,8 @@ bool mpeg_is_playing(void)
|
|||
|
||||
#ifndef SIMULATOR
|
||||
#ifdef HAVE_MAS3507D
|
||||
int current_volume=0; /* all values in tenth of dB */
|
||||
int current_left_volume = 0; /* all values in tenth of dB */
|
||||
int current_right_volume = 0; /* all values in tenth of dB */
|
||||
int current_treble = 0;
|
||||
int current_bass = 0;
|
||||
int current_balance = 0;
|
||||
|
|
@ -1292,13 +1293,8 @@ void set_prescaled_volume(void)
|
|||
mas_writereg(MAS_REG_KPRESCALE, prescale_table[prescale/10]);
|
||||
|
||||
/* gain up the analog volume to compensate the prescale reduction gain */
|
||||
r = l = current_volume + prescale;
|
||||
|
||||
/* balance */
|
||||
if (current_balance >= 0)
|
||||
l -= current_balance;
|
||||
else
|
||||
r += current_balance;
|
||||
l = current_left_volume + prescale;
|
||||
r = current_right_volume + prescale;
|
||||
|
||||
dac_volume(tenthdb2reg(l), tenthdb2reg(r), false);
|
||||
}
|
||||
|
|
@ -1309,8 +1305,12 @@ void mpeg_sound_set(int setting, int value)
|
|||
{
|
||||
#ifdef SIMULATOR
|
||||
setting = value;
|
||||
#else
|
||||
#ifdef HAVE_MAS3507D
|
||||
int l, r;
|
||||
#else
|
||||
int tmp;
|
||||
#endif
|
||||
|
||||
switch(setting)
|
||||
{
|
||||
|
|
@ -1321,15 +1321,44 @@ void mpeg_sound_set(int setting, int value)
|
|||
tmp = 0x7f00 * value / 100;
|
||||
mas_codec_writereg(0x10, tmp & 0xff00);
|
||||
#else
|
||||
tmp = 0x38 * value / 100;
|
||||
l = value;
|
||||
r = value;
|
||||
|
||||
if(current_balance > 0)
|
||||
{
|
||||
l -= current_balance;
|
||||
if(l < 0)
|
||||
l = 0;
|
||||
}
|
||||
|
||||
if(current_balance < 0)
|
||||
{
|
||||
r += current_balance;
|
||||
if(r < 0)
|
||||
r = 0;
|
||||
}
|
||||
|
||||
l = 0x38 * l / 100;
|
||||
r = 0x38 * r / 100;
|
||||
|
||||
/* store volume in tenth of dB */
|
||||
current_volume = ( tmp < 0x08 ? tmp*30 - 780 : tmp*15 - 660 );
|
||||
current_left_volume = ( l < 0x08 ? l*30 - 780 : l*15 - 660 );
|
||||
current_right_volume = ( r < 0x08 ? r*30 - 780 : r*15 - 660 );
|
||||
|
||||
set_prescaled_volume();
|
||||
#endif
|
||||
break;
|
||||
|
||||
case SOUND_BALANCE:
|
||||
#ifdef HAVE_MAS3587F
|
||||
tmp = ((value * 127 / 100) & 0xff) << 8;
|
||||
mas_codec_writereg(0x11, tmp & 0xff00);
|
||||
#else
|
||||
/* Convert to percent */
|
||||
current_balance = value * 2;
|
||||
#endif
|
||||
break;
|
||||
|
||||
case SOUND_BASS:
|
||||
#ifdef HAVE_MAS3587F
|
||||
tmp = (((value-12) * 8) & 0xff) << 8;
|
||||
|
|
@ -1415,6 +1444,10 @@ int mpeg_val2phys(int setting, int value)
|
|||
result = value * 2;
|
||||
break;
|
||||
|
||||
case SOUND_BALANCE:
|
||||
result = value * 2;
|
||||
break;
|
||||
|
||||
case SOUND_BASS:
|
||||
#ifdef HAVE_MAS3587F
|
||||
result = value - 12;
|
||||
|
|
@ -1444,7 +1477,7 @@ int mpeg_val2phys(int setting, int value)
|
|||
return result;
|
||||
}
|
||||
|
||||
void mpeg_init(int volume, int bass, int treble, int loudness, int bass_boost, int avc)
|
||||
void mpeg_init(int volume, int bass, int treble, int balance, int loudness, int bass_boost, int avc)
|
||||
{
|
||||
#ifdef SIMULATOR
|
||||
volume = bass = treble = loudness = bass_boost = avc;
|
||||
|
|
@ -1556,6 +1589,7 @@ void mpeg_init(int volume, int bass, int treble, int loudness, int bass_boost, i
|
|||
|
||||
mpeg_sound_set(SOUND_BASS, bass);
|
||||
mpeg_sound_set(SOUND_TREBLE, treble);
|
||||
mpeg_sound_set(SOUND_BALANCE, balance);
|
||||
mpeg_sound_set(SOUND_VOLUME, volume);
|
||||
|
||||
#ifdef HAVE_MAS3587F
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
void mpeg_init(int volume, int bass, int treble, int loudness, int bass_boost, int avc);
|
||||
void mpeg_init(int volume, int bass, int treble, int balance, int loudness, int bass_boost, int avc);
|
||||
void mpeg_play(char* trackname);
|
||||
void mpeg_stop(void);
|
||||
void mpeg_pause(void);
|
||||
|
|
@ -44,15 +44,9 @@ bool mpeg_has_changed_track(void);
|
|||
#define SOUND_BASS 1
|
||||
#define SOUND_TREBLE 2
|
||||
#define SOUND_BALANCE 3
|
||||
|
||||
#ifdef HAVE_MAS3587F
|
||||
#define SOUND_LOUDNESS 4
|
||||
#define SOUND_SUPERBASS 5
|
||||
#define SOUND_AVC 6
|
||||
#define SOUND_NUMSETTINGS 7
|
||||
#else
|
||||
#define SOUND_DEEMPH 4
|
||||
#define SOUND_NUMSETTINGS 5
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue