2007-02-08 04:33:41 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
2007-02-13 00:32:17 +00:00
|
|
|
* $Id$
|
2007-02-08 04:33:41 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Jonathan Gordon
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2007-02-08 04:33:41 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include "config.h"
|
2010-05-15 13:09:45 +00:00
|
|
|
#include "sound.h"
|
2007-02-08 04:33:41 +00:00
|
|
|
#include "lang.h"
|
|
|
|
#include "action.h"
|
|
|
|
#include "settings.h"
|
|
|
|
#include "menu.h"
|
|
|
|
#include "sound_menu.h"
|
2007-02-08 10:28:42 +00:00
|
|
|
#include "eq_menu.h"
|
2007-02-19 02:14:51 +00:00
|
|
|
#include "exported_menus.h"
|
2008-03-03 11:06:04 +00:00
|
|
|
#include "menu_common.h"
|
2009-06-12 07:20:50 +00:00
|
|
|
#include "splash.h"
|
|
|
|
#include "kernel.h"
|
2013-12-21 13:33:54 +00:00
|
|
|
#include "talk.h"
|
|
|
|
#include "option_select.h"
|
|
|
|
#include "misc.h"
|
|
|
|
|
2021-03-14 16:48:56 +00:00
|
|
|
static const char* vol_limit_format(char* buffer, size_t buffer_size, int value,
|
|
|
|
const char* unit)
|
|
|
|
{
|
|
|
|
(void)unit;
|
|
|
|
format_sound_value(buffer, buffer_size, SOUND_VOLUME, value);
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
2020-07-19 17:42:04 +00:00
|
|
|
static int volume_limit_callback(int action,
|
|
|
|
const struct menu_item_ex *this_item,
|
|
|
|
struct gui_synclist *this_list)
|
2013-12-21 13:33:54 +00:00
|
|
|
{
|
|
|
|
(void)this_item;
|
2020-07-19 17:42:04 +00:00
|
|
|
(void)this_list;
|
2013-12-21 13:33:54 +00:00
|
|
|
|
|
|
|
static struct int_setting volume_limit_int_setting;
|
|
|
|
volume_limit_int_setting.option_callback = NULL;
|
|
|
|
volume_limit_int_setting.unit = UNIT_DB;
|
|
|
|
volume_limit_int_setting.min = sound_min(SOUND_VOLUME);
|
|
|
|
volume_limit_int_setting.max = sound_max(SOUND_VOLUME);
|
|
|
|
volume_limit_int_setting.step = sound_steps(SOUND_VOLUME);
|
2021-03-14 16:48:56 +00:00
|
|
|
volume_limit_int_setting.formatter = vol_limit_format;
|
2019-07-21 13:01:58 +00:00
|
|
|
volume_limit_int_setting.get_talk_id = NULL;
|
2013-12-21 13:33:54 +00:00
|
|
|
|
|
|
|
struct settings_list setting;
|
|
|
|
setting.flags = F_BANFROMQS|F_INT_SETTING|F_T_INT|F_NO_WRAP;
|
|
|
|
setting.lang_id = LANG_VOLUME_LIMIT;
|
2021-03-14 16:48:56 +00:00
|
|
|
setting.default_val.int_ = volume_limit_int_setting.max;
|
2013-12-21 13:33:54 +00:00
|
|
|
setting.int_setting = &volume_limit_int_setting;
|
|
|
|
|
|
|
|
switch (action)
|
|
|
|
{
|
|
|
|
case ACTION_ENTER_MENUITEM:
|
|
|
|
setting.setting = &global_settings.volume_limit;
|
|
|
|
option_screen(&setting, NULL, false, ID2P(LANG_VOLUME_LIMIT));
|
2021-07-22 23:53:48 +00:00
|
|
|
/* Fallthrough */
|
2013-12-21 13:33:54 +00:00
|
|
|
case ACTION_EXIT_MENUITEM: /* on exit */
|
|
|
|
setvol();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return action;
|
|
|
|
}
|
2007-02-08 04:33:41 +00:00
|
|
|
|
2007-02-08 10:28:42 +00:00
|
|
|
/***********************************/
|
|
|
|
/* SOUND MENU */
|
2008-03-03 11:06:04 +00:00
|
|
|
MENUITEM_SETTING(volume, &global_settings.volume, NULL);
|
2013-12-21 13:33:54 +00:00
|
|
|
MENUITEM_SETTING(volume_limit, &global_settings.volume_limit, volume_limit_callback);
|
2010-05-15 13:09:45 +00:00
|
|
|
#ifdef AUDIOHW_HAVE_BASS
|
2008-03-03 11:06:04 +00:00
|
|
|
MENUITEM_SETTING(bass, &global_settings.bass,
|
|
|
|
#ifdef HAVE_SW_TONE_CONTROLS
|
|
|
|
lowlatency_callback
|
2007-02-08 10:28:42 +00:00
|
|
|
#else
|
2008-03-03 11:06:04 +00:00
|
|
|
NULL
|
2007-02-08 10:28:42 +00:00
|
|
|
#endif
|
2008-03-03 11:06:04 +00:00
|
|
|
);
|
2010-05-15 13:09:45 +00:00
|
|
|
|
|
|
|
#ifdef AUDIOHW_HAVE_BASS_CUTOFF
|
2010-05-15 13:30:01 +00:00
|
|
|
MENUITEM_SETTING(bass_cutoff, &global_settings.bass_cutoff, NULL);
|
2007-11-24 07:51:00 +00:00
|
|
|
#endif
|
2010-05-15 13:09:45 +00:00
|
|
|
#endif /* AUDIOHW_HAVE_BASS */
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef AUDIOHW_HAVE_TREBLE
|
2008-03-03 11:06:04 +00:00
|
|
|
MENUITEM_SETTING(treble, &global_settings.treble,
|
|
|
|
#ifdef HAVE_SW_TONE_CONTROLS
|
|
|
|
lowlatency_callback
|
|
|
|
#else
|
|
|
|
NULL
|
|
|
|
#endif
|
|
|
|
);
|
2010-05-15 13:09:45 +00:00
|
|
|
|
|
|
|
#ifdef AUDIOHW_HAVE_TREBLE_CUTOFF
|
2008-03-03 11:06:04 +00:00
|
|
|
MENUITEM_SETTING(treble_cutoff, &global_settings.treble_cutoff, NULL);
|
|
|
|
#endif
|
2010-05-15 13:09:45 +00:00
|
|
|
#endif /* AUDIOHW_HAVE_TREBLE */
|
|
|
|
|
|
|
|
|
2008-03-03 11:06:04 +00:00
|
|
|
MENUITEM_SETTING(balance, &global_settings.balance, NULL);
|
2009-06-12 07:20:50 +00:00
|
|
|
MENUITEM_SETTING(channel_config, &global_settings.channel_config,
|
2008-03-03 11:06:04 +00:00
|
|
|
lowlatency_callback
|
|
|
|
);
|
2009-06-12 07:20:50 +00:00
|
|
|
MENUITEM_SETTING(stereo_width, &global_settings.stereo_width,
|
2008-03-03 11:06:04 +00:00
|
|
|
lowlatency_callback
|
|
|
|
);
|
2007-02-08 10:28:42 +00:00
|
|
|
|
2010-05-15 13:09:45 +00:00
|
|
|
#ifdef AUDIOHW_HAVE_DEPTH_3D
|
|
|
|
MENUITEM_SETTING(depth_3d, &global_settings.depth_3d, NULL);
|
|
|
|
#endif
|
|
|
|
|
2013-05-12 19:23:45 +00:00
|
|
|
#ifdef AUDIOHW_HAVE_FILTER_ROLL_OFF
|
|
|
|
MENUITEM_SETTING(roll_off, &global_settings.roll_off, NULL);
|
|
|
|
#endif
|
|
|
|
|
2021-03-13 02:11:45 +00:00
|
|
|
#ifdef AUDIOHW_HAVE_POWER_MODE
|
|
|
|
MENUITEM_SETTING(power_mode, &global_settings.power_mode, NULL);
|
2018-06-28 10:24:26 +00:00
|
|
|
#endif
|
|
|
|
|
2007-02-08 10:28:42 +00:00
|
|
|
/* Crossfeed Submenu */
|
2008-03-03 11:06:04 +00:00
|
|
|
MENUITEM_SETTING(crossfeed, &global_settings.crossfeed, lowlatency_callback);
|
2007-02-08 10:28:42 +00:00
|
|
|
MENUITEM_SETTING(crossfeed_direct_gain,
|
2008-03-03 11:06:04 +00:00
|
|
|
&global_settings.crossfeed_direct_gain, lowlatency_callback);
|
2007-02-08 10:28:42 +00:00
|
|
|
MENUITEM_SETTING(crossfeed_cross_gain,
|
2008-03-03 11:06:04 +00:00
|
|
|
&global_settings.crossfeed_cross_gain, lowlatency_callback);
|
2007-02-08 10:28:42 +00:00
|
|
|
MENUITEM_SETTING(crossfeed_hf_attenuation,
|
2008-03-03 11:06:04 +00:00
|
|
|
&global_settings.crossfeed_hf_attenuation, lowlatency_callback);
|
2007-02-08 10:28:42 +00:00
|
|
|
MENUITEM_SETTING(crossfeed_hf_cutoff,
|
2008-03-03 11:06:04 +00:00
|
|
|
&global_settings.crossfeed_hf_cutoff, lowlatency_callback);
|
2007-03-03 13:52:14 +00:00
|
|
|
MAKE_MENU(crossfeed_menu,ID2P(LANG_CROSSFEED), NULL, Icon_NOICON,
|
2007-02-08 10:28:42 +00:00
|
|
|
&crossfeed, &crossfeed_direct_gain, &crossfeed_cross_gain,
|
|
|
|
&crossfeed_hf_attenuation, &crossfeed_hf_cutoff);
|
2009-06-12 07:20:50 +00:00
|
|
|
|
2012-05-08 14:34:26 +00:00
|
|
|
#ifdef HAVE_PITCHCONTROL
|
2020-07-19 17:42:04 +00:00
|
|
|
static int timestretch_callback(int action,
|
|
|
|
const struct menu_item_ex *this_item,
|
|
|
|
struct gui_synclist *this_list)
|
2009-06-12 07:20:50 +00:00
|
|
|
{
|
2020-07-19 17:42:04 +00:00
|
|
|
(void)this_list;
|
2009-06-12 07:20:50 +00:00
|
|
|
switch (action)
|
|
|
|
{
|
|
|
|
case ACTION_EXIT_MENUITEM: /* on exit */
|
2009-06-16 07:10:05 +00:00
|
|
|
if (global_settings.timestretch_enabled && !dsp_timestretch_available())
|
2009-06-12 07:20:50 +00:00
|
|
|
splash(HZ*2, ID2P(LANG_PLEASE_REBOOT));
|
|
|
|
break;
|
|
|
|
}
|
2020-07-19 17:42:04 +00:00
|
|
|
lowlatency_callback(action, this_item, NULL);
|
2009-06-12 07:20:50 +00:00
|
|
|
return action;
|
|
|
|
}
|
|
|
|
MENUITEM_SETTING(timestretch_enabled,
|
|
|
|
&global_settings.timestretch_enabled, timestretch_callback);
|
2010-09-17 20:28:47 +00:00
|
|
|
#endif
|
|
|
|
|
2007-02-08 10:28:42 +00:00
|
|
|
MENUITEM_SETTING(dithering_enabled,
|
2008-03-03 11:06:04 +00:00
|
|
|
&global_settings.dithering_enabled, lowlatency_callback);
|
2014-08-22 13:30:35 +00:00
|
|
|
MENUITEM_SETTING(afr_enabled,
|
|
|
|
&global_settings.afr_enabled, lowlatency_callback);
|
|
|
|
MENUITEM_SETTING(pbe,
|
|
|
|
&global_settings.pbe, lowlatency_callback);
|
|
|
|
MENUITEM_SETTING(pbe_precut,
|
|
|
|
&global_settings.pbe_precut, lowlatency_callback);
|
|
|
|
MAKE_MENU(pbe_menu,ID2P(LANG_PBE), NULL, Icon_NOICON,
|
|
|
|
&pbe,&pbe_precut);
|
|
|
|
MENUITEM_SETTING(surround_enabled,
|
|
|
|
&global_settings.surround_enabled, lowlatency_callback);
|
|
|
|
MENUITEM_SETTING(surround_balance,
|
|
|
|
&global_settings.surround_balance, lowlatency_callback);
|
|
|
|
MENUITEM_SETTING(surround_fx1,
|
|
|
|
&global_settings.surround_fx1, lowlatency_callback);
|
|
|
|
MENUITEM_SETTING(surround_fx2,
|
|
|
|
&global_settings.surround_fx2, lowlatency_callback);
|
|
|
|
MENUITEM_SETTING(surround_method2,
|
|
|
|
&global_settings.surround_method2, lowlatency_callback);
|
|
|
|
MENUITEM_SETTING(surround_mix,
|
|
|
|
&global_settings.surround_mix, lowlatency_callback);
|
|
|
|
MAKE_MENU(surround_menu,ID2P(LANG_SURROUND), NULL, Icon_NOICON,
|
|
|
|
&surround_enabled,&surround_balance,&surround_fx1,&surround_fx2,&surround_method2,&surround_mix);
|
2009-09-25 15:46:38 +00:00
|
|
|
|
|
|
|
/* compressor submenu */
|
|
|
|
MENUITEM_SETTING(compressor_threshold,
|
2012-04-26 21:19:16 +00:00
|
|
|
&global_settings.compressor_settings.threshold,
|
|
|
|
lowlatency_callback);
|
2009-09-25 15:46:38 +00:00
|
|
|
MENUITEM_SETTING(compressor_gain,
|
2012-04-26 21:19:16 +00:00
|
|
|
&global_settings.compressor_settings.makeup_gain,
|
|
|
|
lowlatency_callback);
|
2009-11-04 18:14:36 +00:00
|
|
|
MENUITEM_SETTING(compressor_ratio,
|
2012-04-26 21:19:16 +00:00
|
|
|
&global_settings.compressor_settings.ratio,
|
|
|
|
lowlatency_callback);
|
2009-09-25 15:46:38 +00:00
|
|
|
MENUITEM_SETTING(compressor_knee,
|
2012-04-26 21:19:16 +00:00
|
|
|
&global_settings.compressor_settings.knee,
|
|
|
|
lowlatency_callback);
|
DSP Compressor: Sidechain, Exponential Atk/Rls
This is an improvement to the current compressor which I have added
to my own Sansa Fuze V2 build. I am submitting here in case others
find it interesting.
Features added to the existing compressor:
Attack, Look-ahead, Sidechain Filtering.
Exponential attack and release characteristic response.
Benefits from adding missing features:
Attack:
Preserve perceived "brightness" of tone by letting onset transients
come through at a higher level than the rest of the compressed program
material.
Look-ahead:
With Attack comes clipping on the leading several cycles of a transient
onset. With look-ahead function, this can be pre-emptively mitigated with
a slower gain change (less distortion). Look-ahead limiting is implemented
to prevent clipping while keeping gain change ramp to an interval near 3ms
instead of instant attack.
The existing compressor implementation distorts the leading edge of a
transient by causing instant gain change, resulting in log() distortion.
This sounds "woofy" to me.
Exponential Attack/Release:
eMore natural sounding. On attack, this is a true straight line of 10dB per
attack interval. Release is a little different, however, sounds natural as
an analog compressor.
Sidechain Filtering:
Mild high-pass filter reduces response to low frequency onsets. For example,
a hard kick drum is less likely to make the whole of the program material
appear to fade in and out. Combined with a moderate attack time, such a
transient will ride through with minimal audible artifact.
Overall these changes make dynamic music sound more "open", more natural. The
goal of a compressor is to make dyanamic music sound louder without necessarily
sounding as though it has been compressed. I believe these changes come closer to this goal.
Enjoy. If not, I am enjoying it
Change-Id: I664eace546c364b815b4dc9ed4a72849231a0eb2
Reviewed-on: http://gerrit.rockbox.org/626
Tested: Purling Nayuki <cyq.yzfl@gmail.com>
Reviewed-by: Michael Giacomelli <giac2000@hotmail.com>
2013-10-03 12:57:00 +00:00
|
|
|
MENUITEM_SETTING(compressor_attack,
|
|
|
|
&global_settings.compressor_settings.attack_time,
|
|
|
|
lowlatency_callback);
|
2009-09-25 15:46:38 +00:00
|
|
|
MENUITEM_SETTING(compressor_release,
|
2012-04-26 21:19:16 +00:00
|
|
|
&global_settings.compressor_settings.release_time,
|
|
|
|
lowlatency_callback);
|
2009-09-25 15:46:38 +00:00
|
|
|
MAKE_MENU(compressor_menu,ID2P(LANG_COMPRESSOR), NULL, Icon_NOICON,
|
2009-11-04 18:14:36 +00:00
|
|
|
&compressor_threshold, &compressor_gain, &compressor_ratio,
|
DSP Compressor: Sidechain, Exponential Atk/Rls
This is an improvement to the current compressor which I have added
to my own Sansa Fuze V2 build. I am submitting here in case others
find it interesting.
Features added to the existing compressor:
Attack, Look-ahead, Sidechain Filtering.
Exponential attack and release characteristic response.
Benefits from adding missing features:
Attack:
Preserve perceived "brightness" of tone by letting onset transients
come through at a higher level than the rest of the compressed program
material.
Look-ahead:
With Attack comes clipping on the leading several cycles of a transient
onset. With look-ahead function, this can be pre-emptively mitigated with
a slower gain change (less distortion). Look-ahead limiting is implemented
to prevent clipping while keeping gain change ramp to an interval near 3ms
instead of instant attack.
The existing compressor implementation distorts the leading edge of a
transient by causing instant gain change, resulting in log() distortion.
This sounds "woofy" to me.
Exponential Attack/Release:
eMore natural sounding. On attack, this is a true straight line of 10dB per
attack interval. Release is a little different, however, sounds natural as
an analog compressor.
Sidechain Filtering:
Mild high-pass filter reduces response to low frequency onsets. For example,
a hard kick drum is less likely to make the whole of the program material
appear to fade in and out. Combined with a moderate attack time, such a
transient will ride through with minimal audible artifact.
Overall these changes make dynamic music sound more "open", more natural. The
goal of a compressor is to make dyanamic music sound louder without necessarily
sounding as though it has been compressed. I believe these changes come closer to this goal.
Enjoy. If not, I am enjoying it
Change-Id: I664eace546c364b815b4dc9ed4a72849231a0eb2
Reviewed-on: http://gerrit.rockbox.org/626
Tested: Purling Nayuki <cyq.yzfl@gmail.com>
Reviewed-by: Michael Giacomelli <giac2000@hotmail.com>
2013-10-03 12:57:00 +00:00
|
|
|
&compressor_knee, &compressor_attack, &compressor_release);
|
2007-02-08 10:28:42 +00:00
|
|
|
|
2009-03-02 18:18:24 +00:00
|
|
|
#ifdef HAVE_SPEAKER
|
2017-01-14 00:40:12 +00:00
|
|
|
MENUITEM_SETTING(speaker_mode, &global_settings.speaker_mode, NULL);
|
2009-03-02 18:18:24 +00:00
|
|
|
#endif
|
|
|
|
|
2010-05-15 13:09:45 +00:00
|
|
|
#ifdef AUDIOHW_HAVE_EQ
|
|
|
|
#endif /* AUDIOHW_HAVE_EQ */
|
2007-02-08 10:28:42 +00:00
|
|
|
|
2007-03-03 13:52:14 +00:00
|
|
|
MAKE_MENU(sound_settings, ID2P(LANG_SOUND_SETTINGS), NULL, Icon_Audio,
|
2010-05-15 13:09:45 +00:00
|
|
|
&volume
|
2013-12-21 13:33:54 +00:00
|
|
|
,&volume_limit
|
2010-05-15 13:09:45 +00:00
|
|
|
#ifdef AUDIOHW_HAVE_BASS
|
|
|
|
,&bass
|
|
|
|
#endif
|
|
|
|
#ifdef AUDIOHW_HAVE_BASS_CUTOFF
|
|
|
|
,&bass_cutoff
|
|
|
|
#endif
|
|
|
|
#ifdef AUDIOHW_HAVE_TREBLE
|
|
|
|
,&treble
|
|
|
|
#endif
|
|
|
|
#ifdef AUDIOHW_HAVE_TREBLE_CUTOFF
|
|
|
|
,&treble_cutoff
|
|
|
|
#endif
|
|
|
|
#ifdef AUDIOHW_HAVE_EQ
|
|
|
|
,&audiohw_eq_tone_controls
|
2007-11-24 07:51:00 +00:00
|
|
|
#endif
|
2010-05-15 13:09:45 +00:00
|
|
|
,&balance,&channel_config,&stereo_width
|
|
|
|
#ifdef AUDIOHW_HAVE_DEPTH_3D
|
|
|
|
,&depth_3d
|
2007-11-24 07:51:00 +00:00
|
|
|
#endif
|
2013-05-12 19:23:45 +00:00
|
|
|
#ifdef AUDIOHW_HAVE_FILTER_ROLL_OFF
|
|
|
|
,&roll_off
|
|
|
|
#endif
|
2021-03-13 02:11:45 +00:00
|
|
|
#ifdef AUDIOHW_HAVE_POWER_MODE
|
|
|
|
,&power_mode
|
2018-06-28 10:24:26 +00:00
|
|
|
#endif
|
2009-06-12 07:20:50 +00:00
|
|
|
,&crossfeed_menu, &equalizer_menu, &dithering_enabled
|
2014-08-22 13:30:35 +00:00
|
|
|
,&surround_menu, &pbe_menu, &afr_enabled
|
2012-05-08 14:34:26 +00:00
|
|
|
#ifdef HAVE_PITCHCONTROL
|
2009-06-12 07:20:50 +00:00
|
|
|
,×tretch_enabled
|
2010-09-17 20:28:47 +00:00
|
|
|
#endif
|
2009-09-25 15:46:38 +00:00
|
|
|
,&compressor_menu
|
2009-03-02 18:18:24 +00:00
|
|
|
#ifdef HAVE_SPEAKER
|
2017-01-14 00:40:12 +00:00
|
|
|
,&speaker_mode
|
2007-02-08 10:28:42 +00:00
|
|
|
#endif
|
|
|
|
);
|