Subversion Repositories svnkaklik

Compare Revisions

Ignore whitespace Rev 541 → Rev 542

/programy/C/ix86/signals/correlation
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/programy/C/ix86/signals/correlation.c
11,7 → 11,7
int sample[SAMPLES];
int signal[SIGNAL_SAMPLES];
 
double correlation[SIGNAL_SAMPLES];
long int correlation[SIGNAL_SAMPLES];
 
int obdelnik(int *pole, int delka_pole, int delka_pulsu, int spozdeni) //generuje testovaci lichobeznikovy puls do zadaneho pole
{
20,11 → 20,11
for (i=0; i <= delka_pole; i++) {
if (i < spozdeni && i < delka_pole) pole[i]=value;
 
if ((i > spozdeni) && (i < (spozdeni+10))) pole[i] = value++;
if ((i > spozdeni) && (i <= (spozdeni+10))) pole[i] = value++;
 
if (i < (spozdeni+delka_pulsu+10) && i > (spozdeni+10) && i < delka_pole) pole[i]= value;
 
if (i < (spozdeni+delka_pulsu+19) && i > (spozdeni+delka_pulsu+10) && i < delka_pole) pole[i] = value--;
if (i <= (spozdeni+delka_pulsu+19) && i > (spozdeni+delka_pulsu+9) && i < delka_pole) pole[i] = value--;
 
if (i > (spozdeni+delka_pulsu+19) && i < delka_pole) pole[i]=value;
}
39,7 → 39,7
int t;
float ble;
if((spozdeni+delka_pulsu) < delka_pole)
for(t=0;t < delka_pulsu;t++) pole[spozdeni+t] = round ( 100*sin(2*pi*t*(f0+(k/2)*t)) );
for(t=0;t < delka_pulsu;t++) pole[spozdeni+t] = floor( 100*sin(2*pi*t*(f0+(k/2)*t)) );
else return 0;
 
}
53,7 → 53,7
int t;
float ble;
if((spozdeni+delka_pulsu) < delka_pole)
for(t=0;t < delka_pulsu;t++) pole[spozdeni+t] = round ( 100*sin(2*pi*t*(f0+(k/2)*t)) );
for(t=0;t < delka_pulsu;t++) pole[spozdeni+t] = floor ( 100*sin(2*pi*t*(f0+(k/2)*t)) );
else return 0;
 
}
62,11 → 62,11
int main (void)
{
int i,n,m,delay;
double r;
long int r;
FILE *out;
 
obdelnik(sample,SAMPLES,100,0); // vyrobi vzorek signalu
obdelnik(signal,SIGNAL_SAMPLES,100,1100); // vyrobi signal ve kterem se vzorek hleda
linear_chirp(sample,SAMPLES,200,0); // vyrobi vzorek signalu
linear_chirp(signal,SIGNAL_SAMPLES,200,500); // vyrobi signal ve kterem se vzorek hleda
 
for(n=0; n < (SIGNAL_SAMPLES - SAMPLES);n++){ //spocita korelaci pro mozna spozdeni
r=0;
86,9 → 86,9
for(i=0;i< SIGNAL_SAMPLES;i++)
{
// fprintf(stdout,"%3u ",i); // vypise cislo bunky v poli (spozdeni)
// fprintf(stdout,"%2i ",sample[i]);
// fprintf(stdout,"%2i ",sample[i]);
// fprintf(stdout,"%2d ",signal[i]);
fprintf(out,"%3.2f\n",correlation[i]); // vypise hodnotu korelace nejvissi cislo je nejvetsi korelace.
fprintf(out,"%d %d %d %ld \n",i,sample[i], signal[i], correlation[i]); // vypise hodnotu korelace nejvissi cislo je nejvetsi korelace.
}
fprintf(stdout,"\nvzorek v signalu zacina na miste: %3u \n",delay);
fclose(out);
/programy/C/ix86/sound/sonar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/programy/C/ix86/sound/sonar.c
26,7 → 26,7
 
#define SOUND_SPEED 340
#define SIGNAL_SAMPLES 100000
#define CHIRP_OFFSET 300
#define CHIRP_OFFSET 0
 
unsigned int chirp_size;
 
302,8 → 302,10
unsigned int i,j,m,n;
unsigned int delay[10]; //store delay of signifed correlation
long int l,r; // store correlation at strict time
long int correlationl[100000]; //array to store correlation curve
long int correlationr[100000]; //array to store correlation curve
long int correlationl[SIGNAL_SAMPLES]; //array to store correlation curve
long int correlationr[SIGNAL_SAMPLES]; //array to store correlation curve
int L_signal[SIGNAL_SAMPLES];
int R_signal[SIGNAL_SAMPLES];
 
FILE *out;
 
403,24 → 405,28
sleep(1);
printf(".");
}
////
j=0;
for(i=0;i < SIGNAL_SAMPLES;i++){
L_signal[i]=signal[j];
R_signal[i]=signal[j+1];
j+=2;
}
 
printf("\nData transmitted... \ncorrelating...\n");
i=0;
for(n=0; n < (SIGNAL_SAMPLES - chirp_size);n++){ //we have interleaved data we must have 2 saples step
for(n=0; n < (SIGNAL_SAMPLES - chirp_size);n++){
l=0;
r=0;
j=0;
for(m=CHIRP_OFFSET;m < chirp_size;m++)
for(m=CHIRP_OFFSET;m < 500;m++)
{
l += chirp[m]*signal[i+j]; // correlate with left channel
r += chirp[m]*signal[i+j+1]; // correlate with right channel
j+=2;
l += chirp[m]*L_signal[m+n]; // correlate with left channel
r += chirp[m]*R_signal[m+n]; // correlate with right channel
}
correlationl[n]=l;
correlationr[n]=r;
i+=2;
}
 
printf("\nSearching echos...\n");
/* printf("\nSearching echos...\n");
r=0;
l=0;
for(n=0; n < (SIGNAL_SAMPLES - chirp_size);n++){ //najde nejvetsi korelace
432,15 → 438,15
delay[2] = n;
r = correlationr[n];
}
}
}*/
 
out=fopen("./output.txt","w");
out=fopen("./output.txt","w");
j=0;
for(i=0;i<=60000;i++){
fprintf(out,"%6d %6d %6d %6d %9ld %9ld\n",i,chirp[i],signal[j],signal[j+1],correlationl[i], correlationr[i]);
fprintf(out,"%6d %6d %6d %6d %9ld %9ld\n",i,chirp[i],L_signal[i],R_signal[i],correlationl[i], correlationr[i]);
j+=2;
}
fclose(out);
fclose(out);
 
printf("\nEcho zacina na: %d vzorku.\n", delay[1]);
printf("Casove na: %f s\n", ((float)delay[1]/rate));