summaryrefslogtreecommitdiffstats
path: root/Graphic_Equalizer/src/sample.hcc
diff options
context:
space:
mode:
Diffstat (limited to 'Graphic_Equalizer/src/sample.hcc')
-rw-r--r--Graphic_Equalizer/src/sample.hcc106
1 files changed, 106 insertions, 0 deletions
diff --git a/Graphic_Equalizer/src/sample.hcc b/Graphic_Equalizer/src/sample.hcc
new file mode 100644
index 0000000..000baf9
--- /dev/null
+++ b/Graphic_Equalizer/src/sample.hcc
@@ -0,0 +1,106 @@
+/*! \file sample.hcc
+ *
+ * \section generic Handle audio sampling and buffer rotation.
+ *
+ * \section project Project information.
+ * Project Graphic Equalizer\n
+ * \author O.M. Schinagl
+ * \date 20041021
+ * \version 0.1
+ *
+ * \section copyright Copyright
+ * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved
+ *
+ * \section history Change history
+ * 20041021: O.M. Schinagl\n Initial version
+ *
+ ********************************************************************/
+
+/******** System Includes *************/
+
+/******** Application Includes ********/
+#include "sample.hch"
+
+
+
+/*
+ * Pointer that points towards the current 64 bits samples.
+ */
+signed 16 *audio_in_ptr;
+
+/*
+ * 64 step counter to keep track of our samples. This is a private variable.
+ */
+unsigned 8 sample_count;
+
+
+
+/*! \fn void sample_add(signed 16 in_sample);
+ * \brief This procedure adds the supplied sample to the input buffer.
+ *
+ * \param signed 16 in_sample 16 bits signed sample to be added.
+ *
+ * \return void
+ * \retval void
+ */
+void sample_add(signed 16 in_sample) {
+ /*
+ * We only sample 64 bits in our buffer, hence we circulate around the
+ * last 6 bits.
+ */
+ audio_in_ptr[sample_count <-6] = in_sample;
+ sample_count++;
+} /* --- sample_add() --- */
+
+
+
+/*! \fn void sample_get(signed 16 *out_sample);
+ * \brief This procedure gets the sample from the current output buffer.
+ *
+ * \param * in_sample pointer to storage for sample.
+ *
+ * \return void
+ * \retval void
+ */
+void sample_get(signed 16 *out_sample) {
+ /*
+ * We circulate around a 64 bits buffer, therefor we only use the last
+ * 6 bits.
+ */
+ *out_sample = audio_out_ptr[sample_count <-6];
+} /* --- sample_get() --- */
+
+
+
+/*! \fn unsigned 1 sample_rotate_buffers(void);
+ * \brief This procedure rotates our buffers around if 64 samples are
+ * read into our current buffer.
+ *
+ * \param in_sample 16 bits signed sample to be added.
+ *
+ * \return 1 when 64 samples have passed, 0 otherwise.
+ * \retval unsigned 1;
+ */
+unsigned 1 sample_rotate_buffers(void) {
+ unsigned 1 retval; /* store for returnvalue */
+
+ retval = 0;
+ /*
+ * We only want to read 64 samples, but calculations work nicer if we
+ * use 256 samples. Therefor we circulate our audio pointer around.
+ */
+ if (!(sample_count <- 6)) {
+ /*
+ * 64 Samples have passed. We are back at '0'. Use the full
+ * sample count as index which is 0 64 128 or 192 and back to
+ * 0. Our Output is only 128 big so we only look at the
+ * 7 LSB. Also, notify the main application that 64 samples
+ * have been processed.
+ */
+ par {
+ audio_in_ptr = &pcm_audio_in[sample_count];
+ audio_out_ptr = &pcm_audio_out[(sample_count <- 7)];
+ retval = 1;
+ }
+ }
+} /* --- sample_rotate_buffers() --- */