Patch #1403437 by Peter D'Hoye & Martin Scarratt: Recording gain.

Changes:
***1. all platforms:
1.1 corrects gain display bug;
1.2 allows combined setting of stereo gain without an extra
line on the display;

2. iRiver H1xx and H3xx specific:
2.1 correctly named the decimator variables, they were
called 'gain';
2.2 splitted decimator gain settings for mic and line-in so
that they are saved separately;
2.3 added combined analog and decimator gain setting giving a
smooth gain range with the best analog/decimator gain
combination


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8627 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Hristo Kovachev 2006-02-08 13:08:55 +00:00
parent dcc9a8a3d8
commit db734b41d5
10 changed files with 456 additions and 125 deletions

View file

@ -3354,13 +3354,13 @@ voice: "Fade out mode"
new: new:
id: LANG_RECORDING_ADC_RIGHT id: LANG_RECORDING_ADC_RIGHT
desc: in the recording settings desc: DEPRECATED
eng: "ADC Gain Right" eng: "ADC Gain Right"
voice: "ADC Gain Right" voice: "ADC Gain Right"
new: new:
id: LANG_RECORDING_ADC_LEFT id: LANG_RECORDING_ADC_LEFT
desc: in the recording settings desc: DEPRECATED
eng: "ADC Gain Left" eng: "ADC Gain Left"
voice: "ADC Gain Left" voice: "ADC Gain Left"
new: new:
@ -3707,3 +3707,14 @@ eng: "High Shelf Filter"
voice: "" voice: ""
new: new:
id: LANG_RECORDING_GAIN_ANALOG
desc: in the recording screen
eng: "A"
voice: "Analog Gain"
new:
id: LANG_RECORDING_GAIN_DIGITAL
desc: in the recording screen
eng: "D"
voice: "Digital Gain"
new:

View file

@ -357,7 +357,7 @@ bool radio_screen(void)
sound_default(SOUND_RIGHT_GAIN), AUDIO_GAIN_LINEIN); sound_default(SOUND_RIGHT_GAIN), AUDIO_GAIN_LINEIN);
#else #else
uda1380_enable_recording(false); uda1380_enable_recording(false);
uda1380_set_recvol(10, 10, AUDIO_GAIN_ADC); uda1380_set_recvol(10, 10, AUDIO_GAIN_DECIMATOR);
uda1380_set_recvol(0, 0, AUDIO_GAIN_LINEIN); uda1380_set_recvol(0, 0, AUDIO_GAIN_LINEIN);
uda1380_set_monitor(true); uda1380_set_monitor(true);

View file

