#include #include #include //I like these definitions #define begin { #define end } #define int2fix(a) (((int)(a))<<8) #define fix2int(a) ((signed char)((a)>>8)) #define float2fix(a) ((int)((a)*256.0)) #define fix2float(a) ((float)(a)/256.0) #define N_WAVE 16 /* size of FWT */ #define LOG2_N_WAVE 4 /* log2(N_WAVE) */ int fwt_t1, fwt_t2; int ain1[N_WAVE], ain0[N_WAVE] ; //double buffer inputs char countISR, Nbuffer; //Nbuffer keeps track of which buffer is in use //reordering tables flash char reorder16[16] = {0,15,7,8,3,12,4,11,1,14,6,9,2,13,5,10}; //======================================================== void FWTfix(int x[]) // This routine does foward transform only //output is in dyadic order -- see web links //use FWTreorder() to put the transform in sequency order begin unsigned char ii, k, j, i, bb, st; bb = N_WAVE/2; st = N_WAVE; // for (i=1; i>1 ; //scale to keep fixed pt in range fwt_t2 = x[ii+bb] >>1 ; x[ii] = fwt_t1 + fwt_t2 ; // x[ii+bb] = fwt_t1 - fwt_t2 ; end end bb = bb>>1 ; st = st>>1 ; end end //======================================================== void FWTreorder(int x[], flash char r[]) //converts from dyadic order to sequency order -- see references begin char i,j; int xp[N_WAVE]; for (i=0; icompare[i-1]) m = i; end //combine threshold and max and light leds if((m == 7) && (compare[7]>th)) PORTB.0 = 0; else PORTB.0 = 1; if((m == 6) && (compare[6]>th)) PORTB.1 = 0; else PORTB.1 = 1; if((m == 5) && (compare[5]>th)) PORTB.2 = 0; else PORTB.2 = 1; if((m == 4) && (compare[4]>th)) PORTB.3 = 0; else PORTB.3 = 1; if((m == 3) && (compare[3]>th)) PORTB.4 = 0; else PORTB.4 = 1; if((m == 2) && (compare[2]>th)) PORTB.5 = 0; else PORTB.5 = 1; if((m == 1) && (compare[1]>th)) PORTB.6 = 0; else PORTB.6 = 1; if((m == 0) && (compare[0]>th)) PORTB.7 = 0; else PORTB.7 = 1; end end end