Advertisement
martaczaska

ZPS3_4

May 31st, 2020
977
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.54 KB | None | 0 0
  1. #include <dsplib.h>
  2. #include <testsignal.h>
  3. #include <okno_hamminga.h>
  4. #include <stdio.h>
  5.  
  6. #define NUM_SAMPLES 2048
  7.  
  8. int klarnet[NUM_SAMPLES];
  9. int testowa[NUM_SAMPLES]; //potem usunąć
  10. int okno_h[NUM_SAMPLES];
  11.  
  12. int i;
  13. int j = 0;
  14. int roznica = 0;
  15. int znalezione = 0;
  16. int maks = 0;
  17.  
  18. const long f_s = 48000;
  19. const int N = 2048;
  20.  
  21. void maksimum(int* tablica, int podloga, int number){
  22.  
  23.     for(i = 0; i < number; i++){
  24.  
  25.             if(tablica[i] > podloga){
  26.                 roznica = tablica[i] - tablica[i - 1];
  27.                 if(roznica > 0){
  28.                     maks = i;
  29.                     znalezione = 1;
  30.                     printf("%d \n", maks);
  31.                 }
  32.                 else{
  33.                     if(znalezione==1 && (roznica < 0)){
  34.                         break;
  35.                     }
  36.                     else{continue;}
  37.                 }
  38.             }
  39.             else{continue;}
  40.     }
  41.  
  42. }
  43.  
  44. void czestotliwosc(int p){
  45.     int df = f_s / N;
  46.     df = df << 15;
  47.     int f_maks = _smpy(p, df);              //format Q30
  48.  
  49.     f_maks = _sround(f_maks) >> 15;
  50.  
  51.     printf("%d \n", f_maks);
  52.  
  53. }
  54.  
  55.  
  56. void main(void) {
  57.     int x = okno_hamminga[0];
  58.  
  59.  
  60.     for (i = 0; i < NUM_SAMPLES; i++){
  61.         klarnet[i] = testsignal[i];
  62.         //klarnet[i] = _smpy(okno_hamminga[i], testsignal[i]);
  63.         testowa[i] = testsignal[i];
  64.     }
  65.  
  66.     rfft((DATA*)klarnet, NUM_SAMPLES, SCALE);                  // do 2.
  67.  
  68.     for (i = 0; i < NUM_SAMPLES; i++){
  69.         klarnet[i] = _smpy(klarnet[i], klarnet[i]);          //do 2.
  70.     }
  71.  
  72.     for(i = 2; i < NUM_SAMPLES; i = i + 2){
  73.         klarnet[j] = klarnet[i] + klarnet[i + 1];
  74.         j++;
  75.     }
  76.  
  77.     sqrt_16((DATA*)klarnet, (DATA*)klarnet, 512);
  78.  
  79.     maksimum(klarnet, 2800, NUM_SAMPLES);
  80.     czestotliwosc(maks);
  81.  
  82.     while (1); // do not exit
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement