26,6 → 26,7 |
static int period_event = 0; /* produce poll event after each period */ |
|
#define SOUND_SPEED 340 |
#define SIGNAL_SAMPLES 100000 |
|
unsigned int chirp_size; |
|
187,8 → 188,8 |
{ |
unsigned int maxval = (1 << (snd_pcm_format_width(format) - 1)) - 1; |
|
static const float f0 = 8000; |
static const float fmax = 10000; |
static const float f0 = 3000; |
static const float fmax = 5000; |
static const float Tw = 0.002; |
static float k; |
|
356,14 → 357,6 |
exit(EXIT_FAILURE); |
} |
|
//start playback |
if (snd_pcm_state(playback_handle) == SND_PCM_STATE_PREPARED) { |
err = snd_pcm_start(playback_handle); |
if (err < 0) { |
printf("Start error: %s\n", snd_strerror(err)); |
exit(EXIT_FAILURE); |
} |
} |
|
//start capture |
if ((err = snd_pcm_prepare (capture_handle)) < 0) { |
377,6 → 370,17 |
printf("Start error: %s\n", snd_strerror(err)); |
exit(EXIT_FAILURE); |
} |
|
|
//start playback |
if (snd_pcm_state(playback_handle) == SND_PCM_STATE_PREPARED) { |
err = snd_pcm_start(playback_handle); |
if (err < 0) { |
printf("Start error: %s\n", snd_strerror(err)); |
exit(EXIT_FAILURE); |
} |
} |
|
|
//wait until all samples aren't transmitted |
printf("Waiting for transmitt all samples\n"); |
386,12 → 390,10 |
} |
printf("\nData transmitted... \ncorrelating...\n"); |
|
#define SIGNAL_SAMPLES 100000 |
|
for(n=0; n < (SIGNAL_SAMPLES - chirp_size);n++){ //spocita korelaci pro mozna spozdeni |
r=0; |
for(m=0;m < chirp_size;m++) r += chirp[m]*signal[m+n]; |
correlation[n]=r; |
for(m=chirp_size;m > 0;m--) r += chirp[m]*signal[m+n]; // reverse echo patern |
correlation[n]=abs(r); |
} |
|
printf("\nFinding echos...\n"); |