Main Page | File List | Globals

sample.hcc

Go to the documentation of this file.
00001 
00019 /******** System Includes *************/
00020 
00021 /******** Application Includes ********/
00022 #include "sample.hch"
00023 
00024 
00025 
00026 /*
00027  * Pointer that points towards the current 64 bits samples.
00028  */
00029 signed 16 *audio_in_ptr;
00030 
00031 /*
00032  * 64 step counter to keep track of our samples. This is a private variable.
00033  */
00034 unsigned 8 sample_count;
00035 
00036 
00037 
00046 void sample_add(signed 16 in_sample) {
00047         /*
00048          * We only sample 64 bits in our buffer, hence we circulate around the
00049          * last 6 bits.
00050          */
00051         audio_in_ptr[sample_count <-6] = in_sample;
00052         sample_count++;
00053 } /* --- sample_add() --- */
00054 
00055 
00056 
00065 void sample_get(signed 16 *out_sample) {
00066         /*
00067          * We circulate around a 64 bits buffer, therefor we only use the last
00068          *  6 bits.
00069          */
00070         *out_sample = audio_out_ptr[sample_count <-6];
00071 } /* --- sample_get() --- */
00072 
00073 
00074 
00084 unsigned 1 sample_rotate_buffers(void) {
00085         unsigned 1 retval;      /* store for returnvalue */
00086 
00087         retval = 0;
00088         /*
00089          * We only want to read 64 samples, but calculations work nicer if we
00090          * use 256 samples. Therefor we circulate our audio pointer around.
00091          */
00092         if (!(sample_count <- 6)) {
00093                 /*
00094                  * 64 Samples have passed. We are back at '0'. Use the full
00095                  * sample count as index which is 0 64 128 or 192 and back to
00096                  * 0. Our Output is only 128 big so we only look at the
00097                  * 7 LSB. Also, notify the main application that 64 samples
00098                  * have been processed.
00099                  */
00100                 par {
00101                         audio_in_ptr = &pcm_audio_in[sample_count];
00102                         audio_out_ptr = &pcm_audio_out[(sample_count <- 7)];
00103                         retval = 1;
00104                 }
00105         }
00106 } /* --- sample_rotate_buffers() --- */

Generated on Mon Nov 29 10:53:29 2004 for Graphic Equalizer by  doxygen 1.3.9.1