@ -134,44 +134,85 @@ static void set_gain(void)
{ {
if(global_settings.rec_source == SOURCE_MIC) if(global_settings.rec_source == SOURCE_MIC)
{ {
audio_set_recording_gain(global_settings.rec_mic_gain, 0, AUDIO_GAIN_MIC); audio_set_recording_gain(global_settings.rec_mic_gain,
0, AUDIO_GAIN_MIC);
#ifdef HAVE_UDA1380
audio_set_recording_gain(global_settings.rec_mic_decimator_left_gain,
global_settings.rec_mic_decimator_right_gain,
AUDIO_GAIN_DECIMATOR);
#endif
} }
else else
{ {
audio_set_recording_gain(global_settings.rec_left_gain, audio_set_recording_gain(global_settings.rec_left_gain,
global_settings.rec_right_gain, AUDIO_GAIN_LINEIN); global_settings.rec_right_gain,
} AUDIO_GAIN_LINEIN);
#ifdef HAVE_UDA1380 #ifdef HAVE_UDA1380
audio_set_recording_gain(global_settings.rec_adc_left_gain, audio_set_recording_gain(global_settings.rec_linein_decimator_left_gain,
global_settings.rec_adc_right_gain, global_settings.rec_linein_decimator_right_gain,
AUDIO_GAIN_ADC); AUDIO_GAIN_DECIMATOR);
#endif #endif
}
} }
static const char* const fmtstr[] = static const char* const fmtstr[] =
{ {
"%d %s", /* no decimals */ "%c%d %s", /* no decimals */
"%d.%d %s ", /* 1 decimal */ "%c%d.%d %s ", /* 1 decimal */
"%d.%02d %s " /* 2 decimals */ "%c%d.%02d %s " /* 2 decimals */
}; };
char *fmt_gain(int snd, int val, char *str, int len) char *fmt_gain(int snd, int val, char *str, int len)
{ {
int tmp, i, d, numdec; int i, d, numdec;
const char *unit; const char *unit;
tmp = sound_val2phys(snd, val); val = sound_val2phys(snd, val);
char sign = ' ';
if(val < 0)
{
sign = '-';
val = abs(val);
}
numdec = sound_numdecimals(snd); numdec = sound_numdecimals(snd);
unit = sound_unit(snd); unit = sound_unit(snd);
if(numdec) if(numdec)
{ {
i = tmp / (10*numdec); i = val / (10*numdec);
d = abs(tmp % (10*numdec)); d = val % (10*numdec);
snprintf(str, len, fmtstr[numdec], i, d, unit); snprintf(str, len, fmtstr[numdec], sign, i, d, unit);
} }
else else
snprintf(str, len, fmtstr[numdec], tmp, unit); snprintf(str, len, fmtstr[numdec], sign, val, unit);
return str;
}
char *fmt_gain2(int snd1, int val1, int snd2, int val2, char *str, int len)
{
/* same as above but for combined (added) values (recording gain) */
int i, d, numdec;
const char *unit;
int val = sound_val2phys(snd1, val1) + sound_val2phys(snd2, val2);
char sign = ' ';
if(val < 0)
{
sign = '-';
val = abs(val);
}
numdec = MAX(sound_numdecimals(snd1), sound_numdecimals(snd2));
unit = sound_unit(snd1); /* should be same! */
if(numdec)
{
i = val / (10*numdec);
d = val % (10*numdec);
snprintf(str, len, fmtstr[numdec], sign, i, d, unit);
}
else
snprintf(str, len, fmtstr[numdec], sign, val, unit);
return str; return str;
} }
@ -190,7 +231,6 @@ void adjust_cursor(void)
case SOURCE_MIC: case SOURCE_MIC:
max_cursor = 1; max_cursor = 1;
break; break;
case SOURCE_LINE: case SOURCE_LINE:
max_cursor = 3; max_cursor = 3;
break; break;
@ -292,6 +332,158 @@ static void trigger_listener(int trigger_status)
} }
} }
#ifdef HAVE_UDA1380
/* Handles combined recording gain changes.
GAIN RANGE = negative digital / analog / positive digital
*/
void change_recording_gain(bool increment, bool left, bool right,
int ana_mic_size, int ana_line_size)
{
if (increment)
{
if(global_settings.rec_source == SOURCE_MIC)
{
/* always changed as stereo */
if(global_settings.rec_mic_decimator_left_gain <
sound_max(SOUND_DECIMATOR_LEFT_GAIN))
{
/* increase digital gain by 1 if below max */
global_settings.rec_mic_decimator_left_gain++;
global_settings.rec_mic_decimator_right_gain =
global_settings.rec_mic_decimator_left_gain;
}
/* mono increase */
if((global_settings.rec_mic_decimator_left_gain >= ana_mic_size) &&
(global_settings.rec_mic_gain < sound_max(SOUND_MIC_GAIN)))
{
/* in analogue range, cycle digital gain for each analogue */
global_settings.rec_mic_decimator_left_gain = 0;
global_settings.rec_mic_decimator_right_gain =
global_settings.rec_mic_decimator_left_gain;
global_settings.rec_mic_gain++;
}
}
else
{
if(((left) && (right)) &&
(global_settings.rec_linein_decimator_left_gain <
sound_max(SOUND_DECIMATOR_LEFT_GAIN)) &&
(global_settings.rec_linein_decimator_right_gain <
sound_max(SOUND_DECIMATOR_RIGHT_GAIN)) )
{
/* increase digital gain by 1 if below max*/
global_settings.rec_linein_decimator_left_gain++;
global_settings.rec_linein_decimator_right_gain++;
}
else if((right) && (!left) &&
(global_settings.rec_linein_decimator_right_gain <
sound_max(SOUND_DECIMATOR_RIGHT_GAIN)))
{
global_settings.rec_linein_decimator_right_gain++;
}
else if((left) && (!right) &&
(global_settings.rec_linein_decimator_left_gain <
sound_max(SOUND_DECIMATOR_LEFT_GAIN)))
{
global_settings.rec_linein_decimator_left_gain++;
}
/* Stereo increase */
if((left) &&
(global_settings.rec_linein_decimator_left_gain >=
ana_line_size) &&
(global_settings.rec_left_gain < sound_max(SOUND_LEFT_GAIN)))
{
/* if analogue range cycle left digital gain for each */
global_settings.rec_linein_decimator_left_gain = 0;
global_settings.rec_left_gain++;
}
if((right) &&
(global_settings.rec_linein_decimator_right_gain >=
ana_line_size) &&
(global_settings.rec_right_gain < sound_max(SOUND_RIGHT_GAIN)))
{
/* if analogue range cycle right digital for each */
global_settings.rec_linein_decimator_right_gain = 0;
global_settings.rec_right_gain++;
}
}
}
else
{
if(global_settings.rec_source == SOURCE_MIC)
{
/* always changed as stereo */
if(global_settings.rec_mic_decimator_left_gain >
sound_min(SOUND_DECIMATOR_LEFT_GAIN))
{
/* decrease digital gain by 1 if above minimum */
global_settings.rec_mic_decimator_left_gain--;
global_settings.rec_mic_decimator_right_gain =
global_settings.rec_mic_decimator_left_gain;
}
/* mono decrease */
if((global_settings.rec_mic_decimator_left_gain < 0) &&
(global_settings.rec_mic_gain > sound_min(SOUND_MIC_GAIN)))
{
/* if analogue in range, cycle digital gain for each */
global_settings.rec_mic_decimator_left_gain = ana_mic_size - 1;
global_settings.rec_mic_decimator_right_gain =
global_settings.rec_mic_decimator_left_gain;
global_settings.rec_mic_gain--;
}
}
else
{
if( ((left) && (right)) &&
(global_settings.rec_linein_decimator_left_gain >
sound_min(SOUND_DECIMATOR_LEFT_GAIN)) &&
(global_settings.rec_linein_decimator_right_gain >
sound_min(SOUND_DECIMATOR_RIGHT_GAIN)) )
{
/* decrease digital gain by 1 if above minimum */
global_settings.rec_linein_decimator_left_gain--;
global_settings.rec_linein_decimator_right_gain--;
}
else if((right) && (!left) &&
(global_settings.rec_linein_decimator_right_gain >
sound_min(SOUND_DECIMATOR_RIGHT_GAIN)))
{
global_settings.rec_linein_decimator_right_gain--;
}
else if((left) && (!right) &&
(global_settings.rec_linein_decimator_left_gain >
sound_min(SOUND_DECIMATOR_LEFT_GAIN)))
{
global_settings.rec_linein_decimator_left_gain--;
}
/* Stereo decrease */
if((left) &&
(global_settings.rec_linein_decimator_left_gain < 0) &&
(global_settings.rec_left_gain > sound_min(SOUND_LEFT_GAIN)))
{
/* if in analogue range cycle left digital gain for each */
global_settings.rec_left_gain--;
global_settings.rec_linein_decimator_left_gain =
ana_line_size - 1;
}
if((right) &&
(global_settings.rec_linein_decimator_right_gain < 0) &&
(global_settings.rec_right_gain > sound_min(SOUND_RIGHT_GAIN)))
{
/* if in analogue range cycle right digital gain for each */
global_settings.rec_right_gain--;
global_settings.rec_linein_decimator_right_gain =
ana_line_size - 1;
}
}
}
}
#endif /* UDA1380 */
bool recording_screen(void) bool recording_screen(void)
{ {
long button; long button;
@ -299,7 +491,6 @@ bool recording_screen(void)
bool done = false; bool done = false;
char buf[32]; char buf[32];
char buf2[32]; char buf2[32];
int gain;
int w, h; int w, h;
int update_countdown = 1; int update_countdown = 1;
bool have_recorded = false; bool have_recorded = false;
@ -314,6 +505,22 @@ bool recording_screen(void)
int led_countdown = 2; int led_countdown = 2;
#endif #endif
#ifdef HAVE_UDA1380
/*calculate no. of digital steps to each analogue step. Assuming
left dig step = right dig step, and there is an integer no. of digital steps
in each analogue*/
int ana_mic_size = sound_val2phys(SOUND_MIC_GAIN, 1) /
sound_val2phys(SOUND_DECIMATOR_LEFT_GAIN, 1);
int ana_line_size = sound_val2phys(SOUND_LEFT_GAIN, 1) /
sound_val2phys(SOUND_DECIMATOR_LEFT_GAIN, 1);
if(global_settings.rec_source == SOURCE_MIC)
{
global_settings.rec_mic_decimator_left_gain =
global_settings.rec_mic_decimator_right_gain;
}
#endif
const unsigned char *byte_units[] = { const unsigned char *byte_units[] = {
ID2P(LANG_BYTE), ID2P(LANG_BYTE),
ID2P(LANG_KILOBYTE), ID2P(LANG_KILOBYTE),
@ -527,7 +734,20 @@ bool recording_screen(void)
global_settings.volume++; global_settings.volume++;
sound_set_volume(global_settings.volume); sound_set_volume(global_settings.volume);
break; break;
#ifdef HAVE_UDA1380
case 1:
change_recording_gain(true, true, true,
ana_mic_size, ana_line_size);
break;
case 2:
change_recording_gain(true, true, false,
ana_mic_size, ana_line_size);
break;
case 3:
change_recording_gain(true, false, true,
ana_mic_size, ana_line_size);
break;
#else
case 1: case 1:
if(global_settings.rec_source == SOURCE_MIC) if(global_settings.rec_source == SOURCE_MIC)
{ {
@ -537,12 +757,12 @@ bool recording_screen(void)
} }
else else
{ {
gain = MAX(global_settings.rec_left_gain, if(global_settings.rec_left_gain <
global_settings.rec_right_gain); sound_max(SOUND_LEFT_GAIN))
if(gain < sound_max(SOUND_LEFT_GAIN)) global_settings.rec_left_gain++;
gain++; if(global_settings.rec_right_gain <
global_settings.rec_left_gain = gain; sound_max(SOUND_RIGHT_GAIN))
global_settings.rec_right_gain = gain; global_settings.rec_right_gain++;
} }
break; break;
case 2: case 2:
@ -555,6 +775,7 @@ bool recording_screen(void)
sound_max(SOUND_RIGHT_GAIN)) sound_max(SOUND_RIGHT_GAIN))
global_settings.rec_right_gain++; global_settings.rec_right_gain++;
break; break;
#endif
} }
set_gain(); set_gain();
update_countdown = 1; /* Update immediately */ update_countdown = 1; /* Update immediately */
@ -570,7 +791,23 @@ bool recording_screen(void)
global_settings.volume--; global_settings.volume--;
sound_set_volume(global_settings.volume); sound_set_volume(global_settings.volume);
break; break;
#ifdef HAVE_UDA1380
case 1:
/* both channels */
change_recording_gain(false, true, true,
ana_mic_size, ana_line_size);
break;
case 2:
/* only left */
change_recording_gain(false, true, false,
ana_mic_size, ana_line_size);
break;
case 3:
/* only right */
change_recording_gain(false, false, true,
ana_mic_size, ana_line_size);
break;
#else
case 1: case 1:
if(global_settings.rec_source == SOURCE_MIC) if(global_settings.rec_source == SOURCE_MIC)
{ {
@ -580,12 +817,12 @@ bool recording_screen(void)
} }
else else
{ {
gain = MAX(global_settings.rec_left_gain, if(global_settings.rec_left_gain >
global_settings.rec_right_gain); sound_min(SOUND_LEFT_GAIN))
if(gain > sound_min(SOUND_LEFT_GAIN)) global_settings.rec_left_gain--;
gain--; if(global_settings.rec_right_gain >
global_settings.rec_left_gain = gain; sound_min(SOUND_RIGHT_GAIN))
global_settings.rec_right_gain = gain; global_settings.rec_right_gain--;
} }
break; break;
case 2: case 2:
@ -598,6 +835,7 @@ bool recording_screen(void)
sound_min(SOUND_RIGHT_GAIN)) sound_min(SOUND_RIGHT_GAIN))
global_settings.rec_right_gain--; global_settings.rec_right_gain--;
break; break;
#endif
} }
set_gain(); set_gain();
update_countdown = 1; /* Update immediately */ update_countdown = 1; /* Update immediately */
@ -778,62 +1016,147 @@ bool recording_screen(void)
else else
lcd_puts(0, 3, buf); lcd_puts(0, 3, buf);
if(global_settings.rec_source == SOURCE_MIC) if(global_settings.rec_source == SOURCE_MIC)
{ {
snprintf(buf, 32, "%s: %s", str(LANG_RECORDING_GAIN), #ifdef HAVE_UDA1380
/*****************test info code***********************
snprintf(buf, 32, "Aa:(2x) %d DigL:(0.5x) %d ",
global_settings.rec_mic_gain,
global_settings.rec_mic_decimator_left_gain);
lcd_puts(0, 10, buf);
snprintf(buf, 32, "DigR:(0.5x) %d",
global_settings.rec_mic_decimator_right_gain);
lcd_puts(9, 12, buf);
*****************test info code***********************/
snprintf(buf, 32, "%s:%s (%s)",
str(LANG_RECORDING_GAIN),
fmt_gain2(SOUND_MIC_GAIN,
global_settings.rec_mic_gain,
SOUND_DECIMATOR_LEFT_GAIN,
global_settings.rec_mic_decimator_left_gain,
buf2, sizeof(buf2)),
(((global_settings.rec_mic_gain ==
sound_max(SOUND_MIC_GAIN)) &&
(global_settings.rec_mic_decimator_left_gain > 0))||
((global_settings.rec_mic_gain ==
sound_min(SOUND_MIC_GAIN)) &&
(global_settings.rec_mic_decimator_left_gain < 0)))?
str(LANG_RECORDING_GAIN_DIGITAL) :
str(LANG_RECORDING_GAIN_ANALOG)
);
#else /* HAVE_UDA1380 */
snprintf(buf, 32, "%s:%s", str(LANG_RECORDING_GAIN),
fmt_gain(SOUND_MIC_GAIN, fmt_gain(SOUND_MIC_GAIN,
global_settings.rec_mic_gain, global_settings.rec_mic_gain,
buf2, sizeof(buf2))); buf2, sizeof(buf2)));
if (global_settings.invert_cursor && (pos++ == cursor)) #endif
if(global_settings.invert_cursor && ((1==cursor)||(2==cursor)))
lcd_puts_style(0, 4, buf, STYLE_INVERT); lcd_puts_style(0, 4, buf, STYLE_INVERT);
else else
lcd_puts(0, 4, buf); lcd_puts(0, 4, buf);
} }
else else if(global_settings.rec_source == SOURCE_LINE)
{ {
if(global_settings.rec_source == SOURCE_LINE) #ifdef HAVE_UDA1380
{
gain = MAX(global_settings.rec_left_gain,
global_settings.rec_right_gain);
snprintf(buf, 32, "%s: %s", str(LANG_RECORDING_GAIN), /*****************test info code***********************
fmt_gain(SOUND_LEFT_GAIN, gain, snprintf(buf, 32, "AL:(3x) %d DigL:(0.5x) %d",
buf2, sizeof(buf2))); global_settings.rec_left_gain,
if (global_settings.invert_cursor && (pos++ == cursor)) global_settings.rec_linein_decimator_left_gain);
lcd_puts_style(0, 4, buf, STYLE_INVERT); lcd_puts(0, 10, buf);
else snprintf(buf, 32, "AR:(3x) %d DigR:(0.5x) %d",
lcd_puts(0, 4, buf); global_settings.rec_right_gain,
global_settings.rec_linein_decimator_right_gain);
lcd_puts(0, 12, buf);
*****************test info code***********************/
snprintf(buf, 32, "%s: %s", str(LANG_RECORDING_LEFT), snprintf(buf, 32, "%s:%s (%s)",
fmt_gain(SOUND_LEFT_GAIN, str(LANG_RECORDING_LEFT),
global_settings.rec_left_gain, fmt_gain2(SOUND_LEFT_GAIN,
buf2, sizeof(buf2))); global_settings.rec_left_gain,
if (global_settings.invert_cursor && (pos++ == cursor)) SOUND_DECIMATOR_LEFT_GAIN,
lcd_puts_style(0, 5, buf, STYLE_INVERT); global_settings.rec_linein_decimator_left_gain,
else buf2, sizeof(buf2)),
lcd_puts(0, 5, buf); (((global_settings.rec_left_gain ==
sound_max(SOUND_LEFT_GAIN)) &&
(global_settings.rec_linein_decimator_left_gain
> 0)) ||
((global_settings.rec_left_gain ==
sound_min(SOUND_LEFT_GAIN)) &&
(global_settings.rec_linein_decimator_left_gain
< 0))) ?
str(LANG_RECORDING_GAIN_DIGITAL) :
str(LANG_RECORDING_GAIN_ANALOG)
);
#else /* HAVE_UDA1380 */
snprintf(buf, 32, "%s:%s",
str(LANG_RECORDING_LEFT),
fmt_gain(SOUND_LEFT_GAIN,
global_settings.rec_left_gain,
buf2, sizeof(buf2)));
#endif /* HAVE_UDA1380 */
if(global_settings.invert_cursor && ((1==cursor)||(2==cursor)))
lcd_puts_style(0, 4, buf, STYLE_INVERT);
else
lcd_puts(0, 4, buf);
#ifdef HAVE_UDA1380
snprintf(buf, 32, "%s:%s (%s)",
str(LANG_RECORDING_RIGHT),
fmt_gain2(SOUND_RIGHT_GAIN,
global_settings.rec_right_gain,
SOUND_DECIMATOR_RIGHT_GAIN,
global_settings.rec_linein_decimator_right_gain,
buf2, sizeof(buf2)),
(((global_settings.rec_right_gain ==
sound_max(SOUND_RIGHT_GAIN)) &&
(global_settings.rec_linein_decimator_right_gain
> 0)) ||
((global_settings.rec_right_gain ==
sound_min(SOUND_RIGHT_GAIN)) &&
(global_settings.rec_linein_decimator_right_gain
< 0))) ?
str(LANG_RECORDING_GAIN_DIGITAL) :
str(LANG_RECORDING_GAIN_ANALOG)
);
#else /* HAVE_UDA1380 */
snprintf(buf, 32, "%s:%s",
str(LANG_RECORDING_RIGHT),
fmt_gain(SOUND_RIGHT_GAIN,
global_settings.rec_right_gain,
buf2, sizeof(buf2)));
#endif /* HAVE_UDA1380 */
if(global_settings.invert_cursor && ((1==cursor)||(3==cursor)))
lcd_puts_style(0, 5, buf, STYLE_INVERT);
else
lcd_puts(0, 5, buf);
}
switch(cursor)
{
case 1:
put_cursorxy(0, 4, true);
snprintf(buf, 32, "%s: %s", str(LANG_RECORDING_RIGHT), if(global_settings.rec_source != SOURCE_MIC)
fmt_gain(SOUND_RIGHT_GAIN, put_cursorxy(0, 5, true);
global_settings.rec_right_gain,
buf2, sizeof(buf2))); break;
if (global_settings.invert_cursor && (pos == cursor)) case 2:
lcd_puts_style(0, 6, buf, STYLE_INVERT); put_cursorxy(0, 4, true);
else break;
lcd_puts(0, 6, buf); case 3:
} put_cursorxy(0, 5, true);
break;
default:
put_cursorxy(0, 0, true);
} }
put_cursorxy(0, 3 + cursor, true); snprintf(buf, 32, "%s %s",
freq_str[global_settings.rec_frequency],
if (global_settings.rec_source != SOURCE_LINE) { global_settings.rec_channels?
snprintf(buf, 32, "%s %s [%d]", str(LANG_CHANNEL_MONO):str(LANG_CHANNEL_STEREO));
freq_str[global_settings.rec_frequency], lcd_puts(0, 7, buf);
global_settings.rec_channels?
str(LANG_CHANNEL_MONO):str(LANG_CHANNEL_STEREO),
global_settings.rec_quality);
lcd_puts(0, 6, buf);
}
gui_syncstatusbar_draw(&statusbars, true); gui_syncstatusbar_draw(&statusbars, true);
peak_meter_draw(0, 8 + h*2, LCD_WIDTH, h); peak_meter_draw(0, 8 + h*2, LCD_WIDTH, h);

View file

@ -485,8 +485,10 @@ static const struct bit_entry hd_bits[] =
{5, S_O(rec_prerecord_time), 0, "prerecording time", NULL }, /* 0...30 */ {5, S_O(rec_prerecord_time), 0, "prerecording time", NULL }, /* 0...30 */
{1, S_O(rec_directory), 0, /* rec_base_directory */ {1, S_O(rec_directory), 0, /* rec_base_directory */
"rec directory", REC_BASE_DIR ",current" }, "rec directory", REC_BASE_DIR ",current" },
{8|SIGNED, S_O(rec_adc_left_gain), 0, /* 0dB */ "adc left gain", NULL }, /* -128...48 */ {8|SIGNED, S_O(rec_linein_decimator_left_gain), 0, /* 0dB */
{8|SIGNED, S_O(rec_adc_right_gain), 0, /* 0dB */ "adc right gain", NULL }, /* -128...48 */ "line in decimator left gain", NULL }, /* -128...48 */
{8|SIGNED, S_O(rec_linein_decimator_right_gain), 0, /* 0dB */
"line in decimator right gain", NULL }, /* -128...48 */
#endif #endif
#ifdef HAVE_REMOTE_LCD #ifdef HAVE_REMOTE_LCD
@ -507,10 +509,8 @@ static const struct bit_entry hd_bits[] =
{7, S_O(screen_scroll_step), 16, "screen scroll step", NULL }, /* 1...112 */ {7, S_O(screen_scroll_step), 16, "screen scroll step", NULL }, /* 1...112 */
#endif #endif
#endif /* HAVE_LCD_BITMAP */ #endif /* HAVE_LCD_BITMAP */
{1, S_O(warnon_erase_dynplaylist), false, {1, S_O(warnon_erase_dynplaylist), false,
"warn when erasing dynamic playlist", off_on }, "warn when erasing dynamic playlist", off_on },
#if CONFIG_CODEC == SWCODEC #if CONFIG_CODEC == SWCODEC
{1, S_O(eq_enabled), false, "eq enabled", off_on }, {1, S_O(eq_enabled), false, "eq enabled", off_on },
/* 0..32768 Hz */ /* 0..32768 Hz */
@ -532,7 +532,13 @@ static const struct bit_entry hd_bits[] =
{9|SIGNED, S_O(eq_band3_gain), 0, "eq band 3 gain", NULL }, {9|SIGNED, S_O(eq_band3_gain), 0, "eq band 3 gain", NULL },
{9|SIGNED, S_O(eq_band4_gain), 0, "eq band 4 gain", NULL }, {9|SIGNED, S_O(eq_band4_gain), 0, "eq band 4 gain", NULL },
#endif #endif
#if defined(HAVE_UDA1380) /* PLEASE merge this with the other UDA1380 define
when bumping the settings version number PLEASE */
{8|SIGNED, S_O(rec_mic_decimator_left_gain), 0, /* 0dB */
"mic decimator left gain", NULL }, /* -128...48 */
{8|SIGNED, S_O(rec_mic_decimator_right_gain), 0, /* 0dB */
"mic decimator right gain", NULL }, /* -128...48 */
#endif
/* If values are just added to the end, no need to bump the version. */ /* If values are just added to the end, no need to bump the version. */
/* new stuff to be added at the end */ /* new stuff to be added at the end */

View file

@ -217,8 +217,10 @@ struct user_settings
int rec_left_gain; /* 0-15 */ int rec_left_gain; /* 0-15 */
int rec_right_gain; /* 0-15 */ int rec_right_gain; /* 0-15 */
#ifdef HAVE_UDA1380 #ifdef HAVE_UDA1380
int rec_adc_left_gain; /* -128 .. 48 */ int rec_linein_decimator_left_gain; /* -128 .. 48 */
int rec_adc_right_gain; /* -128 .. 48 */ int rec_linein_decimator_right_gain; /* -128 .. 48 */
int rec_mic_decimator_left_gain; /* -128 .. 48 */
int rec_mic_decimator_right_gain; /* -128 .. 48 */
#endif #endif
bool rec_editable; /* true means that the bit reservoir is off */ bool rec_editable; /* true means that the bit reservoir is off */

View file

@ -18,6 +18,7 @@
****************************************************************************/ ****************************************************************************/
#include "config.h" #include "config.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <stdbool.h> #include <stdbool.h>
#include "system.h" #include "system.h"
#include "kernel.h" #include "kernel.h"
@ -53,9 +54,15 @@ int selected_setting; /* Used by the callback */
void dec_sound_formatter(char *buffer, int buffer_size, int val, const char * unit) void dec_sound_formatter(char *buffer, int buffer_size, int val, const char * unit)
{ {
val = sound_val2phys(selected_setting, val); val = sound_val2phys(selected_setting, val);
char sign = ' ';
if(val < 0)
{
sign = '-';
val = abs(val);
}
int integer = val / 10; int integer = val / 10;
int dec = val % 10; int dec = val % 10;
snprintf(buffer, buffer_size, "%d.%d %s", integer, dec, unit); snprintf(buffer, buffer_size, "%c%d.%d %s", sign, integer, dec, unit);
} }
bool set_sound(const unsigned char * string, bool set_sound(const unsigned char * string,
@ -237,6 +244,9 @@ static bool recchannels(void)
static bool recquality(void) static bool recquality(void)
{ {
#ifdef HAVE_UDA1380
(void)recquality();
#endif
return set_int(str(LANG_RECORDING_QUALITY), "", UNIT_INT, return set_int(str(LANG_RECORDING_QUALITY), "", UNIT_INT,
&global_settings.rec_quality, &global_settings.rec_quality,
NULL, 1, 0, 7, NULL ); NULL, 1, 0, 7, NULL );
@ -248,21 +258,6 @@ static bool receditable(void)
&global_settings.rec_editable); &global_settings.rec_editable);
} }
#ifdef HAVE_UDA1380
static bool recadcleft(void)
{
return set_sound(str(LANG_RECORDING_ADC_LEFT),
&global_settings.rec_adc_left_gain,
SOUND_ADC_LEFT_GAIN);
}
static bool recadcright(void)
{
return set_sound(str(LANG_RECORDING_ADC_RIGHT),
&global_settings.rec_adc_right_gain,
SOUND_ADC_RIGHT_GAIN);
}
#endif
static bool rectimesplit(void) static bool rectimesplit(void)
{ {
@ -791,8 +786,10 @@ bool recording_menu(bool no_source)
struct menu_item items[13]; struct menu_item items[13];
bool result; bool result;
#ifndef HAVE_UDA1380
items[i].desc = ID2P(LANG_RECORDING_QUALITY); items[i].desc = ID2P(LANG_RECORDING_QUALITY);
items[i++].function = recquality; items[i++].function = recquality;
#endif
items[i].desc = ID2P(LANG_RECORDING_FREQUENCY); items[i].desc = ID2P(LANG_RECORDING_FREQUENCY);
items[i++].function = recfrequency; items[i++].function = recfrequency;
if(!no_source) { if(!no_source) {
@ -801,14 +798,6 @@ bool recording_menu(bool no_source)
} }
items[i].desc = ID2P(LANG_RECORDING_CHANNELS); items[i].desc = ID2P(LANG_RECORDING_CHANNELS);
items[i++].function = recchannels; items[i++].function = recchannels;
#ifdef HAVE_UDA1380
items[i].desc = ID2P(LANG_RECORDING_ADC_LEFT);
items[i++].function = recadcleft;
items[i].desc = ID2P(LANG_RECORDING_ADC_RIGHT);
items[i++].function = recadcright;
#endif
items[i].desc = ID2P(LANG_RECORDING_EDITABLE); items[i].desc = ID2P(LANG_RECORDING_EDITABLE);
items[i++].function = receditable; items[i++].function = receditable;
items[i].desc = ID2P(LANG_RECORD_TIMESPLIT); items[i].desc = ID2P(LANG_RECORD_TIMESPLIT);

View file

@ -255,10 +255,10 @@ void uda1380_disable_recording(void)
/** /**
* Set recording gain and volume * Set recording gain and volume
* *
* type: params: ranges: * type: params: ranges:
* AUDIO_GAIN_MIC left 0 .. 15 -> 0 .. 30 dB gain * AUDIO_GAIN_MIC left 0 .. 15 -> 0 .. 30 dB gain
* AUDIO_GAIN_LINEIN left & right 0 .. 8 -> 0 .. 24 dB gain * AUDIO_GAIN_LINEIN left & right 0 .. 8 -> 0 .. 24 dB gain
* AUDIO_GAIN_ADC left & right -128 .. 48 -> -64 .. 24 dB gain * AUDIO_GAIN_DECIMATOR left & right -128 .. 48 -> -64 .. 24 dB gain
* *
* Note: For all types the value 0 gives 0 dB gain. * Note: For all types the value 0 gives 0 dB gain.
*/ */
@ -274,7 +274,7 @@ void uda1380_set_recvol(int left, int right, int type)
uda1380_write_reg(REG_PGA, (uda1380_regs[REG_PGA] & ~PGA_GAIN_MASK) | PGA_GAINL(left) | PGA_GAINR(right)); uda1380_write_reg(REG_PGA, (uda1380_regs[REG_PGA] & ~PGA_GAIN_MASK) | PGA_GAINL(left) | PGA_GAINR(right));
break; break;
case AUDIO_GAIN_ADC: case AUDIO_GAIN_DECIMATOR:
uda1380_write_reg(REG_DEC_VOL, DEC_VOLL(left) | DEC_VOLR(right)); uda1380_write_reg(REG_DEC_VOL, DEC_VOLL(left) | DEC_VOLR(right));
break; break;
} }

View file

@ -33,9 +33,9 @@
#define AUDIOERR_DISK_FULL 1 #define AUDIOERR_DISK_FULL 1
#define AUDIO_GAIN_LINEIN 0 #define AUDIO_GAIN_LINEIN 0
#define AUDIO_GAIN_MIC 1 #define AUDIO_GAIN_MIC 1
#define AUDIO_GAIN_ADC 2 /* for UDA1380 */ #define AUDIO_GAIN_DECIMATOR 2 /* for UDA1380 */
struct audio_debug struct audio_debug

View file

@ -42,8 +42,8 @@ enum {
SOUND_MIC_GAIN, SOUND_MIC_GAIN,
#endif #endif
#if defined(HAVE_UDA1380) #if defined(HAVE_UDA1380)
SOUND_ADC_LEFT_GAIN, SOUND_DECIMATOR_LEFT_GAIN,
SOUND_ADC_RIGHT_GAIN, SOUND_DECIMATOR_RIGHT_GAIN,
#endif #endif
}; };

