Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <dsplib.h>
- #include <testsignal.h>
- #include <okno_hamminga.h>
- #include <stdio.h>
- #define NUM_SAMPLES 2048
- #define Nr 1000
- int klarnet[NUM_SAMPLES];
- int testowa[NUM_SAMPLES]; //potem usunąć
- int okno_h[NUM_SAMPLES];
- int bufor[NUM_SAMPLES];
- int autokorelacja[Nr];
- int i;
- int j = 0;
- int roznica = 0;
- int znalezione;
- int maks = 0;
- const long f_s = 48000;
- const int N = 2048;
- void maksimum(int* tablica, int podloga, int number){
- znalezione = 0;
- for(i = 0; i < number; i++){
- if(tablica[i] > podloga){
- roznica = tablica[i] - tablica[i - 1];
- if(roznica > 0){
- maks = i;
- znalezione = 1;
- printf("Indeks maksimum: ");
- printf("%d \n", maks);
- }
- else{
- if(znalezione==1 && (roznica < 0)){
- //znalezione = 0; //myslałam, że potrzebne dla 5. ale co nie
- break;
- }
- else{continue;}
- }
- }
- else{continue;}
- }
- }
- void czestotliwosc(int p){
- long df = f_s / N;
- df = df << 15;
- long f_maks = _smpy(p, df); // >> 15; //format Q30
- //f_maks = _sround(f_maks) >> 15;
- printf("Częstotliwosc znalezionego maksimum wynosi: ");
- printf("%d \n", f_maks);
- }
- void main(void) {
- int x = okno_hamminga[0];
- for (i = 0; i < NUM_SAMPLES; i++){
- klarnet[i] = testsignal[i];
- //klarnet[i] = _smpy(okno_hamminga[i], testsignal[i]);
- testowa[i] = testsignal[i];
- }
- rfft((DATA*)klarnet, NUM_SAMPLES, SCALE); // do 2.
- for (i = 0; i < NUM_SAMPLES; i++){
- klarnet[i] = _smpy(klarnet[i], klarnet[i]); //do 2.
- }
- for(i = 2; i < NUM_SAMPLES; i = i + 2){
- klarnet[j] = klarnet[i] + klarnet[i + 1];
- j++;
- }
- sqrt_16((DATA*)klarnet, (DATA*)klarnet, 512);
- maksimum(klarnet, 2800, NUM_SAMPLES);
- printf("%d \n", maks);
- czestotliwosc(maks);
- /////////////////do 5. :
- for (i = 0; i < NUM_SAMPLES; i++){
- bufor[i] = testsignal[i] >> 4;
- }
- acorr((DATA*)bufor, (DATA*)autokorelacja, NUM_SAMPLES, Nr, bias);
- maksimum(autokorelacja, 10, NUM_SAMPLES);
- //koniec 5.
- while (1); // do not exit
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement