# HG changeset patch # User Eugene Zagidullin # Date 1202093278 -10800 # Node ID 21008f43bb93d2dce596158967a398122a0cbff8 # Parent 63eb5966f105f80aaaf18c620ed89266e1acb131 RG improved. It f... works. diff -r 63eb5966f105 -r 21008f43bb93 src/audacious/output.c --- a/src/audacious/output.c Mon Feb 04 02:52:52 2008 +0300 +++ b/src/audacious/output.c Mon Feb 04 05:47:58 2008 +0300 @@ -23,7 +23,7 @@ * Audacious or using our public API to be a derived work. */ -#define AUD_DEBUG +/* #define AUD_DEBUG */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -492,8 +492,14 @@ fmt = output_fmt; } - if(replay_gain_info.album_peak != 0.0 || replay_gain_info.track_peak != 0.0) - apply_replaygain_info(&replay_gain_info); + if(replay_gain_info.album_peak == 0.0 && replay_gain_info.track_peak == 0.0) { + AUDDBG("RG info isn't set yet. Filling replay_gain_info with default values.\n"); + replay_gain_info.track_gain = cfg.default_gain; + replay_gain_info.track_peak = 1.0; + replay_gain_info.album_gain = cfg.default_gain; + replay_gain_info.album_peak = 1.0; + } + apply_replaygain_info(&replay_gain_info); op = get_current_output_plugin(); @@ -783,7 +789,7 @@ if(!rg_enabled) return; mode.mode = album_mode ? SAD_RG_ALBUM : SAD_RG_TRACK; - mode.preamp = 0.0; /*FIXME*/ + mode.preamp = cfg.replay_gain_preamp; info.present = TRUE; info.track_gain = rg_info->track_gain; diff -r 63eb5966f105 -r 21008f43bb93 src/audacious/ui_preferences.c --- a/src/audacious/ui_preferences.c Mon Feb 04 02:52:52 2008 +0300 +++ b/src/audacious/ui_preferences.c Mon Feb 04 05:47:58 2008 +0300 @@ -190,6 +190,7 @@ static void playlist_font_set_cb(); GtkWidget *ui_preferences_chardet_table_populate(void); static GtkWidget *ui_preferences_bit_depth(void); +static GtkWidget *ui_preferences_rg_params(void); static PreferencesWidget appearance_misc_widgets[] = { {WIDGET_LABEL, N_("_Fonts"), NULL, NULL, NULL, FALSE}, @@ -218,16 +219,19 @@ {WIDGET_CHK_BTN, N_("Detect file formats by extension."), &cfg.use_extension_probing, NULL, N_("When checked, Audacious will detect file formats based by extension. Only files with extensions of supported formats will be loaded."), FALSE}, {WIDGET_LABEL, N_("Bit Depth"), NULL, NULL, NULL, FALSE}, - {WIDGET_CUSTOM, NULL, NULL, NULL, NULL, TRUE, ui_preferences_bit_depth}, + {WIDGET_CUSTOM, NULL, NULL, NULL, NULL, FALSE, ui_preferences_bit_depth}, }; static PreferencesWidget replay_gain_page_widgets[] = { - {WIDGET_LABEL, N_("Replay Gain"), NULL, NULL, NULL, FALSE}, + {WIDGET_LABEL, N_("Replay Gain configuration"), NULL, NULL, NULL, FALSE}, {WIDGET_CHK_BTN, N_("Enable Replay Gain"), &cfg.enable_replay_gain, NULL, NULL, FALSE}, - {WIDGET_RADIO_BTN, N_("Use track gain/peak"), &cfg.replay_gain_track, NULL, NULL, TRUE}, - {WIDGET_RADIO_BTN, N_("Use album gain/peak"), &cfg.replay_gain_album, NULL, NULL, TRUE}, + {WIDGET_LABEL, N_("Replay Gain mode"), NULL, NULL, NULL, TRUE}, + {WIDGET_RADIO_BTN, N_("Track gain/peak"), &cfg.replay_gain_track, NULL, NULL, TRUE}, + {WIDGET_RADIO_BTN, N_("Album gain/peak"), &cfg.replay_gain_album, NULL, NULL, TRUE}, + {WIDGET_LABEL, N_("Miscellaneous"), NULL, NULL, NULL, TRUE}, {WIDGET_CHK_BTN, N_("Enable clipping prevention"), &cfg.enable_clipping_prevention, NULL, NULL, TRUE}, {WIDGET_CHK_BTN, N_("Enable 6 dB hard limiter"), &cfg.enable_hard_limiter, NULL, NULL, TRUE}, + {WIDGET_CUSTOM, NULL, NULL, NULL, NULL, TRUE, ui_preferences_rg_params}, }; static PreferencesWidget playback_page_widgets[] = { @@ -1676,6 +1680,65 @@ return box; } +static void +on_rg_spin_changed(GtkSpinButton *spinbutton, gpointer user_data) +{ + *((gfloat*) user_data) = gtk_spin_button_get_value(spinbutton); +} + +static GtkWidget * +ui_preferences_rg_params(void) +{ + GtkWidget *alignment = gtk_alignment_new(0.5, 0.5, 1, 1); + GtkWidget *table = gtk_table_new(2, 3, FALSE); + gtk_table_set_row_spacings (GTK_TABLE (table), 6); + gtk_table_set_col_spacings (GTK_TABLE (table), 6); + + GtkWidget *label = gtk_label_new(_("Preamp:")); + gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, + (GtkAttachOptions) (GTK_FILL), + (GtkAttachOptions) (0), 0, 0); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); + + GtkWidget *spin = gtk_spin_button_new_with_range(-15, 15, 0.01); + gtk_table_attach(GTK_TABLE(table), spin, 1, 2, 0, 1, + (GtkAttachOptions) (0), + (GtkAttachOptions) (0), 0, 0); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), cfg.replay_gain_preamp); + g_signal_connect(G_OBJECT(spin), "value_changed", G_CALLBACK(on_rg_spin_changed), &cfg.replay_gain_preamp); + + label = gtk_label_new(_("dB")); + gtk_table_attach(GTK_TABLE(table), label, 2, 3, 0, 1, + (GtkAttachOptions) (GTK_FILL), + (GtkAttachOptions) (0), 0, 0); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); + + label = gtk_label_new(_("Default gain:")); + gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, + (GtkAttachOptions) (GTK_FILL), + (GtkAttachOptions) (0), 0, 0); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); + + spin = gtk_spin_button_new_with_range(-15, 15, 0.01); + gtk_table_attach(GTK_TABLE(table), spin, 1, 2, 1, 2, + (GtkAttachOptions) (0), + (GtkAttachOptions) (0), 0, 0); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), cfg.default_gain); + g_signal_connect(G_OBJECT(spin), "value_changed", G_CALLBACK(on_rg_spin_changed), &cfg.default_gain); + gtk_tooltips_set_tip (tooltips, spin, _("This gain will be used if file doesn't contain Replay Gain metadata."), NULL); + + label = gtk_label_new(_("dB")); + gtk_table_attach(GTK_TABLE(table), label, 2, 3, 1, 2, + (GtkAttachOptions) (GTK_FILL), + (GtkAttachOptions) (0), 0, 0); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); + + gtk_container_add(GTK_CONTAINER(alignment), table); + gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 0, 0, 12, 0); + + return alignment; +} + /* it's at early stage */ static void create_widgets(GtkBox *box, PreferencesWidget *widgets, gint amt) diff -r 63eb5966f105 -r 21008f43bb93 src/libSAD/dither_ops.c --- a/src/libSAD/dither_ops.c Mon Feb 04 02:52:52 2008 +0300 +++ b/src/libSAD/dither_ops.c Mon Feb 04 05:47:58 2008 +0300 @@ -17,6 +17,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/* WARNING: reading this can damage your brain */ + #include "common.h" #include "dither_ops.h" #include "dither.h"