View file

@ -97,8 +97,8 @@ static const struct sound_settings_info sound_settings_table[] = {
[SOUND_LEFT_GAIN] = {"dB", 1, 1, 0, 8, 8, NULL}, [SOUND_LEFT_GAIN] = {"dB", 1, 1, 0, 8, 8, NULL},
[SOUND_RIGHT_GAIN] = {"dB", 1, 1, 0, 8, 8, NULL}, [SOUND_RIGHT_GAIN] = {"dB", 1, 1, 0, 8, 8, NULL},
[SOUND_MIC_GAIN] = {"dB", 1, 1, 0, 15, 2, NULL}, [SOUND_MIC_GAIN] = {"dB", 1, 1, 0, 15, 2, NULL},
[SOUND_ADC_LEFT_GAIN] = {"dB", 1, 1,-128, 48, 0, NULL}, [SOUND_DECIMATOR_LEFT_GAIN] = {"dB", 1, 1,-128, 48, 0, NULL},
[SOUND_ADC_RIGHT_GAIN]= {"dB", 1, 1,-128, 48, 0, NULL}, [SOUND_DECIMATOR_RIGHT_GAIN]= {"dB", 1, 1,-128, 48, 0, NULL},
#endif #endif
}; };
@ -762,8 +762,8 @@ int sound_val2phys(int setting, int value)
result = value * 20; /* (30/15) *10 */ result = value * 20; /* (30/15) *10 */
break; break;
case SOUND_ADC_LEFT_GAIN: case SOUND_DECIMATOR_LEFT_GAIN:
case SOUND_ADC_RIGHT_GAIN: case SOUND_DECIMATOR_RIGHT_GAIN:
result = value * 5; /* (1/2) *10 */ result = value * 5; /* (1/2) *10 */
break; break;