Mercurial > audlegacy-plugins
changeset 2390:bd9673d8b7d5
converted to new sound engine scheme.
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Fri, 15 Feb 2008 19:10:19 +0900 |
parents | 46d3e970f0a5 |
children | 7d1411f80023 |
files | src/madplug/Makefile src/madplug/configure.c src/madplug/decoder.c src/madplug/input.c src/madplug/plugin.c src/madplug/plugin.h |
diffstat | 6 files changed, 28 insertions(+), 506 deletions(-) [+] |
line wrap: on
line diff
--- a/src/madplug/Makefile Thu Feb 14 15:44:10 2008 -0600 +++ b/src/madplug/Makefile Fri Feb 15 19:10:19 2008 +0900 @@ -1,7 +1,6 @@ PLUGIN = madplug${PLUGIN_SUFFIX} SRCS = configure.c \ - dither.c \ input.c \ replaygain.c \ decoder.c \
--- a/src/madplug/configure.c Thu Feb 14 15:44:10 2008 -0600 +++ b/src/madplug/configure.c Fri Feb 15 19:10:19 2008 +0900 @@ -35,9 +35,6 @@ { audmad_config_t *copy = g_memdup(orig, sizeof(audmad_config_t)); - copy->replaygain.preamp0_db = g_strdup(orig->replaygain.preamp0_db); - copy->replaygain.preamp1_db = g_strdup(orig->replaygain.preamp1_db); - copy->replaygain.preamp2_db = g_strdup(orig->replaygain.preamp2_db); copy->id3_format = g_strdup(orig->id3_format); return copy; @@ -46,9 +43,6 @@ static void dispose_config(audmad_config_t *config) { - g_free(config->replaygain.preamp0_db); - g_free(config->replaygain.preamp1_db); - g_free(config->replaygain.preamp2_db); g_free(config->id3_format); g_free(config); } @@ -60,25 +54,15 @@ AUDDBG("updating\n"); - GtkWidget *dither = g_object_get_data(widgets, "dither"); GtkWidget *reopen = g_object_get_data(widgets, "reopen"); GtkWidget *fast_playback = g_object_get_data(widgets, "fast_playback"); GtkWidget *use_xing = g_object_get_data(widgets, "use_xing"); GtkWidget *sjis = g_object_get_data(widgets, "sjis"); GtkWidget *show_avg = g_object_get_data(widgets, "show_avg"); - GtkWidget *RG_enable = g_object_get_data(widgets, "RG_enable"); - GtkWidget *preamp0 = g_object_get_data(widgets, "preamp0"); - GtkWidget *preamp1 = g_object_get_data(widgets, "preamp1"); - GtkWidget *preamp2 = g_object_get_data(widgets, "preamp2"); - GtkWidget *trackMode = g_object_get_data(widgets, "trackMode"); - GtkWidget *adaptive_scaler = g_object_get_data(widgets, "adaptive_scaler"); - GtkWidget *anti_clip = g_object_get_data(widgets, "anti_clip"); GtkWidget *title_override = g_object_get_data(widgets, "title_override"); GtkWidget *title_id3_entry = g_object_get_data(widgets, "title_id3_entry"); //audio - audmad_config->dither = - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dither)); audmad_config->force_reopen_audio = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(reopen)); @@ -94,50 +78,6 @@ audmad_config->show_avg_vbr_bitrate = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(show_avg)); - //gain control - text = gtk_entry_get_text(GTK_ENTRY(preamp0)); - g_free(audmad_config->replaygain.preamp0_db); - if(atof(text) > 12.0) - audmad_config->replaygain.preamp0_db = g_strdup("+12.0"); - else if(atof(text) < -12.0) - audmad_config->replaygain.preamp0_db = g_strdup("-12.0"); - else - audmad_config->replaygain.preamp0_db = g_strdup(text); - - gtk_entry_set_text(GTK_ENTRY(preamp0), audmad_config->replaygain.preamp0_db); - - audmad_config->replaygain.enable = - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(RG_enable)); - audmad_config->replaygain.track_mode = - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(trackMode)); - - text = gtk_entry_get_text(GTK_ENTRY(preamp1)); - g_free(audmad_config->replaygain.preamp1_db); - if(atof(text) > 12.0) - audmad_config->replaygain.preamp1_db = g_strdup("+12.0"); - else if(atof(text) < -12.0) - audmad_config->replaygain.preamp1_db = g_strdup("-12.0"); - else - audmad_config->replaygain.preamp1_db = g_strdup(text); - - gtk_entry_set_text(GTK_ENTRY(preamp1), audmad_config->replaygain.preamp1_db); - - text = gtk_entry_get_text(GTK_ENTRY(preamp2)); - g_free(audmad_config->replaygain.preamp2_db); - if(atof(text) > 12.0) - audmad_config->replaygain.preamp2_db = g_strdup("+12.0"); - else if(atof(text) < -12.0) - audmad_config->replaygain.preamp2_db = g_strdup("-12.0"); - else - audmad_config->replaygain.preamp2_db = g_strdup(text); - - gtk_entry_set_text(GTK_ENTRY(preamp2), audmad_config->replaygain.preamp2_db); - - audmad_config->replaygain.anti_clip = - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(anti_clip)); - audmad_config->replaygain.adaptive_scaler = - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(adaptive_scaler)); - //text audmad_config->title_override = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(title_override)); @@ -155,10 +95,7 @@ AUDDBG("saving\n"); - audmad_config_compute(audmad_config); - //audio - aud_cfg_db_set_bool(db, "MAD", "dither", audmad_config->dither); aud_cfg_db_set_bool(db, "MAD", "force_reopen_audio", audmad_config->force_reopen_audio); //metadata @@ -171,22 +108,6 @@ aud_cfg_db_set_bool(db, "MAD", "show_avg_vbr_bitrate", audmad_config->show_avg_vbr_bitrate); - //gain control - aud_cfg_db_set_string(db, "MAD", "RG.preamp0_db", - audmad_config->replaygain.preamp0_db); - aud_cfg_db_set_bool(db, "MAD", "RG.enable", - audmad_config->replaygain.enable); - aud_cfg_db_set_bool(db, "MAD", "RG.track_mode", - audmad_config->replaygain.track_mode); - aud_cfg_db_set_string(db, "MAD", "RG.preamp1_db", - audmad_config->replaygain.preamp1_db); - aud_cfg_db_set_string(db, "MAD", "RG.preamp2_db", - audmad_config->replaygain.preamp2_db); - aud_cfg_db_set_bool(db, "MAD", "RG.anti_clip", - audmad_config->replaygain.anti_clip); - aud_cfg_db_set_bool(db, "MAD", "RG.adaptive_scaler", - audmad_config->replaygain.adaptive_scaler); - //text aud_cfg_db_set_bool(db, "MAD", "title_override", audmad_config->title_override); aud_cfg_db_set_string(db, "MAD", "id3_format", audmad_config->id3_format); @@ -224,46 +145,6 @@ } static void -RG_enable_cb(GtkWidget *w, gpointer widgets) -{ - GtkWidget *type_vbox = g_object_get_data(widgets, "type_vbox"); - GtkWidget *rgtypeSet = g_object_get_data(widgets, "rgtypeSet"); - GtkWidget *preamp1_hbox = g_object_get_data(widgets, "preamp1_hbox"); - GtkWidget *preamp2_hbox = g_object_get_data(widgets, "preamp2_hbox"); - GtkWidget *anti_clip = g_object_get_data(widgets, "anti_clip"); - gboolean enabled; - - update_config(widgets); - save_config(); - - enabled = audmad_config->replaygain.enable; - - gtk_widget_set_sensitive(type_vbox, enabled); - gtk_widget_set_sensitive(rgtypeSet, enabled); - gtk_widget_set_sensitive(preamp1_hbox, enabled); - gtk_widget_set_sensitive(preamp2_hbox, enabled); - gtk_widget_set_sensitive(anti_clip, enabled); -} - -static void -RG_type_track_cb(GtkWidget *w, gpointer widgets) -{ - GtkToggleButton *tb = GTK_TOGGLE_BUTTON(g_object_get_data(widgets, "trackMode")); - - if (gtk_toggle_button_get_active(tb)) - audmad_config->replaygain.track_mode = TRUE; -} - -static void -RG_type_album_cb(GtkWidget *w, gpointer widgets) -{ - GtkToggleButton *tb = GTK_TOGGLE_BUTTON(g_object_get_data(widgets, "albumMode")); - - if (gtk_toggle_button_get_active(tb)) - audmad_config->replaygain.track_mode = FALSE; -} - -static void simple_update_cb(GtkWidget *w, gpointer widgets) { update_config(widgets); @@ -296,14 +177,10 @@ { GtkWidget *vbox; GtkWidget *bbox, *ok, *cancel; - GtkWidget *label, *preamp0_hbox, *preamp1_hbox, *preamp2_hbox; GtkWidget *notebook, *vbox2, *title_id3_label, *title_id3_box; - - GtkWidget *fast_playback, *use_xing, *dither, *sjis, *show_avg, *reopen; - GtkWidget *RG_enable, *type_vbox, *rg_vbox, *preamp0, *preamp1, *preamp2; - GtkWidget *trackMode, *albumMode, *adaptive_scaler, *anti_clip; + GtkWidget *fast_playback, *use_xing, *sjis, *show_avg, *reopen; GtkWidget *title_override, *title_id3_entry; - GtkWidget *rgtypeFrame, *replaygainFrame, *metadataFrame, *audioFrame, *miscFrame; + GtkWidget *metadataFrame, *audioFrame, *miscFrame; GtkWidget *metadata_vbox, *audio_vbox, *misc_vbox; gpointer widgets = g_object_new(G_TYPE_OBJECT, NULL); @@ -354,14 +231,6 @@ gtk_container_add(GTK_CONTAINER(audioFrame), audio_vbox); gtk_container_add(GTK_CONTAINER(vbox2), audioFrame); - dither = gtk_check_button_new_with_label - (_("Dither output when rounding to 16-bit")); - g_object_set_data(widgets, "dither", dither); - gtk_box_pack_start(GTK_BOX(audio_vbox), dither, FALSE, FALSE, 0); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dither), - audmad_config->dither); - g_signal_connect(G_OBJECT(dither), "clicked", G_CALLBACK(simple_update_cb), widgets); - reopen = gtk_check_button_new_with_label(_("Force reopen audio when audio type changed")); g_object_set_data(widgets, "reopen", reopen); gtk_box_pack_start(GTK_BOX(audio_vbox), reopen, FALSE, FALSE, 0); @@ -422,148 +291,6 @@ - /*********************************************************************************/ - - - vbox2 = gtk_vbox_new(FALSE, 10); - gtk_container_border_width(GTK_CONTAINER(vbox2), 5); - - // overall preamp - label = gtk_label_new(_("Base gain (dB):")); - preamp0_hbox = gtk_hbox_new(FALSE, 5); - gtk_box_pack_start(GTK_BOX(vbox2), preamp0_hbox, TRUE, TRUE, 0); - - preamp0 = gtk_entry_new(); - g_object_set_data(widgets, "preamp0", preamp0); - gtk_widget_set_usize(preamp0, 80, -1); - - gtk_entry_set_text(GTK_ENTRY(preamp0), audmad_config->replaygain.preamp0_db); - gtk_box_pack_start(GTK_BOX(preamp0_hbox), label, FALSE, TRUE, 0); - gtk_box_pack_start(GTK_BOX(preamp0_hbox), preamp0, FALSE, TRUE, 0); - g_signal_connect(preamp0, "changed", G_CALLBACK(entry_changed_cb), widgets); - - // replaygain frame - replaygainFrame = gtk_frame_new(_("ReplayGain Settings")); - gtk_container_border_width(GTK_CONTAINER(replaygainFrame), 5); - g_object_set_data(widgets, "replaygainFrame", replaygainFrame); - - rg_vbox = gtk_vbox_new(FALSE, 5); - g_object_set_data(widgets, "rg_vbox", rg_vbox); - gtk_container_add(GTK_CONTAINER(replaygainFrame), rg_vbox); - gtk_container_add(GTK_CONTAINER(vbox2), replaygainFrame); - - - // enable/disable replaygain - RG_enable = gtk_check_button_new_with_label(_("Enable ReplayGain processing")); - g_object_set_data(widgets, "RG_enable", RG_enable); - gtk_box_pack_start(GTK_BOX(rg_vbox), RG_enable, TRUE, TRUE, 0); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(RG_enable), - audmad_config->replaygain.enable); - - g_signal_connect(G_OBJECT(RG_enable), "clicked", G_CALLBACK(RG_enable_cb), widgets); - - - // replaygin type radio button - rgtypeFrame = gtk_frame_new(_("ReplayGain Type")); - g_object_set_data(widgets, "rgtypeFrame", rgtypeFrame); - - type_vbox = gtk_vbox_new(FALSE, 5); - g_object_set_data(widgets, "type_vbox", type_vbox); - - gtk_container_set_border_width(GTK_CONTAINER(type_vbox), 5); - gtk_container_add(GTK_CONTAINER(rgtypeFrame), type_vbox); - gtk_container_add(GTK_CONTAINER(rg_vbox), rgtypeFrame); - - trackMode = gtk_radio_button_new_with_label(NULL, _("Use Track Gain")); - g_object_set_data(widgets, "trackMode", trackMode); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(trackMode), audmad_config->replaygain.track_mode); - gtk_box_pack_start(GTK_BOX(type_vbox), trackMode, FALSE, FALSE, 0); - - - albumMode = - gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(trackMode)), - _("Use Album Gain")); - g_object_set_data(widgets, "albumMode", albumMode); - - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(albumMode), !audmad_config->replaygain.track_mode); - gtk_box_pack_start(GTK_BOX(type_vbox), albumMode, FALSE, FALSE, 0); - - // xxx - g_signal_connect(G_OBJECT(trackMode), "toggled", G_CALLBACK(RG_type_track_cb), widgets); - g_signal_connect(G_OBJECT(albumMode), "toggled", G_CALLBACK(RG_type_album_cb), widgets); - - - - // preamp for the files with RG info - label = gtk_label_new(_("Pre-gain with RG info (dB):")); - preamp1_hbox = gtk_hbox_new(FALSE, 5); - g_object_set_data(widgets, "preamp1_hbox", preamp1_hbox); - gtk_box_pack_start(GTK_BOX(rg_vbox), preamp1_hbox, TRUE, TRUE, 0); - - preamp1 = gtk_entry_new(); - g_object_set_data(widgets, "preamp1", preamp1); - gtk_widget_set_usize(preamp1, 80, -1); - gtk_entry_set_text(GTK_ENTRY(preamp1), - audmad_config->replaygain.preamp1_db); - gtk_box_pack_start(GTK_BOX(preamp1_hbox), label, FALSE, TRUE, 0); - gtk_box_pack_start(GTK_BOX(preamp1_hbox), preamp1, FALSE, TRUE, 0); - g_signal_connect(preamp1, "changed", G_CALLBACK(entry_changed_cb), widgets); - - - // preamp for the files without RG info - label = gtk_label_new(_("Pre-gain without RG info (dB):")); - preamp2_hbox = gtk_hbox_new(FALSE, 5); - g_object_set_data(widgets, "preamp2_hbox", preamp2_hbox); - gtk_box_pack_start(GTK_BOX(rg_vbox), preamp2_hbox, TRUE, TRUE, 0); - - preamp2 = gtk_entry_new(); - g_object_set_data(widgets, "preamp2", preamp2); - gtk_widget_set_usize(preamp2, 80, -1); - gtk_entry_set_text(GTK_ENTRY(preamp2), - audmad_config->replaygain.preamp2_db); - gtk_box_pack_start(GTK_BOX(preamp2_hbox), label, FALSE, TRUE, 0); - gtk_box_pack_start(GTK_BOX(preamp2_hbox), preamp2, FALSE, TRUE, 0); - g_signal_connect(preamp2, "changed", G_CALLBACK(entry_changed_cb), widgets); - - - // clipping prevention - anti_clip = gtk_check_button_new_with_label(_("Enable peak info clip prevention")); - g_object_set_data(widgets, "anti_clip", anti_clip); - gtk_box_pack_start(GTK_BOX(rg_vbox), anti_clip, TRUE, TRUE, 0); - - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(anti_clip), - audmad_config->replaygain.anti_clip); - - g_signal_connect(G_OBJECT(anti_clip), "clicked", - G_CALLBACK(simple_update_cb), widgets); - - // sensitivity - if(!audmad_config->replaygain.enable) { - gtk_widget_set_sensitive(type_vbox, FALSE); - gtk_widget_set_sensitive(rgtypeFrame, FALSE); - gtk_widget_set_sensitive(preamp1_hbox, FALSE); - gtk_widget_set_sensitive(preamp2_hbox, FALSE); - gtk_widget_set_sensitive(anti_clip, FALSE); - } - /* end of replaygainFrame */ - - - // adaptive scale - adaptive_scaler = gtk_check_button_new_with_label(_("Enable adaptive scaler clip prevention")); - g_object_set_data(widgets, "adaptive_scaler", adaptive_scaler); - gtk_box_pack_start(GTK_BOX(vbox2), adaptive_scaler, TRUE, TRUE, 0); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(adaptive_scaler), - audmad_config->replaygain.adaptive_scaler); - g_signal_connect(G_OBJECT(adaptive_scaler), "clicked", - G_CALLBACK(simple_update_cb), widgets); - - - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox2, gtk_label_new(_("Gain Control"))); - - - /*********************************************************************************/ - - vbox2 = gtk_vbox_new(FALSE, 5); title_override = gtk_check_button_new_with_label(_("Override generic titles"));
--- a/src/madplug/decoder.c Thu Feb 14 15:44:10 2008 -0600 +++ b/src/madplug/decoder.c Fri Feb 15 19:10:19 2008 +0900 @@ -36,169 +36,42 @@ #define BUFFER_SIZE 16*1024 #define N_AVERAGE_FRAMES 10 -extern int triangular_dither_noise(int nbits); - -/** - * Scale PCM data - */ -static inline signed int -scale(mad_fixed_t sample, struct mad_info_t *file_info) -{ - gdouble scale = -1; - static double a_scale = -1; - static int iter = 0; - - if (audmad_config->replaygain.enable) { - if (file_info->has_replaygain) { - // apply track gain if it is available and track mode is specified - if(file_info->replaygain_track_scale != -1) { - scale = file_info->replaygain_track_scale; - } - // apply album gain if available - if(!audmad_config->replaygain.track_mode && - file_info->replaygain_album_scale != -1) { - scale = file_info->replaygain_album_scale; - } - - // apply preamp1 - scale *= audmad_config->replaygain.preamp1_scale; - - if (audmad_config->replaygain.anti_clip) { -#ifdef AUD_DEBUG - if(iter % 100000 == 0) - AUDDBG("track_peak = %f\n", file_info->replaygain_track_peak); -#endif - if(scale * file_info->replaygain_track_peak >= 1.0) - scale = 1.0 / file_info->replaygain_track_peak; - } - } - else { - // apply preamp2 for files without RG info - scale = audmad_config->replaygain.preamp2_scale; - } - } - else { - scale = 1.0; - } - - // apply global gain - if (audmad_config->replaygain.preamp0_scale != 1) - scale = scale * audmad_config->replaygain.preamp0_scale; - - // adaptive scaler clip prevention - if (audmad_config->replaygain.adaptive_scaler) { - double x; - double a = 0.1; - int interval = 10000; - - if(a_scale == -1.0) - a_scale = scale; - - x = mad_f_todouble(sample) * a_scale; - - // clippling avoidance - if(x > 1.0) { - a_scale = a_scale + a * (1.0 - x); - AUDDBG("down: x = %f a_scale = %f\n", x, a_scale); - } - // slowly go back to defined scale - else if(iter % interval == 0 && a_scale < scale){ - a_scale = a_scale + 1.0e-4; - AUDDBG("up: a_scale = %f\n", a_scale); - } - - x = mad_f_todouble(sample) * a_scale; - sample = x * (MAD_F_ONE); - } - else { - a_scale = scale; - sample *= scale; - } - - iter++; - - int n_bits_to_loose = MAD_F_FRACBITS + 1 - 16; - - /* round */ - /* add half of the bits_to_loose range to round */ - sample += (1L << (n_bits_to_loose - 1)); - -#ifdef DEBUG_DITHER - mad_fixed_t no_dither = sample; -#endif - - /* dither one bit of actual output */ - if (audmad_config->dither) { - int dither = triangular_dither_noise(n_bits_to_loose + 1); - sample += dither; - } - - /* clip */ - /* make sure we are between -1 and 1 */ - if (sample >= MAD_F_ONE) { - sample = MAD_F_ONE - 1; - } - else if (sample < -MAD_F_ONE) { - sample = -MAD_F_ONE; - } - - /* quantize */ - /* - * Turn our mad_fixed_t into an integer. - * Shift all but 16-bits of the fractional part - * off the right hand side and shift an extra place - * to get the sign bit. - */ - sample >>= n_bits_to_loose; -#ifdef DEBUG_DITHER - static int n_zeros = 0; - no_dither >>= n_bits_to_loose; - if (no_dither - sample == 0) - n_zeros++; - else { - g_message("dither: %d %d", n_zeros, no_dither - sample); - n_zeros = 0; - } -#endif - return sample; -} - void write_output(struct mad_info_t *info, struct mad_pcm *pcm, struct mad_header *header) { unsigned int nsamples; mad_fixed_t const *left_ch, *right_ch; - char *output; - int olen = 0; + mad_fixed_t *output; + int outlen = 0; + int outbyte = 0; int pos = 0; nsamples = pcm->length; left_ch = pcm->samples[0]; right_ch = pcm->samples[1]; - olen = nsamples * MAD_NCHANNELS(header) * 2; - output = (char *) g_malloc(olen * sizeof(char)); + outlen = nsamples * MAD_NCHANNELS(header); + outbyte = outlen * sizeof(mad_fixed_t); + + output = (mad_fixed_t *) g_malloc(outbyte); while (nsamples--) { - signed int sample; - /* output sample(s) in 16-bit signed little-endian PCM */ - sample = scale(*left_ch++, info); - output[pos++] = (sample >> 0) & 0xff; - output[pos++] = (sample >> 8) & 0xff; + output[pos++] = *left_ch++; if (MAD_NCHANNELS(header) == 2) { - sample = scale(*right_ch++, info); - output[pos++] = (sample >> 0) & 0xff; - output[pos++] = (sample >> 8) & 0xff; + output[pos++] = *right_ch++; } } - assert(pos == olen); + + assert(pos == outlen); if (!info->playback->playing) { g_free(output); return; } + info->playback->pass_audio(info->playback, - FMT_S16_LE, MAD_NCHANNELS(header), olen, output, &(info->playback->playing)); + info->fmt, MAD_NCHANNELS(header), outbyte, output, + &(info->playback->playing)); g_free(output); } @@ -445,7 +318,7 @@ static gboolean check_audio_param(struct mad_info_t *info) { - if(info->fmt < FMT_U8 || info->fmt > FMT_S16_NE) + if(info->fmt != FMT_FIXED32 && (info->fmt < FMT_U8 || info->fmt > FMT_S16_NE)) return FALSE; if(info->freq < 0) // not sure about maximum frequency. --yaz return FALSE; @@ -688,6 +561,7 @@ mad_stream_sync(&stream); write_output(info, &synth.pcm, &frame.header); + mad_timer_add(&info->pos, frame.header.duration); } }
--- a/src/madplug/input.c Thu Feb 14 15:44:10 2008 -0600 +++ b/src/madplug/input.c Fri Feb 15 19:10:19 2008 +0900 @@ -76,7 +76,7 @@ memset(info, 0, sizeof(struct mad_info_t)); // all fields are cleared to 0 --yaz - info->fmt = FMT_S16_LE; + info->fmt = FMT_FIXED32; info->channels = -1; info->mpeg_layer = -1; info->size = -1;
--- a/src/madplug/plugin.c Thu Feb 14 15:44:10 2008 -0600 +++ b/src/madplug/plugin.c Fri Feb 15 19:10:19 2008 +0900 @@ -34,7 +34,6 @@ #include <fcntl.h> #include <audacious/vfs.h> #include <sys/stat.h> -#include "SFMT.h" #include "tuple.h" /* @@ -91,42 +90,6 @@ } -void -audmad_config_compute(audmad_config_t *config) -{ - /* set some config parameters by parsing text fields - (RG default gain, etc..) - */ - const gchar *text; - gdouble x; - - text = config->replaygain.preamp0_db; - if ( text != NULL ) - x = g_strtod(text, NULL); - else - x = 0; - config->replaygain.preamp0_scale = (x != 0) ? pow(10.0, x / 20) : 1; - AUDDBG("RG.preamp0=[%s] -> %g -> %g\n", text, x, config->preamp0_scale); - - text = config->replaygain.preamp1_db; - if ( text != NULL ) - x = g_strtod(text, NULL); - else - x = 0; - config->replaygain.preamp1_scale = (x != 0) ? pow(10.0, x / 20) : 1; - AUDDBG("RG.preamp1=[%s] -> %g -> %g\n", text, x, - config->replaygain.preamp1_scale); - - text = config->replaygain.preamp2_db; - if ( text != NULL ) - x = g_strtod(text, NULL); - else - x = 0; - config->replaygain.preamp2_scale = (x != 0) ? pow(10.0, x / 20) : 1; - AUDDBG("RG.preamp2=[%s] -> %g -> %g\n", text, x, - config->replaygain.preamp2_scale); -} - static void audmad_init() { @@ -140,10 +103,6 @@ audmad_config->use_xing = TRUE; audmad_config->sjis = FALSE; audmad_config->show_avg_vbr_bitrate = TRUE; - audmad_config->replaygain.enable = TRUE; - audmad_config->replaygain.track_mode = FALSE; - audmad_config->replaygain.anti_clip = FALSE; - audmad_config->replaygain.adaptive_scaler = FALSE; audmad_config->title_override = FALSE; @@ -165,22 +124,6 @@ aud_cfg_db_get_bool(db, "MAD", "show_avg_vbr_bitrate", &audmad_config->show_avg_vbr_bitrate); - //gain control - aud_cfg_db_get_string(db, "MAD", "RG.preamp0_db", - &audmad_config->replaygain.preamp0_db); - aud_cfg_db_get_bool(db, "MAD", "RG.enable", - &audmad_config->replaygain.enable); - aud_cfg_db_get_bool(db, "MAD", "RG.track_mode", - &audmad_config->replaygain.track_mode); - aud_cfg_db_get_string(db, "MAD", "RG.preamp1_db", - &audmad_config->replaygain.preamp1_db); - aud_cfg_db_get_string(db, "MAD", "RG.preamp2_db", - &audmad_config->replaygain.preamp2_db); - aud_cfg_db_get_bool(db, "MAD", "RG.anti_clip", - &audmad_config->replaygain.anti_clip); - aud_cfg_db_get_bool(db, "MAD", "RG.adaptive_scaler", - &audmad_config->replaygain.adaptive_scaler); - //text aud_cfg_db_get_bool(db, "MAD", "title_override", &audmad_config->title_override); @@ -193,30 +136,16 @@ mad_mutex = g_mutex_new(); pb_mutex = g_mutex_new(); mad_cond = g_cond_new(); - audmad_config_compute(audmad_config); - - if (!audmad_config->replaygain.preamp0_db) - audmad_config->replaygain.preamp0_db = g_strdup("+0.00"); - - if (!audmad_config->replaygain.preamp1_db) - audmad_config->replaygain.preamp1_db = g_strdup("+6.00"); - if (!audmad_config->replaygain.preamp2_db) - audmad_config->replaygain.preamp2_db = g_strdup("+0.00"); if (!audmad_config->id3_format) audmad_config->id3_format = g_strdup("(none)"); - init_gen_rand(4357); - aud_mime_set_plugin("audio/mpeg", mad_plugin); } static void audmad_cleanup() { - g_free(audmad_config->replaygain.preamp0_db); - g_free(audmad_config->replaygain.preamp1_db); - g_free(audmad_config->replaygain.preamp2_db); g_free(audmad_config->id3_format); g_free(audmad_config); @@ -458,6 +387,7 @@ { gboolean rtn; gchar *url = playback->filename; + ReplayGainInfo rg_info; #ifdef AUD_DEBUG { @@ -483,6 +413,13 @@ * that used to work only for nenolod because of his fsck-ing lastfm subscription :p */ } + + rg_info.track_gain = info.replaygain_track_scale; + rg_info.track_peak = info.replaygain_track_peak; + rg_info.album_gain = info.replaygain_album_scale; + rg_info.album_peak = info.replaygain_album_peak; + playback->set_replaygain_info(playback, &rg_info); + g_mutex_lock(pb_mutex); info.playback = playback; info.playback->playing = 1; @@ -813,7 +750,7 @@ static gchar *fmts[] = { "mp3", "mp2", "mpg", "bmu", NULL }; InputPlugin mad_ip = { - .description = "MPEG Audio Plugin", + .description = "MPEG Audio Plugin (experimental)", .init = audmad_init, .about = audmad_about, .configure = audmad_configure,
--- a/src/madplug/plugin.h Thu Feb 14 15:44:10 2008 -0600 +++ b/src/madplug/plugin.h Fri Feb 15 19:10:19 2008 +0900 @@ -109,21 +109,6 @@ gboolean use_xing; gboolean dither; gboolean sjis; - - struct - { - gchar *preamp0_db; // gain applied to samples at decoding stage. - gdouble preamp0_scale; // pow(10, pregain/20) - gboolean enable; - gboolean track_mode; - gchar *preamp1_db; // preamp used with RG info. - gdouble preamp1_scale; - gchar *preamp2_db; // preamp used without RG info. - gdouble preamp2_scale; - gboolean anti_clip; - gboolean adaptive_scaler; - } replaygain; - gboolean title_override; gchar *id3_format; gboolean show_avg_vbr_bitrate;