summaryrefslogtreecommitdiffstats
path: root/apps/recorder/peakmeter.c
diff options
context:
space:
mode:
authorPeter D'Hoye <peter.dhoye@gmail.com>2006-08-16 23:26:55 +0000
committerPeter D'Hoye <peter.dhoye@gmail.com>2006-08-16 23:26:55 +0000
commit5fc66e58dd8a62099cfb1c3f7ae48d7115376be3 (patch)
tree0dc6123bb179a5eba4953d62155a4b48dea75869 /apps/recorder/peakmeter.c
parentc5a24c69221dbd8f2c55f007d9d7eaa2222fa5df (diff)
downloadrockbox-5fc66e58dd8a62099cfb1c3f7ae48d7115376be3.tar.gz
rockbox-5fc66e58dd8a62099cfb1c3f7ae48d7115376be3.zip
Automatic Gain Control during recording. At this point only compiled for iriver h1x0 and h3x0. Patch FS#4748 by Jvo Studer, Martin Scarratt and myself.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10625 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/recorder/peakmeter.c')
-rw-r--r--apps/recorder/peakmeter.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/apps/recorder/peakmeter.c b/apps/recorder/peakmeter.c
index 0f8da98308..58c85b2161 100644
--- a/apps/recorder/peakmeter.c
+++ b/apps/recorder/peakmeter.c
@@ -62,6 +62,10 @@ static int pm_cur_left; /* current values (last peak_meter_peek) */
static int pm_cur_right;
static int pm_max_left; /* maximum values between peak meter draws */
static int pm_max_right;
+#ifdef HAVE_AGC
+static int pm_peakhold_left; /* max. peak values between peakhold calls */
+static int pm_peakhold_right; /* used for AGC and histogram display */
+#endif
/* Clip hold */
static bool pm_clip_left = false; /* when true a clip has occurred */
@@ -716,6 +720,10 @@ static int peak_meter_read_l(void)
by peak_meter_peek since the last call of peak_meter_read_l */
int retval = pm_max_left;
+#ifdef HAVE_AGC
+ /* store max peak value for peak_meter_get_peakhold_x readout */
+ pm_peakhold_left = MAX(pm_max_left, pm_peakhold_left);
+#endif
#ifdef PM_DEBUG
peek_calls = 0;
#endif
@@ -737,6 +745,10 @@ static int peak_meter_read_r(void)
by peak_meter_peek since the last call of peak_meter_read_r */
int retval = pm_max_right;
+#ifdef HAVE_AGC
+ /* store max peak value for peak_meter_get_peakhold_x readout */
+ pm_peakhold_right = MAX(pm_max_right, pm_peakhold_right);
+#endif
#ifdef PM_DEBUG
peek_calls = 0;
#endif
@@ -746,6 +758,23 @@ static int peak_meter_read_r(void)
return retval;
}
+#ifdef HAVE_AGC
+/**
+ * Reads out the current peak-hold values since the last call.
+ * This is used by the histogram feature in the recording screen.
+ * Values are in the range 0 <= peak_x < MAX_PEAK. MAX_PEAK is typ 32767.
+ */
+extern void peak_meter_get_peakhold(int *peak_left, int *peak_right)
+{
+ if (peak_left)
+ *peak_left = pm_peakhold_left;
+ if (peak_right)
+ *peak_right = pm_peakhold_right;
+ pm_peakhold_left = 0;
+ pm_peakhold_right = 0;
+}
+#endif
+
/**
* Reset the detected clips. This method is for
* use by the user interface.