Subversion Repositories svnkaklik

Compare Revisions

Regard whitespace Rev 541 → Rev 542

/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,12 → 438,12
delay[2] = n;
r = correlationr[n];
}
}
}*/
 
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);