Subversion Repositories svnkaklik

Compare Revisions

Ignore whitespace Rev 563 → Rev 564

/programy/C/ix86/echo/SW/plot.gn
3,21 → 3,21
set origin 0,0
set multiplot
 
set size 1,0.2
set size 0.9,0.2
set origin 0,0.8
set xrange [0:150]
set autoscale y
plot "/tmp/chirp.txt" using 1:2 with lines title 'chirp'
 
set size 1,0.4
set size 0.9,0.4
set origin 0,0.4
set xrange [0:3000]
set xrange [0:1000]
set autoscale y
plot "/tmp/sonar.txt" using 1:2 with lines title 'L echo', "" using 1:3 with lines title 'R echo'
 
set size 1,0.4
set origin 0,0.0
set xrange [0:3000]
set size 0.9,0.4
set origin 0,0
set xrange [0:1000]
set yrange [0:1e9]
#set autoscale y
plot "/tmp/sonar.txt" using 1:4 with lines title 'L correlation', "" using 1:5 with lines title 'R correlation'
/programy/C/ix86/echo/SW/sonar/sonar.kdevelop
14,8 → 14,8
<projectname>sonar</projectname>
<projectdirectory>.</projectdirectory>
<absoluteprojectpath>false</absoluteprojectpath>
<description></description>
<defaultencoding></defaultencoding>
<description/>
<defaultencoding/>
<versioncontrol>kdevsubversion</versioncontrol>
</general>
<kdevautoproject>
26,8 → 26,8
<run>
<mainprogram>/home/kaklik/projects/programy/C/ix86/echo/SW/sonar/debug</mainprogram>
<terminal>true</terminal>
<programargs></programargs>
<globaldebugarguments></globaldebugarguments>
<programargs/>
<globaldebugarguments/>
<globalcwd>/home/kaklik/projects/programy/C/ix86/echo/SW/sonar</globalcwd>
<useglobalprogram>false</useglobalprogram>
<autocompile>false</autocompile>
62,20 → 62,20
</debug>
<default>
<envvars/>
<configargs></configargs>
<builddir></builddir>
<topsourcedir></topsourcedir>
<cppflags></cppflags>
<configargs/>
<builddir/>
<topsourcedir/>
<cppflags/>
<ldflags>-lasound -lfftw3</ldflags>
<ccompiler>kdevgccoptions</ccompiler>
<cxxcompiler>kdevgppoptions</cxxcompiler>
<f77compiler>kdevg77options</f77compiler>
<ccompilerbinary></ccompilerbinary>
<cxxcompilerbinary></cxxcompilerbinary>
<f77compilerbinary></f77compilerbinary>
<cflags></cflags>
<cxxflags></cxxflags>
<f77flags></f77flags>
<ccompilerbinary/>
<cxxcompilerbinary/>
<f77compilerbinary/>
<cflags/>
<cxxflags/>
<f77flags/>
</default>
</configurations>
<make>
87,7 → 87,7
<runmultiplejobs>false</runmultiplejobs>
<numberofjobs>1</numberofjobs>
<dontact>false</dontact>
<makebin></makebin>
<makebin/>
<prio>0</prio>
</make>
</kdevautoproject>
216,7 → 216,7
<includePaths>.;</includePaths>
</codecompletion>
<creategettersetter>
<prefixGet></prefixGet>
<prefixGet/>
<prefixSet>set</prefixSet>
<prefixVariable>m_,_</prefixVariable>
<parameterName>theValue</parameterName>
237,11 → 237,11
</cppsupportpart>
<kdevdebugger>
<general>
<gdbpath></gdbpath>
<gdbpath/>
<dbgshell>libtool</dbgshell>
<configGdbScript></configGdbScript>
<runShellScript></runShellScript>
<runGdbScript></runGdbScript>
<configGdbScript/>
<runShellScript/>
<runGdbScript/>
<breakonloadinglibs>true</breakonloadinglibs>
<separatetty>false</separatetty>
<floatingtoolbar>false</floatingtoolbar>
/programy/C/ix86/echo/SW/sonar/src/sonar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/programy/C/ix86/echo/SW/sonar/src/sonar.c
175,7 → 175,7
unsigned int maxval = (1 << (snd_pcm_format_width(format) - 1)) - 1;
 
static const float f0 = 5000; //starting frequency
static const float fmax = 13000; //ending frequency
static const float fmax = 7500; //ending frequency
static const float Tw = 0.0015;
static float k;
 
314,13 → 314,14
}
else printf("Waiting for transmitt all samples\n");
//--------------
while ( snd_pcm_avail_update(capture_handle) < period_size)
 
while ( snd_pcm_avail_update(capture_handle) < period_size) // wait for one period of data
{
usleep(1000);
printf(".");
}
 
err = snd_pcm_drop(playback_handle);
err = snd_pcm_drop(playback_handle); // stop audio stream
err = snd_pcm_drain(capture_handle);
if (err < 0)
{
328,7 → 329,7
exit(EXIT_FAILURE);
}
 
err = snd_pcm_readi(capture_handle, signal, period_size);
err = snd_pcm_readi(capture_handle, signal, period_size); //read period from audio buffer
if (err < 0)
{
printf("Read error: %s\n", snd_strerror(err));
374,27 → 375,36
}
}
 
for(i=delayl[1]; i < delayl[1] + chirp_size; i++) inchirp[i-delayl[1]] = L_signal[i];
fftw_execute(fft_plan_chirp);
for(i=0; i < frequency_bins; i++) echo_spect[i] = sqrt(outchirp[i][0] * outchirp[i][0] + outchirp[i][1] * outchirp[i][1]);
 
printf("Writing output file\n");
printf("Writing output files\n");
out=fopen("/tmp/sonar.txt","w");
j=0;
for (i=0; i <= (period_size - 1); i++)
{
fprintf(out,"%6d %6d %6d %9ld %9ld\n",i,L_signal[i],R_signal[i],correlationl[i], correlationr[i]);
j+=2;
}
fclose(out);
 
out=fopen("/tmp/chirp.txt","w");
j=0;
for (i=0; i <= (chirp_size - 1); i++)
{
fprintf(out,"%6d %6d %f\n", i, chirp[i], chirp_spect[i]);
j+=2;
fprintf(out,"%6d %6d\n", i, chirp[i]);
}
fclose(out);
 
out=fopen("/tmp/echo.txt","w");
for(i=delayl[1]; i < delayl[1] + chirp_size; i++) fprintf(out,"%6d %6d\n", i-delayl[1], L_signal[i]);
fclose(out);
 
out=fopen("/tmp/spektra.txt","w");
for (i=0; i < frequency_bins; i++)
{
fprintf(out,"%4.3f %4.3f %4.3f\n", (i+0.5) * df, chirp_spect[i], echo_spect[i]);
}
fclose(out);
 
printf("Echo zacina na: %d vzorku.\n", delayl[1]);
printf("Casove na: %f s\n", ((float)delayl[1]/rate));
printf("vzdalenost: %f m\n", (SOUND_SPEED*(float)delayl[1]/rate));
/programy/C/ix86/echo/SW/spektra.gn
0,0 → 1,32
!./sonar/src/sonar
set size 1,1
set origin 0,0
set multiplot
 
set size 0.5,0.2
set origin 0,0.8
set xrange [0:250]
set autoscale y
plot "/tmp/chirp.txt" using 1:2 with lines title 'echo'
 
set size 0.5,0.2
set origin 0.5,0.8
set xrange [0:250]
set autoscale y
plot "/tmp/echo.txt" using 1:2 with lines title 'echo'
 
set size 1,0.4
set origin 0,0.4
set xrange [2500:25000]
#set yrange [0:1e9]
set autoscale y
plot "/tmp/spektra.txt" using 1:2 with lines title 'chirp spectrum'
 
set size 1,0.4
set origin 0,0.0
set xrange [2500:25000]
#set yrange [0:1e9]
set autoscale y
plot "/tmp/spektra.txt" using 1:3 with lines title 'echo spectrum'
pause 1
reread