/**************************************************************** * * * Copyright (C) 1991-2003 Celoxica Ltd. All rights reserved. * * * ***************************************************************** * * * Project : PAL * * Date : 31 JAN 2003 * * File : reverb.hcc * * Author : Matthew Aubury (MA) * * Contributors: * * * * Description: * * Simple audio reverb. * * * * Date Version Author Reason for change * * * * 29 OCT 2002 1.00 MA Created * * * ****************************************************************/ #include #include "pal_master.hch" #include "configuration.hch" #if USE_RUNFFT #include "audio.hch" #include "fft.hch" #include "debug.hch" /* * Forward declarations */ static macro expr ClockRate = PAL_ACTUAL_CLOCK_RATE; //EQ settings for the FFT ram unsigned 4 EQ_info[128] with { block = "BlockRAM"}; //EQ settings received from the display extern mpram DualPortRam AudioIn; extern mpram DualPortRam AudioOut; extern chan unsigned 1 AudioOutReady; chan unsigned 1 AudioInReady; #if HARDWARE_MULTIPLY signed 18 *audioptr_in1,*audioptr_in2,*audioptr_in3,*audioptr_in4; signed 18 *audioptr_out1,*audioptr_out2; unsigned 6 *displayptr1,*displayptr2,*displayptr3,*displayptr4; #else signed 16 *audioptr_in1,*audioptr_in2,*audioptr_in3,*audioptr_in4; signed 16 *audioptr_out1,*audioptr_out2; #endif /* * FFT routine */ macro proc audio_main(AUDIOIN, AUDIOOUT) { signed 18 sample; unsigned 6 sample_count; unsigned 8 i,cycle; unsigned 4 eqinfo; unsigned 1 FFT_Sync, first; macro expr OW = PalAudioOutGetMaxDataWidthCT (); macro expr IW = PalAudioInGetMaxDataWidthCT (); signed LeftNew, RightNew; signed Output_sample; ram unsigned 6 input[64]; //pointers for double and quadruple buffering: audioptr_in1 = &AudioIn.audio_io[0]; audioptr_in2 = &AudioIn.audio_io[64]; audioptr_in3 = &AudioIn.audio_io[128]; audioptr_in4 = &AudioIn.audio_io[192]; audioptr_out1 = &AudioOut.audio_io[0]; audioptr_out2 = &AudioOut.audio_io[64]; FFT_Sync=0; par { for(;;) { if (FFT_Sync) //if 64 samples are read from ADC... { par { // switch pointers audioptr_in1 = audioptr_in2; audioptr_in2 = audioptr_in3; audioptr_in3 = audioptr_in4; audioptr_in4 = audioptr_in1; audioptr_out1 = audioptr_out2; audioptr_out2 = audioptr_out1; FFT_Sync = 0; } AudioInReady ! sync; } else delay; } for(sample_count=0;;)//store the samples in the inputbuffer { if (!FFT_Sync) { par { seq { PalAudioInRead(AUDIOIN, &LeftNew, &RightNew); #if HARDWARE_MULTIPLY audioptr_in1[sample_count] = LeftNew;//drop 2 LSB's #else audioptr_in1[sample_count] = (LeftNew\\2);//drop 2 LSB's #endif sample_count++; if (!sample_count) { FFT_Sync = 1; } } seq { Output_sample = audioptr_out2[sample_count]; } } } else { delay; } } for(;;) { PalAudioOutWrite(AUDIOOUT,(signed OW)(Output_sample @ 0),(signed OW)(Output_sample @ 0)); } }//end par }// end function #endif