summaryrefslogtreecommitdiffstats
path: root/Graphic_Equalizer/src
diff options
context:
space:
mode:
authorOliver Schinagl <oliver@schinagl.nl>2004-10-25 13:36:05 (GMT)
committerOliver Schinagl <oliver@schinagl.nl>2004-10-25 13:36:05 (GMT)
commitc515ffa43d033a2e49c5bfab71ee75dc1721958a (patch)
tree6cd82cf254cb85fd9b9d8ce5f0dac5eeab1c3001 /Graphic_Equalizer/src
parent8dc8d2307a1ff34a75b678659434996af3a2e734 (diff)
downloadTASS-c515ffa43d033a2e49c5bfab71ee75dc1721958a.zip
TASS-c515ffa43d033a2e49c5bfab71ee75dc1721958a.tar.gz
TASS-c515ffa43d033a2e49c5bfab71ee75dc1721958a.tar.bz2
Diffstat (limited to 'Graphic_Equalizer/src')
-rw-r--r--Graphic_Equalizer/src/audio/audiodriver.hcc24
-rw-r--r--Graphic_Equalizer/src/audio/sample.hcc61
2 files changed, 68 insertions, 17 deletions
diff --git a/Graphic_Equalizer/src/audio/audiodriver.hcc b/Graphic_Equalizer/src/audio/audiodriver.hcc
index 0038ef6..aadcc6e 100644
--- a/Graphic_Equalizer/src/audio/audiodriver.hcc
+++ b/Graphic_Equalizer/src/audio/audiodriver.hcc
@@ -79,6 +79,28 @@ void audio_main(void) {
*/
macro expr AudioIn = PalAudioInCT(0);
macro expr AudioOut = PalAudioOutCT(0);
+ /*
+ * Determin the data width for the current platform.
+ */
+ macro expr IW = PalAudioInGetMaxDataWidthCT();
+ macro expr OW = PalAudioOutGetMaxDataWidthCT();
+
+ signed IW sample_left_in, sample_right_in;
+ signed 16 sample_left_out, sample_right_out;
+
+ for (;;) {
+ PalAudioRead(AudioIn, &sample_left_in, &sample_right_in);
-
+ par {
+ sample_add(sample_left_in);
+ sample_get(&sample_left_out);
+ sample_right_out = sample_right_in;
+ }
+ if (rotate_samples()) {
+ /*
+ * 64 Samples have been processed, calculate.
+ */
+ }
+ PalAudioWrite(AudioOut, (signed OW)(sample_left @ 0), (signed OW)(sample_right @ 0));
+ }
} /* --- audio_main() --- */
diff --git a/Graphic_Equalizer/src/audio/sample.hcc b/Graphic_Equalizer/src/audio/sample.hcc
index 95139e7..000baf9 100644
--- a/Graphic_Equalizer/src/audio/sample.hcc
+++ b/Graphic_Equalizer/src/audio/sample.hcc
@@ -19,27 +19,33 @@
/******** System Includes *************/
/******** Application Includes ********/
+#include "sample.hch"
/*
- * 64 step counter to keep track of our samples.
+ * Pointer that points towards the current 64 bits samples.
*/
-unsigned 8 sample_count;
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(in_sample);
- * \brief This procedure adds the supplied sample to our internal array.
+
+/*! \fn void sample_add(signed 16 in_sample);
+ * \brief This procedure adds the supplied sample to the input buffer.
*
- * \param in_sample 16 bits signed sample to be added.
+ * \param signed 16 in_sample 16 bits signed sample to be added.
*
* \return void
* \retval void
*/
-void sample_add(in_sample) {
+void sample_add(signed 16 in_sample) {
/*
- * We only want a 64 sample buffer, hence we circulate around only the
+ * We only sample 64 bits in our buffer, hence we circulate around the
* last 6 bits.
*/
audio_in_ptr[sample_count <-6] = in_sample;
@@ -48,30 +54,53 @@ void sample_add(in_sample) {
-/*! \fn void sample_rotate_buffers(void);
+/*! \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 void
- * \retval void
+ * \return 1 when 64 samples have passed, 0 otherwise.
+ * \retval unsigned 1;
*/
-void sample_rotate_buffers(in_sample) {
+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'. Copy 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.
+ * 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;
}
}
-} /* --- main() --- */
+} /* --- sample_rotate_buffers() --- */