From f08be707d62975e6f6dd35720bf0867990dde730 Mon Sep 17 00:00:00 2001 From: Marcel Lauwerijssen Date: Tue, 21 Dec 2004 15:31:03 +0000 Subject: Modified comment --- Graphic_Equalizer/src/fft.hcc | 44 ++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/Graphic_Equalizer/src/fft.hcc b/Graphic_Equalizer/src/fft.hcc index 0be69fe..1fda3b0 100644 --- a/Graphic_Equalizer/src/fft.hcc +++ b/Graphic_Equalizer/src/fft.hcc @@ -40,26 +40,27 @@ mpram { ram signed 18 rwrite[256]; rom signed 18 read[256]; -} real with {block = "BlockRAM"/*, westart=2.5, welength=1, rclkpos={1.5}, wclkpos={3}, clkpulselen=0.5*/}; +} real with {block = "BlockRAM"}; mpram { ram signed 18 rwrite[256]; rom signed 18 read[256]; -} imaginary with {block = "BlockRAM"/*, westart=2.5, welength=1, rclkpos={1.5}, wclkpos={3}, clkpulselen=0.5*/}; +} imaginary with {block = "BlockRAM"}; #else mpram { ram signed 24 rwrite[256]; rom signed 24 read[256]; -} real with {block = "BlockRAM"/*, westart=2.5, welength=1, rclkpos={1.5}, wclkpos={3}, clkpulselen=0.5*/}; +} real with {block = "BlockRAM"}; mpram { ram signed 24 rwrite[256]; rom signed 24 read[256]; -} imaginary with {block = "BlockRAM"/*, westart=2.5, welength=1, rclkpos={1.5}, wclkpos={3}, clkpulselen=0.5*/}; +} imaginary with {block = "BlockRAM"}; #endif + // multiplication factors for equalizer function ram signed 7 eq_settings[16] = {0,2,4,7,10,13,16,19,22,26,30,35,41,48,55,63}; @@ -148,7 +149,8 @@ void calculate_fft(unsigned 1 select_inverse) for(i=0@j;i<=NUMBER_OF_POINTS;i+=e) // count all the blocks in this column - { // Butterfly calculation + { + // Butterfly calculation par { point1 = ((i<-8)-1); @@ -201,11 +203,12 @@ void calculate_fft(unsigned 1 select_inverse) point2=(i-1)<-8; } /* - COPYING ARRAY VALUES FROM ONE PLACE TO ANOTHER IN THE ARRAT MUST BE DONE IN - 2 STEPS. FIRSTLY THE VALUES ARE COPIED TO SEPARATE VARIABLES AFTER THAT THEY - ARE COPIED BACK TO THEIR NEW POSITION IN THE ARRAY. THIS MUST BE DONE TO - PREVENT TIMING ISSUES FROM OCCURING. + * COPYING ARRAY VALUES FROM ONE PLACE TO ANOTHER IN THE ARRAY MUST BE DONE IN + * 2 STEPS. FIRST THE VALUES HAVE TO BE COPIED TO SEPARATE VARIABLES AFTER THAT THEY + * ARE COPIED BACK TO THEIR NEW POSITION IN THE ARRAY. THIS MUST BE DONE TO + * PREVENT TIMING ISSUES FROM OCCURING. */ + /* Copy array values to separate variables */ par { p = real.read[point1]; @@ -216,6 +219,7 @@ void calculate_fft(unsigned 1 select_inverse) r = real.read[point2]; t = imaginary.read[point2]; } + /* Copy variables back to their new positions */ par { real.rwrite[point1] = r; @@ -239,7 +243,7 @@ void calculate_fft(unsigned 1 select_inverse) j+=k; } - + //Bitreversing end } /*! \fn void perform_fft(signed 18 *pcm_audio) @@ -260,6 +264,8 @@ void perform_fft(signed 16 *pcm_audio) #endif { unsigned 8 k; + + //initialize variables before the copying pipeline #if HARDWARE_MULTIPLY signed 18 sample; k=0; @@ -269,11 +275,7 @@ void perform_fft(signed 16 *pcm_audio) k=0; sample = adjs(pcm_audio[k],24); #endif - - //initialize variables for the copying pipeline - - - // copy audio data to real-array before starting FFT calculation + // copy audio data to real-array before starting FFT calculation // and set imaginary values to zero do { @@ -426,12 +428,12 @@ void equalize_audio(audiodata_t *audiodata) for(i=0;i!=NUMBER_OF_FREQUENCIES;i++) { - // set multiplication factor (0..64) for current frequency bar, The first frequency band must be equalized at 100% (63) since there is no DC-component taken into account. - a = adjs(eq_settings[audiodata->equalizer_levels_ptr[i <- 7]],18); + // set multiplication factor (0..64) for current frequency bar, The first frequency band must be equalized at 100% (63) since there is no DC-component taken into account. + a = adjs(eq_settings[audiodata->equalizer_levels_ptr[i <- 7]],18); - // multiply frequency with this factor and divide by 64 (drop 6 LSB's) - q = real.read[i]; + // multiply frequency with this factor and divide by 64 (drop 6 LSB's) + q = real.read[i]; equalize_bar(p); real.rwrite[i] = p; @@ -484,10 +486,14 @@ void equalize_audio(audiodata_t *audiodata) } old_value = audiodata->fft_info.write[0 @ (i <- 7)]; tmp = ((0@old_value) + (0@bit))>>1; + + //Write data to FFT_info array to be displayed as a sound spectrum audiodata->fft_info.write[0 @ (i <- 7)] = (old_value <= (tmp<-7)) ? (tmp<-7) : old_value-1; } else { + //Write data to FFT_info array to be displayed as a sound spectrum + old_value = audiodata->fft_info.write[0 @ (i <- 7)]; #if HARDWARE_MULTIPLY audiodata->fft_info.write[0 @ (i <- 7)] = (old_value<=(unsigned)(p[15:9])) ? (unsigned)(p[15:9]) : old_value-1; -- cgit v0.12