diff --git a/apps/lang/english.lang b/apps/lang/english.lang index d190614a78..6ded417b2d 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -1118,7 +1118,27 @@ desc: in the recording settings eng: "Source" new: -id: LANG_RECORDING_CHANNEL +id: LANG_RECORDING_CHANNELS desc: in the recording settings -eng: "Channel" +eng: "Channels" +new: + +id: LANG_RECORDING_SRC_MIC +desc: in the recording settings +eng: "Mic" +new: + +id: LANG_RECORDING_SRC_LINE +desc: in the recording settings +eng: "Line In" +new: + +id: LANG_RECORDING_SRC_DIGITAL +desc: in the recording settings +eng: "Digital" +new: + +id: LANG_RECORDING_SETTINGS +desc: in the main menu +eng: "Recording settings" new: diff --git a/apps/main_menu.c b/apps/main_menu.c index 5399c996c9..12bd2274cb 100644 --- a/apps/main_menu.c +++ b/apps/main_menu.c @@ -228,6 +228,7 @@ bool main_menu(void) { str(LANG_SOUND_SETTINGS), sound_menu }, { str(LANG_GENERAL_SETTINGS), settings_menu }, #ifdef HAVE_MAS3587F + { str(LANG_RECORDING_SETTINGS), recording_menu }, { str(LANG_RECORDING), recording_screen }, #endif #ifdef HAVE_LCD_BITMAP diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c index 3ec4249f3c..70aa1257ce 100644 --- a/apps/recorder/recording.c +++ b/apps/recorder/recording.c @@ -35,6 +35,7 @@ #include "peakmeter.h" #include "status.h" #include "menu.h" +#include "sound_menu.h" bool f2_rec_screen(void); bool f3_rec_screen(void); @@ -46,14 +47,6 @@ extern int mp3buf_write; extern int mp3buf_read; extern bool recording; -int mic_gain = 8; -int left_gain = 2; -int right_gain = 2; -unsigned int recording_quality = 5; -unsigned int recording_frequency = 0; -unsigned int recording_channel_mode = 0; -unsigned int recording_source = 0; - #define SOURCE_MIC 0 #define SOURCE_LINE 1 #define SOURCE_SPDIF 2 @@ -70,13 +63,15 @@ char *freq_str[6] = static void set_gain(void) { - if(recording_source == SOURCE_MIC) + if(global_settings.rec_source == SOURCE_MIC) { - mpeg_set_recording_gain(left_gain, 0, mic_gain); + mpeg_set_recording_gain(global_settings.rec_left_gain, 0, + global_settings.rec_mic_gain); } else { - mpeg_set_recording_gain(left_gain, right_gain, 0); + mpeg_set_recording_gain(global_settings.rec_left_gain, + global_settings.rec_right_gain, 0); } } @@ -107,7 +102,7 @@ int cursor; void adjust_cursor(void) { - if(recording_source == SOURCE_LINE) + if(global_settings.rec_source == SOURCE_LINE) { if(cursor < 0) cursor = 0; @@ -140,8 +135,10 @@ bool recording_screen(void) peak_meter_enabled = true; - mpeg_set_recording_options(recording_frequency, recording_quality, - recording_source, recording_channel_mode); + mpeg_set_recording_options(global_settings.rec_frequency, + global_settings.rec_quality, + global_settings.rec_source, + global_settings.rec_channels); lcd_setfont(FONT_UI); lcd_getstringsize("M", &w, &h); @@ -189,30 +186,37 @@ bool recording_screen(void) switch(cursor) { case 0: - if(recording_source == SOURCE_MIC) + if(global_settings.rec_source == SOURCE_MIC) { - mic_gain++; - if(mic_gain > mpeg_sound_max(SOUND_MIC_GAIN)) - mic_gain = mpeg_sound_max(SOUND_MIC_GAIN); + global_settings.rec_mic_gain++; + if(global_settings.rec_mic_gain > + mpeg_sound_max(SOUND_MIC_GAIN)) + global_settings.rec_mic_gain = + mpeg_sound_max(SOUND_MIC_GAIN); } else { - gain = MAX(left_gain, right_gain) + 1; + gain = MAX(global_settings.rec_left_gain, + global_settings.rec_right_gain) + 1; if(gain > mpeg_sound_max(SOUND_MIC_GAIN)) gain = mpeg_sound_max(SOUND_MIC_GAIN); - left_gain = gain; - right_gain = gain; + global_settings.rec_left_gain = gain; + global_settings.rec_right_gain = gain; } break; case 1: - left_gain++; - if(left_gain > mpeg_sound_max(SOUND_LEFT_GAIN)) - left_gain = mpeg_sound_max(SOUND_LEFT_GAIN); + global_settings.rec_left_gain++; + if(global_settings.rec_left_gain > + mpeg_sound_max(SOUND_LEFT_GAIN)) + global_settings.rec_left_gain = + mpeg_sound_max(SOUND_LEFT_GAIN); break; case 2: - right_gain++; - if(right_gain > mpeg_sound_max(SOUND_RIGHT_GAIN)) - right_gain = mpeg_sound_max(SOUND_RIGHT_GAIN); + global_settings.rec_right_gain++; + if(global_settings.rec_right_gain > + mpeg_sound_max(SOUND_RIGHT_GAIN)) + global_settings.rec_right_gain = + mpeg_sound_max(SOUND_RIGHT_GAIN); break; } set_gain(); @@ -223,36 +227,50 @@ bool recording_screen(void) switch(cursor) { case 0: - if(recording_source == SOURCE_MIC) + if(global_settings.rec_source == SOURCE_MIC) { - mic_gain--; - if(mic_gain < mpeg_sound_min(SOUND_MIC_GAIN)) - mic_gain = mpeg_sound_min(SOUND_MIC_GAIN); + global_settings.rec_mic_gain--; + if(global_settings.rec_mic_gain < + mpeg_sound_min(SOUND_MIC_GAIN)) + global_settings.rec_mic_gain = + mpeg_sound_min(SOUND_MIC_GAIN); } else { - gain = MAX(left_gain, right_gain) - 1; + gain = MAX(global_settings.rec_left_gain, + global_settings.rec_right_gain) - 1; if(gain < mpeg_sound_min(SOUND_LEFT_GAIN)) gain = mpeg_sound_min(SOUND_LEFT_GAIN); - left_gain = gain; - right_gain = gain; + global_settings.rec_left_gain = gain; + global_settings.rec_right_gain = gain; } break; case 1: - left_gain--; - if(left_gain < mpeg_sound_min(SOUND_LEFT_GAIN)) - left_gain = mpeg_sound_min(SOUND_LEFT_GAIN); + global_settings.rec_left_gain--; + if(global_settings.rec_left_gain < + mpeg_sound_min(SOUND_LEFT_GAIN)) + global_settings.rec_left_gain = + mpeg_sound_min(SOUND_LEFT_GAIN); break; case 2: - right_gain--; - if(right_gain < mpeg_sound_min(SOUND_MIC_GAIN)) - right_gain = mpeg_sound_min(SOUND_MIC_GAIN); + global_settings.rec_right_gain--; + if(global_settings.rec_right_gain < + mpeg_sound_min(SOUND_MIC_GAIN)) + global_settings.rec_right_gain = + mpeg_sound_min(SOUND_MIC_GAIN); break; } set_gain(); update_countdown = 1; /* Update immediately */ break; + case BUTTON_F1: + if (recording_menu()) + return SYS_USB_CONNECTED; + settings_save(); + update_countdown = 1; /* Update immediately */ + break; + case BUTTON_F2: if (f2_rec_screen()) return SYS_USB_CONNECTED; @@ -282,18 +300,20 @@ bool recording_screen(void) peak_meter_draw(0, 8 + h, LCD_WIDTH, h); /* Show mic gain if input source is Mic */ - if(recording_source == 0) + if(global_settings.rec_source == 0) { snprintf(buf, 32, "%s: %s", str(LANG_RECORDING_GAIN), - fmt_gain(SOUND_MIC_GAIN, mic_gain, + fmt_gain(SOUND_MIC_GAIN, + global_settings.rec_mic_gain, buf2, sizeof(buf2))); lcd_puts(0, 3, buf); } else { - if(recording_source == SOURCE_LINE) + if(global_settings.rec_source == SOURCE_LINE) { - gain = MAX(left_gain, right_gain); + gain = MAX(global_settings.rec_left_gain, + global_settings.rec_right_gain); snprintf(buf, 32, "%s: %s", str(LANG_RECORDING_GAIN), fmt_gain(SOUND_LEFT_GAIN, gain, @@ -301,12 +321,14 @@ bool recording_screen(void) lcd_puts(0, 3, buf); snprintf(buf, 32, "%s: %s", str(LANG_RECORDING_LEFT), - fmt_gain(SOUND_LEFT_GAIN, left_gain, + fmt_gain(SOUND_LEFT_GAIN, + global_settings.rec_left_gain, buf2, sizeof(buf2))); lcd_puts(0, 4, buf); snprintf(buf, 32, "%s: %s", str(LANG_RECORDING_RIGHT), - fmt_gain(SOUND_RIGHT_GAIN, right_gain, + fmt_gain(SOUND_RIGHT_GAIN, + global_settings.rec_right_gain, buf2, sizeof(buf2))); lcd_puts(0, 5, buf); } @@ -314,14 +336,14 @@ bool recording_screen(void) status_draw(); - if(recording_source != SOURCE_SPDIF) + if(global_settings.rec_source != SOURCE_SPDIF) put_cursorxy(0, 3 + cursor, true); snprintf(buf, 32, "%s %s [%d]", - freq_str[recording_frequency], - recording_channel_mode? + freq_str[global_settings.rec_frequency], + global_settings.rec_channels? str(LANG_CHANNEL_MONO):str(LANG_CHANNEL_STEREO), - recording_quality); + global_settings.rec_quality); lcd_puts(0, 6, buf); } else @@ -357,7 +379,7 @@ bool f2_rec_screen(void) /* Recording quality */ lcd_putsxy(0, LCD_HEIGHT/2 - h*2, str(LANG_RECORDING_QUALITY)); - snprintf(buf, 32, "%d", recording_quality); + snprintf(buf, 32, "%d", global_settings.rec_quality); lcd_putsxy(0, LCD_HEIGHT/2-h, buf); lcd_bitmap(bitmap_icons_7x8[Icon_FastBackward], LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8, true); @@ -366,14 +388,14 @@ bool f2_rec_screen(void) snprintf(buf, sizeof buf, "%s:", str(LANG_RECORDING_FREQUENCY)); lcd_getstringsize(buf,&w,&h); lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h*2, buf); - ptr = freq_str[recording_frequency]; + ptr = freq_str[global_settings.rec_frequency]; lcd_getstringsize(ptr, &w, &h); lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, ptr); lcd_bitmap(bitmap_icons_7x8[Icon_DownArrow], LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8, true); /* Channel mode */ - switch ( recording_channel_mode ) { + switch ( global_settings.rec_channels ) { case 0: ptr = str(LANG_CHANNEL_STEREO); break; @@ -383,9 +405,9 @@ bool f2_rec_screen(void) break; } - lcd_getstringsize(str(LANG_RECORDING_CHANNEL), &w, &h); + lcd_getstringsize(str(LANG_RECORDING_CHANNELS), &w, &h); lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h*2, - str(LANG_RECORDING_CHANNEL)); + str(LANG_RECORDING_CHANNELS)); lcd_getstringsize(str(LANG_F2_MODE), &w, &h); lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h, str(LANG_F2_MODE)); lcd_getstringsize(ptr, &w, &h); @@ -398,25 +420,25 @@ bool f2_rec_screen(void) switch (button_get(true)) { case BUTTON_LEFT: case BUTTON_F2 | BUTTON_LEFT: - recording_quality++; - if(recording_quality > 7) - recording_quality = 0; + global_settings.rec_quality++; + if(global_settings.rec_quality > 7) + global_settings.rec_quality = 0; used = true; break; case BUTTON_DOWN: case BUTTON_F2 | BUTTON_DOWN: - recording_frequency++; - if(recording_frequency > 5) - recording_frequency = 0; + global_settings.rec_frequency++; + if(global_settings.rec_frequency > 5) + global_settings.rec_frequency = 0; used = true; break; case BUTTON_RIGHT: case BUTTON_F2 | BUTTON_RIGHT: - recording_channel_mode++; - if(recording_channel_mode > 1) - recording_channel_mode = 0; + global_settings.rec_channels++; + if(global_settings.rec_channels > 1) + global_settings.rec_channels = 0; used = true; break; @@ -436,27 +458,30 @@ bool f2_rec_screen(void) } } - mpeg_set_recording_options(recording_frequency, recording_quality, - recording_source, recording_channel_mode); + mpeg_set_recording_options(global_settings.rec_frequency, + global_settings.rec_quality, + global_settings.rec_source, + global_settings.rec_channels); -// settings_save(); + set_gain(); + + settings_save(); lcd_setfont(FONT_UI); return false; } -char *src_str[] = -{ - "Mic", - "Line In", - "Digital" -}; - bool f3_rec_screen(void) { bool exit = false; bool used = false; int w, h; + char *src_str[] = + { + str(LANG_RECORDING_SRC_MIC), + str(LANG_RECORDING_SRC_LINE), + str(LANG_RECORDING_SRC_DIGITAL) + }; lcd_setfont(FONT_SYSFIXED); lcd_getstringsize("A",&w,&h); @@ -469,7 +494,7 @@ bool f3_rec_screen(void) /* Recording source */ lcd_putsxy(0, LCD_HEIGHT/2 - h*2, str(LANG_RECORDING_SOURCE)); - ptr = src_str[recording_source]; + ptr = src_str[global_settings.rec_source]; lcd_getstringsize(ptr, &w, &h); lcd_putsxy(0, LCD_HEIGHT/2-h, ptr); lcd_bitmap(bitmap_icons_7x8[Icon_FastBackward], @@ -480,25 +505,25 @@ bool f3_rec_screen(void) switch (button_get(true)) { case BUTTON_LEFT: case BUTTON_F3 | BUTTON_LEFT: - recording_source++; - if(recording_source > 2) - recording_source = 0; + global_settings.rec_source++; + if(global_settings.rec_source > 2) + global_settings.rec_source = 0; used = true; break; case BUTTON_DOWN: case BUTTON_F3 | BUTTON_DOWN: - recording_frequency++; - if(recording_frequency > 5) - recording_frequency = 0; + global_settings.rec_frequency++; + if(global_settings.rec_frequency > 5) + global_settings.rec_frequency = 0; used = true; break; case BUTTON_RIGHT: case BUTTON_F3 | BUTTON_RIGHT: - recording_channel_mode++; - if(recording_channel_mode > 1) - recording_channel_mode = 0; + global_settings.rec_channels++; + if(global_settings.rec_channels > 1) + global_settings.rec_channels = 0; used = true; break; @@ -518,10 +543,14 @@ bool f3_rec_screen(void) } } - mpeg_set_recording_options(recording_frequency, recording_quality, - recording_source, recording_channel_mode); + mpeg_set_recording_options(global_settings.rec_frequency, + global_settings.rec_quality, + global_settings.rec_source, + global_settings.rec_channels); -// settings_save(); + set_gain(); + + settings_save(); lcd_setfont(FONT_UI); return false; diff --git a/apps/settings.c b/apps/settings.c index 417f0f324f..9ef224e069 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -99,13 +99,15 @@ offset abs peak_meter_dbfs (bit 7) 0x1f 0x33 0x20 0x34 -0x21 0x35 +0x21 0x35 +0x22 0x36 +0x23 0x37 +0x24 0x38 + - the geeky but useless statistics part: -0x24 - 0x2a Config memory is reset to 0xff and initialized with 'factory defaults' if @@ -329,9 +331,16 @@ int settings_save( void ) (global_settings.peak_meter_dbfs ? 0x80 : 0); config_block[0x1f] = (unsigned char)global_settings.peak_meter_min; config_block[0x20] = (unsigned char)global_settings.peak_meter_max; - config_block[0x21] = (unsigned char)global_settings.repeat_mode; - - memcpy(&config_block[0x24], &global_settings.total_uptime, 4); + config_block[0x21] = (unsigned char) + ((global_settings.repeat_mode & 3) | + ((global_settings.rec_channels & 1) << 2) | + ((global_settings.rec_mic_gain & 0x0f) << 3)); + config_block[0x22] = (unsigned char) + ((global_settings.rec_quality & 7) | + ((global_settings.rec_source & 1) << 3) | + ((global_settings.rec_frequency & 7) << 5)); + config_block[0x23] = (unsigned char)global_settings.rec_left_gain; + config_block[0x24] = (unsigned char)global_settings.rec_right_gain; strncpy(&config_block[0xb8], global_settings.wps_file, MAX_FILENAME); strncpy(&config_block[0xcc], global_settings.lang_file, MAX_FILENAME); @@ -565,10 +574,24 @@ void settings_load(void) global_settings.peak_meter_max = config_block[0x20]; if (config_block[0x21] != 0xFF) - global_settings.repeat_mode = config_block[0x21]; + { + global_settings.repeat_mode = config_block[0x21] & 3; + global_settings.rec_channels = (config_block[0x21] >> 2) & 1; + global_settings.rec_mic_gain = (config_block[0x21] >> 4) & 0x0f; + } + + if (config_block[0x22] != 0xFF) + { + global_settings.rec_quality = config_block[0x22] & 7; + global_settings.rec_source = (config_block[0x22] >> 3) & 3; + global_settings.rec_frequency = (config_block[0x22] >> 5) & 7; + } + + if (config_block[0x23] != 0xFF) + global_settings.rec_left_gain = config_block[0x23] & 0x0f; if (config_block[0x24] != 0xFF) - memcpy(&global_settings.total_uptime, &config_block[0x24], 4); + global_settings.rec_right_gain = config_block[0x24] & 0x0f; memcpy(&global_settings.resume_first_index, &config_block[0xF4], 4); memcpy(&global_settings.resume_seed, &config_block[0xF8], 4); @@ -731,6 +754,13 @@ void settings_reset(void) { global_settings.bass_boost = mpeg_sound_default(SOUND_SUPERBASS); global_settings.avc = mpeg_sound_default(SOUND_AVC); global_settings.channel_config = mpeg_sound_default(SOUND_CHANNELS); + global_settings.rec_quality = 5; + global_settings.rec_source = 0; /* 0=mic */ + global_settings.rec_frequency = 0; /* 0=44.1kHz */ + global_settings.rec_channels = 0; /* 0=Stereo */ + global_settings.rec_mic_gain = 8; + global_settings.rec_left_gain = 2; /* 0dB */ + global_settings.rec_right_gain = 2; /* 0dB */ global_settings.resume = RESUME_ASK; global_settings.contrast = DEFAULT_CONTRAST_SETTING; global_settings.poweroff = DEFAULT_POWEROFF_SETTING; @@ -744,7 +774,6 @@ void settings_reset(void) { global_settings.repeat_mode = REPEAT_ALL; global_settings.playlist_shuffle = false; global_settings.discharge = 0; - global_settings.total_uptime = 0; global_settings.timeformat = 0; global_settings.volume_type = 0; global_settings.battery_type = 0; diff --git a/apps/settings.h b/apps/settings.h index 655b2e0245..2622d314f7 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -61,12 +61,27 @@ struct user_settings int bass_boost; /* bass boost eq: 0-100 0=off 100=max */ int avc; /* auto volume correct: 0=disable, 1=2s 2=4s 3=8s */ int channel_config; /* Stereo, Mono, Mono left, Mono right */ + + int rec_quality; /* 0-7 */ + int rec_source; /* 0=mic, 1=line, 2=S/PDIF */ + int rec_frequency; /* 0 = 44.1kHz + 1 = 48kHz + 2 = 32kHz + 3 = 22.05kHz + 4 = 24kHz + 5 = 16kHz */ + int rec_channels; /* 0=Stereo, 1=Mono */ + int rec_mic_gain; /* 0-15 */ + int rec_left_gain; /* 0-15 */ + int rec_right_gain; /* 0-15 */ /* device settings */ int contrast; /* lcd contrast: 0-100 0=low 100=high */ int poweroff; /* power off timer */ - int backlight_timeout; /* backlight off timeout: 0-18 0=never,1=always,then according to timeout_values[] */ + int backlight_timeout; /* backlight off timeout: 0-18 0=never, + 1=always, + then according to timeout_values[] */ bool backlight_on_when_charging; bool discharge; /* maintain charge of at least: false = 90%, true = 10% */ @@ -115,8 +130,6 @@ struct user_settings bool browse_current; /* 1=goto current song, 0=goto previous location */ - /* geeky persistent statistics */ - unsigned int total_uptime; /* total uptime since rockbox was first booted */ }; /* prototypes */ diff --git a/apps/sound_menu.c b/apps/sound_menu.c index 2938e3a527..0f5421e221 100644 --- a/apps/sound_menu.c +++ b/apps/sound_menu.c @@ -183,7 +183,42 @@ static bool avc(void) return set_option(str(LANG_DECAY), &global_settings.avc, names, 4, set_avc); } -#endif /* ARCHOS_RECORDER */ + +static bool recsource(void) +{ + char *names[] = {str(LANG_RECORDING_SRC_MIC), str(LANG_RECORDING_SRC_LINE), + str(LANG_RECORDING_SRC_DIGITAL) }; + return set_option(str(LANG_RECORDING_SOURCE), + &global_settings.rec_source, + names, 3, NULL ); +} + +static bool recfrequency(void) +{ + char *names[] = {"44.1kHz", "48kHz", "32kHz", + "22.05kHz", "24kHz", "16kHz"}; + + return set_option(str(LANG_RECORDING_FREQUENCY), + &global_settings.rec_frequency, + names, 6, NULL ); +} + +static bool recchannels(void) +{ + char *names[] = {str(LANG_CHANNEL_STEREO), str(LANG_CHANNEL_MONO)}; + + return set_option(str(LANG_RECORDING_CHANNELS), + &global_settings.rec_channels, + names, 2, NULL ); +} + +static bool recquality(void) +{ + return set_int(str(LANG_RECORDING_QUALITY), "", + &global_settings.rec_quality, + NULL, 1, 0, 7 ); +} +#endif /* HAVE_MAS3587F */ static void set_chanconf(int val) { @@ -221,3 +256,23 @@ bool sound_menu(void) return result; } + +#ifdef HAVE_MAS3587F +bool recording_menu(void) +{ + int m; + bool result; + struct menu_items items[] = { + { str(LANG_RECORDING_QUALITY), recquality }, + { str(LANG_RECORDING_FREQUENCY), recfrequency }, + { str(LANG_RECORDING_SOURCE), recsource }, + { str(LANG_RECORDING_CHANNELS), recchannels }, + }; + + m=menu_init( items, sizeof items / sizeof(struct menu_items) ); + result = menu_run(m); + menu_exit(m); + + return result; +} +#endif diff --git a/apps/sound_menu.h b/apps/sound_menu.h index 5063a288d9..8c1f4db089 100644 --- a/apps/sound_menu.h +++ b/apps/sound_menu.h @@ -22,5 +22,6 @@ #include "menu.h" bool sound_menu(void); +bool recording_menu(void); #endif