1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
8 * $Id: eq_menu.c 12179 2007-02-01 23:08:15Z amiconn $
10 * Copyright (C) 2006 Dan Everton
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
30 #include "mp3_playback.h"
32 #include "statusbar.h"
45 #include "screen_access.h"
47 #include "gui/scrollbar.h"
59 void eq_gain_format(char* buffer
, size_t buffer_size
, int value
, const char* unit
)
63 snprintf(buffer
, buffer_size
, "%s%d.%d %s", value
< 0 ? "-" : "",
64 v
/ EQ_USER_DIVISOR
, v
% EQ_USER_DIVISOR
, unit
);
67 void eq_q_format(char* buffer
, size_t buffer_size
, int value
, const char* unit
)
69 snprintf(buffer
, buffer_size
, "%d.%d %s", value
/ EQ_USER_DIVISOR
, value
% EQ_USER_DIVISOR
, unit
);
72 void eq_precut_format(char* buffer
, size_t buffer_size
, int value
, const char* unit
)
74 snprintf(buffer
, buffer_size
, "%s%d.%d %s", value
== 0 ? " " : "-",
75 value
/ EQ_USER_DIVISOR
, value
% EQ_USER_DIVISOR
, unit
);
84 dsp_set_eq(global_settings
.eq_enabled
);
85 dsp_set_eq_precut(global_settings
.eq_precut
);
86 /* Update all bands */
87 for(i
= 0; i
< 5; i
++) {
91 int enable_callback(int action
, const struct menu_item_ex
*this_item
)
94 if (action
== ACTION_EXIT_MENUITEM
)
98 MENUITEM_SETTING(eq_enable
, &global_settings
.eq_enabled
, enable_callback
);
99 MENUITEM_SETTING(eq_precut
, &global_settings
.eq_precut
, enable_callback
);
101 int dsp_set_coefs_callback(int action
, const struct menu_item_ex
*this_item
)
104 if (action
== ACTION_EXIT_MENUITEM
)
106 /* for now, set every band... figure out a better way later */
114 char* gainitem_get_name(int selected_item
, void * data
, char *buffer
)
117 int *setting
= (int*)data
;
118 snprintf(buffer
, MAX_PATH
, str(LANG_EQUALIZER_GAIN_ITEM
), *setting
);
121 int gainitem_speak_item(int selected_item
, void * data
)
124 int *setting
= (int*)data
;
125 talk_number(*setting
, false);
126 talk_id(LANG_EQUALIZER_GAIN_ITEM
, true);
130 int do_option(void* param
)
132 const struct menu_item_ex
*setting
= (const struct menu_item_ex
*)param
;
133 do_setting_from_menu(setting
);
138 MENUITEM_SETTING(cutoff_0
, &global_settings
.eq_band0_cutoff
, dsp_set_coefs_callback
);
139 MENUITEM_SETTING(cutoff_1
, &global_settings
.eq_band1_cutoff
, dsp_set_coefs_callback
);
140 MENUITEM_SETTING(cutoff_2
, &global_settings
.eq_band2_cutoff
, dsp_set_coefs_callback
);
141 MENUITEM_SETTING(cutoff_3
, &global_settings
.eq_band3_cutoff
, dsp_set_coefs_callback
);
142 MENUITEM_SETTING(cutoff_4
, &global_settings
.eq_band4_cutoff
, dsp_set_coefs_callback
);
144 MENUITEM_SETTING(q_0
, &global_settings
.eq_band0_q
, dsp_set_coefs_callback
);
145 MENUITEM_SETTING(q_1
, &global_settings
.eq_band1_q
, dsp_set_coefs_callback
);
146 MENUITEM_SETTING(q_2
, &global_settings
.eq_band2_q
, dsp_set_coefs_callback
);
147 MENUITEM_SETTING(q_3
, &global_settings
.eq_band3_q
, dsp_set_coefs_callback
);
148 MENUITEM_SETTING(q_4
, &global_settings
.eq_band4_q
, dsp_set_coefs_callback
);
150 MENUITEM_SETTING(gain_0
, &global_settings
.eq_band0_gain
, dsp_set_coefs_callback
);
151 MENUITEM_SETTING(gain_1
, &global_settings
.eq_band1_gain
, dsp_set_coefs_callback
);
152 MENUITEM_SETTING(gain_2
, &global_settings
.eq_band2_gain
, dsp_set_coefs_callback
);
153 MENUITEM_SETTING(gain_3
, &global_settings
.eq_band3_gain
, dsp_set_coefs_callback
);
154 MENUITEM_SETTING(gain_4
, &global_settings
.eq_band4_gain
, dsp_set_coefs_callback
);
156 MENUITEM_FUNCTION_DYNTEXT(gain_item_0
, MENU_FUNC_USEPARAM
,
157 do_option
, (void*)&gain_0
,
158 gainitem_get_name
, gainitem_speak_item
,
159 &global_settings
.eq_band0_cutoff
, NULL
, Icon_NOICON
);
160 MENUITEM_FUNCTION_DYNTEXT(gain_item_1
, MENU_FUNC_USEPARAM
,
161 do_option
, (void*)&gain_1
,
162 gainitem_get_name
, gainitem_speak_item
,
163 &global_settings
.eq_band1_cutoff
, NULL
, Icon_NOICON
);
164 MENUITEM_FUNCTION_DYNTEXT(gain_item_2
, MENU_FUNC_USEPARAM
,
165 do_option
, (void*)&gain_2
,
166 gainitem_get_name
, gainitem_speak_item
,
167 &global_settings
.eq_band2_cutoff
, NULL
, Icon_NOICON
);
168 MENUITEM_FUNCTION_DYNTEXT(gain_item_3
, MENU_FUNC_USEPARAM
,
169 do_option
, (void*)&gain_3
,
170 gainitem_get_name
, gainitem_speak_item
,
171 &global_settings
.eq_band3_cutoff
, NULL
, Icon_NOICON
);
172 MENUITEM_FUNCTION_DYNTEXT(gain_item_4
, MENU_FUNC_USEPARAM
,
173 do_option
, (void*)&gain_4
,
174 gainitem_get_name
, gainitem_speak_item
,
175 &global_settings
.eq_band4_cutoff
, NULL
, Icon_NOICON
);
177 MAKE_MENU(gain_menu
, ID2P(LANG_EQUALIZER_GAIN
), NULL
, Icon_NOICON
, &gain_item_0
,
178 &gain_item_1
, &gain_item_2
, &gain_item_3
, &gain_item_4
);
180 static const struct menu_item_ex
*band_items
[3][3] = {
181 { &cutoff_1
, &q_1
, &gain_1
},
182 { &cutoff_2
, &q_2
, &gain_2
},
183 { &cutoff_3
, &q_3
, &gain_3
}
185 char* centerband_get_name(int selected_item
, void * data
, char *buffer
)
188 int band
= (intptr_t)data
;
189 snprintf(buffer
, MAX_PATH
, str(LANG_EQUALIZER_BAND_PEAK
), band
);
192 int centerband_speak_item(int selected_item
, void * data
)
195 int band
= (intptr_t)data
;
196 talk_id(LANG_EQUALIZER_BAND_PEAK
, false);
197 talk_number(band
, true);
200 int do_center_band_menu(void* param
)
202 int band
= (intptr_t)param
;
203 struct menu_item_ex menu
;
204 struct menu_callback_with_desc cb_and_desc
;
207 cb_and_desc
.menu_callback
= NULL
;
208 snprintf(desc
, MAX_PATH
, str(LANG_EQUALIZER_BAND_PEAK
), band
);
209 cb_and_desc
.desc
= desc
;
210 cb_and_desc
.icon_id
= Icon_EQ
;
211 menu
.flags
= MT_MENU
|(3<<MENU_COUNT_SHIFT
)|MENU_HAS_DESC
;
212 menu
.submenus
= band_items
[band
-1];
213 menu
.callback_and_desc
= &cb_and_desc
;
214 do_menu(&menu
, NULL
);
217 MAKE_MENU(band_0_menu
, ID2P(LANG_EQUALIZER_BAND_LOW_SHELF
), NULL
,
218 Icon_EQ
, &cutoff_0
, &q_0
, &gain_0
);
219 MENUITEM_FUNCTION_DYNTEXT(band_1_menu
, MENU_FUNC_USEPARAM
,
220 do_center_band_menu
, (void*)1,
221 centerband_get_name
, centerband_speak_item
,
222 (void*)1, NULL
, Icon_EQ
);
223 MENUITEM_FUNCTION_DYNTEXT(band_2_menu
, MENU_FUNC_USEPARAM
,
224 do_center_band_menu
, (void*)2,
225 centerband_get_name
, centerband_speak_item
,
226 (void*)2, NULL
, Icon_EQ
);
227 MENUITEM_FUNCTION_DYNTEXT(band_3_menu
, MENU_FUNC_USEPARAM
,
228 do_center_band_menu
, (void*)3,
229 centerband_get_name
, centerband_speak_item
,
230 (void*)3, NULL
, Icon_EQ
);
231 MAKE_MENU(band_4_menu
, ID2P(LANG_EQUALIZER_BAND_HIGH_SHELF
), NULL
,
232 Icon_EQ
, &cutoff_4
, &q_4
, &gain_4
);
234 MAKE_MENU(advanced_eq_menu_
, ID2P(LANG_EQUALIZER_ADVANCED
), NULL
, Icon_EQ
,
235 &band_0_menu
, &band_1_menu
, &band_2_menu
, &band_3_menu
, &band_4_menu
);
238 enum eq_slider_mode
{
250 /* Draw the UI for a whole EQ band */
251 static int draw_eq_slider(struct screen
* screen
, int x
, int y
,
252 int width
, int cutoff
, int q
, int gain
, bool selected
,
253 enum eq_slider_mode mode
, enum eq_type type
)
256 const char separator
[2] = " ";
257 int steps
, min_item
, max_item
;
258 int abs_gain
= abs(gain
);
259 int current_x
, total_height
, separator_width
, separator_height
;
261 const int slider_height
= 6;
265 steps
= EQ_Q_MAX
- EQ_Q_MIN
;
266 min_item
= q
- EQ_Q_STEP
- EQ_Q_MIN
;
267 max_item
= q
+ EQ_Q_STEP
- EQ_Q_MIN
;
270 steps
= EQ_CUTOFF_MAX
- EQ_CUTOFF_MIN
;
271 min_item
= cutoff
- EQ_CUTOFF_FAST_STEP
* 2;
272 max_item
= cutoff
+ EQ_CUTOFF_FAST_STEP
* 2;
276 steps
= EQ_GAIN_MAX
- EQ_GAIN_MIN
;
277 min_item
= abs(EQ_GAIN_MIN
) + gain
- EQ_GAIN_STEP
* 5;
278 max_item
= abs(EQ_GAIN_MIN
) + gain
+ EQ_GAIN_STEP
* 5;
282 /* Start two pixels in, one for border, one for margin */
285 /* Figure out how large our separator string is */
286 screen
->getstringsize(separator
, &separator_width
, &separator_height
);
288 /* Total height includes margins, text, and line selector */
289 total_height
= separator_height
+ slider_height
+ 2 + 3;
291 /* Print out the band label */
292 if (type
== LOW_SHELF
) {
293 screen
->putsxy(current_x
, y
+ 2, "LS:");
294 screen
->getstringsize("LS:", &w
, &h
);
295 } else if (type
== HIGH_SHELF
) {
296 screen
->putsxy(current_x
, y
+ 2, "HS:");
297 screen
->getstringsize("HS:", &w
, &h
);
299 screen
->putsxy(current_x
, y
+ 2, "PK:");
300 screen
->getstringsize("PK:", &w
, &h
);
304 /* Print separator */
305 screen
->set_drawmode(DRMODE_SOLID
);
306 screen
->putsxy(current_x
, y
+ 2, separator
);
307 current_x
+= separator_width
;
309 if (screen
->screen_type
== SCREEN_REMOTE
) {
311 screen
->putsxy(current_x
, y
+ 2, str(LANG_GAIN
));
312 screen
->getstringsize(str(LANG_GAIN
), &w
, &h
);
313 } else if (mode
== CUTOFF
) {
314 screen
->putsxy(current_x
, y
+ 2, str(LANG_EQUALIZER_BAND_CUTOFF
));
315 screen
->getstringsize(str(LANG_EQUALIZER_BAND_CUTOFF
), &w
, &h
);
317 screen
->putsxy(current_x
, y
+ 2, str(LANG_EQUALIZER_BAND_Q
));
318 screen
->getstringsize(str(LANG_EQUALIZER_BAND_Q
), &w
, &h
);
321 /* Draw horizontal slider. Reuse scrollbar for this */
322 gui_scrollbar_draw(screen
, x
+ 3, y
+ h
+ 3, width
- 6, slider_height
, steps
,
323 min_item
, max_item
, HORIZONTAL
);
325 /* Print out cutoff part */
326 snprintf(buf
, sizeof(buf
), "%sGain %s%2d.%ddB",mode
==GAIN
?" > ":" ", gain
< 0 ? "-" : " ",
327 abs_gain
/ EQ_USER_DIVISOR
, abs_gain
% EQ_USER_DIVISOR
);
328 screen
->getstringsize(buf
, &w
, &h
);
330 screen
->putsxy(0, y
, buf
);
331 /* Print out cutoff part */
332 snprintf(buf
, sizeof(buf
), "%sCutoff %5dHz",mode
==CUTOFF
?" > ":" ", cutoff
);
334 screen
->putsxy(0, y
, buf
);
335 snprintf(buf
, sizeof(buf
), "%sQ setting %d.%d Q",mode
==Q
?" > ":" ", q
/ EQ_USER_DIVISOR
,
336 q
% EQ_USER_DIVISOR
);
338 screen
->putsxy(0, y
, buf
);
343 /* Print out gain part of status line */
344 snprintf(buf
, sizeof(buf
), "%s%2d.%ddB", gain
< 0 ? "-" : " ",
345 abs_gain
/ EQ_USER_DIVISOR
, abs_gain
% EQ_USER_DIVISOR
);
347 if (mode
== GAIN
&& selected
)
348 screen
->set_drawmode(DRMODE_SOLID
| DRMODE_INVERSEVID
);
350 screen
->putsxy(current_x
, y
+ 2, buf
);
351 screen
->getstringsize(buf
, &w
, &h
);
354 /* Print separator */
355 screen
->set_drawmode(DRMODE_SOLID
);
356 screen
->putsxy(current_x
, y
+ 2, separator
);
357 current_x
+= separator_width
;
359 /* Print out cutoff part of status line */
360 snprintf(buf
, sizeof(buf
), "%5dHz", cutoff
);
362 if (mode
== CUTOFF
&& selected
)
363 screen
->set_drawmode(DRMODE_SOLID
| DRMODE_INVERSEVID
);
365 screen
->putsxy(current_x
, y
+ 2, buf
);
366 screen
->getstringsize(buf
, &w
, &h
);
369 /* Print separator */
370 screen
->set_drawmode(DRMODE_SOLID
);
371 screen
->putsxy(current_x
, y
+ 2, separator
);
372 current_x
+= separator_width
;
374 /* Print out Q part of status line */
375 snprintf(buf
, sizeof(buf
), "%d.%d Q", q
/ EQ_USER_DIVISOR
,
376 q
% EQ_USER_DIVISOR
);
378 if (mode
== Q
&& selected
)
379 screen
->set_drawmode(DRMODE_SOLID
| DRMODE_INVERSEVID
);
381 screen
->putsxy(current_x
, y
+ 2, buf
);
382 screen
->getstringsize(buf
, &w
, &h
);
385 screen
->set_drawmode(DRMODE_SOLID
);
387 /* Draw selection box */
389 screen
->drawrect(x
, y
, width
, total_height
);
392 /* Draw horizontal slider. Reuse scrollbar for this */
393 gui_scrollbar_draw(screen
, x
+ 3, y
+ h
+ 3, width
- 6, slider_height
, steps
,
394 min_item
, max_item
, HORIZONTAL
);
399 /* Draw's all the EQ sliders. Returns the total height of the sliders drawn */
400 static int draw_eq_sliders(int current_band
, enum eq_slider_mode mode
)
402 int i
, gain
, q
, cutoff
;
403 int height
= 2; /* Two pixel margin */
404 int slider_width
[NB_SCREENS
];
405 int *setting
= &global_settings
.eq_band0_cutoff
;
409 slider_width
[i
] = screens
[i
].width
- 4; /* two pixel margin on each side */
411 for (i
=0; i
<5; i
++) {
423 height
+= draw_eq_slider(&(screens
[SCREEN_MAIN
]), 2, height
,
424 slider_width
[SCREEN_MAIN
], cutoff
, q
, gain
,
425 i
== current_band
, mode
, type
);
427 if (i
== current_band
)
428 draw_eq_slider(&(screens
[SCREEN_REMOTE
]), 2, 0,
429 slider_width
[SCREEN_REMOTE
], cutoff
, q
, gain
,1, mode
, type
);
438 /* Provides a graphical means of editing the EQ settings */
439 bool eq_menu_graphical(void)
441 bool exit_request
= false;
443 bool has_changed
= false;
446 int current_band
, y
, step
, fast_step
, min
, max
, voice_unit
;
447 enum eq_slider_mode mode
;
448 enum eq_type current_type
;
453 screens
[i
].setfont(FONT_SYSFIXED
);
454 screens
[i
].clear_display();
457 /* Start off editing gain on the first band */
459 current_type
= LOW_SHELF
;
462 while (!exit_request
) {
465 /* Clear the screen. The drawing routines expect this */
466 screens
[i
].clear_display();
467 /* Draw equalizer band details */
468 y
= draw_eq_sliders(current_band
, mode
);
471 /* Set pointer to the band data currently editable */
474 setting
= &global_settings
.eq_band0_gain
;
475 setting
+= current_band
* 3;
478 fast_step
= EQ_GAIN_FAST_STEP
;
481 voice_unit
= UNIT_DB
;
483 snprintf(buf
, sizeof(buf
), str(LANG_SYSFONT_EQUALIZER_EDIT_MODE
),
484 str(LANG_SYSFONT_GAIN
));
486 screens
[SCREEN_MAIN
].putsxy(2, y
, buf
);
487 } else if (mode
== CUTOFF
) {
489 setting
= &global_settings
.eq_band0_cutoff
;
490 setting
+= current_band
* 3;
492 step
= EQ_CUTOFF_STEP
;
493 fast_step
= EQ_CUTOFF_FAST_STEP
;
496 voice_unit
= UNIT_HERTZ
;
498 snprintf(buf
, sizeof(buf
), str(LANG_SYSFONT_EQUALIZER_EDIT_MODE
),
499 str(LANG_SYSFONT_EQUALIZER_BAND_CUTOFF
));
501 screens
[SCREEN_MAIN
].putsxy(2, y
, buf
);
504 setting
= &global_settings
.eq_band0_q
;
505 setting
+= current_band
* 3;
508 fast_step
= EQ_Q_FAST_STEP
;
511 voice_unit
= UNIT_INT
;
513 snprintf(buf
, sizeof(buf
), str(LANG_SYSFONT_EQUALIZER_EDIT_MODE
),
514 str(LANG_EQUALIZER_BAND_Q
));
516 screens
[SCREEN_MAIN
].putsxy(2, y
, buf
);
523 button
= get_action(CONTEXT_SETTINGS_EQ
,TIMEOUT_BLOCK
);
526 case ACTION_SETTINGS_DEC
:
527 case ACTION_SETTINGS_DECREPEAT
:
530 if (*(setting
) < min
)
534 case ACTION_SETTINGS_INC
:
535 case ACTION_SETTINGS_INCREPEAT
:
538 if (*(setting
) > max
)
542 case ACTION_SETTINGS_INCBIGSTEP
:
543 *(setting
) += fast_step
;
545 if (*(setting
) > max
)
549 case ACTION_SETTINGS_DECBIGSTEP
:
550 *(setting
) -= fast_step
;
552 if (*(setting
) < min
)
556 case ACTION_STD_PREV
:
557 case ACTION_STD_PREVREPEAT
:
559 if (current_band
< 0)
560 current_band
= 4; /* wrap around */
563 case ACTION_STD_NEXT
:
564 case ACTION_STD_NEXTREPEAT
:
566 if (current_band
> 4)
567 current_band
= 0; /* wrap around */
573 mode
= GAIN
; /* wrap around */
576 case ACTION_STD_CANCEL
:
582 if(default_event_handler(button
) == SYS_USB_CONNECTED
) {
589 /* Update the filter if the user changed something */
591 dsp_set_eq_coefs(current_band
);
596 /* Reset screen settings */
598 screens
[i
].setfont(FONT_UI
);
599 screens
[i
].clear_display();
605 * TODO: Can the settings system be used to do this instead?
607 static bool eq_save_preset(void)
610 char filename
[MAX_PATH
];
613 create_numbered_filename(filename
, EQS_DIR
, "eq", ".cfg", 2
614 IF_CNFN_NUM_(, NULL
));
616 /* allow user to modify filename */
618 if (!kbd_input(filename
, sizeof filename
)) {
619 fd
= creat(filename
);
621 gui_syncsplash(HZ
, ID2P(LANG_FAILED
));
626 gui_syncsplash(HZ
, ID2P(LANG_CANCEL
));
631 /* TODO: Should we really do this? */
632 fdprintf(fd
, "eq enabled: on\r\n");
633 fdprintf(fd
, "eq precut: %d\r\n", global_settings
.eq_precut
);
635 setting
= &global_settings
.eq_band0_cutoff
;
637 for(i
= 0; i
< 5; ++i
) {
638 fdprintf(fd
, "eq band %d cutoff: %d\r\n", i
, *setting
++);
639 fdprintf(fd
, "eq band %d q: %d\r\n", i
, *setting
++);
640 fdprintf(fd
, "eq band %d gain: %d\r\n", i
, *setting
++);
645 gui_syncsplash(HZ
, ID2P(LANG_SETTINGS_SAVED
));
650 /* Allows browsing of preset files */
651 bool eq_browse_presets(void)
653 return rockbox_browse(EQS_DIR
, SHOW_CFG
);
657 MENUITEM_FUNCTION(eq_graphical
, 0, ID2P(LANG_EQUALIZER_GRAPHICAL
),
658 (int(*)(void))eq_menu_graphical
, NULL
, NULL
,
660 MENUITEM_FUNCTION(eq_save
, 0, ID2P(LANG_EQUALIZER_SAVE
),
661 (int(*)(void))eq_save_preset
, NULL
, NULL
, Icon_NOICON
);
662 MENUITEM_FUNCTION(eq_browse
, 0, ID2P(LANG_EQUALIZER_BROWSE
),
663 (int(*)(void))eq_browse_presets
, NULL
, NULL
, Icon_NOICON
);
665 int soundmenu_callback(int action
,const struct menu_item_ex
*this_item
);
666 MAKE_MENU(equalizer_menu
, ID2P(LANG_EQUALIZER
), soundmenu_callback
, Icon_EQ
,
667 &eq_enable
, &eq_graphical
, &eq_precut
, &gain_menu
,
668 &advanced_eq_menu_
, &eq_save
, &eq_browse
);
673 void eq_hw_gain_format(char* buffer
, size_t buffer_size
, int value
,
676 snprintf(buffer
, buffer_size
, "%d %s", value
, unit
);
679 static int band0_callback(int action
, const struct menu_item_ex
*this_item
)
682 if (action
== ACTION_EXIT_MENUITEM
)
685 audiohw_set_equalizer_band(0, global_settings
.eq_hw_band0_cutoff
, 0,
686 global_settings
.eq_hw_band0_gain
);
691 static int band1_callback(int action
, const struct menu_item_ex
*this_item
)
694 if (action
== ACTION_EXIT_MENUITEM
)
697 audiohw_set_equalizer_band(1, global_settings
.eq_hw_band1_center
,
698 global_settings
.eq_hw_band1_bandwidth
,
699 global_settings
.eq_hw_band1_gain
);
704 static int band2_callback(int action
, const struct menu_item_ex
*this_item
)
707 if (action
== ACTION_EXIT_MENUITEM
)
710 audiohw_set_equalizer_band(2, global_settings
.eq_hw_band2_center
,
711 global_settings
.eq_hw_band2_bandwidth
,
712 global_settings
.eq_hw_band2_gain
);
717 static int band3_callback(int action
, const struct menu_item_ex
*this_item
)
720 if (action
== ACTION_EXIT_MENUITEM
)
723 audiohw_set_equalizer_band(3, global_settings
.eq_hw_band3_center
,
724 global_settings
.eq_hw_band3_bandwidth
,
725 global_settings
.eq_hw_band3_gain
);
730 static int band4_callback(int action
, const struct menu_item_ex
*this_item
)
733 if (action
== ACTION_EXIT_MENUITEM
)
736 audiohw_set_equalizer_band(4, global_settings
.eq_hw_band4_cutoff
, 0,
737 global_settings
.eq_hw_band4_gain
);
742 void eq_hw_enable(bool enable
)
748 audiohw_set_equalizer_band(0, global_settings
.eq_hw_band0_cutoff
,
749 0, global_settings
.eq_hw_band0_gain
);
750 audiohw_set_equalizer_band(1, global_settings
.eq_hw_band1_center
,
751 global_settings
.eq_hw_band1_bandwidth
,
752 global_settings
.eq_hw_band1_gain
);
753 audiohw_set_equalizer_band(2, global_settings
.eq_hw_band2_center
,
754 global_settings
.eq_hw_band2_bandwidth
,
755 global_settings
.eq_hw_band2_gain
);
756 audiohw_set_equalizer_band(3, global_settings
.eq_hw_band3_center
,
757 global_settings
.eq_hw_band3_bandwidth
,
758 global_settings
.eq_hw_band3_gain
);
759 audiohw_set_equalizer_band(4, global_settings
.eq_hw_band4_cutoff
,
760 0, global_settings
.eq_hw_band4_gain
);
762 audiohw_set_equalizer_band(0, global_settings
.eq_hw_band0_cutoff
, 0, 0);
763 audiohw_set_equalizer_band(1, global_settings
.eq_hw_band1_center
,
764 global_settings
.eq_hw_band1_bandwidth
, 0);
765 audiohw_set_equalizer_band(2, global_settings
.eq_hw_band2_center
,
766 global_settings
.eq_hw_band2_bandwidth
, 0);
767 audiohw_set_equalizer_band(3, global_settings
.eq_hw_band3_center
,
768 global_settings
.eq_hw_band3_bandwidth
, 0);
769 audiohw_set_equalizer_band(4, global_settings
.eq_hw_band4_cutoff
, 0, 0);
773 static int hweq_enable_callback(int action
, const struct menu_item_ex
*this_item
)
776 if (action
== ACTION_EXIT_MENUITEM
)
778 eq_hw_enable(global_settings
.eq_hw_enabled
);
782 MENUITEM_SETTING(hw_eq_enable
, &global_settings
.eq_hw_enabled
, hweq_enable_callback
);
784 MENUITEM_SETTING(hw_eq_cutoff_0
, &global_settings
.eq_hw_band0_cutoff
, band0_callback
);
785 MENUITEM_SETTING(hw_eq_gain_0
, &global_settings
.eq_hw_band0_gain
, band0_callback
);
786 MAKE_MENU(hw_eq_band0
, ID2P(LANG_EQUALIZER_BAND_LOW_SHELF
), NULL
, Icon_NOICON
,
787 &hw_eq_cutoff_0
, &hw_eq_gain_0
);
789 MENUITEM_SETTING(hw_eq_cutoff_1
, &global_settings
.eq_hw_band1_center
, band1_callback
);
790 MENUITEM_SETTING(hw_eq_bandwidth_1
, &global_settings
.eq_hw_band1_bandwidth
, band1_callback
);
791 MENUITEM_SETTING(hw_eq_gain_1
, &global_settings
.eq_hw_band1_gain
, band1_callback
);
792 MAKE_MENU(hw_eq_band1
, "Peak Filter 1", NULL
, Icon_NOICON
,
793 &hw_eq_cutoff_1
, &hw_eq_bandwidth_1
, &hw_eq_gain_1
);
795 MENUITEM_SETTING(hw_eq_cutoff_2
, &global_settings
.eq_hw_band2_center
, band2_callback
);
796 MENUITEM_SETTING(hw_eq_bandwidth_2
, &global_settings
.eq_hw_band2_bandwidth
, band2_callback
);
797 MENUITEM_SETTING(hw_eq_gain_2
, &global_settings
.eq_hw_band2_gain
, band2_callback
);
798 MAKE_MENU(hw_eq_band2
, "Peak Filter 2", NULL
, Icon_NOICON
,
799 &hw_eq_cutoff_2
, &hw_eq_bandwidth_2
, &hw_eq_gain_2
);
801 MENUITEM_SETTING(hw_eq_cutoff_3
, &global_settings
.eq_hw_band3_center
, band3_callback
);
802 MENUITEM_SETTING(hw_eq_bandwidth_3
, &global_settings
.eq_hw_band3_bandwidth
, band3_callback
);
803 MENUITEM_SETTING(hw_eq_gain_3
, &global_settings
.eq_hw_band3_gain
, band3_callback
);
804 MAKE_MENU(hw_eq_band3
, "Peak Filter 3", NULL
, Icon_NOICON
,
805 &hw_eq_cutoff_3
, &hw_eq_bandwidth_3
, &hw_eq_gain_3
);
807 MENUITEM_SETTING(hw_eq_cutoff_4
, &global_settings
.eq_hw_band4_cutoff
, band4_callback
);
808 MENUITEM_SETTING(hw_eq_gain_4
, &global_settings
.eq_hw_band4_gain
, band4_callback
);
809 MAKE_MENU(hw_eq_band4
, ID2P(LANG_EQUALIZER_BAND_HIGH_SHELF
), NULL
, Icon_NOICON
,
810 &hw_eq_cutoff_4
, &hw_eq_gain_4
);
812 MAKE_MENU(hw_eq_menu
, ID2P(LANG_EQUALIZER_HARDWARE
), NULL
, Icon_EQ
,
813 &hw_eq_enable
, &hw_eq_band0
, &hw_eq_band1
,
814 &hw_eq_band2
, &hw_eq_band3
, &hw_eq_band4
);