martaczaska

blockfir_final

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