#include "stdio.h" #define BUF_THRESHOLD 9 int main(void) { volatile int * red_LED_ptr = (int *) 0x01111000; // red LED address volatile int * green_LED_ptr = (int *) 0x01111010; // green LED address volatile int * audio_ptr = (int *) 0x01111050; // audio port address int * sw_ptr = (int *) 0x01111020; // sw address int fifospace, left_data, right_data, mono_data; int x[3], y[3]; int gain,b1,b2; gain=3300; // 0.05 b2=65259; // 0.95 b1=-124000; // -1.9 printf("Starting \n"); while(1) { fifospace = *(audio_ptr + 1); // read the audio port fifospace register if ( (fifospace & 0x000000FF) > BUF_THRESHOLD ) // check RARC { // store data until the the audio-in FIFO is empty while (fifospace & 0x000000FF) { left_data = *(audio_ptr + 2); right_data = *(audio_ptr + 3); mono_data = (left_data+right_data)>>2; x[2]=x[1];x[1]=x[0]; x[0]= mono_data; y[2]=y[1];y[1]=y[0]; y[0]=(gain*((x[0]-x[2])>>16))-(b1*(y[1]>>16))-(b2*(y[2]>>16)); mono_data= y[0]; *(audio_ptr + 2) = mono_data; *(audio_ptr + 3) = mono_data; fifospace = *(audio_ptr + 1); // read the audio port fifospace register *(green_LED_ptr) = (fifospace & 0x00FF0000); *(red_LED_ptr) = (fifospace & 0x000000FF); } } } }