Mercurial > audlegacy
annotate src/audacious/equalizer_preset.c @ 4722:1a13d88b72f3
remove legacy interface preferences from ui_preferences.c
author | Tomasz Mon <desowin@gmail.com> |
---|---|
date | Sun, 13 Jul 2008 12:44:23 +0200 |
parents | a33facf19590 |
children |
rev | line source |
---|---|
4704
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
1 /* Audacious - Cross-platform multimedia player |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
2 * Copyright (C) 2005-2008 Audacious team |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
3 * |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
6 * the Free Software Foundation; under version 3 of the License. |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
7 * |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
8 * This program is distributed in the hope that it will be useful, |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
11 * GNU General Public License for more details. |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
12 * |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
13 * You should have received a copy of the GNU General Public License |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
14 * along with this program. If not, see <http://www.gnu.org/licenses>. |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
15 * |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
16 * The Audacious team does not consider modular code linking to |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
17 * Audacious or using our public API to be a derived work. |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
18 */ |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
19 |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
20 /*#define AUD_DEBUG*/ |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
21 |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
22 #include <glib.h> |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
23 #include <math.h> |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
24 #include "config.h" |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
25 #include "i18n.h" |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
26 #include "main.h" |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
27 #include "plugin.h" |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
28 #include "rcfile.h" |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
29 #include "equalizer_preset.h" |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
30 #include "equalizer_flow.h" |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
31 |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
32 EqualizerPreset * |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
33 equalizer_preset_new(const gchar * name) |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
34 { |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
35 EqualizerPreset *preset = g_new0(EqualizerPreset, 1); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
36 preset->name = g_strdup(name); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
37 return preset; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
38 } |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
39 |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
40 void |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
41 equalizer_preset_free(EqualizerPreset * preset) |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
42 { |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
43 if (!preset) |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
44 return; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
45 |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
46 g_free(preset->name); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
47 g_free(preset); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
48 } |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
49 |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
50 GList * |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
51 equalizer_read_presets(const gchar * basename) |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
52 { |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
53 gchar *filename, *name; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
54 RcFile *rcfile; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
55 GList *list = NULL; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
56 gint i, p = 0; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
57 EqualizerPreset *preset; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
58 |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
59 /* START mod: add check for the default presets locate in system path ({prefix}/share/audacious) |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
60 by Massimo Cavalleri (submax) */ |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
61 |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
62 filename = g_build_filename(aud_paths[BMP_PATH_USER_DIR], basename, NULL); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
63 |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
64 if ((rcfile = aud_rcfile_open(filename)) == NULL) { |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
65 g_free(filename); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
66 // DATA_DIR = "{prefix}/share/audacious" ; example is "/usr/share/audacious" |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
67 filename = g_build_filename(DATA_DIR, basename, NULL); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
68 if ((rcfile = aud_rcfile_open(filename)) == NULL) { |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
69 g_free(filename); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
70 return NULL; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
71 } |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
72 } |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
73 |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
74 // END mod |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
75 |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
76 g_free(filename); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
77 |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
78 for (;;) { |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
79 gchar section[32]; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
80 |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
81 g_snprintf(section, sizeof(section), "Preset%d", p++); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
82 if (aud_rcfile_read_string(rcfile, "Presets", section, &name)) { |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
83 preset = g_new0(EqualizerPreset, 1); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
84 preset->name = name; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
85 aud_rcfile_read_float(rcfile, name, "Preamp", &preset->preamp); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
86 for (i = 0; i < AUD_EQUALIZER_NBANDS; i++) { |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
87 gchar band[16]; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
88 g_snprintf(band, sizeof(band), "Band%d", i); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
89 aud_rcfile_read_float(rcfile, name, band, &preset->bands[i]); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
90 } |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
91 list = g_list_prepend(list, preset); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
92 } |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
93 else |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
94 break; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
95 } |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
96 list = g_list_reverse(list); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
97 aud_rcfile_free(rcfile); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
98 return list; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
99 } |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
100 |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
101 void |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
102 equalizer_write_preset_file(GList * list, const gchar * basename) |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
103 { |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
104 gchar *filename, *tmp; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
105 gint i, p; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
106 EqualizerPreset *preset; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
107 RcFile *rcfile; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
108 GList *node; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
109 |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
110 rcfile = aud_rcfile_new(); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
111 p = 0; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
112 for (node = list; node; node = g_list_next(node)) { |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
113 preset = node->data; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
114 tmp = g_strdup_printf("Preset%d", p++); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
115 aud_rcfile_write_string(rcfile, "Presets", tmp, preset->name); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
116 g_free(tmp); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
117 aud_rcfile_write_float(rcfile, preset->name, "Preamp", |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
118 preset->preamp); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
119 for (i = 0; i < 10; i++) { |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
120 tmp = g_strdup_printf("Band%d\n", i); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
121 aud_rcfile_write_float(rcfile, preset->name, tmp, |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
122 preset->bands[i]); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
123 g_free(tmp); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
124 } |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
125 } |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
126 |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
127 filename = g_build_filename(aud_paths[BMP_PATH_USER_DIR], basename, NULL); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
128 aud_rcfile_write(rcfile, filename); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
129 aud_rcfile_free(rcfile); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
130 g_free(filename); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
131 } |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
132 |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
133 GList * |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
134 import_winamp_eqf(VFSFile * file) |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
135 { |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
136 gchar header[31]; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
137 gchar bands[11]; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
138 gint i = 0; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
139 EqualizerPreset *preset = NULL; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
140 GList *list = NULL; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
141 GtkWidget *dialog; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
142 gchar *realfn; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
143 gchar preset_name[0xb4]; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
144 |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
145 vfs_fread(header, 1, 31, file); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
146 if (strncmp(header, "Winamp EQ library file v1.1", 27)) goto error; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
147 |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
148 AUDDBG("The EQF header is OK\n"); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
149 |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
150 if (vfs_fseek(file, 0x1f, SEEK_SET) == -1) goto error; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
151 |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
152 while (vfs_fread(preset_name, 1, 0xb4, file) == 0xb4) { |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
153 AUDDBG("The preset name is '%s'\n", preset_name); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
154 vfs_fseek(file, 0x4d, SEEK_CUR); /* unknown crap --asphyx */ |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
155 if (vfs_fread(bands, 1, 11, file) != 11) break; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
156 |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
157 preset = equalizer_preset_new(preset_name); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
158 /*this was divided by 63, but shouldn't it be 64? --majeru*/ |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
159 preset->preamp = EQUALIZER_MAX_GAIN - ((bands[10] * EQUALIZER_MAX_GAIN * 2) / 64.0); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
160 |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
161 for (i = 0; i < 10; i++) |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
162 preset->bands[i] = EQUALIZER_MAX_GAIN - ((bands[i] * EQUALIZER_MAX_GAIN * 2) / 64.0); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
163 |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
164 list = g_list_prepend(list, preset); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
165 } |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
166 |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
167 list = g_list_reverse(list); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
168 if (list == NULL) goto error; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
169 |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
170 return list; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
171 |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
172 error: |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
173 realfn = g_filename_from_uri(file->uri, NULL, NULL); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
174 dialog = gtk_message_dialog_new (GTK_WINDOW(mainwin), |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
175 GTK_DIALOG_DESTROY_WITH_PARENT, |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
176 GTK_MESSAGE_ERROR, |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
177 GTK_BUTTONS_CLOSE, |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
178 _("Error importing Winamp EQF file '%s'"), |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
179 realfn); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
180 gtk_dialog_run (GTK_DIALOG (dialog)); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
181 gtk_widget_destroy (dialog); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
182 g_free(realfn); |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
183 return NULL; |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
184 } |
3534e9edc168
and of course I forgot to add new files...
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
185 |
4711
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
186 void |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
187 save_preset_file(EqualizerPreset *preset, const gchar * filename) |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
188 { |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
189 RcFile *rcfile; |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
190 gint i; |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
191 |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
192 rcfile = aud_rcfile_new(); |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
193 aud_rcfile_write_float(rcfile, "Equalizer preset", "Preamp", |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
194 preset->preamp); |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
195 |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
196 for (i = 0; i < 10; i++) { |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
197 gchar tmp[7]; |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
198 g_snprintf(tmp, sizeof(tmp), "Band%d", i); |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
199 aud_rcfile_write_float(rcfile, "Equalizer preset", tmp, |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
200 preset->bands[i]); |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
201 } |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
202 |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
203 aud_rcfile_write(rcfile, filename); |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
204 aud_rcfile_free(rcfile); |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
205 } |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
206 |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
207 EqualizerPreset * |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
208 equalizer_read_aud_preset(const gchar * filename) |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
209 { |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
210 gfloat val; |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
211 gint i; |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
212 EqualizerPreset *preset = g_new0(EqualizerPreset, 1); |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
213 preset->name = g_strdup(""); |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
214 |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
215 RcFile *rcfile = aud_rcfile_open(filename); |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
216 if (rcfile == NULL) |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
217 return NULL; |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
218 |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
219 if (aud_rcfile_read_float(rcfile, "Equalizer preset", "Preamp", &val)) |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
220 preset->preamp = val; |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
221 for (i = 0; i < 10; i++) { |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
222 gchar tmp[7]; |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
223 g_snprintf(tmp, sizeof(tmp), "Band%d", i); |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
224 if (aud_rcfile_read_float(rcfile, "Equalizer preset", tmp, &val)) |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
225 preset->bands[i] = val; |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
226 } |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
227 aud_rcfile_free(rcfile); |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
228 return preset; |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
229 } |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
230 |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
231 EqualizerPreset * |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
232 load_preset_file(const gchar *filename) |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
233 { |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
234 if (filename) { |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
235 EqualizerPreset *preset = equalizer_read_aud_preset(filename); |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
236 return preset; |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
237 } |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
238 return NULL; |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
239 } |
a33facf19590
more work on seperating presets from legacy ui
Tomasz Mon <desowin@gmail.com>
parents:
4704
diff
changeset
|
240 |