/**************************************************************** * * * 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 "config.hch" #include "debug.hch" #include "fft.hch" #include "runfft.hch" #include "presets.hch" /* * Forward declarations */ static macro expr ClockRate = PAL_ACTUAL_CLOCK_RATE; #if HARDWARE_MULTIPLY //input buffer ram signed 18 audio_buffer_in[256] with { block = "BlockRAM"}; //output buffer ram signed 18 audio_buffer_out[128] with { block = "BlockRAM"}; #else //input buffer ram signed 16 audio_buffer_in[256] with { block = "BlockRAM"}; //output buffer ram signed 16 audio_buffer_out[128] with { block = "BlockRAM"}; #endif //EQ settings for the FFT ram unsigned 4 EQ_info[128] with { block = "BlockRAM"}; //EQ settings received from the display mpram { ram unsigned 4 write[768]; rom unsigned 4 read[768]; }EQ_level with { block = "BlockRAM"}; mpram { ram unsigned 7 write[256]; rom unsigned 7 read[256]; }fft_info with { block = "BlockRAM"}; #if HARDWARE_MULTIPLY signed 18 *audioptr_in1,*audioptr_in2,*audioptr_in3,*audioptr_in4; signed 18 *audioptr_out1,*audioptr_out2; signed 18 *audioptr_temp; #else signed 16 *audioptr_in1,*audioptr_in2,*audioptr_in3,*audioptr_in4; signed 16 *audioptr_out1,*audioptr_out2; signed 16 *audioptr_temp; #endif unsigned 3 active_preset; shared expr preset_address = (0@(active_preset-1))<<7; void LoadPresets() { unsigned 16 temp; unsigned 10 count; unsigned 8 index; count=0; do { par { temp = presets[index]; index++; } par { EQ_level.write[count] = temp[7:4]; count++; } par { EQ_level.write[count] = temp[3:0]; count++; } par { EQ_level.write[count] = temp[15:12]; count++; } par { EQ_level.write[count] = temp[11:8]; count++; } } while (count<768); } /* * FFT routine */ macro proc RunFFT (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]; active_preset = 3; //pointers for double and quadruple buffering: audioptr_in1=&audio_buffer_in[0]; audioptr_in2=&audio_buffer_in[64]; audioptr_in3=&audio_buffer_in[128]; audioptr_in4=&audio_buffer_in[192]; audioptr_out1=&audio_buffer_out[0]; audioptr_out2=&audio_buffer_out[64]; FFT_Sync=0; LoadPresets(); first = 1; 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; } // FFT calculation perform_fft(audioptr_in1); #if 1 for(i=0;i