From 2993ae69b5cfd95ddab595fcce9cc7637477d6a5 Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Wed, 7 Dec 2005 23:07:07 +0000 Subject: Simplified and uniform volume handling: * Volume setting in dB on all targets, within the 'natural' range defined by the respective DAC (limited to -100..+12 dB for archos Recorders and Ondios in order to avoid 4 chars being displayed in the status bar). 0 dB means line level on all targets. * No more artificial volume limiting for Iriver and Player, settings always represent true values. Removed the various sound scaling options. * Bumped config version so save your settings. Also make sure to adjust the volume after loading a .cfg, then save the .cfg again, otherwise the volume will be out of range (a flaw in the .cfg loader). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8197 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/gwps-common.c | 7 +++++-- apps/gui/statusbar.c | 39 +++++++++++++++++++++------------------ apps/gui/statusbar.h | 2 +- apps/lang/english.lang | 30 ------------------------------ apps/settings.c | 17 ++++++----------- apps/settings.h | 3 --- apps/sound_menu.c | 18 ------------------ 7 files changed, 33 insertions(+), 83 deletions(-) (limited to 'apps') diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c index 7590f493e8..307036eda4 100644 --- a/apps/gui/gwps-common.c +++ b/apps/gui/gwps-common.c @@ -569,7 +569,10 @@ static char* get_tag(struct wps_data* wps_data, case 'v': /* volume */ *flags |= WPS_REFRESH_DYNAMIC; snprintf(buf, buf_size, "%d", global_settings.volume); - *intval = global_settings.volume / 10 + 1; + *intval = 10 * (global_settings.volume + - sound_min(SOUND_VOLUME)) + / (sound_max(SOUND_VOLUME) + - sound_min(SOUND_VOLUME)) + 1; return buf; } @@ -1892,7 +1895,7 @@ bool update_onvol_change(struct gui_wps * gwps) gui_wps_refresh(gwps, 0, WPS_REFRESH_NON_STATIC); #ifdef HAVE_LCD_CHARCELLS - gui_splash(gwps->display,0, false, "Vol: %d %% ", + gui_splash(gwps->display,0, false, "Vol: %d dB ", sound_val2phys(SOUND_VOLUME, global_settings.volume)); return true; #endif diff --git a/apps/gui/statusbar.c b/apps/gui/statusbar.c index fda54a610e..56d1647d9b 100644 --- a/apps/gui/statusbar.c +++ b/apps/gui/statusbar.c @@ -102,7 +102,7 @@ struct gui_syncstatusbar statusbars; void gui_statusbar_init(struct gui_statusbar * bar) { - bar->last_volume = -1; /* -1 means "first update ever" */ + bar->last_volume = -1000; /* -1000 means "first update ever" */ bar->battery_icon_switch_tick = 0; #ifdef HAVE_CHARGING bar->battery_charge_step = 0; @@ -117,6 +117,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw) #endif /* CONFIG_RTC */ #ifdef HAVE_LCD_CHARCELLS + int vol; (void)force_redraw; /* players always "redraw" */ #endif /* HAVE_LCD_CHARCELLS */ @@ -277,12 +278,14 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw) display->icon(ICON_BATTERY_2, bar->info.battlevel > 50); display->icon(ICON_BATTERY_3, bar->info.battlevel > 75); + vol = 100 * (bar->info.volume - sound_min(SOUND_VOLUME)) + / (sound_max(SOUND_VOLUME) - sound_min(SOUND_VOLUME)); display->icon(ICON_VOLUME, true); - display->icon(ICON_VOLUME_1, bar->info.volume > 10); - display->icon(ICON_VOLUME_2, bar->info.volume > 30); - display->icon(ICON_VOLUME_3, bar->info.volume > 50); - display->icon(ICON_VOLUME_4, bar->info.volume > 70); - display->icon(ICON_VOLUME_5, bar->info.volume > 90); + display->icon(ICON_VOLUME_1, vol > 10); + display->icon(ICON_VOLUME_2, vol > 30); + display->icon(ICON_VOLUME_3, vol > 50); + display->icon(ICON_VOLUME_4, vol > 70); + display->icon(ICON_VOLUME_5, vol > 90); display->icon(ICON_PLAY, current_playmode() == STATUS_PLAY); display->icon(ICON_PAUSE, current_playmode() == STATUS_PAUSE); @@ -356,31 +359,31 @@ void gui_statusbar_icon_battery(struct screen * display, int percent) /* * Print volume gauge to status bar */ -bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int percent) +bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int volume) { int i; - int volume; int vol; char buffer[4]; unsigned int width, height; bool needs_redraw = false; int type = global_settings.volume_type; - struct screen * display=bar->display; + struct screen * display=bar->display; + int minvol = sound_min(SOUND_VOLUME); + int maxvol = sound_max(SOUND_VOLUME); - volume = percent; - if (volume < 0) - volume = 0; - if (volume > 100) - volume = 100; + if (volume < minvol) + volume = minvol; + if (volume > maxvol) + volume = maxvol; - if (volume == 0) { + if (volume == minvol) { display->mono_bitmap(bitmap_icons_7x8[Icon_Mute], STATUSBAR_VOLUME_X_POS + STATUSBAR_VOLUME_WIDTH / 2 - 4, STATUSBAR_Y_POS, 7, STATUSBAR_HEIGHT); } else { /* We want to redraw the icon later on */ - if (bar->last_volume != volume && bar->last_volume >= 0) { + if (bar->last_volume != volume && bar->last_volume >= minvol) { bar->volume_icon_switch_tick = current_tick + HZ; } @@ -395,7 +398,7 @@ bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int percent) if (type) { display->setfont(FONT_SYSFIXED); - snprintf(buffer, sizeof(buffer), "%2d", percent); + snprintf(buffer, sizeof(buffer), "%2d", volume); display->getstringsize(buffer, &width, &height); if (height <= STATUSBAR_HEIGHT) { @@ -406,7 +409,7 @@ bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int percent) display->setfont(FONT_UI); } else { /* display volume bar */ - vol = volume * 14 / 100; + vol = (volume - minvol) * 14 / (maxvol - minvol); for(i=0; i < vol; i++) { display->vline(STATUSBAR_VOLUME_X_POS + i, STATUSBAR_Y_POS + 6 - i / 2, diff --git a/apps/gui/statusbar.h b/apps/gui/statusbar.h index 6b8e49a838..650b49d63b 100644 --- a/apps/gui/statusbar.h +++ b/apps/gui/statusbar.h @@ -102,7 +102,7 @@ extern void gui_statusbar_init(struct gui_statusbar * bar); extern void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw); void gui_statusbar_icon_battery(struct screen * display, int percent); -bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int percent); +bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int volume); void gui_statusbar_icon_play_state(struct screen * display, int state); void gui_statusbar_icon_play_mode(struct screen * display, int mode); void gui_statusbar_icon_shuffle(struct screen * display); diff --git a/apps/lang/english.lang b/apps/lang/english.lang index 3595281209..1f0ef87ca4 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -3550,33 +3550,3 @@ desc: in radio screen / menu eng: "Mode:" voice: "" new: - -id: LANG_SCALING_MODE -desc: in sound_settings. How to scale volume/bass to prevent clipping -eng: "Prevent clipping" -voice: "Prevent clipping" -new: - -id: LANG_SCALE_OFF -desc: in sound_settings. Do not reduce volume/bass -eng: "Off" -voice: "Off" -new: - -id: LANG_SCALE_VOLUME -desc: in sound_settings. Reduce volume -eng: "Adjust volume" -voice: "Adjust volume" -new: - -id: LANG_SCALE_BASS -desc: in sound_settings. Reduce bass -eng: "Adjust bass" -voice: "Adjust bass" -new: - -id: LANG_SCALE_CURRENT -desc: in sound_settings. Reduce other metric than currently modified -eng: "Adjust current" -voice: "Adjust current" -new: diff --git a/apps/settings.c b/apps/settings.c index d3441630fd..bd6076dc93 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -85,7 +85,7 @@ const char rec_base_directory[] = REC_BASE_DIR; #include "dsp.h" #endif -#define CONFIG_BLOCK_VERSION 35 +#define CONFIG_BLOCK_VERSION 36 #define CONFIG_BLOCK_SIZE 512 #define RTC_BLOCK_SIZE 44 @@ -193,7 +193,11 @@ static const struct bit_entry rtc_bits[] = /* # of bits, offset+size, default, .cfg name, .cfg values */ /* sound */ - {7, S_O(volume), 70, "volume", NULL }, /* 0...100 */ +#if CONFIG_CODEC == MAS3507D + {8 | SIGNED, S_O(volume), -18, "volume", NULL }, /* -78...+18 */ +#else + {8 | SIGNED, S_O(volume), -25, "volume", NULL }, /* -100...+12 / -84...0 */ +#endif {8 | SIGNED, S_O(balance), 0, "balance", NULL }, /* -100...100 */ #if CONFIG_CODEC != SWCODEC /* any MAS */ {5 | SIGNED, S_O(bass), 0, "bass", NULL }, /* -15..+15 / -12..+12 */ @@ -210,9 +214,6 @@ static const struct bit_entry rtc_bits[] = {3, S_O(channel_config), 0, "channels", "stereo,mono,custom,mono left,mono right,karaoke" }, {8, S_O(stereo_width), 100, "stereo width", NULL}, -#ifdef HAVE_UDA1380 - {2, S_O(sound_scaling), SOUND_SCALE_VOLUME, "prevent clipping", "adjust volume,adjust bass,adjust current,off"}, -#endif /* playback */ {1, S_O(resume), false, "resume", off_on }, {1, S_O(playlist_shuffle), false, "shuffle", off_on }, @@ -842,9 +843,6 @@ void sound_settings_apply(void) sound_set(SOUND_VOLUME, global_settings.volume); sound_set(SOUND_CHANNELS, global_settings.channel_config); sound_set(SOUND_STEREO_WIDTH, global_settings.stereo_width); -#ifdef HAVE_UDA1380 - sound_set(SOUND_SCALING, global_settings.sound_scaling); -#endif #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) sound_set(SOUND_LOUDNESS, global_settings.loudness); sound_set(SOUND_AVC, global_settings.avc); @@ -1429,9 +1427,6 @@ void settings_reset(void) { global_settings.treble = sound_default(SOUND_TREBLE); global_settings.channel_config = sound_default(SOUND_CHANNELS); global_settings.stereo_width = sound_default(SOUND_STEREO_WIDTH); -#ifdef HAVE_UDA1380 - global_settings.sound_scaling = sound_default(SOUND_SCALING); -#endif #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) global_settings.loudness = sound_default(SOUND_LOUDNESS); global_settings.avc = sound_default(SOUND_AVC); diff --git a/apps/settings.h b/apps/settings.h index 6b34543c27..b1e8c9e2e8 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -157,9 +157,6 @@ struct user_settings int avc; /* auto volume correct: 0=off, 1=20ms, 2=2s 3=4s 4=8s */ int channel_config; /* Stereo, Mono, Custom, Mono left, Mono right, Karaoke */ int stereo_width; /* 0-255% */ -#ifdef HAVE_UDA1380 - int sound_scaling; /* Off, Volume, Bass, Current metric */ -#endif int mdb_strength; /* 0-127dB */ int mdb_harmonics; /* 0-100% */ int mdb_center; /* 20-300Hz */ diff --git a/apps/sound_menu.c b/apps/sound_menu.c index f97cdde2ab..e44aa68231 100644 --- a/apps/sound_menu.c +++ b/apps/sound_menu.c @@ -366,21 +366,6 @@ static bool stereo_width(void) SOUND_STEREO_WIDTH); } -#ifdef HAVE_UDA1380 -static bool sound_scaling(void) -{ - static const struct opt_items names[] = { - { STR(LANG_SCALE_VOLUME) }, - { STR(LANG_SCALE_BASS) }, - { STR(LANG_SCALE_CURRENT)}, - { STR(LANG_SCALE_OFF) } - }; - - return set_option(str(LANG_SCALING_MODE), &global_settings.sound_scaling, INT, - names, 4, sound_set_scaling); -} -#endif - bool sound_menu(void) { int m; @@ -395,9 +380,6 @@ bool sound_menu(void) #if CONFIG_CODEC == SWCODEC { ID2P(LANG_CROSSFEED), crossfeed }, #endif -#ifdef HAVE_UDA1380 - { ID2P(LANG_SCALING_MODE), sound_scaling }, -#endif #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) { ID2P(LANG_LOUDNESS), loudness }, { ID2P(LANG_AUTOVOL), avc }, -- cgit v1.2.3