martaczaska

blockfir_2

May 16th, 2020
1,305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.26 KB | None | 0 0
  1. /*
  2. WYKONAŁA: MARTA TRZASKA 171632
  3. TELEKOMUNIKACJA 1, SEMESTR 6
  4. */
  5.  
  6. #include <dsplib.h>
  7.  
  8. //częstotliwosc graniczna filtru dolnoprzepustowego: fc=1320
  9. //długoć filtru N = 57
  10.  
  11. #define NUM_SAMPLES 5000
  12. int samples[NUM_SAMPLES];
  13.  
  14. #define N 57
  15.  
  16. const short filtr_fir[] = {-30, -32, -36, -41, -46, -51, -53, -50, -41,
  17. -23, 6, 49, 106, 178, 267,372, 492, 624, 766, 914, 1064, 1212, 1353,
  18. 1482, 1594, 1687, 1755, 1797, 1811, 1797,1755, 1687, 1594, 1482, 1353,
  19. 1212, 1064, 914, 766, 624, 492, 372, 267, 178, 106,49, 6, -23, -41
  20. , -50, -53, -51, -46, -41, -36, -32, -30}; //suma współczynników = 32441; 32441/2^15 = 0,990021 (przemnożenie przez 0.99 przed zaokrągleniem)
  21.  
  22. short white_noise[NUM_SAMPLES];
  23. int pila[NUM_SAMPLES];
  24.  
  25. short wynik[NUM_SAMPLES];
  26. short bufor[N]; //int (?)
  27. int indeks = 0;
  28.  
  29.  
  30.  
  31. void blockfir(short* input, const short* filter, short* output, int numSamples, int numFilter){
  32.     int i;
  33.     int j;
  34.  
  35.     for(j = 0; j < numSamples; j++){
  36.         long y = 0;
  37.  
  38.             for(i = 0; i < N; i++){
  39.                 y = _smaci(y, input[i], filter[i]);
  40.             }
  41.  
  42.         output[j] = (short)(_sround(y) >> 15);
  43.     }
  44. }
  45.  
  46. void main(void) {
  47.     rand16init();
  48.     rand16((DATA*)white_noise, NUM_SAMPLES);
  49.  
  50.     blockfir(white_noise, filtr_fir, wynik, NUM_SAMPLES, N);
  51.  
  52.     while (1); // do not exit
  53. }
Advertisement
Add Comment
Please, Sign In to add comment