summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/lang/english.lang15
-rw-r--r--apps/recorder/radio.c2
-rw-r--r--apps/recorder/recording.c481
-rw-r--r--apps/settings.c16
-rw-r--r--apps/settings.h6
-rw-r--r--apps/sound_menu.c37
-rw-r--r--firmware/drivers/uda1380.c10
-rw-r--r--firmware/export/audio.h6
-rw-r--r--firmware/export/sound.h4
-rw-r--r--firmware/sound.c8
10 files changed, 458 insertions, 127 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 6ba5e39c9f..1a342420b4 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -3354,13 +3354,13 @@ voice: "Fade out mode"
3354new: 3354new:
3355 3355
3356id: LANG_RECORDING_ADC_RIGHT 3356id: LANG_RECORDING_ADC_RIGHT
3357desc: in the recording settings 3357desc: DEPRECATED
3358eng: "ADC Gain Right" 3358eng: "ADC Gain Right"
3359voice: "ADC Gain Right" 3359voice: "ADC Gain Right"
3360new: 3360new:
3361 3361
3362id: LANG_RECORDING_ADC_LEFT 3362id: LANG_RECORDING_ADC_LEFT
3363desc: in the recording settings 3363desc: DEPRECATED
3364eng: "ADC Gain Left" 3364eng: "ADC Gain Left"
3365voice: "ADC Gain Left" 3365voice: "ADC Gain Left"
3366new: 3366new:
@@ -3707,3 +3707,14 @@ eng: "High Shelf Filter"
3707voice: "" 3707voice: ""
3708new: 3708new:
3709 3709
3710id: LANG_RECORDING_GAIN_ANALOG
3711desc: in the recording screen
3712eng: "A"
3713voice: "Analog Gain"
3714new:
3715
3716id: LANG_RECORDING_GAIN_DIGITAL
3717desc: in the recording screen
3718eng: "D"
3719voice: "Digital Gain"
3720new:
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c
index 5e40425d30..073d537f24 100644
--- a/apps/recorder/radio.c
+++ b/apps/recorder/radio.c
@@ -357,7 +357,7 @@ bool radio_screen(void)
357 sound_default(SOUND_RIGHT_GAIN), AUDIO_GAIN_LINEIN); 357 sound_default(SOUND_RIGHT_GAIN), AUDIO_GAIN_LINEIN);
358#else 358#else
359 uda1380_enable_recording(false); 359 uda1380_enable_recording(false);
360 uda1380_set_recvol(10, 10, AUDIO_GAIN_ADC); 360 uda1380_set_recvol(10, 10, AUDIO_GAIN_DECIMATOR);
361 uda1380_set_recvol(0, 0, AUDIO_GAIN_LINEIN); 361 uda1380_set_recvol(0, 0, AUDIO_GAIN_LINEIN);
362 uda1380_set_monitor(true); 362 uda1380_set_monitor(true);
363 363
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index e611e25d15..2d31419cbb 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -134,44 +134,85 @@ static void set_gain(void)
134{ 134{
135 if(global_settings.rec_source == SOURCE_MIC) 135 if(global_settings.rec_source == SOURCE_MIC)
136 { 136 {
137 audio_set_recording_gain(global_settings.rec_mic_gain, 0, AUDIO_GAIN_MIC); 137 audio_set_recording_gain(global_settings.rec_mic_gain,
138 0, AUDIO_GAIN_MIC);
139#ifdef HAVE_UDA1380
140 audio_set_recording_gain(global_settings.rec_mic_decimator_left_gain,
141 global_settings.rec_mic_decimator_right_gain,
142 AUDIO_GAIN_DECIMATOR);
143#endif
138 } 144 }
139 else 145 else
140 { 146 {
141 audio_set_recording_gain(global_settings.rec_left_gain, 147 audio_set_recording_gain(global_settings.rec_left_gain,
142 global_settings.rec_right_gain, AUDIO_GAIN_LINEIN); 148 global_settings.rec_right_gain,
143 } 149 AUDIO_GAIN_LINEIN);
144#ifdef HAVE_UDA1380 150#ifdef HAVE_UDA1380
145 audio_set_recording_gain(global_settings.rec_adc_left_gain, 151 audio_set_recording_gain(global_settings.rec_linein_decimator_left_gain,
146 global_settings.rec_adc_right_gain, 152 global_settings.rec_linein_decimator_right_gain,
147 AUDIO_GAIN_ADC); 153 AUDIO_GAIN_DECIMATOR);
148#endif 154#endif
155 }
149} 156}
150 157
151static const char* const fmtstr[] = 158static const char* const fmtstr[] =
152{ 159{
153 "%d %s", /* no decimals */ 160 "%c%d %s", /* no decimals */
154 "%d.%d %s ", /* 1 decimal */ 161 "%c%d.%d %s ", /* 1 decimal */
155 "%d.%02d %s " /* 2 decimals */ 162 "%c%d.%02d %s " /* 2 decimals */
156}; 163};
157 164
158char *fmt_gain(int snd, int val, char *str, int len) 165char *fmt_gain(int snd, int val, char *str, int len)
159{ 166{
160 int tmp, i, d, numdec; 167 int i, d, numdec;
161 const char *unit; 168 const char *unit;
162 169
163 tmp = sound_val2phys(snd, val); 170 val = sound_val2phys(snd, val);
171 char sign = ' ';
172 if(val < 0)
173 {
174 sign = '-';
175 val = abs(val);
176 }
164 numdec = sound_numdecimals(snd); 177 numdec = sound_numdecimals(snd);
165 unit = sound_unit(snd); 178 unit = sound_unit(snd);
166 179
167 if(numdec) 180 if(numdec)
168 { 181 {
169 i = tmp / (10*numdec); 182 i = val / (10*numdec);
170 d = abs(tmp % (10*numdec)); 183 d = val % (10*numdec);
171 snprintf(str, len, fmtstr[numdec], i, d, unit); 184 snprintf(str, len, fmtstr[numdec], sign, i, d, unit);
172 } 185 }
173 else 186 else
174 snprintf(str, len, fmtstr[numdec], tmp, unit); 187 snprintf(str, len, fmtstr[numdec], sign, val, unit);
188
189 return str;
190}
191
192char *fmt_gain2(int snd1, int val1, int snd2, int val2, char *str, int len)
193{
194 /* same as above but for combined (added) values (recording gain) */
195 int i, d, numdec;
196 const char *unit;
197
198 int val = sound_val2phys(snd1, val1) + sound_val2phys(snd2, val2);
199 char sign = ' ';
200 if(val < 0)
201 {
202 sign = '-';
203 val = abs(val);
204 }
205 numdec = MAX(sound_numdecimals(snd1), sound_numdecimals(snd2));
206 unit = sound_unit(snd1); /* should be same! */
207
208 if(numdec)
209 {
210 i = val / (10*numdec);
211 d = val % (10*numdec);
212 snprintf(str, len, fmtstr[numdec], sign, i, d, unit);
213 }
214 else
215 snprintf(str, len, fmtstr[numdec], sign, val, unit);
175 216
176 return str; 217 return str;
177} 218}
@@ -190,7 +231,6 @@ void adjust_cursor(void)
190 case SOURCE_MIC: 231 case SOURCE_MIC:
191 max_cursor = 1; 232 max_cursor = 1;
192 break; 233 break;
193
194 case SOURCE_LINE: 234 case SOURCE_LINE:
195 max_cursor = 3; 235 max_cursor = 3;
196 break; 236 break;
@@ -198,7 +238,7 @@ void adjust_cursor(void)
198 max_cursor = 0; 238 max_cursor = 0;
199 break; 239 break;
200 } 240 }
201 241
202 if(cursor > max_cursor) 242 if(cursor > max_cursor)
203 cursor = max_cursor; 243 cursor = max_cursor;
204} 244}
@@ -292,6 +332,158 @@ static void trigger_listener(int trigger_status)
292 } 332 }
293} 333}
294 334
335#ifdef HAVE_UDA1380
336/* Handles combined recording gain changes.
337 GAIN RANGE = negative digital / analog / positive digital
338 */
339void change_recording_gain(bool increment, bool left, bool right,
340 int ana_mic_size, int ana_line_size)
341{
342 if (increment)
343 {
344 if(global_settings.rec_source == SOURCE_MIC)
345 {
346 /* always changed as stereo */
347 if(global_settings.rec_mic_decimator_left_gain <
348 sound_max(SOUND_DECIMATOR_LEFT_GAIN))
349 {
350 /* increase digital gain by 1 if below max */
351 global_settings.rec_mic_decimator_left_gain++;
352 global_settings.rec_mic_decimator_right_gain =
353 global_settings.rec_mic_decimator_left_gain;
354 }
355
356 /* mono increase */
357 if((global_settings.rec_mic_decimator_left_gain >= ana_mic_size) &&
358 (global_settings.rec_mic_gain < sound_max(SOUND_MIC_GAIN)))
359 {
360 /* in analogue range, cycle digital gain for each analogue */
361 global_settings.rec_mic_decimator_left_gain = 0;
362 global_settings.rec_mic_decimator_right_gain =
363 global_settings.rec_mic_decimator_left_gain;
364 global_settings.rec_mic_gain++;
365 }
366 }
367 else
368 {
369 if(((left) && (right)) &&
370 (global_settings.rec_linein_decimator_left_gain <
371 sound_max(SOUND_DECIMATOR_LEFT_GAIN)) &&
372 (global_settings.rec_linein_decimator_right_gain <
373 sound_max(SOUND_DECIMATOR_RIGHT_GAIN)) )
374 {
375 /* increase digital gain by 1 if below max*/
376 global_settings.rec_linein_decimator_left_gain++;
377 global_settings.rec_linein_decimator_right_gain++;
378 }
379 else if((right) && (!left) &&
380 (global_settings.rec_linein_decimator_right_gain <
381 sound_max(SOUND_DECIMATOR_RIGHT_GAIN)))
382 {
383 global_settings.rec_linein_decimator_right_gain++;
384 }
385 else if((left) && (!right) &&
386 (global_settings.rec_linein_decimator_left_gain <
387 sound_max(SOUND_DECIMATOR_LEFT_GAIN)))
388 {
389 global_settings.rec_linein_decimator_left_gain++;
390 }
391
392 /* Stereo increase */
393 if((left) &&
394 (global_settings.rec_linein_decimator_left_gain >=
395 ana_line_size) &&
396 (global_settings.rec_left_gain < sound_max(SOUND_LEFT_GAIN)))
397 {
398 /* if analogue range cycle left digital gain for each */
399 global_settings.rec_linein_decimator_left_gain = 0;
400 global_settings.rec_left_gain++;
401 }
402 if((right) &&
403 (global_settings.rec_linein_decimator_right_gain >=
404 ana_line_size) &&
405 (global_settings.rec_right_gain < sound_max(SOUND_RIGHT_GAIN)))
406 {
407 /* if analogue range cycle right digital for each */
408 global_settings.rec_linein_decimator_right_gain = 0;
409 global_settings.rec_right_gain++;
410 }
411 }
412 }
413 else
414 {
415 if(global_settings.rec_source == SOURCE_MIC)
416 {
417 /* always changed as stereo */
418 if(global_settings.rec_mic_decimator_left_gain >
419 sound_min(SOUND_DECIMATOR_LEFT_GAIN))
420 {
421 /* decrease digital gain by 1 if above minimum */
422 global_settings.rec_mic_decimator_left_gain--;
423 global_settings.rec_mic_decimator_right_gain =
424 global_settings.rec_mic_decimator_left_gain;
425 }
426
427 /* mono decrease */
428 if((global_settings.rec_mic_decimator_left_gain < 0) &&
429 (global_settings.rec_mic_gain > sound_min(SOUND_MIC_GAIN)))
430 {
431 /* if analogue in range, cycle digital gain for each */
432 global_settings.rec_mic_decimator_left_gain = ana_mic_size - 1;
433 global_settings.rec_mic_decimator_right_gain =
434 global_settings.rec_mic_decimator_left_gain;
435 global_settings.rec_mic_gain--;
436 }
437 }
438 else
439 {
440 if( ((left) && (right)) &&
441 (global_settings.rec_linein_decimator_left_gain >
442 sound_min(SOUND_DECIMATOR_LEFT_GAIN)) &&
443 (global_settings.rec_linein_decimator_right_gain >
444 sound_min(SOUND_DECIMATOR_RIGHT_GAIN)) )
445 {
446 /* decrease digital gain by 1 if above minimum */
447 global_settings.rec_linein_decimator_left_gain--;
448 global_settings.rec_linein_decimator_right_gain--;
449 }
450 else if((right) && (!left) &&
451 (global_settings.rec_linein_decimator_right_gain >
452 sound_min(SOUND_DECIMATOR_RIGHT_GAIN)))
453 {
454 global_settings.rec_linein_decimator_right_gain--;
455 }
456 else if((left) && (!right) &&
457 (global_settings.rec_linein_decimator_left_gain >
458 sound_min(SOUND_DECIMATOR_LEFT_GAIN)))
459 {
460 global_settings.rec_linein_decimator_left_gain--;
461 }
462
463 /* Stereo decrease */
464 if((left) &&
465 (global_settings.rec_linein_decimator_left_gain < 0) &&
466 (global_settings.rec_left_gain > sound_min(SOUND_LEFT_GAIN)))
467 {
468 /* if in analogue range cycle left digital gain for each */
469 global_settings.rec_left_gain--;
470 global_settings.rec_linein_decimator_left_gain =
471 ana_line_size - 1;
472 }
473 if((right) &&
474 (global_settings.rec_linein_decimator_right_gain < 0) &&
475 (global_settings.rec_right_gain > sound_min(SOUND_RIGHT_GAIN)))
476 {
477 /* if in analogue range cycle right digital gain for each */
478 global_settings.rec_right_gain--;
479 global_settings.rec_linein_decimator_right_gain =
480 ana_line_size - 1;
481 }
482 }
483 }
484}
485#endif /* UDA1380 */
486
295bool recording_screen(void) 487bool recording_screen(void)
296{ 488{
297 long button; 489 long button;
@@ -299,7 +491,6 @@ bool recording_screen(void)
299 bool done = false; 491 bool done = false;
300 char buf[32]; 492 char buf[32];
301 char buf2[32]; 493 char buf2[32];
302 int gain;
303 int w, h; 494 int w, h;
304 int update_countdown = 1; 495 int update_countdown = 1;
305 bool have_recorded = false; 496 bool have_recorded = false;
@@ -314,6 +505,22 @@ bool recording_screen(void)
314 int led_countdown = 2; 505 int led_countdown = 2;
315#endif 506#endif
316 507
508#ifdef HAVE_UDA1380
509/*calculate no. of digital steps to each analogue step. Assuming
510 left dig step = right dig step, and there is an integer no. of digital steps
511 in each analogue*/
512 int ana_mic_size = sound_val2phys(SOUND_MIC_GAIN, 1) /
513 sound_val2phys(SOUND_DECIMATOR_LEFT_GAIN, 1);
514 int ana_line_size = sound_val2phys(SOUND_LEFT_GAIN, 1) /
515 sound_val2phys(SOUND_DECIMATOR_LEFT_GAIN, 1);
516
517 if(global_settings.rec_source == SOURCE_MIC)
518 {
519 global_settings.rec_mic_decimator_left_gain =
520 global_settings.rec_mic_decimator_right_gain;
521 }
522#endif
523
317 const unsigned char *byte_units[] = { 524 const unsigned char *byte_units[] = {
318 ID2P(LANG_BYTE), 525 ID2P(LANG_BYTE),
319 ID2P(LANG_KILOBYTE), 526 ID2P(LANG_KILOBYTE),
@@ -516,7 +723,7 @@ bool recording_screen(void)
516 update_countdown = 1; /* Update immediately */ 723 update_countdown = 1; /* Update immediately */
517 break; 724 break;
518#endif 725#endif
519 726
520 case REC_INC: 727 case REC_INC:
521 case REC_INC | BUTTON_REPEAT: 728 case REC_INC | BUTTON_REPEAT:
522 switch(cursor) 729 switch(cursor)
@@ -527,7 +734,20 @@ bool recording_screen(void)
527 global_settings.volume++; 734 global_settings.volume++;
528 sound_set_volume(global_settings.volume); 735 sound_set_volume(global_settings.volume);
529 break; 736 break;
530 737#ifdef HAVE_UDA1380
738 case 1:
739 change_recording_gain(true, true, true,
740 ana_mic_size, ana_line_size);
741 break;
742 case 2:
743 change_recording_gain(true, true, false,
744 ana_mic_size, ana_line_size);
745 break;
746 case 3:
747 change_recording_gain(true, false, true,
748 ana_mic_size, ana_line_size);
749 break;
750#else
531 case 1: 751 case 1:
532 if(global_settings.rec_source == SOURCE_MIC) 752 if(global_settings.rec_source == SOURCE_MIC)
533 { 753 {
@@ -537,12 +757,12 @@ bool recording_screen(void)
537 } 757 }
538 else 758 else
539 { 759 {
540 gain = MAX(global_settings.rec_left_gain, 760 if(global_settings.rec_left_gain <
541 global_settings.rec_right_gain); 761 sound_max(SOUND_LEFT_GAIN))
542 if(gain < sound_max(SOUND_LEFT_GAIN)) 762 global_settings.rec_left_gain++;
543 gain++; 763 if(global_settings.rec_right_gain <
544 global_settings.rec_left_gain = gain; 764 sound_max(SOUND_RIGHT_GAIN))
545 global_settings.rec_right_gain = gain; 765 global_settings.rec_right_gain++;
546 } 766 }
547 break; 767 break;
548 case 2: 768 case 2:
@@ -555,6 +775,7 @@ bool recording_screen(void)
555 sound_max(SOUND_RIGHT_GAIN)) 775 sound_max(SOUND_RIGHT_GAIN))
556 global_settings.rec_right_gain++; 776 global_settings.rec_right_gain++;
557 break; 777 break;
778#endif
558 } 779 }
559 set_gain(); 780 set_gain();
560 update_countdown = 1; /* Update immediately */ 781 update_countdown = 1; /* Update immediately */
@@ -570,7 +791,23 @@ bool recording_screen(void)
570 global_settings.volume--; 791 global_settings.volume--;
571 sound_set_volume(global_settings.volume); 792 sound_set_volume(global_settings.volume);
572 break; 793 break;
573 794#ifdef HAVE_UDA1380
795 case 1:
796 /* both channels */
797 change_recording_gain(false, true, true,
798 ana_mic_size, ana_line_size);
799 break;
800 case 2:
801 /* only left */
802 change_recording_gain(false, true, false,
803 ana_mic_size, ana_line_size);
804 break;
805 case 3:
806 /* only right */
807 change_recording_gain(false, false, true,
808 ana_mic_size, ana_line_size);
809 break;
810#else
574 case 1: 811 case 1:
575 if(global_settings.rec_source == SOURCE_MIC) 812 if(global_settings.rec_source == SOURCE_MIC)
576 { 813 {
@@ -580,12 +817,12 @@ bool recording_screen(void)
580 } 817 }
581 else 818 else
582 { 819 {
583 gain = MAX(global_settings.rec_left_gain, 820 if(global_settings.rec_left_gain >
584 global_settings.rec_right_gain); 821 sound_min(SOUND_LEFT_GAIN))
585 if(gain > sound_min(SOUND_LEFT_GAIN)) 822 global_settings.rec_left_gain--;
586 gain--; 823 if(global_settings.rec_right_gain >
587 global_settings.rec_left_gain = gain; 824 sound_min(SOUND_RIGHT_GAIN))
588 global_settings.rec_right_gain = gain; 825 global_settings.rec_right_gain--;
589 } 826 }
590 break; 827 break;
591 case 2: 828 case 2:
@@ -598,6 +835,7 @@ bool recording_screen(void)
598 sound_min(SOUND_RIGHT_GAIN)) 835 sound_min(SOUND_RIGHT_GAIN))
599 global_settings.rec_right_gain--; 836 global_settings.rec_right_gain--;
600 break; 837 break;
838#endif
601 } 839 }
602 set_gain(); 840 set_gain();
603 update_countdown = 1; /* Update immediately */ 841 update_countdown = 1; /* Update immediately */
@@ -777,64 +1015,149 @@ bool recording_screen(void)
777 lcd_puts_style(0, 3, buf, STYLE_INVERT); 1015 lcd_puts_style(0, 3, buf, STYLE_INVERT);
778 else 1016 else
779 lcd_puts(0, 3, buf); 1017 lcd_puts(0, 3, buf);
1018
780 1019
781 if(global_settings.rec_source == SOURCE_MIC) 1020 if(global_settings.rec_source == SOURCE_MIC)
782 { 1021 {
783 snprintf(buf, 32, "%s: %s", str(LANG_RECORDING_GAIN), 1022#ifdef HAVE_UDA1380
1023
1024 /*****************test info code***********************
1025 snprintf(buf, 32, "Aa:(2x) %d DigL:(0.5x) %d ",
1026 global_settings.rec_mic_gain,
1027 global_settings.rec_mic_decimator_left_gain);
1028 lcd_puts(0, 10, buf);
1029 snprintf(buf, 32, "DigR:(0.5x) %d",
1030 global_settings.rec_mic_decimator_right_gain);
1031 lcd_puts(9, 12, buf);
1032 *****************test info code***********************/
1033
1034 snprintf(buf, 32, "%s:%s (%s)",
1035 str(LANG_RECORDING_GAIN),
1036 fmt_gain2(SOUND_MIC_GAIN,
1037 global_settings.rec_mic_gain,
1038 SOUND_DECIMATOR_LEFT_GAIN,
1039 global_settings.rec_mic_decimator_left_gain,
1040 buf2, sizeof(buf2)),
1041 (((global_settings.rec_mic_gain ==
1042 sound_max(SOUND_MIC_GAIN)) &&
1043 (global_settings.rec_mic_decimator_left_gain > 0))||
1044 ((global_settings.rec_mic_gain ==
1045 sound_min(SOUND_MIC_GAIN)) &&
1046 (global_settings.rec_mic_decimator_left_gain < 0)))?
1047 str(LANG_RECORDING_GAIN_DIGITAL) :
1048 str(LANG_RECORDING_GAIN_ANALOG)
1049 );
1050#else /* HAVE_UDA1380 */
1051 snprintf(buf, 32, "%s:%s", str(LANG_RECORDING_GAIN),
784 fmt_gain(SOUND_MIC_GAIN, 1052 fmt_gain(SOUND_MIC_GAIN,
785 global_settings.rec_mic_gain, 1053 global_settings.rec_mic_gain,
786 buf2, sizeof(buf2))); 1054 buf2, sizeof(buf2)));
787 if (global_settings.invert_cursor && (pos++ == cursor)) 1055#endif
1056 if(global_settings.invert_cursor && ((1==cursor)||(2==cursor)))
788 lcd_puts_style(0, 4, buf, STYLE_INVERT); 1057 lcd_puts_style(0, 4, buf, STYLE_INVERT);
789 else 1058 else
790 lcd_puts(0, 4, buf); 1059 lcd_puts(0, 4, buf);
791 } 1060 }
792 else 1061 else if(global_settings.rec_source == SOURCE_LINE)
793 { 1062 {
794 if(global_settings.rec_source == SOURCE_LINE) 1063#ifdef HAVE_UDA1380
795 {
796 gain = MAX(global_settings.rec_left_gain,
797 global_settings.rec_right_gain);
798
799 snprintf(buf, 32, "%s: %s", str(LANG_RECORDING_GAIN),
800 fmt_gain(SOUND_LEFT_GAIN, gain,
801 buf2, sizeof(buf2)));
802 if (global_settings.invert_cursor && (pos++ == cursor))
803 lcd_puts_style(0, 4, buf, STYLE_INVERT);
804 else
805 lcd_puts(0, 4, buf);
806
807 snprintf(buf, 32, "%s: %s", str(LANG_RECORDING_LEFT),
808 fmt_gain(SOUND_LEFT_GAIN,
809 global_settings.rec_left_gain,
810 buf2, sizeof(buf2)));
811 if (global_settings.invert_cursor && (pos++ == cursor))
812 lcd_puts_style(0, 5, buf, STYLE_INVERT);
813 else
814 lcd_puts(0, 5, buf);
815
816 snprintf(buf, 32, "%s: %s", str(LANG_RECORDING_RIGHT),
817 fmt_gain(SOUND_RIGHT_GAIN,
818 global_settings.rec_right_gain,
819 buf2, sizeof(buf2)));
820 if (global_settings.invert_cursor && (pos == cursor))
821 lcd_puts_style(0, 6, buf, STYLE_INVERT);
822 else
823 lcd_puts(0, 6, buf);
824 }
825 }
826 1064
827 put_cursorxy(0, 3 + cursor, true); 1065 /*****************test info code***********************
828 1066 snprintf(buf, 32, "AL:(3x) %d DigL:(0.5x) %d",
829 if (global_settings.rec_source != SOURCE_LINE) { 1067 global_settings.rec_left_gain,
830 snprintf(buf, 32, "%s %s [%d]", 1068 global_settings.rec_linein_decimator_left_gain);
831 freq_str[global_settings.rec_frequency], 1069 lcd_puts(0, 10, buf);
832 global_settings.rec_channels? 1070 snprintf(buf, 32, "AR:(3x) %d DigR:(0.5x) %d",
833 str(LANG_CHANNEL_MONO):str(LANG_CHANNEL_STEREO), 1071 global_settings.rec_right_gain,
834 global_settings.rec_quality); 1072 global_settings.rec_linein_decimator_right_gain);
835 lcd_puts(0, 6, buf); 1073 lcd_puts(0, 12, buf);
1074 *****************test info code***********************/
1075
1076 snprintf(buf, 32, "%s:%s (%s)",
1077 str(LANG_RECORDING_LEFT),
1078 fmt_gain2(SOUND_LEFT_GAIN,
1079 global_settings.rec_left_gain,
1080 SOUND_DECIMATOR_LEFT_GAIN,
1081 global_settings.rec_linein_decimator_left_gain,
1082 buf2, sizeof(buf2)),
1083 (((global_settings.rec_left_gain ==
1084 sound_max(SOUND_LEFT_GAIN)) &&
1085 (global_settings.rec_linein_decimator_left_gain
1086 > 0)) ||
1087 ((global_settings.rec_left_gain ==
1088 sound_min(SOUND_LEFT_GAIN)) &&
1089 (global_settings.rec_linein_decimator_left_gain
1090 < 0))) ?
1091 str(LANG_RECORDING_GAIN_DIGITAL) :
1092 str(LANG_RECORDING_GAIN_ANALOG)
1093 );
1094#else /* HAVE_UDA1380 */
1095 snprintf(buf, 32, "%s:%s",
1096 str(LANG_RECORDING_LEFT),
1097 fmt_gain(SOUND_LEFT_GAIN,
1098 global_settings.rec_left_gain,
1099 buf2, sizeof(buf2)));
1100#endif /* HAVE_UDA1380 */
1101 if(global_settings.invert_cursor && ((1==cursor)||(2==cursor)))
1102 lcd_puts_style(0, 4, buf, STYLE_INVERT);
1103 else
1104 lcd_puts(0, 4, buf);
1105#ifdef HAVE_UDA1380
1106 snprintf(buf, 32, "%s:%s (%s)",
1107 str(LANG_RECORDING_RIGHT),
1108 fmt_gain2(SOUND_RIGHT_GAIN,
1109 global_settings.rec_right_gain,
1110 SOUND_DECIMATOR_RIGHT_GAIN,
1111 global_settings.rec_linein_decimator_right_gain,
1112 buf2, sizeof(buf2)),
1113 (((global_settings.rec_right_gain ==
1114 sound_max(SOUND_RIGHT_GAIN)) &&
1115 (global_settings.rec_linein_decimator_right_gain
1116 > 0)) ||
1117 ((global_settings.rec_right_gain ==
1118 sound_min(SOUND_RIGHT_GAIN)) &&
1119 (global_settings.rec_linein_decimator_right_gain
1120 < 0))) ?
1121 str(LANG_RECORDING_GAIN_DIGITAL) :
1122 str(LANG_RECORDING_GAIN_ANALOG)
1123 );
1124#else /* HAVE_UDA1380 */
1125 snprintf(buf, 32, "%s:%s",
1126 str(LANG_RECORDING_RIGHT),
1127 fmt_gain(SOUND_RIGHT_GAIN,
1128 global_settings.rec_right_gain,
1129 buf2, sizeof(buf2)));
1130#endif /* HAVE_UDA1380 */
1131 if(global_settings.invert_cursor && ((1==cursor)||(3==cursor)))
1132 lcd_puts_style(0, 5, buf, STYLE_INVERT);
1133 else
1134 lcd_puts(0, 5, buf);
1135 }
1136 switch(cursor)
1137 {
1138 case 1:
1139 put_cursorxy(0, 4, true);
1140
1141 if(global_settings.rec_source != SOURCE_MIC)
1142 put_cursorxy(0, 5, true);
1143
1144 break;
1145 case 2:
1146 put_cursorxy(0, 4, true);
1147 break;
1148 case 3:
1149 put_cursorxy(0, 5, true);
1150 break;
1151 default:
1152 put_cursorxy(0, 0, true);
836 } 1153 }
837 1154
1155 snprintf(buf, 32, "%s %s",
1156 freq_str[global_settings.rec_frequency],
1157 global_settings.rec_channels?
1158 str(LANG_CHANNEL_MONO):str(LANG_CHANNEL_STEREO));
1159 lcd_puts(0, 7, buf);
1160
838 gui_syncstatusbar_draw(&statusbars, true); 1161 gui_syncstatusbar_draw(&statusbars, true);
839 peak_meter_draw(0, 8 + h*2, LCD_WIDTH, h); 1162 peak_meter_draw(0, 8 + h*2, LCD_WIDTH, h);
840 1163
diff --git a/apps/settings.c b/apps/settings.c
index ea8c562a04..2f782f46de 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -485,8 +485,10 @@ static const struct bit_entry hd_bits[] =
485 {5, S_O(rec_prerecord_time), 0, "prerecording time", NULL }, /* 0...30 */ 485 {5, S_O(rec_prerecord_time), 0, "prerecording time", NULL }, /* 0...30 */
486 {1, S_O(rec_directory), 0, /* rec_base_directory */ 486 {1, S_O(rec_directory), 0, /* rec_base_directory */
487 "rec directory", REC_BASE_DIR ",current" }, 487 "rec directory", REC_BASE_DIR ",current" },
488 {8|SIGNED, S_O(rec_adc_left_gain), 0, /* 0dB */ "adc left gain", NULL }, /* -128...48 */ 488 {8|SIGNED, S_O(rec_linein_decimator_left_gain), 0, /* 0dB */
489 {8|SIGNED, S_O(rec_adc_right_gain), 0, /* 0dB */ "adc right gain", NULL }, /* -128...48 */ 489 "line in decimator left gain", NULL }, /* -128...48 */
490 {8|SIGNED, S_O(rec_linein_decimator_right_gain), 0, /* 0dB */
491 "line in decimator right gain", NULL }, /* -128...48 */
490#endif 492#endif
491 493
492#ifdef HAVE_REMOTE_LCD 494#ifdef HAVE_REMOTE_LCD
@@ -507,10 +509,8 @@ static const struct bit_entry hd_bits[] =
507 {7, S_O(screen_scroll_step), 16, "screen scroll step", NULL }, /* 1...112 */ 509 {7, S_O(screen_scroll_step), 16, "screen scroll step", NULL }, /* 1...112 */
508#endif 510#endif
509#endif /* HAVE_LCD_BITMAP */ 511#endif /* HAVE_LCD_BITMAP */
510
511 {1, S_O(warnon_erase_dynplaylist), false, 512 {1, S_O(warnon_erase_dynplaylist), false,
512 "warn when erasing dynamic playlist", off_on }, 513 "warn when erasing dynamic playlist", off_on },
513
514#if CONFIG_CODEC == SWCODEC 514#if CONFIG_CODEC == SWCODEC
515 {1, S_O(eq_enabled), false, "eq enabled", off_on }, 515 {1, S_O(eq_enabled), false, "eq enabled", off_on },
516 /* 0..32768 Hz */ 516 /* 0..32768 Hz */
@@ -532,7 +532,13 @@ static const struct bit_entry hd_bits[] =
532 {9|SIGNED, S_O(eq_band3_gain), 0, "eq band 3 gain", NULL }, 532 {9|SIGNED, S_O(eq_band3_gain), 0, "eq band 3 gain", NULL },
533 {9|SIGNED, S_O(eq_band4_gain), 0, "eq band 4 gain", NULL }, 533 {9|SIGNED, S_O(eq_band4_gain), 0, "eq band 4 gain", NULL },
534#endif 534#endif
535 535#if defined(HAVE_UDA1380) /* PLEASE merge this with the other UDA1380 define
536 when bumping the settings version number PLEASE */
537 {8|SIGNED, S_O(rec_mic_decimator_left_gain), 0, /* 0dB */
538 "mic decimator left gain", NULL }, /* -128...48 */
539 {8|SIGNED, S_O(rec_mic_decimator_right_gain), 0, /* 0dB */
540 "mic decimator right gain", NULL }, /* -128...48 */
541#endif
536 /* If values are just added to the end, no need to bump the version. */ 542 /* If values are just added to the end, no need to bump the version. */
537 /* new stuff to be added at the end */ 543 /* new stuff to be added at the end */
538 544
diff --git a/apps/settings.h b/apps/settings.h
index 6efaacbaf3..20877b1f75 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -217,8 +217,10 @@ struct user_settings
217 int rec_left_gain; /* 0-15 */ 217 int rec_left_gain; /* 0-15 */
218 int rec_right_gain; /* 0-15 */ 218 int rec_right_gain; /* 0-15 */
219#ifdef HAVE_UDA1380 219#ifdef HAVE_UDA1380
220 int rec_adc_left_gain; /* -128 .. 48 */ 220 int rec_linein_decimator_left_gain; /* -128 .. 48 */
221 int rec_adc_right_gain; /* -128 .. 48 */ 221 int rec_linein_decimator_right_gain; /* -128 .. 48 */
222 int rec_mic_decimator_left_gain; /* -128 .. 48 */
223 int rec_mic_decimator_right_gain; /* -128 .. 48 */
222#endif 224#endif
223 bool rec_editable; /* true means that the bit reservoir is off */ 225 bool rec_editable; /* true means that the bit reservoir is off */
224 226
diff --git a/apps/sound_menu.c b/apps/sound_menu.c
index 9c8d398029..e4820b3379 100644
--- a/apps/sound_menu.c
+++ b/apps/sound_menu.c
@@ -18,6 +18,7 @@
18 ****************************************************************************/ 18 ****************************************************************************/
19#include "config.h" 19#include "config.h"
20#include <stdio.h> 20#include <stdio.h>
21#include <stdlib.h>
21#include <stdbool.h> 22#include <stdbool.h>
22#include "system.h" 23#include "system.h"
23#include "kernel.h" 24#include "kernel.h"
@@ -53,9 +54,15 @@ int selected_setting; /* Used by the callback */
53void dec_sound_formatter(char *buffer, int buffer_size, int val, const char * unit) 54void dec_sound_formatter(char *buffer, int buffer_size, int val, const char * unit)
54{ 55{
55 val = sound_val2phys(selected_setting, val); 56 val = sound_val2phys(selected_setting, val);
57 char sign = ' ';
58 if(val < 0)
59 {
60 sign = '-';
61 val = abs(val);
62 }
56 int integer = val / 10; 63 int integer = val / 10;
57 int dec = val % 10; 64 int dec = val % 10;
58 snprintf(buffer, buffer_size, "%d.%d %s", integer, dec, unit); 65 snprintf(buffer, buffer_size, "%c%d.%d %s", sign, integer, dec, unit);
59} 66}
60 67
61bool set_sound(const unsigned char * string, 68bool set_sound(const unsigned char * string,
@@ -237,6 +244,9 @@ static bool recchannels(void)
237 244
238static bool recquality(void) 245static bool recquality(void)
239{ 246{
247#ifdef HAVE_UDA1380
248 (void)recquality();
249#endif
240 return set_int(str(LANG_RECORDING_QUALITY), "", UNIT_INT, 250 return set_int(str(LANG_RECORDING_QUALITY), "", UNIT_INT,
241 &global_settings.rec_quality, 251 &global_settings.rec_quality,
242 NULL, 1, 0, 7, NULL ); 252 NULL, 1, 0, 7, NULL );
@@ -248,21 +258,6 @@ static bool receditable(void)
248 &global_settings.rec_editable); 258 &global_settings.rec_editable);
249} 259}
250 260
251#ifdef HAVE_UDA1380
252static bool recadcleft(void)
253{
254 return set_sound(str(LANG_RECORDING_ADC_LEFT),
255 &global_settings.rec_adc_left_gain,
256 SOUND_ADC_LEFT_GAIN);
257}
258
259static bool recadcright(void)
260{
261 return set_sound(str(LANG_RECORDING_ADC_RIGHT),
262 &global_settings.rec_adc_right_gain,
263 SOUND_ADC_RIGHT_GAIN);
264}
265#endif
266 261
267static bool rectimesplit(void) 262static bool rectimesplit(void)
268{ 263{
@@ -791,8 +786,10 @@ bool recording_menu(bool no_source)
791 struct menu_item items[13]; 786 struct menu_item items[13];
792 bool result; 787 bool result;
793 788
789#ifndef HAVE_UDA1380
794 items[i].desc = ID2P(LANG_RECORDING_QUALITY); 790 items[i].desc = ID2P(LANG_RECORDING_QUALITY);
795 items[i++].function = recquality; 791 items[i++].function = recquality;
792#endif
796 items[i].desc = ID2P(LANG_RECORDING_FREQUENCY); 793 items[i].desc = ID2P(LANG_RECORDING_FREQUENCY);
797 items[i++].function = recfrequency; 794 items[i++].function = recfrequency;
798 if(!no_source) { 795 if(!no_source) {
@@ -801,14 +798,6 @@ bool recording_menu(bool no_source)
801 } 798 }
802 items[i].desc = ID2P(LANG_RECORDING_CHANNELS); 799 items[i].desc = ID2P(LANG_RECORDING_CHANNELS);
803 items[i++].function = recchannels; 800 items[i++].function = recchannels;
804
805#ifdef HAVE_UDA1380
806 items[i].desc = ID2P(LANG_RECORDING_ADC_LEFT);
807 items[i++].function = recadcleft;
808 items[i].desc = ID2P(LANG_RECORDING_ADC_RIGHT);
809 items[i++].function = recadcright;
810#endif
811
812 items[i].desc = ID2P(LANG_RECORDING_EDITABLE); 801 items[i].desc = ID2P(LANG_RECORDING_EDITABLE);
813 items[i++].function = receditable; 802 items[i++].function = receditable;
814 items[i].desc = ID2P(LANG_RECORD_TIMESPLIT); 803 items[i].desc = ID2P(LANG_RECORD_TIMESPLIT);
diff --git a/firmware/drivers/uda1380.c b/firmware/drivers/uda1380.c
index eb2b57e7f3..3281391c72 100644
--- a/firmware/drivers/uda1380.c
+++ b/firmware/drivers/uda1380.c
@@ -255,10 +255,10 @@ void uda1380_disable_recording(void)
255/** 255/**
256 * Set recording gain and volume 256 * Set recording gain and volume
257 * 257 *
258 * type: params: ranges: 258 * type: params: ranges:
259 * AUDIO_GAIN_MIC left 0 .. 15 -> 0 .. 30 dB gain 259 * AUDIO_GAIN_MIC left 0 .. 15 -> 0 .. 30 dB gain
260 * AUDIO_GAIN_LINEIN left & right 0 .. 8 -> 0 .. 24 dB gain 260 * AUDIO_GAIN_LINEIN left & right 0 .. 8 -> 0 .. 24 dB gain
261 * AUDIO_GAIN_ADC left & right -128 .. 48 -> -64 .. 24 dB gain 261 * AUDIO_GAIN_DECIMATOR left & right -128 .. 48 -> -64 .. 24 dB gain
262 * 262 *
263 * Note: For all types the value 0 gives 0 dB gain. 263 * Note: For all types the value 0 gives 0 dB gain.
264 */ 264 */
@@ -274,7 +274,7 @@ void uda1380_set_recvol(int left, int right, int type)
274 uda1380_write_reg(REG_PGA, (uda1380_regs[REG_PGA] & ~PGA_GAIN_MASK) | PGA_GAINL(left) | PGA_GAINR(right)); 274 uda1380_write_reg(REG_PGA, (uda1380_regs[REG_PGA] & ~PGA_GAIN_MASK) | PGA_GAINL(left) | PGA_GAINR(right));
275 break; 275 break;
276 276
277 case AUDIO_GAIN_ADC: 277 case AUDIO_GAIN_DECIMATOR:
278 uda1380_write_reg(REG_DEC_VOL, DEC_VOLL(left) | DEC_VOLR(right)); 278 uda1380_write_reg(REG_DEC_VOL, DEC_VOLL(left) | DEC_VOLR(right));
279 break; 279 break;
280 } 280 }
diff --git a/firmware/export/audio.h b/firmware/export/audio.h
index 214f298a75..6867f3a268 100644
--- a/firmware/export/audio.h
+++ b/firmware/export/audio.h
@@ -33,9 +33,9 @@
33 33
34#define AUDIOERR_DISK_FULL 1 34#define AUDIOERR_DISK_FULL 1
35 35
36#define AUDIO_GAIN_LINEIN 0 36#define AUDIO_GAIN_LINEIN 0
37#define AUDIO_GAIN_MIC 1 37#define AUDIO_GAIN_MIC 1
38#define AUDIO_GAIN_ADC 2 /* for UDA1380 */ 38#define AUDIO_GAIN_DECIMATOR 2 /* for UDA1380 */
39 39
40 40
41struct audio_debug 41struct audio_debug
diff --git a/firmware/export/sound.h b/firmware/export/sound.h
index 2c002063db..dae124d8f7 100644
--- a/firmware/export/sound.h
+++ b/firmware/export/sound.h
@@ -42,8 +42,8 @@ enum {
42 SOUND_MIC_GAIN, 42 SOUND_MIC_GAIN,
43#endif 43#endif
44#if defined(HAVE_UDA1380) 44#if defined(HAVE_UDA1380)
45 SOUND_ADC_LEFT_GAIN, 45 SOUND_DECIMATOR_LEFT_GAIN,
46 SOUND_ADC_RIGHT_GAIN, 46 SOUND_DECIMATOR_RIGHT_GAIN,
47#endif 47#endif
48}; 48};
49 49
diff --git a/firmware/sound.c b/firmware/sound.c
index cee8c06294..110c2c91b8 100644
--- a/firmware/sound.c
+++ b/firmware/sound.c
@@ -97,8 +97,8 @@ static const struct sound_settings_info sound_settings_table[] = {
97 [SOUND_LEFT_GAIN] = {"dB", 1, 1, 0, 8, 8, NULL}, 97 [SOUND_LEFT_GAIN] = {"dB", 1, 1, 0, 8, 8, NULL},
98 [SOUND_RIGHT_GAIN] = {"dB", 1, 1, 0, 8, 8, NULL}, 98 [SOUND_RIGHT_GAIN] = {"dB", 1, 1, 0, 8, 8, NULL},
99 [SOUND_MIC_GAIN] = {"dB", 1, 1, 0, 15, 2, NULL}, 99 [SOUND_MIC_GAIN] = {"dB", 1, 1, 0, 15, 2, NULL},
100 [SOUND_ADC_LEFT_GAIN] = {"dB", 1, 1,-128, 48, 0, NULL}, 100 [SOUND_DECIMATOR_LEFT_GAIN] = {"dB", 1, 1,-128, 48, 0, NULL},
101 [SOUND_ADC_RIGHT_GAIN]= {"dB", 1, 1,-128, 48, 0, NULL}, 101 [SOUND_DECIMATOR_RIGHT_GAIN]= {"dB", 1, 1,-128, 48, 0, NULL},
102#endif 102#endif
103}; 103};
104 104
@@ -762,8 +762,8 @@ int sound_val2phys(int setting, int value)
762 result = value * 20; /* (30/15) *10 */ 762 result = value * 20; /* (30/15) *10 */
763 break; 763 break;
764 764
765 case SOUND_ADC_LEFT_GAIN: 765 case SOUND_DECIMATOR_LEFT_GAIN:
766 case SOUND_ADC_RIGHT_GAIN: 766 case SOUND_DECIMATOR_RIGHT_GAIN:
767 result = value * 5; /* (1/2) *10 */ 767 result = value * 5; /* (1/2) *10 */
768 break; 768 break;
769 769