diff --git a/src/plugin_xmms/configure.c b/src/plugin_xmms/configure.c index 35438940..e47210d9 100644 --- a/src/plugin_xmms/configure.c +++ b/src/plugin_xmms/configure.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -45,7 +46,15 @@ flac_config_t flac_cfg = { NULL, FALSE, NULL, - NULL + NULL, + /* replaygain */ + { + FALSE, + 0, + TRUE, + TRUE, + 1 + } }; @@ -54,12 +63,15 @@ static GtkWidget *vbox, *notebook; static GtkWidget *title_tag_override, *title_tag_box, *title_tag_entry, *title_desc; static GtkWidget *convert_char_set, *fileCharacterSetEntry, *userCharacterSetEntry; +static GtkWidget *replaygain_enable, *replaygain_preamp_hscale, *replaygain_preamp_label; +static GtkObject *replaygain_preamp; static gchar *gtk_entry_get_text_1 (GtkWidget *widget); static void flac_configurewin_ok(GtkWidget * widget, gpointer data); static void configure_destroy(GtkWidget * w, gpointer data); static void title_tag_override_cb(GtkWidget * w, gpointer data); static void convert_char_set_cb(GtkWidget * w, gpointer data); +static void replaygain_enable_cb(GtkWidget * w, gpointer data); static void flac_configurewin_ok(GtkWidget * widget, gpointer data) { @@ -81,6 +93,12 @@ static void flac_configurewin_ok(GtkWidget * widget, gpointer data) xmms_cfg_write_boolean(cfg, "flac", "convert_char_set", flac_cfg.convert_char_set); xmms_cfg_write_string(cfg, "flac", "file_char_set", flac_cfg.file_char_set); xmms_cfg_write_string(cfg, "flac", "user_char_set", flac_cfg.user_char_set); + /* replaygain */ + xmms_cfg_write_boolean(cfg, "flac", "replaygain_enable", flac_cfg.replaygain.enable); + xmms_cfg_write_int(cfg, "flac", "replaygain_preamp", flac_cfg.replaygain.preamp); + xmms_cfg_write_boolean(cfg, "flac", "replaygain_hard_limit", flac_cfg.replaygain.hard_limit); + xmms_cfg_write_boolean(cfg, "flac", "replaygain_dither", flac_cfg.replaygain.dither); + xmms_cfg_write_int(cfg, "flac", "replaygain_noise_shaping", flac_cfg.replaygain.noise_shaping); xmms_cfg_write_file(cfg, filename); xmms_cfg_free(cfg); g_free(filename); @@ -111,9 +129,28 @@ static void convert_char_set_cb(GtkWidget *widget, gpointer data) gtk_widget_set_sensitive(userCharacterSetEntry, flac_cfg.convert_char_set); } +static void replaygain_enable_cb(GtkWidget *widget, gpointer data) +{ + (void)widget, (void)data; /* unused arguments */ + flac_cfg.replaygain.enable = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(replaygain_enable)); + + gtk_widget_set_sensitive(replaygain_preamp_hscale, flac_cfg.replaygain.enable); +} + +static void replaygain_preamp_cb(GtkWidget *widget, gpointer data) +{ + GString *gstring = g_string_new(""); + (void)widget, (void)data; /* unused arguments */ + flac_cfg.replaygain.preamp = (int) floor(GTK_ADJUSTMENT(replaygain_preamp)->value + 0.5); + + g_string_sprintf(gstring, "%i dB", flac_cfg.replaygain.preamp); + gtk_label_set_text(GTK_LABEL(replaygain_preamp_label), _(gstring->str)); +} + void FLAC_XMMS__configure(void) { GtkWidget *title_frame, *title_tag_vbox, *title_tag_label; + GtkWidget *replaygain_frame, *replaygain_vbox; GtkWidget *label, *hbox; GtkWidget *bbox, *ok, *cancel; GList *list; @@ -137,7 +174,7 @@ void FLAC_XMMS__configure(void) /* Title config.. */ - title_frame = gtk_frame_new(_("ID3 Tags:")); + title_frame = gtk_frame_new(_("Tag Handling")); gtk_container_border_width(GTK_CONTAINER(title_frame), 5); title_tag_vbox = gtk_vbox_new(FALSE, 10); @@ -200,6 +237,37 @@ void FLAC_XMMS__configure(void) gtk_notebook_append_page(GTK_NOTEBOOK(notebook), title_frame, gtk_label_new(_("Title"))); + /* ReplayGain config.. */ + + replaygain_frame = gtk_frame_new(_("ReplayGain")); + gtk_container_border_width(GTK_CONTAINER(replaygain_frame), 5); + + replaygain_vbox = gtk_vbox_new(FALSE, 10); + gtk_container_border_width(GTK_CONTAINER(replaygain_vbox), 5); + gtk_container_add(GTK_CONTAINER(replaygain_frame), replaygain_vbox); + + /* Preamp */ + + replaygain_enable = gtk_check_button_new_with_label(_("Enable ReplayGain processing")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(replaygain_enable), flac_cfg.replaygain.enable); + gtk_signal_connect(GTK_OBJECT(replaygain_enable), "clicked", replaygain_enable_cb, NULL); + gtk_box_pack_start(GTK_BOX(replaygain_vbox), replaygain_enable, FALSE, FALSE, 0); + + hbox = gtk_hbox_new(FALSE,3); + gtk_container_add(GTK_CONTAINER(replaygain_vbox),hbox); + label = gtk_label_new(_("Preamp:")); + gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,0); + replaygain_preamp = gtk_adjustment_new(flac_cfg.replaygain.preamp, -24.0, +24.0, 1.0, 6.0, 6.0); + gtk_signal_connect(GTK_OBJECT(replaygain_preamp), "value-changed", replaygain_preamp_cb, NULL); + replaygain_preamp_hscale = gtk_hscale_new(GTK_ADJUSTMENT(replaygain_preamp)); + gtk_widget_set_sensitive(replaygain_preamp_hscale, flac_cfg.replaygain.enable); + gtk_box_pack_start(GTK_BOX(hbox),replaygain_preamp_hscale,TRUE,TRUE,0); + replaygain_preamp_label = gtk_label_new(_("0 dB")); + gtk_box_pack_start(GTK_BOX(hbox),replaygain_preamp_label,FALSE,FALSE,0); + gtk_adjustment_value_changed(GTK_ADJUSTMENT(replaygain_preamp)); + + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), replaygain_frame, gtk_label_new(_("ReplayGain"))); + /* Buttons */ bbox = gtk_hbutton_box_new(); diff --git a/src/plugin_xmms/configure.h b/src/plugin_xmms/configure.h index 1b030503..6128921a 100644 --- a/src/plugin_xmms/configure.h +++ b/src/plugin_xmms/configure.h @@ -29,6 +29,14 @@ typedef struct { gboolean convert_char_set; gchar *file_char_set; gchar *user_char_set; + + struct { + gboolean enable; + gint preamp; + gboolean hard_limit; + gboolean dither; + guint noise_shaping; /* value must be one of NoiseShaping enum, c.f. plugin_common/replaygain_synthesis.h */ + } replaygain; } flac_config_t; extern flac_config_t flac_cfg; diff --git a/src/plugin_xmms/plugin.c b/src/plugin_xmms/plugin.c index 59b7a3ee..168faf19 100644 --- a/src/plugin_xmms/plugin.c +++ b/src/plugin_xmms/plugin.c @@ -146,6 +146,20 @@ void FLAC_XMMS__init() if(!xmms_cfg_read_string(cfg, "flac", "user_char_set", &flac_cfg.user_char_set)) flac_cfg.user_char_set = FLAC_plugin__charset_get_current(); + /* replaygain */ + + xmms_cfg_read_boolean(cfg, "flac", "replaygain_enable", &flac_cfg.replaygain.enable); + + if(!xmms_cfg_read_int(cfg, "flac", "replaygain_preamp", &flac_cfg.replaygain.preamp)) + flac_cfg.replaygain.preamp = 0; + + xmms_cfg_read_boolean(cfg, "flac", "replaygain_hard_limit", &flac_cfg.replaygain.hard_limit); + + xmms_cfg_read_boolean(cfg, "flac", "replaygain_dither", &flac_cfg.replaygain.dither); + + if(!xmms_cfg_read_int(cfg, "flac", "replaygain_noise_shaping", &flac_cfg.replaygain.noise_shaping)) + flac_cfg.replaygain.noise_shaping = 1; + decoder_ = FLAC__file_decoder_new(); } diff --git a/src/plugin_xmms/wrap_id3.c b/src/plugin_xmms/wrap_id3.c index cb697904..c5a0ef90 100644 --- a/src/plugin_xmms/wrap_id3.c +++ b/src/plugin_xmms/wrap_id3.c @@ -109,6 +109,9 @@ char *flac_format_song_title(char *filename) input->file_path = filename; input->file_ext = local__extname(filename); ret = xmms_get_titlestring(flac_cfg.tag_override ? flac_cfg.tag_format : xmms_get_gentitle_format(), input); +fprintf(stderr,"@@@@ override=%c\n",flac_cfg.tag_override?'y':'n'); +fprintf(stderr,"@@@@ fmt=%s\n",flac_cfg.tag_override ? flac_cfg.tag_format : xmms_get_gentitle_format()); +fprintf(stderr,"@@@@ ret=%s\n",ret); g_free(input); if (!ret) {