summaryrefslogtreecommitdiff
path: root/apps/recorder/recording.c
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2006-05-14 23:34:24 +0000
committerJens Arnold <amiconn@rockbox.org>2006-05-14 23:34:24 +0000
commita238ab9df8f19ecd7abc44b6707a5622fcd770fe (patch)
treed6f786b92d649166545d235b2a4dfb72fe54ba7f /apps/recorder/recording.c
parentc9a1b4e9aaba244d27a1e770052697bab8a6ae3e (diff)
Iriver: Moved the handling of the UDA1380 split gain (analog preamp + decimator gain) into the UDA driver. * All: Settings structure sorted & cleaned up.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9927 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/recorder/recording.c')
-rw-r--r--apps/recorder/recording.c331
1 files changed, 4 insertions, 327 deletions
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index f6ce9bc872..cdbc170b03 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -155,22 +155,12 @@ static void set_gain(void)
{
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
{
audio_set_recording_gain(global_settings.rec_left_gain,
global_settings.rec_right_gain,
AUDIO_GAIN_LINEIN);
-#ifdef HAVE_UDA1380
- audio_set_recording_gain(global_settings.rec_linein_decimator_left_gain,
- global_settings.rec_linein_decimator_right_gain,
- AUDIO_GAIN_DECIMATOR);
-#endif
}
}
@@ -185,13 +175,13 @@ char *fmt_gain(int snd, int val, char *str, int len)
{
int i, d, numdec;
const char *unit;
+ char sign = ' ';
val = sound_val2phys(snd, val);
- char sign = ' ';
if(val < 0)
{
sign = '-';
- val = abs(val);
+ val = -val;
}
numdec = sound_numdecimals(snd);
unit = sound_unit(snd);
@@ -208,34 +198,6 @@ char *fmt_gain(int snd, int val, char *str, int len)
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;
-}
-
static int cursor;
void adjust_cursor(void)
@@ -351,158 +313,6 @@ 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)
{
long button;
@@ -525,22 +335,6 @@ bool recording_screen(void)
#endif
int i;
-#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[] = {
ID2P(LANG_BYTE),
ID2P(LANG_KILOBYTE),
@@ -789,20 +583,6 @@ bool recording_screen(void)
global_settings.volume++;
sound_set_volume(global_settings.volume);
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:
if(global_settings.rec_source == SOURCE_MIC)
{
@@ -830,7 +610,6 @@ bool recording_screen(void)
sound_max(SOUND_RIGHT_GAIN))
global_settings.rec_right_gain++;
break;
-#endif
}
set_gain();
update_countdown = 1; /* Update immediately */
@@ -850,23 +629,6 @@ bool recording_screen(void)
global_settings.volume--;
sound_set_volume(global_settings.volume);
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:
if(global_settings.rec_source == SOURCE_MIC)
{
@@ -894,7 +656,6 @@ bool recording_screen(void)
sound_min(SOUND_RIGHT_GAIN))
global_settings.rec_right_gain--;
break;
-#endif
}
set_gain();
update_countdown = 1; /* Update immediately */
@@ -1097,40 +858,10 @@ bool recording_screen(void)
if(global_settings.rec_source == SOURCE_MIC)
{
-#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,
global_settings.rec_mic_gain,
buf2, sizeof(buf2)));
-#endif
if(global_settings.invert_cursor && ((1==cursor)||(2==cursor)))
{
FOR_NB_SCREENS(i)
@@ -1145,44 +876,11 @@ bool recording_screen(void)
}
else if(global_settings.rec_source == SOURCE_LINE)
{
-#ifdef HAVE_UDA1380
-
- /*****************test info code***********************
- snprintf(buf, 32, "AL:(3x) %d DigL:(0.5x) %d",
- global_settings.rec_left_gain,
- global_settings.rec_linein_decimator_left_gain);
- lcd_puts(0, 10, buf);
- snprintf(buf, 32, "AR:(3x) %d DigR:(0.5x) %d",
- 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 (%s)",
- str(LANG_RECORDING_LEFT),
- fmt_gain2(SOUND_LEFT_GAIN,
- global_settings.rec_left_gain,
- SOUND_DECIMATOR_LEFT_GAIN,
- global_settings.rec_linein_decimator_left_gain,
- buf2, sizeof(buf2)),
- (((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)))
{
FOR_NB_SCREENS(i)
@@ -1195,32 +893,11 @@ bool recording_screen(void)
screens[i].puts(0, 3+PM_HEIGHT, 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)))
{
FOR_NB_SCREENS(i)
@@ -1266,14 +943,14 @@ bool recording_screen(void)
}
}
/* Can't measure S/PDIF sample rate on Archos yet */
-#if CONFIG_CODEC != MAS3587F && defined(HAVE_SPDIF_IN) && !defined(SIMULATOR)
+#if (CONFIG_CODEC != MAS3587F) && defined(HAVE_SPDIF_IN) && !defined(SIMULATOR)
if (global_settings.rec_source == SOURCE_SPDIF)
snprintf(spdif_sfreq, 8, "%dHz", audio_get_spdif_sample_rate());
#else
(void)spdif_sfreq;
#endif
snprintf(buf, 32, "%s %s",
-#if CONFIG_CODEC != MAS3587F && defined(HAVE_SPDIF_IN) && !defined(SIMULATOR)
+#if (CONFIG_CODEC != MAS3587F) && defined(HAVE_SPDIF_IN) && !defined(SIMULATOR)
global_settings.rec_source == SOURCE_SPDIF ?
spdif_sfreq :
#endif