filter/replay_gain: added option "replaygain_limit"
This commit is contained in:
parent
3709b9aa11
commit
e8310211e2
@ -72,6 +72,7 @@ static struct config_entry config_entries[] = {
|
||||
{ .name = CONF_REPLAYGAIN, false, false },
|
||||
{ .name = CONF_REPLAYGAIN_PREAMP, false, false },
|
||||
{ .name = CONF_REPLAYGAIN_MISSING_PREAMP, false, false },
|
||||
{ .name = CONF_REPLAYGAIN_LIMIT, false, false },
|
||||
{ .name = CONF_VOLUME_NORMALIZATION, false, false },
|
||||
{ .name = CONF_SAMPLERATE_CONVERTER, false, false },
|
||||
{ .name = CONF_AUDIO_BUFFER_SIZE, false, false },
|
||||
|
@ -48,6 +48,7 @@
|
||||
#define CONF_REPLAYGAIN "replaygain"
|
||||
#define CONF_REPLAYGAIN_PREAMP "replaygain_preamp"
|
||||
#define CONF_REPLAYGAIN_MISSING_PREAMP "replaygain_missing_preamp"
|
||||
#define CONF_REPLAYGAIN_LIMIT "replaygain_limit"
|
||||
#define CONF_VOLUME_NORMALIZATION "volume_normalization"
|
||||
#define CONF_SAMPLERATE_CONVERTER "samplerate_converter"
|
||||
#define CONF_AUDIO_BUFFER_SIZE "audio_buffer_size"
|
||||
|
@ -420,7 +420,8 @@ decoder_replay_gain(struct decoder *decoder,
|
||||
return_db = 20.0 * log10f(
|
||||
replay_gain_tuple_scale(
|
||||
&replay_gain_info->tuples[replay_gain_get_real_mode()],
|
||||
replay_gain_preamp));
|
||||
replay_gain_preamp, replay_gain_missing_preamp,
|
||||
replay_gain_limit));
|
||||
}
|
||||
|
||||
decoder->replay_gain_info = *replay_gain_info;
|
||||
|
@ -78,11 +78,8 @@ static void
|
||||
replay_gain_filter_update(struct replay_gain_filter *filter)
|
||||
{
|
||||
if (filter->mode != REPLAY_GAIN_OFF) {
|
||||
const struct replay_gain_tuple *tuple =
|
||||
&filter->info.tuples[filter->mode];
|
||||
float scale = replay_gain_tuple_defined(tuple)
|
||||
? replay_gain_tuple_scale(tuple, replay_gain_preamp)
|
||||
: replay_gain_missing_preamp;
|
||||
float scale = replay_gain_tuple_scale(&filter->info.tuples[filter->mode],
|
||||
replay_gain_preamp, replay_gain_missing_preamp, replay_gain_limit);
|
||||
g_debug("scale=%f\n", (double)scale);
|
||||
|
||||
filter->volume = pcm_float_to_volume(scale);
|
||||
|
@ -37,8 +37,11 @@ static const char *const replay_gain_mode_names[] = {
|
||||
|
||||
enum replay_gain_mode replay_gain_mode = REPLAY_GAIN_OFF;
|
||||
|
||||
const bool DEFAULT_REPLAYGAIN_LIMIT = true;
|
||||
|
||||
float replay_gain_preamp = 1.0;
|
||||
float replay_gain_missing_preamp = 1.0;
|
||||
bool replay_gain_limit;
|
||||
|
||||
const char *
|
||||
replay_gain_get_mode_string(void)
|
||||
@ -129,6 +132,8 @@ void replay_gain_global_init(void)
|
||||
|
||||
replay_gain_missing_preamp = pow(10, f / 20.0);
|
||||
}
|
||||
|
||||
replay_gain_limit = config_get_bool(CONF_REPLAYGAIN_LIMIT, DEFAULT_REPLAYGAIN_LIMIT);
|
||||
}
|
||||
|
||||
enum replay_gain_mode replay_gain_get_real_mode(void)
|
||||
|
@ -28,6 +28,7 @@
|
||||
extern enum replay_gain_mode replay_gain_mode;
|
||||
extern float replay_gain_preamp;
|
||||
extern float replay_gain_missing_preamp;
|
||||
extern bool replay_gain_limit;
|
||||
|
||||
void replay_gain_global_init(void);
|
||||
|
||||
|
@ -21,17 +21,23 @@
|
||||
#include "replay_gain_info.h"
|
||||
|
||||
float
|
||||
replay_gain_tuple_scale(const struct replay_gain_tuple *tuple, float preamp)
|
||||
replay_gain_tuple_scale(const struct replay_gain_tuple *tuple, float preamp, float missing_preamp, bool peak_limit)
|
||||
{
|
||||
float scale;
|
||||
|
||||
scale = pow(10.0, tuple->gain / 20.0);
|
||||
scale *= preamp;
|
||||
if (scale > 15.0)
|
||||
scale = 15.0;
|
||||
if (replay_gain_tuple_defined(tuple))
|
||||
{
|
||||
scale = pow(10.0, tuple->gain / 20.0);
|
||||
scale *= preamp;
|
||||
if (scale > 15.0)
|
||||
scale = 15.0;
|
||||
|
||||
if (scale * tuple->peak > 1.0)
|
||||
scale = 1.0 / tuple->peak;
|
||||
if (peak_limit)
|
||||
if (scale * tuple->peak > 1.0)
|
||||
scale = 1.0 / tuple->peak;
|
||||
} else {
|
||||
scale = missing_preamp;
|
||||
}
|
||||
|
||||
return scale;
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ replay_gain_tuple_defined(const struct replay_gain_tuple *tuple)
|
||||
}
|
||||
|
||||
float
|
||||
replay_gain_tuple_scale(const struct replay_gain_tuple *tuple, float preamp);
|
||||
replay_gain_tuple_scale(const struct replay_gain_tuple *tuple, float preamp, float missing_preamp, bool peak_limit);
|
||||
|
||||
/**
|
||||
* Attempt to auto-complete missing data. In particular, if album
|
||||
|
Loading…
Reference in New Issue
Block a user