summaryrefslogtreecommitdiff
path: root/apps/recorder/recording.c
diff options
context:
space:
mode:
authorPeter D'Hoye <peter.dhoye@gmail.com>2006-10-01 10:04:40 +0000
committerPeter D'Hoye <peter.dhoye@gmail.com>2006-10-01 10:04:40 +0000
commitcb5129d07466d10e6d78190fc2bf2e478e782f13 (patch)
tree7f017de47117fda7aafd4d2e98be2ff12751a20e /apps/recorder/recording.c
parent4caa676a9c91e6855fc9f4780d7fb72498dd1804 (diff)
Prevent gain increase when using AGC in Safety mode
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11101 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/recorder/recording.c')
-rw-r--r--apps/recorder/recording.c121
1 files changed, 63 insertions, 58 deletions
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index c51569ad31..0a21d96566 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -119,6 +119,8 @@ static short balance_mem[BAL_MEM_SIZE];
/* Automatic Gain Control */
#define AGC_MODE_SIZE 5
+#define AGC_SAFETY_MODE 0
+
static char* agc_preset_str[] =
{ "Off", "S", "L", "D", "M", "V" };
/* "Off",
@@ -282,71 +284,73 @@ void auto_gain_control(int *peak_l, int *peak_r, int *balance)
return;
}
- /* Automatic balance control */
- if ((agc_left > AGC_IMG) && (agc_right > AGC_IMG))
- {
- if (*balance < -556)
- {
- if (*balance > -900)
- agc_baltime -= !(peak_time % 4); /* 0.47 - 0.75dB */
- else if (*balance > -4125)
- agc_baltime--; /* 0.75 - 3.00dB */
- else if (*balance > -7579)
- agc_baltime -= 2; /* 3.00 - 4.90dB */
- else
- agc_baltime -= !(peak_time % 8); /* 4.90 - inf dB */
- if (agc_baltime > 0)
- agc_baltime -= (peak_time % 2);
- }
- else if (*balance > 556)
+ if (agc_mode != AGC_SAFETY_MODE) {
+ /* Automatic balance control - only if not in safety mode */
+ if ((agc_left > AGC_IMG) && (agc_right > AGC_IMG))
{
- if (*balance < 900)
- agc_baltime += !(peak_time % 4);
- else if (*balance < 4125)
- agc_baltime++;
- else if (*balance < 7579)
- agc_baltime += 2;
- else
- agc_baltime += !(peak_time % 8);
- if (agc_baltime < 0)
- agc_baltime += (peak_time % 2);
- }
+ if (*balance < -556)
+ {
+ if (*balance > -900)
+ agc_baltime -= !(peak_time % 4); /* 0.47 - 0.75dB */
+ else if (*balance > -4125)
+ agc_baltime--; /* 0.75 - 3.00dB */
+ else if (*balance > -7579)
+ agc_baltime -= 2; /* 3.00 - 4.90dB */
+ else
+ agc_baltime -= !(peak_time % 8); /* 4.90 - inf dB */
+ if (agc_baltime > 0)
+ agc_baltime -= (peak_time % 2);
+ }
+ else if (*balance > 556)
+ {
+ if (*balance < 900)
+ agc_baltime += !(peak_time % 4);
+ else if (*balance < 4125)
+ agc_baltime++;
+ else if (*balance < 7579)
+ agc_baltime += 2;
+ else
+ agc_baltime += !(peak_time % 8);
+ if (agc_baltime < 0)
+ agc_baltime += (peak_time % 2);
+ }
- if ((*balance * agc_baltime) < 0)
- {
- if (*balance < 0)
- agc_baltime -= peak_time % 2;
- else
- agc_baltime += peak_time % 2;
- }
+ if ((*balance * agc_baltime) < 0)
+ {
+ if (*balance < 0)
+ agc_baltime -= peak_time % 2;
+ else
+ agc_baltime += peak_time % 2;
+ }
- increment = ((agc_risetime / 2) > agc_droptime);
-
- if (agc_baltime < -agc_tbal[agc_mode])
- {
- if (!increment || !agc_gain_is_max(!increment, increment)) {
- change_recording_gain(increment, !increment, increment);
- set_gain();
+ increment = ((agc_risetime / 2) > agc_droptime);
+
+ if (agc_baltime < -agc_tbal[agc_mode])
+ {
+ if (!increment || !agc_gain_is_max(!increment, increment)) {
+ change_recording_gain(increment, !increment, increment);
+ set_gain();
+ }
+ agc_baltime = 0;
+ }
+ else if (agc_baltime > +agc_tbal[agc_mode])
+ {
+ if (!increment || !agc_gain_is_max(increment, !increment)) {
+ change_recording_gain(increment, increment, !increment);
+ set_gain();
+ }
+ agc_baltime = 0;
}
- agc_baltime = 0;
}
- else if (agc_baltime > +agc_tbal[agc_mode])
+ else if (!(hist_time % 4))
{
- if (!increment || !agc_gain_is_max(increment, !increment)) {
- change_recording_gain(increment, increment, !increment);
- set_gain();
- }
- agc_baltime = 0;
+ if (agc_baltime < 0)
+ agc_baltime++;
+ else
+ agc_baltime--;
}
}
- else if (!(hist_time % 4))
- {
- if (agc_baltime < 0)
- agc_baltime++;
- else
- agc_baltime--;
- }
-
+
/* Automatic gain control */
if ((agc_left > agc_th_hi[agc_mode]) || (agc_right > agc_th_hi[agc_mode]))
{
@@ -389,7 +393,8 @@ void auto_gain_control(int *peak_l, int *peak_r, int *balance)
agc_risetime++;
if (agc_risetime >= agc_trise[agc_mode]) {
- if (!agc_gain_is_max(true, true)) {
+ if ((agc_mode != AGC_SAFETY_MODE) &&
+ (!agc_gain_is_max(true, true))) {
change_recording_gain(true, true, true);
set_gain();
}