skin tags: fix the id3 track/disc numbers in conditionals
[maemo-rb.git] / apps / menus / eq_menu.c
blob63df6bee15dda58fdfc834995c049af4add13a7d
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2006 Dan Everton
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include "config.h"
23 #include <stdio.h>
24 #include <stdbool.h>
25 #include <string.h>
26 #include "eq_menu.h"
27 #include "system.h"
28 #include "kernel.h"
29 #include "lcd.h"
30 #include "list.h"
31 #include "menu.h"
32 #include "action.h"
33 #include "mp3_playback.h"
34 #include "settings.h"
35 #include "screens.h"
36 #include "icons.h"
37 #include "font.h"
38 #include "lang.h"
39 #include "talk.h"
40 #include "misc.h"
41 #include "sound.h"
42 #include "dsp_proc_settings.h"
43 #include "tree.h"
44 #include "screen_access.h"
45 #include "keyboard.h"
46 #include "gui/scrollbar.h"
47 #include "menu_common.h"
48 #include "viewport.h"
49 #include "exported_menus.h"
50 #include "pcmbuf.h"
51 #include "option_select.h"
54 * Utility functions
57 const char* eq_q_format(char* buffer, size_t buffer_size, int value, const char* unit)
59 snprintf(buffer, buffer_size, "%d.%d %s", value / EQ_USER_DIVISOR,
60 value % EQ_USER_DIVISOR, unit);
61 return buffer;
64 const char* eq_precut_format(char* buffer, size_t buffer_size, int value, const char* unit)
66 snprintf(buffer, buffer_size, "%s%d.%d %s", value == 0 ? " " : "-",
67 value / EQ_USER_DIVISOR, value % EQ_USER_DIVISOR, unit);
68 return buffer;
72 * Settings functions
74 static void eq_apply(void)
76 dsp_eq_enable(global_settings.eq_enabled);
77 dsp_set_eq_precut(global_settings.eq_precut);
78 /* Update all bands */
79 for(int i = 0; i < EQ_NUM_BANDS; i++) {
80 dsp_set_eq_coefs(i, &global_settings.eq_band_settings[i]);
84 static int eq_setting_callback(int action, const struct menu_item_ex *this_item)
86 switch (action)
88 case ACTION_ENTER_MENUITEM:
89 action = lowlatency_callback(action, this_item);
90 break;
91 case ACTION_EXIT_MENUITEM:
92 eq_apply();
93 action = lowlatency_callback(action, this_item);
94 break;
97 return action;
99 MENUITEM_SETTING(eq_enable, &global_settings.eq_enabled, eq_setting_callback);
100 MENUITEM_SETTING(eq_precut, &global_settings.eq_precut, eq_setting_callback);
102 static char* gainitem_get_name(int selected_item, void *data, char *buffer, size_t len)
104 (void)data;
105 snprintf(buffer, len, str(LANG_EQUALIZER_GAIN_ITEM),
106 global_settings.eq_band_settings[selected_item].cutoff);
108 return buffer;
111 static int gainitem_speak_item(int selected_item, void *data)
113 (void)data;
114 talk_number(global_settings.eq_band_settings[selected_item].cutoff, false);
115 talk_id(LANG_EQUALIZER_GAIN_ITEM, true);
116 return 0;
119 static enum themable_icons gainitem_get_icon(int selected_item, void * data)
121 (void)selected_item;
122 (void)data;
124 return Icon_Menu_functioncall;
127 static const char* db_format(char* buffer, size_t buffer_size, int value,
128 const char* unit)
130 int v = abs(value);
132 snprintf(buffer, buffer_size, "%s%d.%d %s", value < 0 ? "-" : "",
133 v / 10, v % 10, unit);
134 return buffer;
137 static int32_t get_dec_talkid(int value, int unit)
139 return TALK_ID_DECIMAL(value, 1, unit);
142 static const struct int_setting gain_int_setting = {
143 .option_callback = NULL,
144 .unit = UNIT_DB,
145 .min = EQ_GAIN_MIN,
146 .max = EQ_GAIN_MAX,
147 .step = EQ_GAIN_STEP,
148 .formatter = db_format,
149 .get_talk_id = get_dec_talkid,
152 static const struct int_setting q_int_setting = {
153 .option_callback = NULL,
154 .unit = UNIT_INT,
155 .min = EQ_Q_MIN,
156 .max = EQ_Q_MAX,
157 .step = EQ_Q_STEP,
158 .formatter = eq_q_format,
159 .get_talk_id = get_dec_talkid,
162 static const struct int_setting cutoff_int_setting = {
163 .option_callback = NULL,
164 .unit = UNIT_HERTZ,
165 .min = EQ_CUTOFF_MIN,
166 .max = EQ_CUTOFF_MAX,
167 .step = EQ_CUTOFF_STEP,
168 .formatter = NULL,
169 .get_talk_id = NULL,
172 static int simplelist_action_callback(int action, struct gui_synclist *lists)
174 (void)lists;
175 if (action == ACTION_STD_OK)
176 return ACTION_STD_CANCEL;
177 return action;
180 static int eq_do_simple_menu(void * param)
182 (void)param;
183 struct simplelist_info info;
184 struct settings_list setting;
185 char title[MAX_PATH];
187 simplelist_info_init(&info, str(LANG_EQUALIZER_GAIN), EQ_NUM_BANDS, NULL);
188 info.get_name = (list_get_name*)gainitem_get_name;
189 info.get_talk = gainitem_speak_item;
190 info.get_icon = gainitem_get_icon;
191 info.action_callback = simplelist_action_callback;
192 info.selection = -1;
193 info.title_icon = Icon_Submenu;
194 setting.flags = F_BANFROMQS|F_INT_SETTING|F_T_INT|F_NO_WRAP;
195 setting.lang_id = LANG_GAIN;
196 setting.default_val.int_ = 0;
197 setting.int_setting = &gain_int_setting;
199 while (true)
201 simplelist_show_list(&info);
202 if (info.selection < 0)
203 break;
204 pcmbuf_set_low_latency(true);
205 setting.setting = &global_settings.eq_band_settings[info.selection].gain;
206 option_screen(&setting, NULL, false,
207 gainitem_get_name(info.selection, NULL, title, MAX_PATH));
208 eq_apply();
209 pcmbuf_set_low_latency(false);
211 return 0;
213 MENUITEM_FUNCTION(gain_menu, 0, ID2P(LANG_EQUALIZER_GAIN), eq_do_simple_menu,
214 NULL, NULL, Icon_Submenu);
216 static void selection_to_banditem(int selection, int expanded_band, int *band, int *item)
218 int diff = selection - expanded_band;
220 if (expanded_band < 0 || diff < 0)
222 *item = 0;
223 *band = selection;
225 else if (diff < 4)
227 *item = selection - expanded_band;
228 *band = expanded_band;
230 else
232 *item = 0;
233 *band = expanded_band + diff - 3;
237 static char *advancedmenu_item_get_name(int selected_item, void *data, char *buffer, size_t len)
239 (void)len;
240 int band;
241 int item;
242 char *lang = NULL;
244 selection_to_banditem(selected_item, *(intptr_t*)data, &band, &item);
246 strcpy(buffer, "\t");
247 switch (item)
249 case 0: /* Band title */
250 if (band == 0)
251 return str(LANG_EQUALIZER_BAND_LOW_SHELF);
252 else if (band == EQ_NUM_BANDS - 1)
253 return str(LANG_EQUALIZER_BAND_HIGH_SHELF);
254 else
256 snprintf(buffer, MAX_PATH, str(LANG_EQUALIZER_BAND_PEAK), band);
257 return buffer;
259 break;
260 case 1: /* cutoff */
261 if (band == 0)
262 lang = str(LANG_EQUALIZER_BAND_CUTOFF);
263 else if (band == EQ_NUM_BANDS - 1)
264 lang = str(LANG_EQUALIZER_BAND_CUTOFF);
265 else
266 lang = str(LANG_EQUALIZER_BAND_CENTER);
267 break;
268 case 2: /* Q */
269 lang = str(LANG_EQUALIZER_BAND_Q);
270 break;
271 case 3: /* Gain */
272 lang = str(LANG_GAIN);
273 break;
276 return strcat(buffer, lang);;
279 static int advancedmenu_speak_item(int selected_item, void *data)
281 (void)data;
282 int band;
283 int item;
284 int lang = -1;
286 selection_to_banditem(selected_item, *(intptr_t*)data, &band, &item);
288 switch (item)
290 case 0: /* Band title */
291 if (band == 0)
292 lang = LANG_EQUALIZER_BAND_LOW_SHELF;
293 else if (band == EQ_NUM_BANDS - 1)
294 lang = LANG_EQUALIZER_BAND_HIGH_SHELF;
295 else
297 talk_id(LANG_EQUALIZER_BAND_PEAK, false);
298 talk_number(band, true);
299 return -1;
301 break;
302 case 1: /* cutoff */
303 if (band == 0)
304 lang = LANG_EQUALIZER_BAND_CUTOFF;
305 else if (band == EQ_NUM_BANDS - 1)
306 lang = LANG_EQUALIZER_BAND_CUTOFF;
307 else
308 lang = LANG_EQUALIZER_BAND_CENTER;
309 break;
310 case 2: /* Q */
311 lang = LANG_EQUALIZER_BAND_Q;
312 break;
313 case 3: /* Gain */
314 lang = LANG_GAIN;
315 break;
317 talk_id(lang, true);
318 return -1;
321 static enum themable_icons advancedmenu_get_icon(int selected_item, void * data)
323 (void)data;
324 int band;
325 int item;
327 selection_to_banditem(selected_item, *(intptr_t*)data, &band, &item);
329 if (item == 0)
330 return Icon_Submenu;
331 else
332 return Icon_Menu_setting;
334 extern struct eq_band_setting eq_defaults[EQ_NUM_BANDS];
336 static int eq_do_advanced_menu(void * param)
338 (void)param;
339 struct simplelist_info info;
340 struct settings_list setting;
341 char title[MAX_PATH];
342 int band, item;
343 intptr_t selected_band = -1;
345 simplelist_info_init(&info, str(LANG_EQUALIZER_ADVANCED),
346 EQ_NUM_BANDS, &selected_band);
347 info.get_name = (list_get_name*)advancedmenu_item_get_name;
348 info.get_talk = advancedmenu_speak_item;
349 info.get_icon = advancedmenu_get_icon;
350 info.action_callback = simplelist_action_callback;
351 info.selection = -1;
352 info.title_icon = Icon_EQ;
353 setting.flags = F_BANFROMQS|F_INT_SETTING|F_T_INT|F_NO_WRAP;
355 while (true)
357 simplelist_show_list(&info);
358 if (info.selection < 0)
359 break;
360 selection_to_banditem(info.selection, selected_band, &band, &item);
361 switch (item)
363 case 0: /* title, do nothing */
365 int extra;
366 if (selected_band == band)
368 extra = 0;
369 selected_band = -1;
371 else
373 extra = 3;
374 selected_band = band;
376 info.selection = band;
377 info.count = EQ_NUM_BANDS + extra;
378 continue;
380 case 1: /* cutoff */
381 if (band == 0 || band == EQ_NUM_BANDS - 1)
382 setting.lang_id = LANG_EQUALIZER_BAND_CUTOFF;
383 else
384 setting.lang_id = LANG_EQUALIZER_BAND_CENTER;
385 setting.default_val.int_ = eq_defaults[band].cutoff;
386 setting.int_setting = &cutoff_int_setting;
387 setting.setting = &global_settings.eq_band_settings[band].cutoff;
388 break;
389 case 2: /* Q */
390 setting.lang_id = LANG_EQUALIZER_BAND_Q;
391 setting.default_val.int_ = eq_defaults[band].q;
392 setting.int_setting = &q_int_setting;
393 setting.setting = &global_settings.eq_band_settings[band].q;
394 break;
395 case 3: /* Gain */
396 setting.lang_id = LANG_GAIN;
397 setting.default_val.int_ = eq_defaults[band].gain;
398 setting.int_setting = &gain_int_setting;
399 setting.setting = &global_settings.eq_band_settings[band].gain;
400 break;
402 pcmbuf_set_low_latency(true);
403 advancedmenu_item_get_name(info.selection, &selected_band, title, MAX_PATH);
405 option_screen(&setting, NULL, false, title[0] == '\t' ? &title[1] : title);
406 eq_apply();
407 pcmbuf_set_low_latency(false);
409 return 0;
411 MENUITEM_FUNCTION(advanced_menu, 0, ID2P(LANG_EQUALIZER_ADVANCED),
412 eq_do_advanced_menu, NULL, NULL, Icon_EQ);
414 enum eq_slider_mode {
415 GAIN,
416 CUTOFF,
420 enum eq_type {
421 LOW_SHELF,
422 PEAK,
423 HIGH_SHELF
426 /* Size of just the slider/srollbar */
427 #define SCROLLBAR_SIZE 6
429 /* Draw the UI for a whole EQ band */
430 static int draw_eq_slider(struct screen * screen, int x, int y,
431 int width, int cutoff, int q, int gain, bool selected,
432 enum eq_slider_mode mode, int band)
434 char buf[26];
435 int steps, min_item, max_item;
436 int abs_gain = abs(gain);
437 int x1, x2, y1, total_height;
438 int w, h;
440 switch(mode) {
441 case Q:
442 steps = EQ_Q_MAX - EQ_Q_MIN;
443 min_item = q - EQ_Q_STEP - EQ_Q_MIN;
444 max_item = q + EQ_Q_STEP - EQ_Q_MIN;
445 break;
446 case CUTOFF:
447 steps = EQ_CUTOFF_MAX - EQ_CUTOFF_MIN;
448 min_item = cutoff - EQ_CUTOFF_FAST_STEP * 2;
449 max_item = cutoff + EQ_CUTOFF_FAST_STEP * 2;
450 break;
451 case GAIN:
452 default:
453 steps = EQ_GAIN_MAX - EQ_GAIN_MIN;
454 min_item = abs(EQ_GAIN_MIN) + gain - EQ_GAIN_STEP * 5;
455 max_item = abs(EQ_GAIN_MIN) + gain + EQ_GAIN_STEP * 5;
456 break;
459 /* Start two pixels in, one for border, one for margin */
460 x1 = x + 2;
461 y1 = y + 2;
463 /* Print out the band label */
464 if (band == 0) {
465 screen->putsxy(x1, y1, "LS: ");
466 screen->getstringsize("LS:", &w, &h);
467 } else if (band == EQ_NUM_BANDS - 1) {
468 screen->putsxy(x1, y1, "HS: ");
469 screen->getstringsize("HS:", &w, &h);
470 } else {
471 snprintf(buf, sizeof(buf), "PK%d:", band);
472 screen->putsxy(x1, y1, buf);
473 screen->getstringsize(buf, &w, &h);
476 screen->getstringsize("A", &w, &h);
477 x1 += 5*w; /* 4 chars for label + 1 space = 5 */
479 /* Print out gain part of status line (left justify after label) */
480 if (mode == GAIN && selected)
481 screen->set_drawmode(DRMODE_SOLID | DRMODE_INVERSEVID);
482 else
483 screen->set_drawmode(DRMODE_SOLID);
485 snprintf(buf, sizeof(buf), "%s%2d.%d%s", gain < 0 ? "-" : " ",
486 abs_gain / EQ_USER_DIVISOR, abs_gain % EQ_USER_DIVISOR,
487 screen->lcdwidth >= 160 ? "dB" : "");
488 screen->putsxy(x1, y1, buf);
489 screen->getstringsize(buf, &w, &h);
490 x1 += w;
492 /* Print out Q part of status line (right justify) */
493 if (mode == Q && selected)
494 screen->set_drawmode(DRMODE_SOLID | DRMODE_INVERSEVID);
495 else
496 screen->set_drawmode(DRMODE_SOLID);
498 snprintf(buf, sizeof(buf), "%d.%d%s", q / EQ_USER_DIVISOR,
499 q % EQ_USER_DIVISOR, screen->lcdwidth >= 160 ? " Q" : "");
500 screen->getstringsize(buf, &w, &h);
501 x2 = x + width - w - 2;
502 screen->putsxy(x2, y1, buf);
504 /* Print out cutoff part of status line (center between gain & Q) */
505 if (mode == CUTOFF && selected)
506 screen->set_drawmode(DRMODE_SOLID | DRMODE_INVERSEVID);
507 else
508 screen->set_drawmode(DRMODE_SOLID);
510 snprintf(buf, sizeof(buf), "%5d%s", cutoff,
511 screen->lcdwidth >= 160 ? "Hz" : "");
512 screen->getstringsize(buf, &w, &h);
513 x1 = x1 + (x2 - x1 - w)/2;
514 screen->putsxy(x1, y1, buf);
516 /* Draw selection box */
517 total_height = 3 + h + 1 + SCROLLBAR_SIZE + 3;
518 screen->set_drawmode(DRMODE_SOLID);
519 if (selected) {
520 screen->drawrect(x, y, width, total_height);
523 /* Draw horizontal slider. Reuse scrollbar for this */
524 gui_scrollbar_draw(screen, x + 3, y1 + h + 1, width - 6, SCROLLBAR_SIZE,
525 steps, min_item, max_item, HORIZONTAL);
527 return total_height;
530 /* Draw's all the EQ sliders. Returns the total height of the sliders drawn */
531 static void draw_eq_sliders(struct screen * screen, int x, int y,
532 int nb_eq_sliders, int start_item,
533 int current_band, enum eq_slider_mode mode)
535 int height = y;
537 start_item = MIN(start_item, EQ_NUM_BANDS - nb_eq_sliders);
539 for (int i = 0; i < EQ_NUM_BANDS; i++) {
540 struct eq_band_setting *setting = &global_settings.eq_band_settings[i];
541 int cutoff = setting->cutoff;
542 int q = setting->q;
543 int gain = setting->gain;
545 if (i == start_item + nb_eq_sliders)
546 break;
548 if (i >= start_item) {
549 height += draw_eq_slider(screen, x, height, screen->lcdwidth - x - 1,
550 cutoff, q, gain, i == current_band, mode,
552 /* add a margin */
553 height++;
557 if (nb_eq_sliders != EQ_NUM_BANDS)
558 gui_scrollbar_draw(screen, 0, y, SCROLLBAR_SIZE - 1,
559 screen->lcdheight - y, EQ_NUM_BANDS,
560 start_item, start_item + nb_eq_sliders,
561 VERTICAL);
562 return;
565 /* Provides a graphical means of editing the EQ settings */
566 bool eq_menu_graphical(void)
568 bool exit_request = false;
569 bool result = true;
570 bool has_changed = false;
571 int button;
572 int *setting;
573 int current_band, x, y, step, fast_step, min, max;
574 enum eq_slider_mode mode;
575 char buf[24];
576 int w, h, height, start_item, nb_eq_sliders[NB_SCREENS];
577 FOR_NB_SCREENS(i)
578 viewportmanager_theme_enable(i, false, NULL);
581 FOR_NB_SCREENS(i) {
582 screens[i].set_viewport(NULL);
583 screens[i].setfont(FONT_SYSFIXED);
584 screens[i].clear_display();
586 /* Figure out how many sliders can be drawn on the screen */
587 screens[i].getstringsize("A", &w, &h);
589 /* Total height includes margins (1), text, slider, and line selector (1) */
590 height = 3 + h + 1 + SCROLLBAR_SIZE + 3;
591 nb_eq_sliders[i] = screens[i].lcdheight / height;
593 /* Make sure the "Edit Mode" text fits too */
594 height = nb_eq_sliders[i]*height + h + 2;
595 if (height > screens[i].lcdheight)
596 nb_eq_sliders[i]--;
598 if (nb_eq_sliders[i] > EQ_NUM_BANDS)
599 nb_eq_sliders[i] = EQ_NUM_BANDS;
602 y = h + 1;
604 /* Start off editing gain on the first band */
605 mode = GAIN;
606 current_band = 0;
608 while (!exit_request) {
609 FOR_NB_SCREENS(i)
611 screens[i].clear_display();
613 /* Set pointer to the band data currently editable */
614 if (mode == GAIN) {
615 /* gain */
616 setting = &global_settings.eq_band_settings[current_band].gain;
618 step = EQ_GAIN_STEP;
619 fast_step = EQ_GAIN_FAST_STEP;
620 min = EQ_GAIN_MIN;
621 max = EQ_GAIN_MAX;
623 snprintf(buf, sizeof(buf), str(LANG_SYSFONT_EQUALIZER_EDIT_MODE),
624 str(LANG_SYSFONT_GAIN), "(dB)");
626 screens[i].putsxy(0, 0, buf);
627 } else if (mode == CUTOFF) {
628 /* cutoff */
629 setting = &global_settings.eq_band_settings[current_band].cutoff;
631 step = EQ_CUTOFF_STEP;
632 fast_step = EQ_CUTOFF_FAST_STEP;
633 min = EQ_CUTOFF_MIN;
634 max = EQ_CUTOFF_MAX;
636 snprintf(buf, sizeof(buf), str(LANG_SYSFONT_EQUALIZER_EDIT_MODE),
637 str(LANG_SYSFONT_EQUALIZER_BAND_CUTOFF), "(Hz)");
639 screens[i].putsxy(0, 0, buf);
640 } else {
641 /* Q */
642 setting = &global_settings.eq_band_settings[current_band].q;
644 step = EQ_Q_STEP;
645 fast_step = EQ_Q_FAST_STEP;
646 min = EQ_Q_MIN;
647 max = EQ_Q_MAX;
649 snprintf(buf, sizeof(buf), str(LANG_SYSFONT_EQUALIZER_EDIT_MODE),
650 str(LANG_EQUALIZER_BAND_Q), "");
652 screens[i].putsxy(0, 0, buf);
655 /* Draw scrollbar if needed */
656 if (nb_eq_sliders[i] != EQ_NUM_BANDS)
658 if (current_band == 0) {
659 start_item = 0;
660 } else if (current_band == 9) {
661 start_item = EQ_NUM_BANDS - nb_eq_sliders[i];
662 } else {
663 start_item = current_band - 1;
665 x = SCROLLBAR_SIZE;
666 } else {
667 x = 1;
668 start_item = 0;
670 /* Draw equalizer band details */
671 draw_eq_sliders(&screens[i], x, y, nb_eq_sliders[i], start_item,
672 current_band, mode);
674 screens[i].update();
677 button = get_action(CONTEXT_SETTINGS_EQ,TIMEOUT_BLOCK);
679 switch (button) {
680 case ACTION_SETTINGS_DEC:
681 case ACTION_SETTINGS_DECREPEAT:
682 *(setting) -= step;
683 has_changed = true;
684 if (*(setting) < min)
685 *(setting) = min;
686 break;
688 case ACTION_SETTINGS_INC:
689 case ACTION_SETTINGS_INCREPEAT:
690 *(setting) += step;
691 has_changed = true;
692 if (*(setting) > max)
693 *(setting) = max;
694 break;
696 case ACTION_SETTINGS_INCBIGSTEP:
697 *(setting) += fast_step;
698 has_changed = true;
699 if (*(setting) > max)
700 *(setting) = max;
701 break;
703 case ACTION_SETTINGS_DECBIGSTEP:
704 *(setting) -= fast_step;
705 has_changed = true;
706 if (*(setting) < min)
707 *(setting) = min;
708 break;
710 case ACTION_STD_PREV:
711 case ACTION_STD_PREVREPEAT:
712 current_band--;
713 if (current_band < 0)
714 current_band = EQ_NUM_BANDS - 1; /* wrap around */
715 break;
717 case ACTION_STD_NEXT:
718 case ACTION_STD_NEXTREPEAT:
719 current_band = (current_band + 1) % EQ_NUM_BANDS;
720 break;
722 case ACTION_STD_OK:
723 mode++;
724 if (mode > Q)
725 mode = GAIN; /* wrap around */
726 break;
728 case ACTION_STD_CANCEL:
729 exit_request = true;
730 result = false;
731 break;
732 default:
733 if(default_event_handler(button) == SYS_USB_CONNECTED) {
734 exit_request = true;
735 result = true;
737 break;
740 /* Update the filter if the user changed something */
741 if (has_changed) {
742 dsp_set_eq_coefs(current_band,
743 &global_settings.eq_band_settings[current_band]);
744 has_changed = false;
748 /* Reset screen settings */
749 FOR_NB_SCREENS(i)
751 screens[i].setfont(FONT_UI);
752 screens[i].clear_display();
753 screens[i].set_viewport(NULL);
754 viewportmanager_theme_undo(i, false);
756 return result;
759 static bool eq_save_preset(void)
761 /* make sure that the eq is enabled for setting saving */
762 bool enabled = global_settings.eq_enabled;
763 global_settings.eq_enabled = true;
765 bool result = settings_save_config(SETTINGS_SAVE_EQPRESET);
767 global_settings.eq_enabled = enabled;
769 return result;
771 /* Allows browsing of preset files */
772 static struct browse_folder_info eqs = { EQS_DIR, SHOW_CFG };
774 MENUITEM_FUNCTION(eq_graphical, 0, ID2P(LANG_EQUALIZER_GRAPHICAL),
775 (int(*)(void))eq_menu_graphical, NULL, lowlatency_callback,
776 Icon_EQ);
777 MENUITEM_FUNCTION(eq_save, 0, ID2P(LANG_EQUALIZER_SAVE),
778 (int(*)(void))eq_save_preset, NULL, NULL, Icon_NOICON);
779 MENUITEM_FUNCTION(eq_browse, MENU_FUNC_USEPARAM, ID2P(LANG_EQUALIZER_BROWSE),
780 browse_folder, (void*)&eqs, lowlatency_callback,
781 Icon_NOICON);
783 MAKE_MENU(equalizer_menu, ID2P(LANG_EQUALIZER), NULL, Icon_EQ,
784 &eq_enable, &eq_graphical, &eq_precut, &gain_menu,
785 &advanced_menu, &eq_save, &eq_browse);