Mercurial > audlegacy
comparison src/audacious/ui_equalizer.c @ 4307:cfaecedace4e
importing of winamp EQ presets library
| author | Eugene Zagidullin <e.asphyx@gmail.com> |
|---|---|
| date | Mon, 25 Feb 2008 02:29:28 +0300 |
| parents | 172d49b1200b |
| children | e708d98dcc0c |
comparison
equal
deleted
inserted
replaced
| 4306:172d49b1200b | 4307:cfaecedace4e |
|---|---|
| 21 * | 21 * |
| 22 * The Audacious team does not consider modular code linking to | 22 * The Audacious team does not consider modular code linking to |
| 23 * Audacious or using our public API to be a derived work. | 23 * Audacious or using our public API to be a derived work. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 /*#define AUD_DEBUG*/ | |
| 27 | |
| 26 #ifdef HAVE_CONFIG_H | 28 #ifdef HAVE_CONFIG_H |
| 27 # include "config.h" | 29 # include "config.h" |
| 28 #endif | 30 #endif |
| 29 | 31 |
| 30 #include "ui_equalizer.h" | 32 #include "ui_equalizer.h" |
| 765 | 767 |
| 766 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | 768 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
| 767 } | 769 } |
| 768 } | 770 } |
| 769 | 771 |
| 770 static EqualizerPreset * | 772 static GList * |
| 771 load_winamp_eqf(VFSFile * file) | 773 import_winamp_eqf(VFSFile * file) |
| 772 { | 774 { |
| 773 gchar header[31]; | 775 gchar header[31]; |
| 774 gchar *name; | |
| 775 gchar *filename; | |
| 776 gchar bands[11]; | 776 gchar bands[11]; |
| 777 gint i = 0; | 777 gint i = 0; |
| 778 EqualizerPreset *preset = NULL; | 778 EqualizerPreset *preset = NULL; |
| 779 GList *list = NULL; | |
| 780 gchar preset_name[0xb4]; | |
| 779 | 781 |
| 780 vfs_fread(header, 1, 31, file); | 782 vfs_fread(header, 1, 31, file); |
| 781 if (!strncmp(header, "Winamp EQ library file v1.1", 27)) | 783 if (strncmp(header, "Winamp EQ library file v1.1", 27)) return NULL; |
| 782 { | 784 |
| 783 | 785 AUDDBG("The EQF header is OK\n"); |
| 784 AUDDBG("The EQF header is OK\n"); | 786 |
| 785 | 787 if(vfs_fseek(file, 0x1f, SEEK_SET) == -1) return NULL; |
| 786 if(vfs_fseek(file, 0x120, SEEK_SET) == -1) | 788 |
| 787 return NULL; | 789 while(vfs_fread(preset_name, 1, 0xb4, file) == 0xb4) { |
| 788 if(vfs_fread(bands, 1, 11, file) != 11) | 790 AUDDBG("The preset name is '%s'\n", preset_name); |
| 789 return NULL; | 791 vfs_fseek(file, 0x4d, SEEK_CUR); /* unknown crap --asphyx */ |
| 790 | 792 if(vfs_fread(bands, 1, 11, file) != 11) break; |
| 791 filename = g_filename_from_uri(file->uri,NULL,NULL); | 793 |
| 792 name = g_path_get_basename(filename); | 794 preset = equalizer_preset_new(preset_name); |
| 793 g_free(filename); | |
| 794 AUDDBG("The preset name is '%s'\n", name); | |
| 795 | |
| 796 preset = equalizer_preset_new(name); | |
| 797 g_free(name); | |
| 798 /*this was divided by 63, but shouldn't it be 64? --majeru*/ | 795 /*this was divided by 63, but shouldn't it be 64? --majeru*/ |
| 799 preset->preamp = EQUALIZER_MAX_GAIN - ((bands[10] * EQUALIZER_MAX_GAIN * 2) / 64.0); | 796 preset->preamp = EQUALIZER_MAX_GAIN - ((bands[10] * EQUALIZER_MAX_GAIN * 2) / 64.0); |
| 800 | 797 |
| 801 for (i = 0; i < 10; i++) | 798 for (i = 0; i < 10; i++) |
| 802 preset->bands[i] = EQUALIZER_MAX_GAIN - ((bands[i] * EQUALIZER_MAX_GAIN) / 64.0); | 799 preset->bands[i] = EQUALIZER_MAX_GAIN - ((bands[i] * EQUALIZER_MAX_GAIN * 2) / 64.0); |
| 803 } | 800 |
| 804 | 801 list = g_list_prepend(list, preset); |
| 805 return preset; | 802 } |
| 806 } | 803 |
| 807 | 804 /*list = g_list_reverse(list);*/ |
| 808 static GList * | 805 |
| 809 import_winamp_eqf(VFSFile * file) | |
| 810 { | |
| 811 EqualizerPreset *preset; | |
| 812 GList *list = NULL; | |
| 813 | |
| 814 if((preset = load_winamp_eqf(file)) == NULL) return NULL; | |
| 815 list = g_list_prepend(list, preset); | |
| 816 list = g_list_reverse(list); | |
| 817 return list; | 806 return list; |
| 818 } | 807 } |
| 819 | 808 |
| 820 static void | 809 static void |
| 810 free_cb (gpointer data, gpointer user_data) | |
| 811 { | |
| 812 equalizer_preset_free((EqualizerPreset*)data); | |
| 813 } | |
| 814 | |
| 815 static void | |
| 821 equalizerwin_read_winamp_eqf(VFSFile * file) | 816 equalizerwin_read_winamp_eqf(VFSFile * file) |
| 822 { | 817 { |
| 823 EqualizerPreset *preset; | 818 GList *presets; |
| 824 gint i; | 819 gint i; |
| 825 | 820 |
| 826 if((preset = load_winamp_eqf(file)) == NULL) return; | 821 if((presets = import_winamp_eqf(file)) == NULL) return; |
| 822 EqualizerPreset *preset = (EqualizerPreset*)presets->data; /* just get the first preset --asphyx */ | |
| 827 | 823 |
| 828 ui_skinned_equalizer_slider_set_position(equalizerwin_preamp, preset->preamp); | 824 ui_skinned_equalizer_slider_set_position(equalizerwin_preamp, preset->preamp); |
| 829 | 825 |
| 830 for (i = 0; i < 10; i++) | 826 for (i = 0; i < 10; i++) |
| 831 ui_skinned_equalizer_slider_set_position(equalizerwin_bands[i], preset->bands[i]); | 827 ui_skinned_equalizer_slider_set_position(equalizerwin_bands[i], preset->bands[i]); |
| 832 | 828 |
| 833 equalizer_preset_free(preset); | 829 g_list_foreach(presets, free_cb, NULL); |
| 830 g_list_free(presets); | |
| 831 | |
| 834 equalizerwin_eq_changed(); | 832 equalizerwin_eq_changed(); |
| 835 } | 833 } |
| 836 | 834 |
| 837 static void | 835 static void |
| 838 equalizerwin_read_bmp_preset(RcFile * rcfile) | 836 equalizerwin_read_bmp_preset(RcFile * rcfile) |
