1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 Björn Stenberg
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 ****************************************************************************/
26 #include "mp3_playback.h"
30 #ifdef HAVE_LCD_BITMAP
38 static const char* const fmt
[] =
41 "%d.%d %s ", /* 1 decimal */
42 "%d.%02d %s " /* 2 decimals */
45 bool set_sound(const char* string
,
58 int talkunit
= UNIT_INT
;
62 unit
= mpeg_sound_unit(setting
);
63 numdec
= mpeg_sound_numdecimals(setting
);
64 steps
= mpeg_sound_steps(setting
);
65 min
= mpeg_sound_min(setting
);
66 max
= mpeg_sound_max(setting
);
67 if (*unit
== 'd') /* crude reconstruction */
69 else if (*unit
== '%')
70 talkunit
= UNIT_PERCENT
;
71 else if (*unit
== 'H')
72 talkunit
= UNIT_HERTZ
;
74 #ifdef HAVE_LCD_BITMAP
75 if(global_settings
.statusbar
)
76 lcd_setmargins(0, STATUSBAR_HEIGHT
);
81 lcd_puts_scroll(0,0,string
);
85 val
= mpeg_val2phys(setting
, *variable
);
88 integer
= val
/ (10 * numdec
);
89 dec
= val
% (10 * numdec
);
90 snprintf(str
,sizeof str
, fmt
[numdec
], integer
, dec
, unit
);
94 snprintf(str
,sizeof str
,"%d %s ", val
, unit
);
96 if (global_settings
.talk_menu
)
97 talk_value(val
, talkunit
, false); /* speak it */
104 button
= button_get_w_tmo(HZ
/2);
107 case SETTINGS_INC
| BUTTON_REPEAT
:
115 case SETTINGS_DEC
| BUTTON_REPEAT
:
123 case SETTINGS_CANCEL
:
127 #ifdef SETTINGS_CANCEL2
128 case SETTINGS_CANCEL2
:
134 if(default_event_handler(button
) == SYS_USB_CONNECTED
)
139 mpeg_sound_set(setting
, *variable
);
140 #if CONFIG_HWCODEC == MAS3507D
141 if(setting
== SOUND_BALANCE
)
142 mpeg_sound_set(SOUND_VOLUME
, global_settings
.volume
);
150 static bool volume(void)
152 return set_sound(str(LANG_VOLUME
), &global_settings
.volume
, SOUND_VOLUME
);
155 static bool balance(void)
157 return set_sound(str(LANG_BALANCE
), &global_settings
.balance
,
161 static bool bass(void)
163 return set_sound(str(LANG_BASS
), &global_settings
.bass
, SOUND_BASS
);
166 static bool treble(void)
168 return set_sound(str(LANG_TREBLE
), &global_settings
.treble
, SOUND_TREBLE
);
171 #if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
172 static bool loudness(void)
174 return set_sound(str(LANG_LOUDNESS
), &global_settings
.loudness
,
178 static bool mdb_strength(void)
180 return set_sound(str(LANG_MDB_STRENGTH
), &global_settings
.mdb_strength
,
184 static bool mdb_harmonics(void)
186 return set_sound(str(LANG_MDB_HARMONICS
), &global_settings
.mdb_harmonics
,
187 SOUND_MDB_HARMONICS
);
190 static bool mdb_center(void)
192 return set_sound(str(LANG_MDB_CENTER
), &global_settings
.mdb_center
,
196 static bool mdb_shape(void)
198 return set_sound(str(LANG_MDB_SHAPE
), &global_settings
.mdb_shape
,
202 static void set_mdb_enable(bool value
)
204 mpeg_sound_set(SOUND_MDB_ENABLE
, (int)value
);
207 static bool mdb_enable(void)
209 return set_bool_options(str(LANG_MDB_ENABLE
),
210 &global_settings
.mdb_enable
,
211 STR(LANG_SET_BOOL_YES
),
212 STR(LANG_SET_BOOL_NO
),
216 static void set_superbass(bool value
)
218 mpeg_sound_set(SOUND_SUPERBASS
, (int)value
);
221 static bool superbass(void)
223 return set_bool_options(str(LANG_SUPERBASS
),
224 &global_settings
.superbass
,
225 STR(LANG_SET_BOOL_YES
),
226 STR(LANG_SET_BOOL_NO
),
230 static void set_avc(int val
)
232 mpeg_sound_set(SOUND_AVC
, val
);
235 static bool avc(void)
237 static const struct opt_items names
[] = {
239 { "20ms", TALK_ID(20, UNIT_MS
) },
240 { "2s", TALK_ID(2, UNIT_SEC
) },
241 { "4s", TALK_ID(4, UNIT_SEC
) },
242 { "8s", TALK_ID(8, UNIT_SEC
) }
244 return set_option(str(LANG_DECAY
), &global_settings
.avc
, INT
,
249 #if CONFIG_HWCODEC == MAS3587F
250 static bool recsource(void)
252 static const struct opt_items names
[] = {
253 { STR(LANG_RECORDING_SRC_MIC
) },
254 { STR(LANG_RECORDING_SRC_LINE
) },
255 { STR(LANG_RECORDING_SRC_DIGITAL
) }
257 return set_option(str(LANG_RECORDING_SOURCE
),
258 &global_settings
.rec_source
, INT
,
262 static bool recfrequency(void)
264 static const struct opt_items names
[] = {
265 { "44.1kHz", TALK_ID(44, UNIT_KHZ
) },
266 { "48kHz", TALK_ID(48, UNIT_KHZ
) },
267 { "32kHz", TALK_ID(32, UNIT_KHZ
) },
268 { "22.05kHz", TALK_ID(22, UNIT_KHZ
) },
269 { "24kHz", TALK_ID(24, UNIT_KHZ
) },
270 { "16kHz", TALK_ID(16, UNIT_KHZ
) }
272 return set_option(str(LANG_RECORDING_FREQUENCY
),
273 &global_settings
.rec_frequency
, INT
,
277 static bool recchannels(void)
279 static const struct opt_items names
[] = {
280 { STR(LANG_CHANNEL_STEREO
) },
281 { STR(LANG_CHANNEL_MONO
) }
283 return set_option(str(LANG_RECORDING_CHANNELS
),
284 &global_settings
.rec_channels
, INT
,
288 static bool recquality(void)
290 return set_int(str(LANG_RECORDING_QUALITY
), "", UNIT_INT
,
291 &global_settings
.rec_quality
,
295 static bool receditable(void)
297 return set_bool(str(LANG_RECORDING_EDITABLE
),
298 &global_settings
.rec_editable
);
301 static bool rectimesplit(void)
303 static const struct opt_items names
[] = {
305 { "00:05" , TALK_ID(5, UNIT_MIN
) },
306 { "00:10" , TALK_ID(10, UNIT_MIN
) },
307 { "00:15" , TALK_ID(15, UNIT_MIN
) },
308 { "00:30" , TALK_ID(30, UNIT_MIN
) },
309 { "01:00" , TALK_ID(1, UNIT_HOUR
) },
310 { "01:14" , TALK_ID(74, UNIT_MIN
) },
311 { "01:20" , TALK_ID(80, UNIT_MIN
) },
312 { "02:00" , TALK_ID(2, UNIT_HOUR
) },
313 { "04:00" , TALK_ID(4, UNIT_HOUR
) },
314 { "06:00" , TALK_ID(6, UNIT_HOUR
) },
315 { "08:00" , TALK_ID(8, UNIT_HOUR
) },
316 { "10:00" , TALK_ID(10, UNIT_HOUR
) },
317 { "12:00" , TALK_ID(12, UNIT_HOUR
) },
318 { "18:00" , TALK_ID(18, UNIT_HOUR
) },
319 { "24:00" , TALK_ID(24, UNIT_HOUR
) }
321 return set_option(str(LANG_RECORD_TIMESPLIT
),
322 &global_settings
.rec_timesplit
, INT
,
326 static bool recprerecord(void)
328 static const struct opt_items names
[] = {
330 { "1s", TALK_ID(1, UNIT_SEC
) },
331 { "2s", TALK_ID(2, UNIT_SEC
) },
332 { "3s", TALK_ID(3, UNIT_SEC
) },
333 { "4s", TALK_ID(4, UNIT_SEC
) },
334 { "5s", TALK_ID(5, UNIT_SEC
) },
335 { "6s", TALK_ID(6, UNIT_SEC
) },
336 { "7s", TALK_ID(7, UNIT_SEC
) },
337 { "8s", TALK_ID(8, UNIT_SEC
) },
338 { "9s", TALK_ID(9, UNIT_SEC
) },
339 { "10s", TALK_ID(10, UNIT_SEC
) },
340 { "11s", TALK_ID(11, UNIT_SEC
) },
341 { "12s", TALK_ID(12, UNIT_SEC
) },
342 { "13s", TALK_ID(13, UNIT_SEC
) },
343 { "14s", TALK_ID(14, UNIT_SEC
) },
344 { "15s", TALK_ID(15, UNIT_SEC
) },
345 { "16s", TALK_ID(16, UNIT_SEC
) },
346 { "17s", TALK_ID(17, UNIT_SEC
) },
347 { "18s", TALK_ID(18, UNIT_SEC
) },
348 { "19s", TALK_ID(19, UNIT_SEC
) },
349 { "20s", TALK_ID(20, UNIT_SEC
) },
350 { "21s", TALK_ID(21, UNIT_SEC
) },
351 { "22s", TALK_ID(22, UNIT_SEC
) },
352 { "23s", TALK_ID(23, UNIT_SEC
) },
353 { "24s", TALK_ID(24, UNIT_SEC
) },
354 { "25s", TALK_ID(25, UNIT_SEC
) },
355 { "26s", TALK_ID(26, UNIT_SEC
) },
356 { "27s", TALK_ID(27, UNIT_SEC
) },
357 { "28s", TALK_ID(28, UNIT_SEC
) },
358 { "29s", TALK_ID(29, UNIT_SEC
) },
359 { "30s", TALK_ID(30, UNIT_SEC
) }
361 return set_option(str(LANG_RECORD_PRERECORD_TIME
),
362 &global_settings
.rec_prerecord_time
, INT
,
366 static bool recdirectory(void)
368 static const struct opt_items names
[] = {
369 { rec_base_directory
, -1 },
370 { STR(LANG_RECORD_CURRENT_DIR
) }
372 return set_option(str(LANG_RECORD_DIRECTORY
),
373 &global_settings
.rec_directory
, INT
,
377 #endif /* MAS3587F */
379 static void set_chanconf(int val
)
381 mpeg_sound_set(SOUND_CHANNELS
, val
);
384 static bool chanconf(void)
386 static const struct opt_items names
[] = {
387 { STR(LANG_CHANNEL_STEREO
) },
388 { STR(LANG_CHANNEL_MONO
) },
389 { STR(LANG_CHANNEL_CUSTOM
) },
390 { STR(LANG_CHANNEL_LEFT
) },
391 { STR(LANG_CHANNEL_RIGHT
) },
392 { STR(LANG_CHANNEL_KARAOKE
) }
394 return set_option(str(LANG_CHANNEL
), &global_settings
.channel_config
, INT
,
395 names
, 6, set_chanconf
);
398 static bool stereo_width(void)
400 return set_sound(str(LANG_STEREO_WIDTH
), &global_settings
.stereo_width
,
404 bool sound_menu(void)
408 static const struct menu_item items
[] = {
409 { ID2P(LANG_VOLUME
), volume
},
410 { ID2P(LANG_BASS
), bass
},
411 { ID2P(LANG_TREBLE
), treble
},
412 { ID2P(LANG_BALANCE
), balance
},
413 { ID2P(LANG_CHANNEL_MENU
), chanconf
},
414 { ID2P(LANG_STEREO_WIDTH
), stereo_width
},
415 #if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
416 { ID2P(LANG_LOUDNESS
), loudness
},
417 { ID2P(LANG_AUTOVOL
), avc
},
418 { ID2P(LANG_SUPERBASS
), superbass
},
419 { ID2P(LANG_MDB_ENABLE
), mdb_enable
},
420 { ID2P(LANG_MDB_STRENGTH
), mdb_strength
},
421 { ID2P(LANG_MDB_HARMONICS
), mdb_harmonics
},
422 { ID2P(LANG_MDB_CENTER
), mdb_center
},
423 { ID2P(LANG_MDB_SHAPE
), mdb_shape
},
427 m
=menu_init( items
, sizeof(items
) / sizeof(*items
), NULL
,
429 result
= menu_run(m
);
435 #if CONFIG_HWCODEC == MAS3587F
436 bool recording_menu(bool no_source
)
440 struct menu_item items
[8];
443 items
[i
].desc
= ID2P(LANG_RECORDING_QUALITY
);
444 items
[i
++].function
= recquality
;
445 items
[i
].desc
= ID2P(LANG_RECORDING_FREQUENCY
);
446 items
[i
++].function
= recfrequency
;
448 items
[i
].desc
= ID2P(LANG_RECORDING_SOURCE
);
449 items
[i
++].function
= recsource
;
451 items
[i
].desc
= ID2P(LANG_RECORDING_CHANNELS
);
452 items
[i
++].function
= recchannels
;
453 items
[i
].desc
= ID2P(LANG_RECORDING_EDITABLE
);
454 items
[i
++].function
= receditable
;
455 items
[i
].desc
= ID2P(LANG_RECORD_TIMESPLIT
);
456 items
[i
++].function
= rectimesplit
;
457 items
[i
].desc
= ID2P(LANG_RECORD_PRERECORD_TIME
);
458 items
[i
++].function
= recprerecord
;
459 items
[i
].desc
= ID2P(LANG_RECORD_DIRECTORY
);
460 items
[i
++].function
= recdirectory
;
462 m
=menu_init( items
, i
, NULL
, NULL
, NULL
, NULL
);
463 result
= menu_run(m
);