summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jan D. Behrens <zykure@web.de>2011-09-01 12:36:13 +0200
committerGravatar waker <wakeroid@gmail.com>2011-10-02 10:14:42 +0200
commit290bb2255d8e21ba79521d033c5fcfd50acd67b4 (patch)
treeeb4e28c46c1bcc2bd8758d12fc2139ff7e43416e
parent221b91c86953434cd2a56a5af76928e42cc03d8c (diff)
Add-global-preamp-in-addition-to-replaygain-preamp Global preamp is applied to all tracks, while replaygain preamp is only applied to tracks with rg info.
-rw-r--r--plugins/gtkui/callbacks.h4
-rw-r--r--plugins/gtkui/deadbeef.glade107
-rw-r--r--plugins/gtkui/interface.c35
-rw-r--r--plugins/gtkui/prefwin.c11
-rw-r--r--replaygain.c43
-rw-r--r--replaygain.h2
-rw-r--r--streamer.c4
7 files changed, 187 insertions, 19 deletions
diff --git a/plugins/gtkui/callbacks.h b/plugins/gtkui/callbacks.h
index fd92b376..149b04fc 100644
--- a/plugins/gtkui/callbacks.h
+++ b/plugins/gtkui/callbacks.h
@@ -1105,6 +1105,10 @@ on_replaygain_preamp_value_changed (GtkRange *range,
gpointer user_data);
void
+on_global_preamp_value_changed (GtkRange *range,
+ gpointer user_data);
+
+void
on_tabstrip_text_color_set (GtkColorButton *colorbutton,
gpointer user_data);
diff --git a/plugins/gtkui/deadbeef.glade b/plugins/gtkui/deadbeef.glade
index 73759b65..aacb6ab3 100644
--- a/plugins/gtkui/deadbeef.glade
+++ b/plugins/gtkui/deadbeef.glade
@@ -2781,6 +2781,113 @@ Album</property>
</child>
<child>
+ <widget class="GtkHBox" id="hbox100a">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">8</property>
+
+ <child>
+ <widget class="GtkLabel" id="label124a">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Global preamp:</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label125a">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">-12 dB</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHScale" id="global_preamp">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="draw_value">True</property>
+ <property name="value_pos">GTK_POS_BOTTOM</property>
+ <property name="digits">0</property>
+ <property name="update_policy">GTK_UPDATE_CONTINUOUS</property>
+ <property name="inverted">False</property>
+ <property name="adjustment">0 -12 12 0 0 0</property>
+ <signal name="value_changed" handler="on_global_preamp_value_changed" last_modification_time="Sat, 01 Sep 2011 11:40:00 GMT"/>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label126a">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">+12 dB</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
<widget class="GtkHBox" id="hbox66">
<property name="visible">True</property>
<property name="homogeneous">False</property>
diff --git a/plugins/gtkui/interface.c b/plugins/gtkui/interface.c
index 67d70dba..2478edaf 100644
--- a/plugins/gtkui/interface.c
+++ b/plugins/gtkui/interface.c
@@ -1667,6 +1667,11 @@ create_prefwin (void)
GtkWidget *label125;
GtkWidget *replaygain_preamp;
GtkWidget *label126;
+ GtkWidget *hbox100a;
+ GtkWidget *label124a;
+ GtkWidget *label125a;
+ GtkWidget *global_preamp;
+ GtkWidget *label126a;
GtkWidget *hbox66;
GtkWidget *cli_add_to_playlist;
GtkWidget *cli_playlist_name;
@@ -1894,6 +1899,28 @@ create_prefwin (void)
gtk_widget_show (label126);
gtk_box_pack_start (GTK_BOX (hbox100), label126, FALSE, FALSE, 0);
+ hbox100a = gtk_hbox_new (FALSE, 8);
+ gtk_widget_show (hbox100a);
+ gtk_box_pack_start (GTK_BOX (vbox8), hbox100a, FALSE, FALSE, 0);
+
+ label124a = gtk_label_new (_("Global preamp:"));
+ gtk_widget_show (label124a);
+ gtk_box_pack_start (GTK_BOX (hbox100a), label124a, FALSE, FALSE, 0);
+
+ label125a = gtk_label_new (_("-12 dB"));
+ gtk_widget_show (label125a);
+ gtk_box_pack_start (GTK_BOX (hbox100a), label125a, FALSE, FALSE, 0);
+
+ global_preamp = gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (0, -12, 12, 0, 0, 0)));
+ gtk_widget_show (global_preamp);
+ gtk_box_pack_start (GTK_BOX (hbox100a), global_preamp, TRUE, TRUE, 0);
+ gtk_scale_set_value_pos (GTK_SCALE (global_preamp), GTK_POS_BOTTOM);
+ gtk_scale_set_digits (GTK_SCALE (global_preamp), 0);
+
+ label126a = gtk_label_new (_("+12 dB"));
+ gtk_widget_show (label126a);
+ gtk_box_pack_start (GTK_BOX (hbox100a), label126a, FALSE, FALSE, 0);
+
hbox66 = gtk_hbox_new (FALSE, 8);
gtk_widget_show (hbox66);
gtk_box_pack_start (GTK_BOX (vbox8), hbox66, FALSE, FALSE, 0);
@@ -2534,6 +2561,9 @@ create_prefwin (void)
g_signal_connect ((gpointer) replaygain_preamp, "value_changed",
G_CALLBACK (on_replaygain_preamp_value_changed),
NULL);
+ g_signal_connect ((gpointer) global_preamp, "value_changed",
+ G_CALLBACK (on_global_preamp_value_changed),
+ NULL);
g_signal_connect ((gpointer) cli_add_to_playlist, "toggled",
G_CALLBACK (on_cli_add_to_playlist_toggled),
NULL);
@@ -2699,6 +2729,11 @@ create_prefwin (void)
GLADE_HOOKUP_OBJECT (prefwin, label125, "label125");
GLADE_HOOKUP_OBJECT (prefwin, replaygain_preamp, "replaygain_preamp");
GLADE_HOOKUP_OBJECT (prefwin, label126, "label126");
+ GLADE_HOOKUP_OBJECT (prefwin, hbox100a, "hbox100a");
+ GLADE_HOOKUP_OBJECT (prefwin, label124a, "label124a");
+ GLADE_HOOKUP_OBJECT (prefwin, label125a, "label125a");
+ GLADE_HOOKUP_OBJECT (prefwin, global_preamp, "global_preamp");
+ GLADE_HOOKUP_OBJECT (prefwin, label126a, "label126a");
GLADE_HOOKUP_OBJECT (prefwin, hbox66, "hbox66");
GLADE_HOOKUP_OBJECT (prefwin, cli_add_to_playlist, "cli_add_to_playlist");
GLADE_HOOKUP_OBJECT (prefwin, cli_playlist_name, "cli_playlist_name");
diff --git a/plugins/gtkui/prefwin.c b/plugins/gtkui/prefwin.c
index 4f6207f4..3c0e0932 100644
--- a/plugins/gtkui/prefwin.c
+++ b/plugins/gtkui/prefwin.c
@@ -500,6 +500,9 @@ on_preferences_activate (GtkMenuItem *menuitem,
// replaygain_preamp
gtk_range_set_value (GTK_RANGE (lookup_widget (w, "replaygain_preamp")), deadbeef->conf_get_int ("replaygain_preamp", 0));
+ // global_preamp
+ gtk_range_set_value (GTK_RANGE (lookup_widget (w, "global_preamp")), deadbeef->conf_get_int ("global_preamp", 0));
+
// 8_to_16
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lookup_widget (w, "convert8to16")), deadbeef->conf_get_int ("streamer.8_to_16", 1));
@@ -725,6 +728,14 @@ on_replaygain_preamp_value_changed (GtkRange *range,
deadbeef->sendmessage (DB_EV_CONFIGCHANGED, 0, 0, 0);
}
+void
+on_global_preamp_value_changed (GtkRange *range,
+ gpointer user_data)
+{
+ float val = gtk_range_get_value (range);
+ deadbeef->conf_set_float ("global_preamp", val);
+ deadbeef->sendmessage (DB_EV_CONFIGCHANGED, 0, 0, 0);
+}
void
on_pref_close_send_to_tray_clicked (GtkButton *button,
diff --git a/replaygain.c b/replaygain.c
index 887580f1..b2791b4c 100644
--- a/replaygain.c
+++ b/replaygain.c
@@ -24,13 +24,16 @@
static int conf_replaygain_mode = 0;
static int conf_replaygain_scale = 1;
static float conf_replaygain_preamp = 0;
+static float conf_global_preamp = 0;
static float rg_albumgain = 1;
static float rg_albumpeak = 1;
static float rg_trackgain = 1;
static float rg_trackpeak = 1;
-static float rg_albumgain_preamp = 1;
-static float rg_trackgain_preamp = 1;
+static float rg_albumgain_full_preamp = 1;
+static float rg_trackgain_full_preamp = 1;
+static float rg_albumgain_global_preamp = 1;
+static float rg_trackgain_global_preamp = 1;
void
replaygain_apply (ddb_waveformat_t *fmt, playItem_t *it, char *bytes, int bytesread) {
@@ -53,12 +56,15 @@ replaygain_apply (ddb_waveformat_t *fmt, playItem_t *it, char *bytes, int bytesr
}
void
-replaygain_set (int mode, int scale, float preamp) {
+replaygain_set (int mode, int scale, float preamp, float global_preamp) {
conf_replaygain_mode = mode;
conf_replaygain_scale = scale;
conf_replaygain_preamp = db_to_amp (preamp);
- rg_albumgain_preamp = rg_albumgain * conf_replaygain_preamp;
- rg_trackgain_preamp = rg_trackgain * conf_replaygain_preamp;
+ conf_global_preamp = db_to_amp (global_preamp);
+ rg_albumgain_full_preamp = rg_albumgain * conf_replaygain_preamp * conf_global_preamp;
+ rg_trackgain_full_preamp = rg_trackgain * conf_replaygain_preamp * conf_global_preamp;
+ rg_albumgain_global_preamp = rg_albumgain * conf_global_preamp;
+ rg_trackgain_global_preamp = rg_trackgain * conf_global_preamp;
}
void
@@ -76,8 +82,10 @@ replaygain_set_values (float albumgain, float albumpeak, float trackgain, float
}
rg_albumgain = db_to_amp (albumgain);
rg_trackgain = db_to_amp (trackgain);
- rg_albumgain_preamp = rg_albumgain * conf_replaygain_preamp;
- rg_trackgain_preamp = rg_trackgain * conf_replaygain_preamp;
+ rg_albumgain_full_preamp = rg_albumgain * conf_replaygain_preamp * conf_global_preamp;
+ rg_trackgain_full_preamp = rg_trackgain * conf_replaygain_preamp * conf_global_preamp;
+ rg_albumgain_global_preamp = rg_albumgain * conf_global_preamp;
+ rg_trackgain_global_preamp = rg_trackgain * conf_global_preamp;
rg_albumpeak = albumpeak;
rg_trackpeak = trackpeak;
}
@@ -87,9 +95,10 @@ get_int_volume (void) {
int vol = 1000;
if (conf_replaygain_mode == 1) {
if (rg_trackgain == 1) {
- return -1;
+ vol = rg_trackgain_global_preamp * 1000;
+ } else {
+ vol = rg_trackgain_full_preamp * 1000;
}
- vol = rg_trackgain * 1000;
if (conf_replaygain_scale) {
if (vol * rg_trackpeak > 1000) {
vol = 1000 / rg_trackpeak;
@@ -98,16 +107,16 @@ get_int_volume (void) {
}
else if (conf_replaygain_mode == 2) {
if (rg_albumgain == 1) {
- return -1;
+ vol = rg_albumgain_global_preamp * 1000;
+ } else {
+ vol = rg_albumgain_full_preamp * 1000;
}
- vol = rg_albumgain * 1000;
if (conf_replaygain_scale) {
if (vol * rg_albumpeak > 1000) {
vol = 1000 / rg_albumpeak;
}
}
}
- vol *= conf_replaygain_preamp;
return vol;
}
@@ -214,9 +223,10 @@ apply_replay_gain_float32 (playItem_t *it, char *bytes, int size) {
float vol = 1.f;
if (conf_replaygain_mode == 1) {
if (rg_trackgain == 1) {
- return;
+ vol = rg_trackgain_global_preamp;
+ } else {
+ vol = rg_trackgain_full_preamp;
}
- vol = rg_trackgain_preamp;
if (conf_replaygain_scale) {
if (vol * rg_trackpeak > 1.f) {
vol = 1.f / rg_trackpeak;
@@ -225,9 +235,10 @@ apply_replay_gain_float32 (playItem_t *it, char *bytes, int size) {
}
else if (conf_replaygain_mode == 2) {
if (rg_albumgain == 1) {
- return;
+ vol = rg_albumgain_global_preamp;
+ } else {
+ vol = rg_albumgain_full_preamp;
}
- vol = rg_albumgain_preamp;
if (conf_replaygain_scale) {
if (vol * rg_albumpeak > 1.f) {
vol = 1.f / rg_albumpeak;
diff --git a/replaygain.h b/replaygain.h
index cee57782..f7027230 100644
--- a/replaygain.h
+++ b/replaygain.h
@@ -25,7 +25,7 @@ void
replaygain_apply (ddb_waveformat_t *fmt, playItem_t *it, char *bytes, int bytesread);
void
-replaygain_set (int mode, int scale, float preamp);
+replaygain_set (int mode, int scale, float preamp, float global_preamp);
void
replaygain_set_values (float albumgain, float albumpeak, float trackgain, float trackpeak);
diff --git a/streamer.c b/streamer.c
index 07e835ce..e5aecfa3 100644
--- a/streamer.c
+++ b/streamer.c
@@ -1713,7 +1713,7 @@ streamer_init (void) {
streamer_dsp_init ();
- replaygain_set (conf_get_int ("replaygain_mode", 0), conf_get_int ("replaygain_scale", 1), conf_get_float ("replaygain_preamp", 0));
+ replaygain_set (conf_get_int ("replaygain_mode", 0), conf_get_int ("replaygain_scale", 1), conf_get_float ("replaygain_preamp", 0), conf_get_float ("global_preamp", 0));
streamer_tid = thread_start (streamer_thread, NULL);
return 0;
}
@@ -2089,7 +2089,7 @@ streamer_ok_to_read (int len) {
void
streamer_configchanged (void) {
- replaygain_set (conf_get_int ("replaygain_mode", 0), conf_get_int ("replaygain_scale", 1), conf_get_float ("replaygain_preamp", 0));
+ replaygain_set (conf_get_int ("replaygain_mode", 0), conf_get_int ("replaygain_scale", 1), conf_get_float ("replaygain_preamp", 0), conf_get_float ("global_preamp", 0));
pl_set_order (conf_get_int ("playback.order", 0));
if (playing_track) {
playing_track->played = 1;