Mercurial > audlegacy
changeset 4306:172d49b1200b
- equalizer sliders range changed to -12..12 dB
- removed duplicated code
author | Eugene Zagidullin <e.asphyx@gmail.com> |
---|---|
date | Mon, 25 Feb 2008 01:32:18 +0300 |
parents | 59b573234ba2 |
children | cfaecedace4e |
files | src/audacious/equalizer_flow.h src/audacious/output.c src/audacious/ui_equalizer.c src/audacious/ui_skinned_equalizer_slider.c |
diffstat | 4 files changed, 35 insertions(+), 48 deletions(-) [+] |
line wrap: on
line diff
--- a/src/audacious/equalizer_flow.h Sun Feb 24 18:35:50 2008 +0300 +++ b/src/audacious/equalizer_flow.h Mon Feb 25 01:32:18 2008 +0300 @@ -3,6 +3,8 @@ #include "flow.h" +#define EQUALIZER_MAX_GAIN 12.0 + void equalizer_flow(FlowContext *context); void equalizer_flow_set_bands(gfloat pre, gfloat *bands); void equalizer_flow_free();
--- a/src/audacious/output.c Sun Feb 24 18:35:50 2008 +0300 +++ b/src/audacious/output.c Mon Feb 25 01:32:18 2008 +0300 @@ -221,25 +221,10 @@ void output_set_eq(gboolean active, gfloat pre, gfloat * bands) { - int i; - /* - preamp[0] = 1.0 + 0.0932471 * pre + 0.00279033 * pre * pre; - preamp[1] = 1.0 + 0.0932471 * pre + 0.00279033 * pre * pre; AUDDBG("preamp: %f, bands: %f:%f:%f:%f:%f:%f:%f:%f:%f:%f\n", pre, bands[0], bands[1], bands[2], bands[3], bands[4], bands[5], bands[6], bands[7], bands[8], bands[9]); - for (i = 0; i < 10; ++i) - { - set_gain(i, 0, 0.03 * bands[i] + 0.000999999 * bands[i] * bands[i]); - set_gain(i, 1, 0.03 * bands[i] + 0.000999999 * bands[i] * bands[i]); - } - */ - - gfloat b[10]; - for (i = 0; i < 10; i++) { - b[i] = bands[i] * 12.0 / 20.0; /* FIXME: change equalizer sliders range from -20..20 to -12..12 dB --asphyx */ - } - equalizer_flow_set_bands(pre, b); + equalizer_flow_set_bands(pre, bands); } /* called by input plugin to peek at the output plugin's write progress */
--- a/src/audacious/ui_equalizer.c Sun Feb 24 18:35:50 2008 +0300 +++ b/src/audacious/ui_equalizer.c Mon Feb 25 01:32:18 2008 +0300 @@ -48,6 +48,7 @@ #include "ui_playlist.h" #include "util.h" #include "output.h" +#include "equalizer_flow.h" #include "rcfile.h" #include "vfs.h" @@ -766,23 +767,21 @@ } } - -static GList * -import_winamp_eqf(VFSFile * file) +static EqualizerPreset * +load_winamp_eqf(VFSFile * file) { gchar header[31]; gchar *name; gchar *filename; gchar bands[11]; gint i = 0; - GList *list = NULL; - EqualizerPreset *preset; + EqualizerPreset *preset = NULL; vfs_fread(header, 1, 31, file); if (!strncmp(header, "Winamp EQ library file v1.1", 27)) { - g_print("The EQF header is OK\n"); + AUDDBG("The EQF header is OK\n"); if(vfs_fseek(file, 0x120, SEEK_SET) == -1) return NULL; @@ -792,17 +791,28 @@ filename = g_filename_from_uri(file->uri,NULL,NULL); name = g_path_get_basename(filename); g_free(filename); - g_print("The preset name is '%s'\n", name); + AUDDBG("The preset name is '%s'\n", name); preset = equalizer_preset_new(name); g_free(name); - preset->preamp = 20.0 - ((bands[10] * 40.0) / 64.0); + /*this was divided by 63, but shouldn't it be 64? --majeru*/ + preset->preamp = EQUALIZER_MAX_GAIN - ((bands[10] * EQUALIZER_MAX_GAIN * 2) / 64.0); for (i = 0; i < 10; i++) - preset->bands[i] = 20.0 - ((bands[i] * 40.0) / 64.0); + preset->bands[i] = EQUALIZER_MAX_GAIN - ((bands[i] * EQUALIZER_MAX_GAIN) / 64.0); + } + + return preset; +} - list = g_list_prepend(list, preset); - } +static GList * +import_winamp_eqf(VFSFile * file) +{ + EqualizerPreset *preset; + GList *list = NULL; + + if((preset = load_winamp_eqf(file)) == NULL) return NULL; + list = g_list_prepend(list, preset); list = g_list_reverse(list); return list; } @@ -810,28 +820,17 @@ static void equalizerwin_read_winamp_eqf(VFSFile * file) { - gchar header[31]; - guchar bands[11]; + EqualizerPreset *preset; gint i; - vfs_fread(header, 1, 31, file); + if((preset = load_winamp_eqf(file)) == NULL) return; - if (!strncmp(header, "Winamp EQ library file v1.1", 27)) { - /* Skip name */ - if (vfs_fseek(file, 0x120, SEEK_SET) == -1) - return; + ui_skinned_equalizer_slider_set_position(equalizerwin_preamp, preset->preamp); - if (vfs_fread(bands, 1, 11, file) != 11) - return; - - ui_skinned_equalizer_slider_set_position(equalizerwin_preamp, - 20.0 - ((bands[10] * 40.0) / 64.0)); /*this was divided by 63, but shouldn't it be 64? --majeru*/ + for (i = 0; i < 10; i++) + ui_skinned_equalizer_slider_set_position(equalizerwin_bands[i], preset->bands[i]); - for (i = 0; i < 10; i++) - ui_skinned_equalizer_slider_set_position(equalizerwin_bands[i], - 20.0 - ((bands[i] * 40.0) / 64.0)); - } - + equalizer_preset_free(preset); equalizerwin_eq_changed(); } @@ -1089,8 +1088,8 @@ vfs_fwrite(name, 1, 257, file); for (i = 0; i < 10; i++) - bands[i] = 63 - (((ui_skinned_equalizer_slider_get_position(equalizerwin_bands[i]) + 20) * 63) / 40); - bands[10] = 63 - (((ui_skinned_equalizer_slider_get_position(equalizerwin_preamp) + 20) * 63) / 40); + bands[i] = 63 - (((ui_skinned_equalizer_slider_get_position(equalizerwin_bands[i]) + EQUALIZER_MAX_GAIN) * 63) / EQUALIZER_MAX_GAIN / 2); + bands[10] = 63 - (((ui_skinned_equalizer_slider_get_position(equalizerwin_preamp) + EQUALIZER_MAX_GAIN) * 63) / EQUALIZER_MAX_GAIN / 2); vfs_fwrite(bands, 1, 11, file); vfs_fclose(file);
--- a/src/audacious/ui_skinned_equalizer_slider.c Sun Feb 24 18:35:50 2008 +0300 +++ b/src/audacious/ui_skinned_equalizer_slider.c Mon Feb 25 01:32:18 2008 +0300 @@ -26,6 +26,7 @@ #include "util.h" #include "ui_equalizer.h" #include "ui_main.h" +#include "equalizer_flow.h" #include <glib/gi18n.h> #define UI_TYPE_SKINNED_EQUALIZER_SLIDER (ui_skinned_equalizer_slider_get_type()) @@ -346,7 +347,7 @@ if (priv->pressed) return; - priv->position = 25 - (gint) ((pos * 25.0) / 20.0); + priv->position = 25 - (gint) ((pos * 25.0) / EQUALIZER_MAX_GAIN); if (priv->position < 0) priv->position = 0; @@ -363,7 +364,7 @@ gfloat ui_skinned_equalizer_slider_get_position(GtkWidget *widget) { g_return_val_if_fail (UI_SKINNED_IS_EQUALIZER_SLIDER (widget), -1); UiSkinnedEqualizerSliderPrivate *priv = UI_SKINNED_EQUALIZER_SLIDER_GET_PRIVATE(widget); - return (20.0 - (((gfloat) priv->position * 20.0) / 25.0)); + return (EQUALIZER_MAX_GAIN - (((gfloat) priv->position * EQUALIZER_MAX_GAIN) / 25.0)); } void ui_skinned_equalizer_slider_set_mainwin_text(UiSkinnedEqualizerSlider * es) {