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