summaryrefslogtreecommitdiffstats
path: root/Graphic_Equalizer/src
diff options
context:
space:
mode:
authorOliver Schinagl <oliver@schinagl.nl>2004-10-21 09:38:26 (GMT)
committerOliver Schinagl <oliver@schinagl.nl>2004-10-21 09:38:26 (GMT)
commit8dc8d2307a1ff34a75b678659434996af3a2e734 (patch)
treebb4304dd2fadaaad15d621c3163532c59c3f832b /Graphic_Equalizer/src
parenta651ae0a1d303f92043624dec87314e369bf2bca (diff)
downloadTASS-8dc8d2307a1ff34a75b678659434996af3a2e734.zip
TASS-8dc8d2307a1ff34a75b678659434996af3a2e734.tar.gz
TASS-8dc8d2307a1ff34a75b678659434996af3a2e734.tar.bz2
Diffstat (limited to 'Graphic_Equalizer/src')
-rw-r--r--Graphic_Equalizer/src/audio/audiodriver.hcc84
-rw-r--r--Graphic_Equalizer/src/audio/main.hcc88
-rw-r--r--Graphic_Equalizer/src/audio/sample.hcc77
3 files changed, 249 insertions, 0 deletions
diff --git a/Graphic_Equalizer/src/audio/audiodriver.hcc b/Graphic_Equalizer/src/audio/audiodriver.hcc
new file mode 100644
index 0000000..0038ef6
--- /dev/null
+++ b/Graphic_Equalizer/src/audio/audiodriver.hcc
@@ -0,0 +1,84 @@
+/*! \file header_templace.hcc
+ *
+ * \section generic Message build up information and more
+ *
+ * \section project Project information.
+ * Project Graphic Equalizer\n
+ * \author
+ * \date 20041011
+ * \version 0.1
+ *
+ * \section copyright Copyright
+ * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved
+ *
+ * \section history Change history
+ * 20041011: \n Initial version
+ *
+ ********************************************************************/
+
+/******** System Includes *************/
+#include <stdlib.hch>
+
+#include "pal_master.hch"
+
+/******** Application Includes ********/
+#include "audiodriver.hch"
+#include "audiodriver_shared.hch"
+
+
+
+/*! \fn void audio_init(unsigned 4 gain_level,
+ * unsigned 1 input_source,
+ * unsigned 3 sample_rate)
+ *
+ * \brief Set some inital values to the audio hardware.
+ *
+ * \param unsigned 4 gain_level Set the input amplifier to this
+ * amplification level.
+ * \param unsigned 1 input_source Choose between microphone input
+ * or linein input
+ * \param unsigned 3 sample_rate Set the sample rate between 8000
+ * and 48000
+ *
+ * \return void
+ * \retval void
+ *
+ */
+void audio_init(unsigned 4 gain_level,
+ unsigned 1 input_source,
+ unsigned 3 sample_rate) {
+ /*
+ * We simply call the appropiate handlers and pass values along. We
+ * Don't set the mute on input gain. We have volume control to do this.
+ * Input and Output sampling rates are equal. We dont' need different
+ * rates.
+ */
+ RC200AudioInSetGain(FALSE, gain_level, gain_level);
+ RC200AudioInSetInput(input_source);
+ PalAudioInSetSampleRate(AudioIn, sample_rate);
+ PalAudioOutSetSampleRate(AudioOut, sample_rate);
+} /* --- audio_init() --- */
+
+
+
+/*! \fn void audio_main(void);
+ * \brief Main audiodriver. This function never returns! It calls the
+ * audiohandlers and stores samples into a global array. Once 64
+ * Samples are collected it raises a signal AUDIO_READY to let
+ * other processes know it's ready. We use quadruple buffering for
+ * audio input and double buffering for audio output.
+ *
+ * \param void
+ *
+ * \return Never Returns.
+ * \retval void
+ */
+void audio_main(void) {
+ /*
+ * Setup audio pointers.
+ */
+ macro expr AudioIn = PalAudioInCT(0);
+ macro expr AudioOut = PalAudioOutCT(0);
+
+
+} /* --- audio_main() --- */
diff --git a/Graphic_Equalizer/src/audio/main.hcc b/Graphic_Equalizer/src/audio/main.hcc
new file mode 100644
index 0000000..cd98565
--- /dev/null
+++ b/Graphic_Equalizer/src/audio/main.hcc
@@ -0,0 +1,88 @@
+/*! \file header_templace.hcc
+ *
+ * \section generic Message build up information and more
+ *
+ * \section project Project information.
+ * Project Graphic Equalizer\n
+ * \author
+ * \date 20041011
+ * \version 0.1
+ *
+ * \section copyright Copyright
+ * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved
+ *
+ * \section history Change history
+ * 20041011: \n Initial version
+ *
+ ********************************************************************/
+
+
+/*
+ * Set the Clock rate for this domain. 50.0 Mhz is minimally required while
+ * performing audio tasks.
+ */
+#define PAL_TARGET_CLOCK_RATE 50000000
+
+/******** System Includes *************/
+#include <stdlib.hch>
+
+#include "pal_master.hch"
+
+/******** Application Includes ********/
+#include "audiodriver.hch"
+
+
+/*
+ * Request Clockrate. Approximated ClockRate is compiler assigned.
+ */
+static macro expr ClockRate = PAL_ACTUAL_CLOCK_RATE;
+
+
+
+/*! \fn void main(void);
+ * \brief Main audio handling loop.
+ *
+ * \param void
+ *
+ * \return void
+ * \retval void
+ */
+void main(void) {
+ /* Setup Audio I/O Pointers */
+ macro expr AudioIn = PalAudioInCT(0);
+ macro expr AudioOut = PalAudioOutCT(0);
+
+ /*
+ * Check library versions and Request VideoOutput.
+ * We need at least Major Version 1 and minor version 2.
+ */
+ PalVersionRequire(1, 2);
+ PalAudioInRequire(1);
+ PalAudioOutRequire(1);
+
+ /*
+ * Run The Following main tasks in parallel.
+ */
+ par {
+ /*
+ * Primary task is to 'Run' several hardware simultaniously.
+ * Audio I/O needs to be in sync.
+ */
+ PalAudioInRun(AudioIn, ClockRate);
+ PalAudioOutRun(AudioOut, ClockRate);
+
+ /* Parallel to our Primary tasks we run the application. */
+ seq {
+ /* But first we need to enable and initialize the audio. */
+ PalAudioInEnable(AudioIn);
+ PalAudioOutEnable(AudioOut);
+ audio_init(7, LINE_IN, SR_44100);
+ par {
+ /*
+ * From here we run the main audio loop.
+ */
+ audio_main();
+ }
+ }
+ }
+} /* --- main() --- */
diff --git a/Graphic_Equalizer/src/audio/sample.hcc b/Graphic_Equalizer/src/audio/sample.hcc
new file mode 100644
index 0000000..95139e7
--- /dev/null
+++ b/Graphic_Equalizer/src/audio/sample.hcc
@@ -0,0 +1,77 @@
+/*! \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 ********/
+
+
+
+/*
+ * 64 step counter to keep track of our samples.
+ */
+unsigned 8 sample_count;
+signed 16 *audio_in_ptr;
+
+
+/*! \fn void sample_add(in_sample);
+ * \brief This procedure adds the supplied sample to our internal array.
+ *
+ * \param in_sample 16 bits signed sample to be added.
+ *
+ * \return void
+ * \retval void
+ */
+void sample_add(in_sample) {
+ /*
+ * We only want a 64 sample buffer, hence we circulate around only the
+ * last 6 bits.
+ */
+ audio_in_ptr[sample_count <-6] = in_sample;
+ sample_count++;
+} /* --- sample_add() --- */
+
+
+
+/*! \fn void 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
+ */
+void sample_rotate_buffers(in_sample) {
+ /*
+ * 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.
+ */
+ par {
+ audio_in_ptr = &pcm_audio_in[sample_count];
+ audio_out_ptr = &pcm_audio_out[(sample_count <- 7)];
+ }
+ }
+} /* --- main() --- */