replay_gain: added mode "auto"
This commit is contained in:
parent
54dedef9cf
commit
92e66e5ab2
1
NEWS
1
NEWS
|
@ -77,6 +77,7 @@ ver 0.16 (20??/??/??)
|
||||||
- reimplemented as a filter plugin
|
- reimplemented as a filter plugin
|
||||||
- fall back to track gain if album gain is unavailable
|
- fall back to track gain if album gain is unavailable
|
||||||
- optionally use hardware mixer to apply replay gain
|
- optionally use hardware mixer to apply replay gain
|
||||||
|
- added mode "auto"
|
||||||
* log unused/unknown block parameters
|
* log unused/unknown block parameters
|
||||||
* removed the deprecated "error_file" option
|
* removed the deprecated "error_file" option
|
||||||
* save state when stopped
|
* save state when stopped
|
||||||
|
|
|
@ -170,12 +170,14 @@ only choice) if MPD was compiled without libsamplerate.
|
||||||
For an up-to-date list of available converters, please see the libsamplerate
|
For an up-to-date list of available converters, please see the libsamplerate
|
||||||
documentation (available online at <\fBhttp://www.mega-nerd.com/SRC/\fP>).
|
documentation (available online at <\fBhttp://www.mega-nerd.com/SRC/\fP>).
|
||||||
.TP
|
.TP
|
||||||
.B replaygain <off or album or track>
|
.B replaygain <off or album or track or auto>
|
||||||
If specified, mpd will adjust the volume of songs played using ReplayGain tags
|
If specified, mpd will adjust the volume of songs played using ReplayGain tags
|
||||||
(see <\fBhttp://www.replaygain.org/\fP>). Setting this to "album" will adjust
|
(see <\fBhttp://www.replaygain.org/\fP>). Setting this to "album" will adjust
|
||||||
volume using the album's ReplayGain tags, while setting it to "track" will
|
volume using the album's ReplayGain tags, while setting it to "track" will
|
||||||
adjust it using the track ReplayGain tags. Currently only FLAC, Ogg Vorbis,
|
adjust it using the track ReplayGain tags. "auto" uses the track ReplayGain
|
||||||
Musepack, and MP3 (through ID3v2 ReplayGain tags, not APEv2) are supported.
|
tags if random play is activated otherwise the album ReplayGain tags. Currently
|
||||||
|
only FLAC, Ogg Vorbis, Musepack, and MP3 (through ID3v2 ReplayGain tags, not
|
||||||
|
APEv2) are supported.
|
||||||
.TP
|
.TP
|
||||||
.B replaygain_preamp <-15 to 15>
|
.B replaygain_preamp <-15 to 15>
|
||||||
This is the gain (in dB) applied to songs with ReplayGain tags.
|
This is the gain (in dB) applied to songs with ReplayGain tags.
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "replay_gain_info.h"
|
#include "replay_gain_info.h"
|
||||||
#include "replay_gain_config.h"
|
#include "replay_gain_config.h"
|
||||||
#include "mixer_control.h"
|
#include "mixer_control.h"
|
||||||
|
#include "playlist.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -114,7 +115,11 @@ replay_gain_filter_init(G_GNUC_UNUSED const struct config_param *param,
|
||||||
filter_init(&filter->filter, &replay_gain_filter_plugin);
|
filter_init(&filter->filter, &replay_gain_filter_plugin);
|
||||||
filter->mixer = NULL;
|
filter->mixer = NULL;
|
||||||
|
|
||||||
filter->mode = replay_gain_mode;
|
if (replay_gain_mode == REPLAY_GAIN_AUTO) {
|
||||||
|
filter->mode = g_playlist.queue.random ? REPLAY_GAIN_TRACK : REPLAY_GAIN_ALBUM;
|
||||||
|
} else {
|
||||||
|
filter->mode = replay_gain_mode;
|
||||||
|
}
|
||||||
replay_gain_info_init(&filter->info);
|
replay_gain_info_init(&filter->info);
|
||||||
filter->volume = PCM_VOLUME_1;
|
filter->volume = PCM_VOLUME_1;
|
||||||
|
|
||||||
|
@ -161,10 +166,18 @@ replay_gain_filter_filter(struct filter *_filter,
|
||||||
(struct replay_gain_filter *)_filter;
|
(struct replay_gain_filter *)_filter;
|
||||||
bool success;
|
bool success;
|
||||||
void *dest;
|
void *dest;
|
||||||
|
enum replay_gain_mode rg_mode;
|
||||||
|
|
||||||
/* check if the mode has been changed since the last call */
|
/* check if the mode has been changed since the last call */
|
||||||
if (filter->mode != replay_gain_mode) {
|
if (replay_gain_mode == REPLAY_GAIN_AUTO) {
|
||||||
filter->mode = replay_gain_mode;
|
rg_mode = g_playlist.queue.random ? REPLAY_GAIN_TRACK : REPLAY_GAIN_ALBUM;
|
||||||
|
} else {
|
||||||
|
rg_mode = replay_gain_mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter->mode != rg_mode) {
|
||||||
|
g_debug("replay gain mode has changed %d->%d\n", filter->mode, rg_mode);
|
||||||
|
filter->mode = rg_mode;
|
||||||
replay_gain_filter_update(filter);
|
replay_gain_filter_update(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,9 @@ const char *
|
||||||
replay_gain_get_mode_string(void)
|
replay_gain_get_mode_string(void)
|
||||||
{
|
{
|
||||||
switch (replay_gain_mode) {
|
switch (replay_gain_mode) {
|
||||||
|
case REPLAY_GAIN_AUTO:
|
||||||
|
return "auto";
|
||||||
|
|
||||||
case REPLAY_GAIN_OFF:
|
case REPLAY_GAIN_OFF:
|
||||||
return "off";
|
return "off";
|
||||||
|
|
||||||
|
@ -69,6 +72,8 @@ replay_gain_set_mode_string(const char *p)
|
||||||
replay_gain_mode = REPLAY_GAIN_TRACK;
|
replay_gain_mode = REPLAY_GAIN_TRACK;
|
||||||
else if (strcmp(p, "album") == 0)
|
else if (strcmp(p, "album") == 0)
|
||||||
replay_gain_mode = REPLAY_GAIN_ALBUM;
|
replay_gain_mode = REPLAY_GAIN_ALBUM;
|
||||||
|
else if (strcmp(p, "auto") == 0)
|
||||||
|
replay_gain_mode = REPLAY_GAIN_AUTO;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,8 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
enum replay_gain_mode {
|
enum replay_gain_mode {
|
||||||
REPLAY_GAIN_OFF = -1,
|
REPLAY_GAIN_AUTO = -2,
|
||||||
|
REPLAY_GAIN_OFF,
|
||||||
REPLAY_GAIN_ALBUM,
|
REPLAY_GAIN_ALBUM,
|
||||||
REPLAY_GAIN_TRACK,
|
REPLAY_GAIN_TRACK,
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "pcm_volume.h"
|
#include "pcm_volume.h"
|
||||||
#include "idle.h"
|
#include "idle.h"
|
||||||
#include "mixer_control.h"
|
#include "mixer_control.h"
|
||||||
|
#include "playlist.h"
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
|
@ -33,6 +34,8 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
struct playlist g_playlist;
|
||||||
|
|
||||||
void
|
void
|
||||||
idle_add(G_GNUC_UNUSED unsigned flags)
|
idle_add(G_GNUC_UNUSED unsigned flags)
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "pcm_convert.h"
|
#include "pcm_convert.h"
|
||||||
#include "event_pipe.h"
|
#include "event_pipe.h"
|
||||||
#include "idle.h"
|
#include "idle.h"
|
||||||
|
#include "playlist.h"
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
|
@ -34,6 +35,8 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
struct playlist g_playlist;
|
||||||
|
|
||||||
void
|
void
|
||||||
idle_add(G_GNUC_UNUSED unsigned flags)
|
idle_add(G_GNUC_UNUSED unsigned flags)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue