annotate src/libsamplerate-0.1.8/tests/src-evaluate.c @ 83:ae30d91d2ffe

Replace these with versions built using an older toolset (so as to avoid ABI compatibilities when linking on Ubuntu 14.04 for packaging purposes)
author Chris Cannam
date Fri, 07 Feb 2020 11:51:13 +0000
parents c7265573341e
children
rev   line source
Chris@0 1 /*
Chris@0 2 ** Copyright (C) 2002-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
Chris@0 3 **
Chris@0 4 ** This program is free software; you can redistribute it and/or modify
Chris@0 5 ** it under the terms of the GNU General Public License as published by
Chris@0 6 ** the Free Software Foundation; either version 2 of the License, or
Chris@0 7 ** (at your option) any later version.
Chris@0 8 **
Chris@0 9 ** This program is distributed in the hope that it will be useful,
Chris@0 10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@0 11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@0 12 ** GNU General Public License for more details.
Chris@0 13 **
Chris@0 14 ** You should have received a copy of the GNU General Public License
Chris@0 15 ** along with this program; if not, write to the Free Software
Chris@0 16 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
Chris@0 17 */
Chris@0 18
Chris@0 19 #include <stdio.h>
Chris@0 20 #include <stdlib.h>
Chris@0 21 #include <unistd.h>
Chris@0 22 #include <string.h>
Chris@0 23 #include <ctype.h>
Chris@0 24
Chris@0 25 #include "config.h"
Chris@0 26
Chris@0 27 #if (HAVE_FFTW3 && HAVE_SNDFILE && HAVE_SYS_TIMES_H)
Chris@0 28
Chris@0 29 #include <time.h>
Chris@0 30 #include <sys/times.h>
Chris@0 31
Chris@0 32 #include <sndfile.h>
Chris@0 33 #include <math.h>
Chris@0 34 #include <sys/utsname.h>
Chris@0 35
Chris@0 36 #include "util.h"
Chris@0 37
Chris@0 38 #define MAX_FREQS 4
Chris@0 39 #define BUFFER_LEN 80000
Chris@0 40
Chris@0 41 #define SAFE_STRNCAT(dest,src,len) \
Chris@0 42 { int safe_strncat_count ; \
Chris@0 43 safe_strncat_count = (len) - strlen (dest) - 1 ; \
Chris@0 44 strncat ((dest), (src), safe_strncat_count) ; \
Chris@0 45 (dest) [(len) - 1] = 0 ; \
Chris@0 46 } ;
Chris@0 47
Chris@0 48 typedef struct
Chris@0 49 { int freq_count ;
Chris@0 50 double freqs [MAX_FREQS] ;
Chris@0 51
Chris@0 52 int output_samplerate ;
Chris@0 53 int pass_band_peaks ;
Chris@0 54
Chris@0 55 double peak_value ;
Chris@0 56 } SNR_TEST ;
Chris@0 57
Chris@0 58 typedef struct
Chris@0 59 { const char *progname ;
Chris@0 60 const char *version_cmd ;
Chris@0 61 const char *version_start ;
Chris@0 62 const char *convert_cmd ;
Chris@0 63 int format ;
Chris@0 64 } RESAMPLE_PROG ;
Chris@0 65
Chris@0 66 static char *get_progname (char *) ;
Chris@0 67 static void usage_exit (const char *, const RESAMPLE_PROG *prog, int count) ;
Chris@0 68 static void measure_program (const RESAMPLE_PROG *prog, int verbose) ;
Chris@0 69 static void generate_source_wav (const char *filename, const double *freqs, int freq_count, int format) ;
Chris@0 70 static const char* get_machine_details (void) ;
Chris@0 71
Chris@0 72 static char version_string [512] ;
Chris@0 73
Chris@0 74 int
Chris@0 75 main (int argc, char *argv [])
Chris@0 76 { static RESAMPLE_PROG resample_progs [] =
Chris@0 77 { { "sndfile-resample",
Chris@0 78 "examples/sndfile-resample --version",
Chris@0 79 "libsamplerate",
Chris@0 80 "examples/sndfile-resample --max-speed -c 0 -to %d source.wav destination.wav",
Chris@0 81 SF_FORMAT_WAV | SF_FORMAT_PCM_32
Chris@0 82 },
Chris@0 83 { "sox",
Chris@0 84 "sox -h 2>&1",
Chris@0 85 "sox",
Chris@0 86 "sox source.wav -r %d destination.wav resample 0.835",
Chris@0 87 SF_FORMAT_WAV | SF_FORMAT_PCM_32
Chris@0 88 },
Chris@0 89 { "ResampAudio",
Chris@0 90 "ResampAudio --version",
Chris@0 91 "ResampAudio",
Chris@0 92 "ResampAudio -f cutoff=0.41,atten=100,ratio=128 -s %d source.wav destination.wav",
Chris@0 93 SF_FORMAT_WAV | SF_FORMAT_PCM_32
Chris@0 94 },
Chris@0 95
Chris@0 96 /*-
Chris@0 97 { /+*
Chris@0 98 ** The Shibatch converter doesn't work for all combinations of
Chris@0 99 ** source and destination sample rates. Therefore it can't be
Chris@0 100 ** included in this test.
Chris@0 101 *+/
Chris@0 102 "shibatch",
Chris@0 103 "ssrc",
Chris@0 104 "Shibatch",
Chris@0 105 "ssrc --rate %d source.wav destination.wav",
Chris@0 106 SF_FORMAT_WAV | SF_FORMAT_PCM_32
Chris@0 107 },-*/
Chris@0 108
Chris@0 109 /*-
Chris@0 110 { /+*
Chris@0 111 ** The resample program is not able to match the bandwidth and SNR
Chris@0 112 ** specs or sndfile-resample and hence will not be tested.
Chris@0 113 *+/
Chris@0 114 "resample",
Chris@0 115 "resample -version",
Chris@0 116 "resample",
Chris@0 117 "resample -to %d source.wav destination.wav",
Chris@0 118 SF_FORMAT_WAV | SF_FORMAT_FLOAT
Chris@0 119 },-*/
Chris@0 120
Chris@0 121 /*-
Chris@0 122 { "mplayer",
Chris@0 123 "mplayer -v 2>&1",
Chris@0 124 "MPlayer ",
Chris@0 125 "mplayer -ao pcm -srate %d source.wav >/dev/null 2>&1 && mv audiodump.wav destination.wav",
Chris@0 126 SF_FORMAT_WAV | SF_FORMAT_PCM_32
Chris@0 127 },-*/
Chris@0 128
Chris@0 129 } ; /* resample_progs */
Chris@0 130
Chris@0 131 char *progname ;
Chris@0 132 int prog = 0, verbose = 0 ;
Chris@0 133
Chris@0 134 progname = get_progname (argv [0]) ;
Chris@0 135
Chris@0 136 printf ("\n %s : evaluate a sample rate converter.\n", progname) ;
Chris@0 137
Chris@0 138 if (argc == 3 && strcmp ("--verbose", argv [1]) == 0)
Chris@0 139 { verbose = 1 ;
Chris@0 140 prog = atoi (argv [2]) ;
Chris@0 141 }
Chris@0 142 else if (argc == 2)
Chris@0 143 { verbose = 0 ;
Chris@0 144 prog = atoi (argv [1]) ;
Chris@0 145 }
Chris@0 146 else
Chris@0 147 usage_exit (progname, resample_progs, ARRAY_LEN (resample_progs)) ;
Chris@0 148
Chris@0 149 if (prog < 0 || prog >= ARRAY_LEN (resample_progs))
Chris@0 150 usage_exit (progname, resample_progs, ARRAY_LEN (resample_progs)) ;
Chris@0 151
Chris@0 152 measure_program (& (resample_progs [prog]), verbose) ;
Chris@0 153
Chris@0 154 puts ("") ;
Chris@0 155
Chris@0 156 return 0 ;
Chris@0 157 } /* main */
Chris@0 158
Chris@0 159 /*==============================================================================
Chris@0 160 */
Chris@0 161
Chris@0 162 static char *
Chris@0 163 get_progname (char *progname)
Chris@0 164 { char *cptr ;
Chris@0 165
Chris@0 166 if ((cptr = strrchr (progname, '/')) != NULL)
Chris@0 167 progname = cptr + 1 ;
Chris@0 168
Chris@0 169 if ((cptr = strrchr (progname, '\\')) != NULL)
Chris@0 170 progname = cptr + 1 ;
Chris@0 171
Chris@0 172 return progname ;
Chris@0 173 } /* get_progname */
Chris@0 174
Chris@0 175 static void
Chris@0 176 usage_exit (const char *progname, const RESAMPLE_PROG *prog, int count)
Chris@0 177 { int k ;
Chris@0 178
Chris@0 179 printf ("\n Usage : %s <number>\n\n", progname) ;
Chris@0 180
Chris@0 181 puts (" where <number> specifies the program to test:\n") ;
Chris@0 182
Chris@0 183 for (k = 0 ; k < count ; k++)
Chris@0 184 printf (" %d : %s\n", k, prog [k].progname) ;
Chris@0 185
Chris@0 186 puts ("\n"
Chris@0 187 " Obviously to test a given program you have to have it available on\n"
Chris@0 188 " your system. See http://www.mega-nerd.com/SRC/quality.html for\n"
Chris@0 189 " the download location of these programs.\n") ;
Chris@0 190
Chris@0 191 exit (1) ;
Chris@0 192 } /* usage_exit */
Chris@0 193
Chris@0 194 static const char*
Chris@0 195 get_machine_details (void)
Chris@0 196 { static char namestr [256] ;
Chris@0 197
Chris@0 198 struct utsname name ;
Chris@0 199
Chris@0 200 if (uname (&name) != 0)
Chris@0 201 { snprintf (namestr, sizeof (namestr), "Unknown") ;
Chris@0 202 return namestr ;
Chris@0 203 } ;
Chris@0 204
Chris@0 205 snprintf (namestr, sizeof (namestr), "%s (%s %s %s)", name.nodename,
Chris@0 206 name.machine, name.sysname, name.release) ;
Chris@0 207
Chris@0 208 return namestr ;
Chris@0 209 } /* get_machine_details */
Chris@0 210
Chris@0 211
Chris@0 212 /*==============================================================================
Chris@0 213 */
Chris@0 214
Chris@0 215 static void
Chris@0 216 get_version_string (const RESAMPLE_PROG *prog)
Chris@0 217 { FILE *file ;
Chris@0 218 char *cptr ;
Chris@0 219
Chris@0 220 /* Default. */
Chris@0 221 snprintf (version_string, sizeof (version_string), "no version") ;
Chris@0 222
Chris@0 223 if (prog->version_cmd == NULL)
Chris@0 224 return ;
Chris@0 225
Chris@0 226 if ((file = popen (prog->version_cmd, "r")) == NULL)
Chris@0 227 return ;
Chris@0 228
Chris@0 229 while ((cptr = fgets (version_string, sizeof (version_string), file)) != NULL)
Chris@0 230 {
Chris@0 231 if (strstr (cptr, prog->version_start) != NULL)
Chris@0 232 break ;
Chris@0 233
Chris@0 234 version_string [0] = 0 ;
Chris@0 235 } ;
Chris@0 236
Chris@0 237 pclose (file) ;
Chris@0 238
Chris@0 239 /* Remove trailing newline. */
Chris@0 240 if ((cptr = strchr (version_string, '\n')) != NULL)
Chris@0 241 cptr [0] = 0 ;
Chris@0 242
Chris@0 243 /* Remove leading whitespace from version string. */
Chris@0 244 cptr = version_string ;
Chris@0 245 while (cptr [0] != 0 && isspace (cptr [0]))
Chris@0 246 cptr ++ ;
Chris@0 247
Chris@0 248 if (cptr != version_string)
Chris@0 249 strncpy (version_string, cptr, sizeof (version_string)) ;
Chris@0 250
Chris@0 251 return ;
Chris@0 252 } /* get_version_string */
Chris@0 253
Chris@0 254 static void
Chris@0 255 generate_source_wav (const char *filename, const double *freqs, int freq_count, int format)
Chris@0 256 { static float buffer [BUFFER_LEN] ;
Chris@0 257
Chris@0 258 SNDFILE *sndfile ;
Chris@0 259 SF_INFO sfinfo ;
Chris@0 260
Chris@0 261 sfinfo.channels = 1 ;
Chris@0 262 sfinfo.samplerate = 44100 ;
Chris@0 263 sfinfo.format = format ;
Chris@0 264
Chris@0 265 if ((sndfile = sf_open (filename, SFM_WRITE, &sfinfo)) == NULL)
Chris@0 266 { printf ("Line %d : cound not open '%s' : %s\n", __LINE__, filename, sf_strerror (NULL)) ;
Chris@0 267 exit (1) ;
Chris@0 268 } ;
Chris@0 269
Chris@0 270 sf_command (sndfile, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_FALSE) ;
Chris@0 271
Chris@0 272 gen_windowed_sines (freq_count, freqs, 0.9, buffer, ARRAY_LEN (buffer)) ;
Chris@0 273
Chris@0 274 if (sf_write_float (sndfile, buffer, ARRAY_LEN (buffer)) != ARRAY_LEN (buffer))
Chris@0 275 { printf ("Line %d : sf_write_float short write.\n", __LINE__) ;
Chris@0 276 exit (1) ;
Chris@0 277 } ;
Chris@0 278
Chris@0 279 sf_close (sndfile) ;
Chris@0 280 } /* generate_source_wav */
Chris@0 281
Chris@0 282 static double
Chris@0 283 measure_destination_wav (char *filename, int *output_samples, int expected_peaks)
Chris@0 284 { static float buffer [250000] ;
Chris@0 285
Chris@0 286 SNDFILE *sndfile ;
Chris@0 287 SF_INFO sfinfo ;
Chris@0 288 double snr ;
Chris@0 289
Chris@0 290 if ((sndfile = sf_open (filename, SFM_READ, &sfinfo)) == NULL)
Chris@0 291 { printf ("Line %d : Cound not open '%s' : %s\n", __LINE__, filename, sf_strerror (NULL)) ;
Chris@0 292 exit (1) ;
Chris@0 293 } ;
Chris@0 294
Chris@0 295 if (sfinfo.channels != 1)
Chris@0 296 { printf ("Line %d : Bad channel count (%d). Should be 1.\n", __LINE__, sfinfo.channels) ;
Chris@0 297 exit (1) ;
Chris@0 298 } ;
Chris@0 299
Chris@0 300 if (sfinfo.frames > ARRAY_LEN (buffer))
Chris@0 301 { printf ("Line %d : Too many frames (%ld) of data in file.\n", __LINE__, (long) sfinfo.frames) ;
Chris@0 302 exit (1) ;
Chris@0 303 } ;
Chris@0 304
Chris@0 305 *output_samples = (int) sfinfo.frames ;
Chris@0 306
Chris@0 307 if (sf_read_float (sndfile, buffer, sfinfo.frames) != sfinfo.frames)
Chris@0 308 { printf ("Line %d : Bad read.\n", __LINE__) ;
Chris@0 309 exit (1) ;
Chris@0 310 } ;
Chris@0 311
Chris@0 312 sf_close (sndfile) ;
Chris@0 313
Chris@0 314 snr = calculate_snr (buffer, sfinfo.frames, expected_peaks) ;
Chris@0 315
Chris@0 316 return snr ;
Chris@0 317 } /* measure_desination_wav */
Chris@0 318
Chris@0 319 static double
Chris@0 320 measure_snr (const RESAMPLE_PROG *prog, int *output_samples, int verbose)
Chris@0 321 { static SNR_TEST snr_test [] =
Chris@0 322 {
Chris@0 323 { 1, { 0.211111111111 }, 48000, 1, 1.0 },
Chris@0 324 { 1, { 0.011111111111 }, 132301, 1, 1.0 },
Chris@0 325 { 1, { 0.111111111111 }, 92301, 1, 1.0 },
Chris@0 326 { 1, { 0.011111111111 }, 26461, 1, 1.0 },
Chris@0 327 { 1, { 0.011111111111 }, 13231, 1, 1.0 },
Chris@0 328 { 1, { 0.011111111111 }, 44101, 1, 1.0 },
Chris@0 329 { 2, { 0.311111, 0.49 }, 78199, 2, 1.0 },
Chris@0 330 { 2, { 0.011111, 0.49 }, 12345, 1, 0.5 },
Chris@0 331 { 2, { 0.0123456, 0.4 }, 20143, 1, 0.5 },
Chris@0 332 { 2, { 0.0111111, 0.4 }, 26461, 1, 0.5 },
Chris@0 333 { 1, { 0.381111111111 }, 58661, 1, 1.0 }
Chris@0 334 } ; /* snr_test */
Chris@0 335 static char command [256] ;
Chris@0 336
Chris@0 337 double snr, worst_snr = 500.0 ;
Chris@0 338 int k , retval, sample_count ;
Chris@0 339
Chris@0 340 *output_samples = 0 ;
Chris@0 341
Chris@0 342 for (k = 0 ; k < ARRAY_LEN (snr_test) ; k++)
Chris@0 343 { remove ("source.wav") ;
Chris@0 344 remove ("destination.wav") ;
Chris@0 345
Chris@0 346 if (verbose)
Chris@0 347 printf (" SNR test #%d : ", k) ;
Chris@0 348 fflush (stdout) ;
Chris@0 349 generate_source_wav ("source.wav", snr_test [k].freqs, snr_test [k].freq_count, prog->format) ;
Chris@0 350
Chris@0 351 snprintf (command, sizeof (command), prog->convert_cmd, snr_test [k].output_samplerate) ;
Chris@0 352 SAFE_STRNCAT (command, " >/dev/null 2>&1", sizeof (command)) ;
Chris@0 353 if ((retval = system (command)) != 0)
Chris@0 354 printf ("system returned %d\n", retval) ;
Chris@0 355
Chris@0 356 snr = measure_destination_wav ("destination.wav", &sample_count, snr_test->pass_band_peaks) ;
Chris@0 357
Chris@0 358 *output_samples += sample_count ;
Chris@0 359
Chris@0 360 if (fabs (snr) < fabs (worst_snr))
Chris@0 361 worst_snr = fabs (snr) ;
Chris@0 362
Chris@0 363 if (verbose)
Chris@0 364 printf ("%6.2f dB\n", snr) ;
Chris@0 365 } ;
Chris@0 366
Chris@0 367 return worst_snr ;
Chris@0 368 } /* measure_snr */
Chris@0 369
Chris@0 370 /*------------------------------------------------------------------------------
Chris@0 371 */
Chris@0 372
Chris@0 373 static double
Chris@0 374 measure_destination_peak (const char *filename)
Chris@0 375 { static float data [2 * BUFFER_LEN] ;
Chris@0 376 SNDFILE *sndfile ;
Chris@0 377 SF_INFO sfinfo ;
Chris@0 378 double peak = 0.0 ;
Chris@0 379 int k = 0 ;
Chris@0 380
Chris@0 381 if ((sndfile = sf_open (filename, SFM_READ, &sfinfo)) == NULL)
Chris@0 382 { printf ("Line %d : failed to open file %s\n", __LINE__, filename) ;
Chris@0 383 exit (1) ;
Chris@0 384 } ;
Chris@0 385
Chris@0 386 if (sfinfo.channels != 1)
Chris@0 387 { printf ("Line %d : bad channel count.\n", __LINE__) ;
Chris@0 388 exit (1) ;
Chris@0 389 } ;
Chris@0 390
Chris@0 391 if (sfinfo.frames > ARRAY_LEN (data) + 4 || sfinfo.frames < ARRAY_LEN (data) - 100)
Chris@0 392 { printf ("Line %d : bad frame count (got %d, expected %d).\n", __LINE__, (int) sfinfo.frames, ARRAY_LEN (data)) ;
Chris@0 393 exit (1) ;
Chris@0 394 } ;
Chris@0 395
Chris@0 396 if (sf_read_float (sndfile, data, sfinfo.frames) != sfinfo.frames)
Chris@0 397 { printf ("Line %d : bad read.\n", __LINE__) ;
Chris@0 398 exit (1) ;
Chris@0 399 } ;
Chris@0 400
Chris@0 401 sf_close (sndfile) ;
Chris@0 402
Chris@0 403 for (k = 0 ; k < (int) sfinfo.frames ; k++)
Chris@0 404 if (fabs (data [k]) > peak)
Chris@0 405 peak = fabs (data [k]) ;
Chris@0 406
Chris@0 407 return peak ;
Chris@0 408 } /* measure_destination_peak */
Chris@0 409
Chris@0 410 static double
Chris@0 411 find_attenuation (double freq, const RESAMPLE_PROG *prog, int verbose)
Chris@0 412 { static char command [256] ;
Chris@0 413 double output_peak ;
Chris@0 414 int retval ;
Chris@0 415 char *filename ;
Chris@0 416
Chris@0 417 filename = "destination.wav" ;
Chris@0 418
Chris@0 419 generate_source_wav ("source.wav", &freq, 1, prog->format) ;
Chris@0 420
Chris@0 421 remove (filename) ;
Chris@0 422
Chris@0 423 snprintf (command, sizeof (command), prog->convert_cmd, 88189) ;
Chris@0 424 SAFE_STRNCAT (command, " >/dev/null 2>&1", sizeof (command)) ;
Chris@0 425 if ((retval = system (command)) != 0)
Chris@0 426 printf ("system returned %d\n", retval) ;
Chris@0 427
Chris@0 428 output_peak = measure_destination_peak (filename) ;
Chris@0 429
Chris@0 430 if (verbose)
Chris@0 431 printf (" freq : %f peak : %f\n", freq, output_peak) ;
Chris@0 432
Chris@0 433 return fabs (20.0 * log10 (output_peak)) ;
Chris@0 434 } /* find_attenuation */
Chris@0 435
Chris@0 436 static double
Chris@0 437 bandwidth_test (const RESAMPLE_PROG *prog, int verbose)
Chris@0 438 { double f1, f2, a1, a2 ;
Chris@0 439 double freq, atten ;
Chris@0 440
Chris@0 441 f1 = 0.35 ;
Chris@0 442 a1 = find_attenuation (f1, prog, verbose) ;
Chris@0 443
Chris@0 444 f2 = 0.49999 ;
Chris@0 445 a2 = find_attenuation (f2, prog, verbose) ;
Chris@0 446
Chris@0 447
Chris@0 448 if (fabs (a1) < 1e-2 && a2 < 3.0)
Chris@0 449 return -1.0 ;
Chris@0 450
Chris@0 451 if (a1 > 3.0 || a2 < 3.0)
Chris@0 452 { printf ("\n\nLine %d : cannot bracket 3dB point.\n\n", __LINE__) ;
Chris@0 453 exit (1) ;
Chris@0 454 } ;
Chris@0 455
Chris@0 456 while (a2 - a1 > 1.0)
Chris@0 457 { freq = f1 + 0.5 * (f2 - f1) ;
Chris@0 458 atten = find_attenuation (freq, prog, verbose) ;
Chris@0 459
Chris@0 460 if (atten < 3.0)
Chris@0 461 { f1 = freq ;
Chris@0 462 a1 = atten ;
Chris@0 463 }
Chris@0 464 else
Chris@0 465 { f2 = freq ;
Chris@0 466 a2 = atten ;
Chris@0 467 } ;
Chris@0 468 } ;
Chris@0 469
Chris@0 470 freq = f1 + (3.0 - a1) * (f2 - f1) / (a2 - a1) ;
Chris@0 471
Chris@0 472 return 200.0 * freq ;
Chris@0 473 } /* bandwidth_test */
Chris@0 474
Chris@0 475 static void
Chris@0 476 measure_program (const RESAMPLE_PROG *prog, int verbose)
Chris@0 477 { double snr, bandwidth, conversion_rate ;
Chris@0 478 int output_samples ;
Chris@0 479 struct tms time_data ;
Chris@0 480 time_t time_now ;
Chris@0 481
Chris@0 482 printf ("\n Machine : %s\n", get_machine_details ()) ;
Chris@0 483 time_now = time (NULL) ;
Chris@0 484 printf (" Date : %s", ctime (&time_now)) ;
Chris@0 485
Chris@0 486 get_version_string (prog) ;
Chris@0 487 printf (" Program : %s\n", version_string) ;
Chris@0 488 printf (" Command : %s\n\n", prog->convert_cmd) ;
Chris@0 489
Chris@0 490 snr = measure_snr (prog, &output_samples, verbose) ;
Chris@0 491
Chris@0 492 printf (" Worst case SNR : %6.2f dB\n", snr) ;
Chris@0 493
Chris@0 494 times (&time_data) ;
Chris@0 495
Chris@0 496 conversion_rate = (1.0 * output_samples * sysconf (_SC_CLK_TCK)) / time_data.tms_cutime ;
Chris@0 497
Chris@0 498 printf (" Conversion rate : %5.0f samples/sec\n", conversion_rate) ;
Chris@0 499
Chris@0 500 bandwidth = bandwidth_test (prog, verbose) ;
Chris@0 501
Chris@0 502 if (bandwidth > 0.0)
Chris@0 503 printf (" Measured bandwidth : %5.2f %%\n", bandwidth) ;
Chris@0 504 else
Chris@0 505 printf (" Could not measure bandwidth (no -3dB point found).\n") ;
Chris@0 506
Chris@0 507 return ;
Chris@0 508 } /* measure_program */
Chris@0 509
Chris@0 510 /*##############################################################################
Chris@0 511 */
Chris@0 512
Chris@0 513 #else
Chris@0 514
Chris@0 515 int
Chris@0 516 main (void)
Chris@0 517 { puts ("\n"
Chris@0 518 "****************************************************************\n"
Chris@0 519 " This program has been compiled without :\n"
Chris@0 520 " 1) FFTW (http://www.fftw.org/).\n"
Chris@0 521 " 2) libsndfile (http://www.zip.com.au/~erikd/libsndfile/).\n"
Chris@0 522 " Without these two libraries there is not much it can do.\n"
Chris@0 523 "****************************************************************\n") ;
Chris@0 524
Chris@0 525 return 0 ;
Chris@0 526 } /* main */
Chris@0 527
Chris@0 528 #endif /* (HAVE_FFTW3 && HAVE_SNDFILE) */
Chris@0 529