annotate src/libsndfile-1.0.27/tests/floating_point_test.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 1df64224f5ac
children
rev   line source
Chris@40 1 /*
Chris@40 2 ** Copyright (C) 1999-2016 Erik de Castro Lopo <erikd@mega-nerd.com>
Chris@40 3 **
Chris@40 4 ** This program is free software; you can redistribute it and/or modify
Chris@40 5 ** it under the terms of the GNU General Public License as published by
Chris@40 6 ** the Free Software Foundation; either version 2 of the License, or
Chris@40 7 ** (at your option) any later version.
Chris@40 8 **
Chris@40 9 ** This program is distributed in the hope that it will be useful,
Chris@40 10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@40 11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@40 12 ** GNU General Public License for more details.
Chris@40 13 **
Chris@40 14 ** You should have received a copy of the GNU General Public License
Chris@40 15 ** along with this program; if not, write to the Free Software
Chris@40 16 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Chris@40 17 */
Chris@40 18
Chris@40 19 #include "sfconfig.h"
Chris@40 20
Chris@40 21 #include <stdio.h>
Chris@40 22 #include <stdlib.h>
Chris@40 23 #include <string.h>
Chris@40 24 #include <math.h>
Chris@40 25 #include <inttypes.h>
Chris@40 26
Chris@40 27 #if HAVE_UNISTD_H
Chris@40 28 #include <unistd.h>
Chris@40 29 #endif
Chris@40 30
Chris@40 31 #include <sndfile.h>
Chris@40 32
Chris@40 33 #include "dft_cmp.h"
Chris@40 34 #include "utils.h"
Chris@40 35
Chris@40 36 #define SAMPLE_RATE 16000
Chris@40 37
Chris@40 38 static void float_scaled_test (const char *filename, int allow_exit, int replace_float, int filetype, double target_snr) ;
Chris@40 39 static void double_scaled_test (const char *filename, int allow_exit, int replace_float, int filetype, double target_snr) ;
Chris@40 40
Chris@40 41 static void float_short_little_test (const char * filename) ;
Chris@40 42 static void float_short_big_test (const char * filename) ;
Chris@40 43 static void float_int_little_test (const char * filename) ;
Chris@40 44 static void float_int_big_test (const char * filename) ;
Chris@40 45 static void double_short_little_test (const char * filename) ;
Chris@40 46 static void double_short_big_test (const char * filename) ;
Chris@40 47 static void double_int_little_test (const char * filename) ;
Chris@40 48 static void double_int_big_test (const char * filename) ;
Chris@40 49
Chris@40 50
Chris@40 51 static double double_data [DFT_DATA_LENGTH] ;
Chris@40 52 static double double_test [DFT_DATA_LENGTH] ;
Chris@40 53
Chris@40 54 static float float_data [DFT_DATA_LENGTH] ;
Chris@40 55 static float float_test [DFT_DATA_LENGTH] ;
Chris@40 56
Chris@40 57 static double double_data [DFT_DATA_LENGTH] ;
Chris@40 58 static short short_data [DFT_DATA_LENGTH] ;
Chris@40 59 static int int_data [DFT_DATA_LENGTH] ;
Chris@40 60
Chris@40 61 int
Chris@40 62 main (int argc, char *argv [])
Chris@40 63 { int allow_exit = 1 ;
Chris@40 64
Chris@40 65 if (argc == 2 && ! strstr (argv [1], "no-exit"))
Chris@40 66 allow_exit = 0 ;
Chris@40 67
Chris@40 68 #if (HAVE_LRINTF == 0)
Chris@40 69 puts ("*** Cannot run this test on this platform because it lacks lrintf().") ;
Chris@40 70 exit (0) ;
Chris@40 71 #endif
Chris@40 72
Chris@40 73 /* Float tests. */
Chris@40 74 float_scaled_test ("float.raw", allow_exit, SF_FALSE, SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_FLOAT,
Chris@40 75 OS_IS_OPENBSD ? -98.0 : -163.0) ;
Chris@40 76
Chris@40 77 /* Test both signed and unsigned 8 bit files. */
Chris@40 78 float_scaled_test ("pcm_s8.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_PCM_S8, -39.0) ;
Chris@40 79 float_scaled_test ("pcm_u8.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_PCM_U8, -39.0) ;
Chris@40 80
Chris@40 81 float_scaled_test ("pcm_16.raw", allow_exit, SF_FALSE, SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_16, -87.0) ;
Chris@40 82 float_scaled_test ("pcm_24.raw", allow_exit, SF_FALSE, SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_24, -138.0) ;
Chris@40 83 float_scaled_test ("pcm_32.raw", allow_exit, SF_FALSE, SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_32, -163.0) ;
Chris@40 84
Chris@40 85 float_scaled_test ("ulaw.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_ULAW, -50.0) ;
Chris@40 86 float_scaled_test ("alaw.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_ALAW, -49.0) ;
Chris@40 87
Chris@40 88 float_scaled_test ("ima_adpcm.wav", allow_exit, SF_FALSE, SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM, -47.0) ;
Chris@40 89 float_scaled_test ("ms_adpcm.wav" , allow_exit, SF_FALSE, SF_FORMAT_WAV | SF_FORMAT_MS_ADPCM, -40.0) ;
Chris@40 90 float_scaled_test ("gsm610.raw" , allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_GSM610, -33.0) ;
Chris@40 91
Chris@40 92 float_scaled_test ("g721_32.au", allow_exit, SF_FALSE, SF_FORMAT_AU | SF_FORMAT_G721_32, -32.3) ;
Chris@40 93 float_scaled_test ("g723_24.au", allow_exit, SF_FALSE, SF_FORMAT_AU | SF_FORMAT_G723_24, -32.3) ;
Chris@40 94 float_scaled_test ("g723_40.au", allow_exit, SF_FALSE, SF_FORMAT_AU | SF_FORMAT_G723_40, -40.0) ;
Chris@40 95
Chris@40 96 /* PAF files do not use the same encoding method for 24 bit PCM data as other file
Chris@40 97 ** formats so we need to explicitly test it here.
Chris@40 98 */
Chris@40 99 float_scaled_test ("le_paf_24.paf", allow_exit, SF_FALSE, SF_ENDIAN_LITTLE | SF_FORMAT_PAF | SF_FORMAT_PCM_24, -149.0) ;
Chris@40 100 float_scaled_test ("be_paf_24.paf", allow_exit, SF_FALSE, SF_ENDIAN_BIG | SF_FORMAT_PAF | SF_FORMAT_PCM_24, -149.0) ;
Chris@40 101
Chris@40 102 float_scaled_test ("dwvw_12.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_DWVW_12, -64.0) ;
Chris@40 103 float_scaled_test ("dwvw_16.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_DWVW_16, -92.0) ;
Chris@40 104 float_scaled_test ("dwvw_24.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_DWVW_24, -151.0) ;
Chris@40 105
Chris@40 106 float_scaled_test ("adpcm.vox", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_VOX_ADPCM, -40.0) ;
Chris@40 107
Chris@40 108 float_scaled_test ("dpcm_16.xi", allow_exit, SF_FALSE, SF_FORMAT_XI | SF_FORMAT_DPCM_16, -90.0) ;
Chris@40 109 float_scaled_test ("dpcm_8.xi" , allow_exit, SF_FALSE, SF_FORMAT_XI | SF_FORMAT_DPCM_8 , -41.0) ;
Chris@40 110
Chris@40 111 float_scaled_test ("pcm_s8.sds", allow_exit, SF_FALSE, SF_FORMAT_SDS | SF_FORMAT_PCM_S8, -89.0) ;
Chris@40 112 float_scaled_test ("pcm_16.sds", allow_exit, SF_FALSE, SF_FORMAT_SDS | SF_FORMAT_PCM_16, -132.0) ;
Chris@40 113 float_scaled_test ("pcm_24.sds", allow_exit, SF_FALSE, SF_FORMAT_SDS | SF_FORMAT_PCM_24, -170.0) ;
Chris@40 114
Chris@40 115 float_scaled_test ("alac_16.caf", allow_exit, SF_FALSE, SF_FORMAT_CAF | SF_FORMAT_ALAC_16, -90.0) ;
Chris@40 116 float_scaled_test ("alac_32.caf", allow_exit, SF_FALSE, SF_FORMAT_CAF | SF_FORMAT_ALAC_32, -76.0) ;
Chris@40 117 float_scaled_test ("alac_24.caf", allow_exit, SF_FALSE, SF_FORMAT_CAF | SF_FORMAT_ALAC_24, -153.0) ;
Chris@40 118 float_scaled_test ("alac_20.caf", allow_exit, SF_FALSE, SF_FORMAT_CAF | SF_FORMAT_ALAC_20, -125.0) ;
Chris@40 119
Chris@40 120 #if HAVE_EXTERNAL_XIPH_LIBS
Chris@40 121 float_scaled_test ("flac_8.flac", allow_exit, SF_FALSE, SF_FORMAT_FLAC | SF_FORMAT_PCM_S8, -39.0) ;
Chris@40 122 float_scaled_test ("flac_16.flac", allow_exit, SF_FALSE, SF_FORMAT_FLAC | SF_FORMAT_PCM_16, -87.0) ;
Chris@40 123 float_scaled_test ("flac_24.flac", allow_exit, SF_FALSE, SF_FORMAT_FLAC | SF_FORMAT_PCM_24, -138.0) ;
Chris@40 124
Chris@40 125 float_scaled_test ("vorbis.oga", allow_exit, SF_FALSE, SF_FORMAT_OGG | SF_FORMAT_VORBIS, -31.0) ;
Chris@40 126 #endif
Chris@40 127
Chris@40 128 float_scaled_test ("replace_float.raw", allow_exit, SF_TRUE, SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_FLOAT, -163.0) ;
Chris@40 129
Chris@40 130 /*==============================================================================
Chris@40 131 ** Double tests.
Chris@40 132 */
Chris@40 133
Chris@40 134 double_scaled_test ("double.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_DOUBLE, -201.0) ;
Chris@40 135
Chris@40 136 /* Test both signed (AIFF) and unsigned (WAV) 8 bit files. */
Chris@40 137 double_scaled_test ("pcm_s8.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_PCM_S8, -39.0) ;
Chris@40 138 double_scaled_test ("pcm_u8.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_PCM_U8, -39.0) ;
Chris@40 139
Chris@40 140 double_scaled_test ("pcm_16.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_PCM_16, -87.0) ;
Chris@40 141 double_scaled_test ("pcm_24.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_PCM_24, -135.0) ;
Chris@40 142 double_scaled_test ("pcm_32.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_PCM_32, -184.0) ;
Chris@40 143
Chris@40 144 double_scaled_test ("ulaw.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_ULAW, -50.0) ;
Chris@40 145 double_scaled_test ("alaw.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_ALAW, -49.0) ;
Chris@40 146
Chris@40 147 double_scaled_test ("ima_adpcm.wav", allow_exit, SF_FALSE, SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM, -47.0) ;
Chris@40 148 double_scaled_test ("ms_adpcm.wav" , allow_exit, SF_FALSE, SF_FORMAT_WAV | SF_FORMAT_MS_ADPCM, -40.0) ;
Chris@40 149 double_scaled_test ("gsm610.raw" , allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_GSM610, -33.0) ;
Chris@40 150
Chris@40 151 double_scaled_test ("g721_32.au", allow_exit, SF_FALSE, SF_FORMAT_AU | SF_FORMAT_G721_32, -32.3) ;
Chris@40 152 double_scaled_test ("g723_24.au", allow_exit, SF_FALSE, SF_FORMAT_AU | SF_FORMAT_G723_24, -32.3) ;
Chris@40 153 double_scaled_test ("g723_40.au", allow_exit, SF_FALSE, SF_FORMAT_AU | SF_FORMAT_G723_40, -40.0) ;
Chris@40 154
Chris@40 155 /* 24 bit PCM PAF files tested here. */
Chris@40 156 double_scaled_test ("be_paf_24.paf", allow_exit, SF_FALSE, SF_ENDIAN_BIG | SF_FORMAT_PAF | SF_FORMAT_PCM_24, -151.0) ;
Chris@40 157 double_scaled_test ("le_paf_24.paf", allow_exit, SF_FALSE, SF_ENDIAN_LITTLE | SF_FORMAT_PAF | SF_FORMAT_PCM_24, -151.0) ;
Chris@40 158
Chris@40 159 double_scaled_test ("dwvw_12.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_DWVW_12, -64.0) ;
Chris@40 160 double_scaled_test ("dwvw_16.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_DWVW_16, -92.0) ;
Chris@40 161 double_scaled_test ("dwvw_24.raw", allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_DWVW_24, -151.0) ;
Chris@40 162
Chris@40 163 double_scaled_test ("adpcm.vox" , allow_exit, SF_FALSE, SF_FORMAT_RAW | SF_FORMAT_VOX_ADPCM, -40.0) ;
Chris@40 164
Chris@40 165 double_scaled_test ("dpcm_16.xi", allow_exit, SF_FALSE, SF_FORMAT_XI | SF_FORMAT_DPCM_16, -90.0) ;
Chris@40 166 double_scaled_test ("dpcm_8.xi" , allow_exit, SF_FALSE, SF_FORMAT_XI | SF_FORMAT_DPCM_8 , -41.0) ;
Chris@40 167
Chris@40 168 double_scaled_test ("pcm_s8.sds", allow_exit, SF_FALSE, SF_FORMAT_SDS | SF_FORMAT_PCM_S8, -89.0) ;
Chris@40 169 double_scaled_test ("pcm_16.sds", allow_exit, SF_FALSE, SF_FORMAT_SDS | SF_FORMAT_PCM_16, -132.0) ;
Chris@40 170 double_scaled_test ("pcm_24.sds", allow_exit, SF_FALSE, SF_FORMAT_SDS | SF_FORMAT_PCM_24, -180.0) ;
Chris@40 171
Chris@40 172 double_scaled_test ("alac_16.caf", allow_exit, SF_FALSE, SF_FORMAT_CAF | SF_FORMAT_ALAC_16, -90.0) ;
Chris@40 173 double_scaled_test ("alac_20.caf", allow_exit, SF_FALSE, SF_FORMAT_CAF | SF_FORMAT_ALAC_20, -125.0) ;
Chris@40 174 double_scaled_test ("alac_24.caf", allow_exit, SF_FALSE, SF_FORMAT_CAF | SF_FORMAT_ALAC_24, -153.0) ;
Chris@40 175 double_scaled_test ("alac_32.caf", allow_exit, SF_FALSE, SF_FORMAT_CAF | SF_FORMAT_ALAC_32, -186.0) ;
Chris@40 176
Chris@40 177 #if HAVE_EXTERNAL_XIPH_LIBS
Chris@40 178 double_scaled_test ("flac_8.flac", allow_exit, SF_FALSE, SF_FORMAT_FLAC | SF_FORMAT_PCM_S8, -39.0) ;
Chris@40 179 double_scaled_test ("flac_16.flac", allow_exit, SF_FALSE, SF_FORMAT_FLAC | SF_FORMAT_PCM_16, -87.0) ;
Chris@40 180 double_scaled_test ("flac_24.flac", allow_exit, SF_FALSE, SF_FORMAT_FLAC | SF_FORMAT_PCM_24, -138.0) ;
Chris@40 181
Chris@40 182 double_scaled_test ("vorbis.oga", allow_exit, SF_FALSE, SF_FORMAT_OGG | SF_FORMAT_VORBIS, -29.0) ;
Chris@40 183 #endif
Chris@40 184
Chris@40 185 double_scaled_test ("replace_double.raw", allow_exit, SF_TRUE, SF_FORMAT_RAW | SF_FORMAT_DOUBLE, -201.0) ;
Chris@40 186
Chris@40 187 putchar ('\n') ;
Chris@40 188 /* Float int tests. */
Chris@40 189 float_short_little_test ("float_short_little.au") ;
Chris@40 190 float_short_big_test ("float_short_big.au") ;
Chris@40 191 float_int_little_test ("float_int_little.au") ;
Chris@40 192 float_int_big_test ("float_int_big.au") ;
Chris@40 193 double_short_little_test ("double_short_little.au") ;
Chris@40 194 double_short_big_test ("double_short_big.au") ;
Chris@40 195 double_int_little_test ("double_int_little.au") ;
Chris@40 196 double_int_big_test ("double_int_big.au") ;
Chris@40 197
Chris@40 198
Chris@40 199 return 0 ;
Chris@40 200 } /* main */
Chris@40 201
Chris@40 202 /*============================================================================================
Chris@40 203 * Here are the test functions.
Chris@40 204 */
Chris@40 205
Chris@40 206 static void
Chris@40 207 float_scaled_test (const char *filename, int allow_exit, int replace_float, int filetype, double target_snr)
Chris@40 208 { SNDFILE *file ;
Chris@40 209 SF_INFO sfinfo ;
Chris@40 210 double snr ;
Chris@40 211 int byterate ;
Chris@40 212
Chris@40 213 print_test_name ("float_scaled_test", filename) ;
Chris@40 214
Chris@40 215 gen_windowed_sine_float (float_data, DFT_DATA_LENGTH, 0.9999) ;
Chris@40 216
Chris@40 217 sfinfo.samplerate = SAMPLE_RATE ;
Chris@40 218 sfinfo.frames = DFT_DATA_LENGTH ;
Chris@40 219 sfinfo.channels = 1 ;
Chris@40 220 sfinfo.format = filetype ;
Chris@40 221
Chris@40 222 file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
Chris@40 223 sf_command (file, SFC_TEST_IEEE_FLOAT_REPLACE, NULL, replace_float) ;
Chris@40 224
Chris@40 225 test_write_float_or_die (file, 0, float_data, DFT_DATA_LENGTH, __LINE__) ;
Chris@40 226
Chris@40 227 sf_close (file) ;
Chris@40 228
Chris@40 229 memset (float_test, 0, sizeof (float_test)) ;
Chris@40 230
Chris@40 231 file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
Chris@40 232 sf_command (file, SFC_TEST_IEEE_FLOAT_REPLACE, NULL, replace_float) ;
Chris@40 233
Chris@40 234 exit_if_true (sfinfo.format != filetype, "\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, filetype, sfinfo.format) ;
Chris@40 235 exit_if_true (sfinfo.frames < DFT_DATA_LENGTH, "\n\nLine %d: Incorrect number of frames in file (too short). (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, DFT_DATA_LENGTH) ;
Chris@40 236 exit_if_true (sfinfo.channels != 1, "\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ;
Chris@40 237
Chris@40 238 check_log_buffer_or_die (file, __LINE__) ;
Chris@40 239
Chris@40 240 test_read_float_or_die (file, 0, float_test, DFT_DATA_LENGTH, __LINE__) ;
Chris@40 241
Chris@40 242 byterate = sf_current_byterate (file) ;
Chris@40 243 exit_if_true (byterate <= 0, "\n\nLine %d: byterate is zero.\n", __LINE__) ;
Chris@40 244
Chris@40 245 sf_close (file) ;
Chris@40 246
Chris@40 247 snr = dft_cmp_float (__LINE__, float_data, float_test, DFT_DATA_LENGTH, target_snr, allow_exit) ;
Chris@40 248
Chris@40 249 exit_if_true (snr > target_snr, "% 6.1fdB SNR\n\n Error : should be better than % 6.1fdB\n\n", snr, target_snr) ;
Chris@40 250
Chris@40 251 printf ("% 6.1fdB SNR ... ok\n", snr) ;
Chris@40 252
Chris@40 253 unlink (filename) ;
Chris@40 254
Chris@40 255 return ;
Chris@40 256 } /* float_scaled_test */
Chris@40 257
Chris@40 258 static void
Chris@40 259 double_scaled_test (const char *filename, int allow_exit, int replace_float, int filetype, double target_snr)
Chris@40 260 { SNDFILE *file ;
Chris@40 261 SF_INFO sfinfo ;
Chris@40 262 double snr ;
Chris@40 263 int byterate ;
Chris@40 264
Chris@40 265 print_test_name ("double_scaled_test", filename) ;
Chris@40 266
Chris@40 267 gen_windowed_sine_double (double_data, DFT_DATA_LENGTH, 0.9999) ;
Chris@40 268
Chris@40 269 sfinfo.samplerate = SAMPLE_RATE ;
Chris@40 270 sfinfo.frames = DFT_DATA_LENGTH ;
Chris@40 271 sfinfo.channels = 1 ;
Chris@40 272 sfinfo.format = filetype ;
Chris@40 273
Chris@40 274 file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
Chris@40 275 sf_command (file, SFC_TEST_IEEE_FLOAT_REPLACE, NULL, replace_float) ;
Chris@40 276
Chris@40 277 test_write_double_or_die (file, 0, double_data, DFT_DATA_LENGTH, __LINE__) ;
Chris@40 278
Chris@40 279 sf_close (file) ;
Chris@40 280
Chris@40 281 memset (double_test, 0, sizeof (double_test)) ;
Chris@40 282
Chris@40 283 file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
Chris@40 284 sf_command (file, SFC_TEST_IEEE_FLOAT_REPLACE, NULL, replace_float) ;
Chris@40 285
Chris@40 286 exit_if_true (sfinfo.format != filetype, "\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, filetype, sfinfo.format) ;
Chris@40 287 exit_if_true (sfinfo.frames < DFT_DATA_LENGTH, "\n\nLine %d: Incorrect number of frames in file (too short). (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, DFT_DATA_LENGTH) ;
Chris@40 288 exit_if_true (sfinfo.channels != 1, "\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ;
Chris@40 289
Chris@40 290 check_log_buffer_or_die (file, __LINE__) ;
Chris@40 291
Chris@40 292 test_read_double_or_die (file, 0, double_test, DFT_DATA_LENGTH, __LINE__) ;
Chris@40 293
Chris@40 294 byterate = sf_current_byterate (file) ;
Chris@40 295 exit_if_true (byterate <= 0, "\n\nLine %d: byterate is zero.\n", __LINE__) ;
Chris@40 296
Chris@40 297 sf_close (file) ;
Chris@40 298
Chris@40 299 snr = dft_cmp_double (__LINE__, double_data, double_test, DFT_DATA_LENGTH, target_snr, allow_exit) ;
Chris@40 300
Chris@40 301 exit_if_true (snr > target_snr, "% 6.1fdB SNR\n\n Error : should be better than % 6.1fdB\n\n", snr, target_snr) ;
Chris@40 302
Chris@40 303 printf ("% 6.1fdB SNR ... ok\n", snr) ;
Chris@40 304
Chris@40 305 unlink (filename) ;
Chris@40 306
Chris@40 307 return ;
Chris@40 308 } /* double_scaled_test */
Chris@40 309
Chris@40 310 /*==============================================================================
Chris@40 311 */
Chris@40 312
Chris@40 313
Chris@40 314 static void
Chris@40 315 float_short_little_test (const char * filename)
Chris@40 316 { SNDFILE *file ;
Chris@40 317 SF_INFO sfinfo ;
Chris@40 318 int max ;
Chris@40 319 unsigned k ;
Chris@40 320
Chris@40 321 print_test_name ("float_short_little_test", filename) ;
Chris@40 322
Chris@40 323 gen_windowed_sine_float (float_data, ARRAY_LEN (float_data), 0.9999) ;
Chris@40 324
Chris@40 325 sfinfo.samplerate = SAMPLE_RATE ;
Chris@40 326 sfinfo.frames = ARRAY_LEN (short_data) ;
Chris@40 327 sfinfo.channels = 1 ;
Chris@40 328 sfinfo.format = SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_FLOAT ;
Chris@40 329
Chris@40 330 file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
Chris@40 331 test_write_float_or_die (file, 0, float_data, ARRAY_LEN (float_data), __LINE__) ;
Chris@40 332 sf_close (file) ;
Chris@40 333
Chris@40 334 file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
Chris@40 335
Chris@40 336 if (sfinfo.frames != ARRAY_LEN (float_data))
Chris@40 337 { printf ("\n\nLine %d: Incorrect number of frames in file (too short). (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, DFT_DATA_LENGTH) ;
Chris@40 338 exit (1) ;
Chris@40 339 } ;
Chris@40 340
Chris@40 341 if (sfinfo.channels != 1)
Chris@40 342 { printf ("\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ;
Chris@40 343 exit (1) ;
Chris@40 344 } ;
Chris@40 345
Chris@40 346 sf_command (file, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ;
Chris@40 347
Chris@40 348 test_read_short_or_die (file, 0, short_data, ARRAY_LEN (short_data), __LINE__) ;
Chris@40 349 sf_close (file) ;
Chris@40 350
Chris@40 351 max = 0 ;
Chris@40 352 for (k = 0 ; k < ARRAY_LEN (short_data) ; k++)
Chris@40 353 if (abs (short_data [k]) > max)
Chris@40 354 max = abs (short_data [k]) ;
Chris@40 355
Chris@40 356 if (1.0 * abs (max - 0x7FFF) / 0x7FFF > 0.01)
Chris@40 357 { printf ("\n\nLine %d: Bad maximum (%d should be %d).\n\n", __LINE__, max, 0x7FFF) ;
Chris@40 358 exit (1) ;
Chris@40 359 } ;
Chris@40 360
Chris@40 361 unlink (filename) ;
Chris@40 362 puts ("ok") ;
Chris@40 363 } /* float_short_little_test */
Chris@40 364
Chris@40 365 static void
Chris@40 366 float_short_big_test (const char * filename)
Chris@40 367 { SNDFILE *file ;
Chris@40 368 SF_INFO sfinfo ;
Chris@40 369 int max ;
Chris@40 370 unsigned k ;
Chris@40 371
Chris@40 372 print_test_name ("float_short_big_test", filename) ;
Chris@40 373
Chris@40 374 gen_windowed_sine_float (float_data, ARRAY_LEN (float_data), 0.9999) ;
Chris@40 375
Chris@40 376 sfinfo.samplerate = SAMPLE_RATE ;
Chris@40 377 sfinfo.frames = ARRAY_LEN (short_data) ;
Chris@40 378 sfinfo.channels = 1 ;
Chris@40 379 sfinfo.format = SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_FLOAT ;
Chris@40 380
Chris@40 381 file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
Chris@40 382 test_write_float_or_die (file, 0, float_data, ARRAY_LEN (float_data), __LINE__) ;
Chris@40 383 sf_close (file) ;
Chris@40 384
Chris@40 385 file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
Chris@40 386
Chris@40 387 if (sfinfo.frames != ARRAY_LEN (float_data))
Chris@40 388 { printf ("\n\nLine %d: Incorrect number of frames in file (too short). (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, DFT_DATA_LENGTH) ;
Chris@40 389 exit (1) ;
Chris@40 390 } ;
Chris@40 391
Chris@40 392 if (sfinfo.channels != 1)
Chris@40 393 { printf ("\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ;
Chris@40 394 exit (1) ;
Chris@40 395 } ;
Chris@40 396
Chris@40 397 sf_command (file, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ;
Chris@40 398
Chris@40 399 test_read_short_or_die (file, 0, short_data, ARRAY_LEN (short_data), __LINE__) ;
Chris@40 400 sf_close (file) ;
Chris@40 401
Chris@40 402 max = 0 ;
Chris@40 403 for (k = 0 ; k < ARRAY_LEN (short_data) ; k++)
Chris@40 404 if (abs (short_data [k]) > max)
Chris@40 405 max = abs (short_data [k]) ;
Chris@40 406
Chris@40 407 if (1.0 * abs (max - 0x7FFF) / 0x7FFF > 0.01)
Chris@40 408 { printf ("\n\nLine %d: Bad maximum (%d should be %d).\n\n", __LINE__, max, 0x7FFF) ;
Chris@40 409 exit (1) ;
Chris@40 410 } ;
Chris@40 411
Chris@40 412 unlink (filename) ;
Chris@40 413 puts ("ok") ;
Chris@40 414 } /* float_short_big_test */
Chris@40 415
Chris@40 416 static void
Chris@40 417 float_int_little_test (const char * filename)
Chris@40 418 { SNDFILE *file ;
Chris@40 419 SF_INFO sfinfo ;
Chris@40 420 int max ;
Chris@40 421 unsigned k ;
Chris@40 422
Chris@40 423 print_test_name ("float_int_little_test", filename) ;
Chris@40 424
Chris@40 425 gen_windowed_sine_float (float_data, ARRAY_LEN (float_data), 0.9999) ;
Chris@40 426
Chris@40 427 sfinfo.samplerate = SAMPLE_RATE ;
Chris@40 428 sfinfo.frames = ARRAY_LEN (int_data) ;
Chris@40 429 sfinfo.channels = 1 ;
Chris@40 430 sfinfo.format = SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_FLOAT ;
Chris@40 431
Chris@40 432 file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
Chris@40 433 test_write_float_or_die (file, 0, float_data, ARRAY_LEN (float_data), __LINE__) ;
Chris@40 434 sf_close (file) ;
Chris@40 435
Chris@40 436 file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
Chris@40 437
Chris@40 438 if (sfinfo.frames != ARRAY_LEN (float_data))
Chris@40 439 { printf ("\n\nLine %d: Incorrect number of frames in file (too short). (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, DFT_DATA_LENGTH) ;
Chris@40 440 exit (1) ;
Chris@40 441 } ;
Chris@40 442
Chris@40 443 if (sfinfo.channels != 1)
Chris@40 444 { printf ("\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ;
Chris@40 445 exit (1) ;
Chris@40 446 } ;
Chris@40 447
Chris@40 448 sf_command (file, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ;
Chris@40 449
Chris@40 450 test_read_int_or_die (file, 0, int_data, ARRAY_LEN (int_data), __LINE__) ;
Chris@40 451 sf_close (file) ;
Chris@40 452
Chris@40 453 max = 0 ;
Chris@40 454 for (k = 0 ; k < ARRAY_LEN (int_data) ; k++)
Chris@40 455 if (abs (int_data [k]) > max)
Chris@40 456 max = abs (int_data [k]) ;
Chris@40 457
Chris@40 458 if (1.0 * abs (max - 0x7FFFFFFF) / 0x7FFFFFFF > 0.01)
Chris@40 459 { printf ("\n\nLine %d: Bad maximum (%d should be %d).\n\n", __LINE__, max, 0x7FFFFFFF) ;
Chris@40 460 exit (1) ;
Chris@40 461 } ;
Chris@40 462
Chris@40 463 unlink (filename) ;
Chris@40 464 puts ("ok") ;
Chris@40 465 } /* float_int_little_test */
Chris@40 466
Chris@40 467 static void
Chris@40 468 float_int_big_test (const char * filename)
Chris@40 469 { SNDFILE *file ;
Chris@40 470 SF_INFO sfinfo ;
Chris@40 471 int max ;
Chris@40 472 unsigned k ;
Chris@40 473
Chris@40 474 print_test_name ("float_int_big_test", filename) ;
Chris@40 475
Chris@40 476 gen_windowed_sine_float (float_data, ARRAY_LEN (float_data), 0.9999) ;
Chris@40 477
Chris@40 478 sfinfo.samplerate = SAMPLE_RATE ;
Chris@40 479 sfinfo.frames = ARRAY_LEN (int_data) ;
Chris@40 480 sfinfo.channels = 1 ;
Chris@40 481 sfinfo.format = SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_FLOAT ;
Chris@40 482
Chris@40 483 file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
Chris@40 484 test_write_float_or_die (file, 0, float_data, ARRAY_LEN (float_data), __LINE__) ;
Chris@40 485 sf_close (file) ;
Chris@40 486
Chris@40 487 file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
Chris@40 488
Chris@40 489 if (sfinfo.frames != ARRAY_LEN (float_data))
Chris@40 490 { printf ("\n\nLine %d: Incorrect number of frames in file (too short). (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, DFT_DATA_LENGTH) ;
Chris@40 491 exit (1) ;
Chris@40 492 } ;
Chris@40 493
Chris@40 494 if (sfinfo.channels != 1)
Chris@40 495 { printf ("\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ;
Chris@40 496 exit (1) ;
Chris@40 497 } ;
Chris@40 498
Chris@40 499 sf_command (file, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ;
Chris@40 500
Chris@40 501 test_read_int_or_die (file, 0, int_data, ARRAY_LEN (int_data), __LINE__) ;
Chris@40 502 sf_close (file) ;
Chris@40 503
Chris@40 504 max = 0 ;
Chris@40 505 for (k = 0 ; k < ARRAY_LEN (int_data) ; k++)
Chris@40 506 if (abs (int_data [k]) > max)
Chris@40 507 max = abs (int_data [k]) ;
Chris@40 508
Chris@40 509 if (1.0 * abs (max - 0x7FFFFFFF) / 0x7FFFFFFF > 0.01)
Chris@40 510 { printf ("\n\nLine %d: Bad maximum (%d should be %d).\n\n", __LINE__, max, 0x7FFFFFFF) ;
Chris@40 511 exit (1) ;
Chris@40 512 } ;
Chris@40 513
Chris@40 514 unlink (filename) ;
Chris@40 515 puts ("ok") ;
Chris@40 516 } /* float_int_big_test */
Chris@40 517
Chris@40 518 static void
Chris@40 519 double_short_little_test (const char * filename)
Chris@40 520 { SNDFILE *file ;
Chris@40 521 SF_INFO sfinfo ;
Chris@40 522 int max ;
Chris@40 523 unsigned k ;
Chris@40 524
Chris@40 525 print_test_name ("double_short_little_test", filename) ;
Chris@40 526
Chris@40 527 gen_windowed_sine_double (double_data, ARRAY_LEN (double_data), 0.9999) ;
Chris@40 528
Chris@40 529 sfinfo.samplerate = SAMPLE_RATE ;
Chris@40 530 sfinfo.frames = ARRAY_LEN (short_data) ;
Chris@40 531 sfinfo.channels = 1 ;
Chris@40 532 sfinfo.format = SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_DOUBLE ;
Chris@40 533
Chris@40 534 file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
Chris@40 535 test_write_double_or_die (file, 0, double_data, ARRAY_LEN (double_data), __LINE__) ;
Chris@40 536 sf_close (file) ;
Chris@40 537
Chris@40 538 file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
Chris@40 539
Chris@40 540 if (sfinfo.frames != ARRAY_LEN (double_data))
Chris@40 541 { printf ("\n\nLine %d: Incorrect number of frames in file (too short). (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, DFT_DATA_LENGTH) ;
Chris@40 542 exit (1) ;
Chris@40 543 } ;
Chris@40 544
Chris@40 545 if (sfinfo.channels != 1)
Chris@40 546 { printf ("\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ;
Chris@40 547 exit (1) ;
Chris@40 548 } ;
Chris@40 549
Chris@40 550 sf_command (file, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ;
Chris@40 551
Chris@40 552 test_read_short_or_die (file, 0, short_data, ARRAY_LEN (short_data), __LINE__) ;
Chris@40 553 sf_close (file) ;
Chris@40 554
Chris@40 555 max = 0 ;
Chris@40 556 for (k = 0 ; k < ARRAY_LEN (short_data) ; k++)
Chris@40 557 if (abs (short_data [k]) > max)
Chris@40 558 max = abs (short_data [k]) ;
Chris@40 559
Chris@40 560 if (1.0 * abs (max - 0x7FFF) / 0x7FFF > 0.01)
Chris@40 561 { printf ("\n\nLine %d: Bad maximum (%d should be %d).\n\n", __LINE__, max, 0x7FFF) ;
Chris@40 562 exit (1) ;
Chris@40 563 } ;
Chris@40 564
Chris@40 565 unlink (filename) ;
Chris@40 566 puts ("ok") ;
Chris@40 567 } /* double_short_little_test */
Chris@40 568
Chris@40 569 static void
Chris@40 570 double_short_big_test (const char * filename)
Chris@40 571 { SNDFILE *file ;
Chris@40 572 SF_INFO sfinfo ;
Chris@40 573 int max ;
Chris@40 574 unsigned k ;
Chris@40 575
Chris@40 576 print_test_name ("double_short_big_test", filename) ;
Chris@40 577
Chris@40 578 gen_windowed_sine_double (double_data, ARRAY_LEN (double_data), 0.9999) ;
Chris@40 579
Chris@40 580 sfinfo.samplerate = SAMPLE_RATE ;
Chris@40 581 sfinfo.frames = ARRAY_LEN (short_data) ;
Chris@40 582 sfinfo.channels = 1 ;
Chris@40 583 sfinfo.format = SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_DOUBLE ;
Chris@40 584
Chris@40 585 file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
Chris@40 586 test_write_double_or_die (file, 0, double_data, ARRAY_LEN (double_data), __LINE__) ;
Chris@40 587 sf_close (file) ;
Chris@40 588
Chris@40 589 file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
Chris@40 590
Chris@40 591 if (sfinfo.frames != ARRAY_LEN (double_data))
Chris@40 592 { printf ("\n\nLine %d: Incorrect number of frames in file (too short). (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, DFT_DATA_LENGTH) ;
Chris@40 593 exit (1) ;
Chris@40 594 } ;
Chris@40 595
Chris@40 596 if (sfinfo.channels != 1)
Chris@40 597 { printf ("\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ;
Chris@40 598 exit (1) ;
Chris@40 599 } ;
Chris@40 600
Chris@40 601 sf_command (file, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ;
Chris@40 602
Chris@40 603 test_read_short_or_die (file, 0, short_data, ARRAY_LEN (short_data), __LINE__) ;
Chris@40 604 sf_close (file) ;
Chris@40 605
Chris@40 606 max = 0 ;
Chris@40 607 for (k = 0 ; k < ARRAY_LEN (short_data) ; k++)
Chris@40 608 if (abs (short_data [k]) > max)
Chris@40 609 max = abs (short_data [k]) ;
Chris@40 610
Chris@40 611 if (1.0 * abs (max - 0x7FFF) / 0x7FFF > 0.01)
Chris@40 612 { printf ("\n\nLine %d: Bad maximum (%d should be %d).\n\n", __LINE__, max, 0x7FFF) ;
Chris@40 613 exit (1) ;
Chris@40 614 } ;
Chris@40 615
Chris@40 616 unlink (filename) ;
Chris@40 617 puts ("ok") ;
Chris@40 618 } /* double_short_big_test */
Chris@40 619
Chris@40 620 static void
Chris@40 621 double_int_little_test (const char * filename)
Chris@40 622 { SNDFILE *file ;
Chris@40 623 SF_INFO sfinfo ;
Chris@40 624 int max ;
Chris@40 625 unsigned k ;
Chris@40 626
Chris@40 627 print_test_name ("double_int_little_test", filename) ;
Chris@40 628
Chris@40 629 gen_windowed_sine_double (double_data, ARRAY_LEN (double_data), 0.9999) ;
Chris@40 630
Chris@40 631 sfinfo.samplerate = SAMPLE_RATE ;
Chris@40 632 sfinfo.frames = ARRAY_LEN (int_data) ;
Chris@40 633 sfinfo.channels = 1 ;
Chris@40 634 sfinfo.format = SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_DOUBLE ;
Chris@40 635
Chris@40 636 file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
Chris@40 637 test_write_double_or_die (file, 0, double_data, ARRAY_LEN (double_data), __LINE__) ;
Chris@40 638 sf_close (file) ;
Chris@40 639
Chris@40 640 file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
Chris@40 641
Chris@40 642 if (sfinfo.frames != ARRAY_LEN (double_data))
Chris@40 643 { printf ("\n\nLine %d: Incorrect number of frames in file (too short). (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, DFT_DATA_LENGTH) ;
Chris@40 644 exit (1) ;
Chris@40 645 } ;
Chris@40 646
Chris@40 647 if (sfinfo.channels != 1)
Chris@40 648 { printf ("\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ;
Chris@40 649 exit (1) ;
Chris@40 650 } ;
Chris@40 651
Chris@40 652 sf_command (file, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ;
Chris@40 653
Chris@40 654 test_read_int_or_die (file, 0, int_data, ARRAY_LEN (int_data), __LINE__) ;
Chris@40 655 sf_close (file) ;
Chris@40 656
Chris@40 657 max = 0 ;
Chris@40 658 for (k = 0 ; k < ARRAY_LEN (int_data) ; k++)
Chris@40 659 if (abs (int_data [k]) > max)
Chris@40 660 max = abs (int_data [k]) ;
Chris@40 661
Chris@40 662 if (1.0 * abs (max - 0x7FFFFFFF) / 0x7FFFFFFF > 0.01)
Chris@40 663 { printf ("\n\nLine %d: Bad maximum (%d should be %d).\n\n", __LINE__, max, 0x7FFFFFFF) ;
Chris@40 664 exit (1) ;
Chris@40 665 } ;
Chris@40 666
Chris@40 667 unlink (filename) ;
Chris@40 668 puts ("ok") ;
Chris@40 669 } /* double_int_little_test */
Chris@40 670
Chris@40 671 static void
Chris@40 672 double_int_big_test (const char * filename)
Chris@40 673 { SNDFILE *file ;
Chris@40 674 SF_INFO sfinfo ;
Chris@40 675 int max ;
Chris@40 676 unsigned k ;
Chris@40 677
Chris@40 678 print_test_name ("double_int_big_test", filename) ;
Chris@40 679
Chris@40 680 gen_windowed_sine_double (double_data, ARRAY_LEN (double_data), 0.9999) ;
Chris@40 681
Chris@40 682 sfinfo.samplerate = SAMPLE_RATE ;
Chris@40 683 sfinfo.frames = ARRAY_LEN (int_data) ;
Chris@40 684 sfinfo.channels = 1 ;
Chris@40 685 sfinfo.format = SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_DOUBLE ;
Chris@40 686
Chris@40 687 file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
Chris@40 688 test_write_double_or_die (file, 0, double_data, ARRAY_LEN (double_data), __LINE__) ;
Chris@40 689 sf_close (file) ;
Chris@40 690
Chris@40 691 file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
Chris@40 692
Chris@40 693 if (sfinfo.frames != ARRAY_LEN (double_data))
Chris@40 694 { printf ("\n\nLine %d: Incorrect number of frames in file (too short). (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, DFT_DATA_LENGTH) ;
Chris@40 695 exit (1) ;
Chris@40 696 } ;
Chris@40 697
Chris@40 698 if (sfinfo.channels != 1)
Chris@40 699 { printf ("\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ;
Chris@40 700 exit (1) ;
Chris@40 701 } ;
Chris@40 702
Chris@40 703 sf_command (file, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ;
Chris@40 704
Chris@40 705 test_read_int_or_die (file, 0, int_data, ARRAY_LEN (int_data), __LINE__) ;
Chris@40 706 sf_close (file) ;
Chris@40 707
Chris@40 708 max = 0 ;
Chris@40 709 for (k = 0 ; k < ARRAY_LEN (int_data) ; k++)
Chris@40 710 if (abs (int_data [k]) > max)
Chris@40 711 max = abs (int_data [k]) ;
Chris@40 712
Chris@40 713 if (1.0 * abs (max - 0x7FFFFFFF) / 0x7FFFFFFF > 0.01)
Chris@40 714 { printf ("\n\nLine %d: Bad maximum (%d should be %d).\n\n", __LINE__, max, 0x7FFFFFFF) ;
Chris@40 715 exit (1) ;
Chris@40 716 } ;
Chris@40 717
Chris@40 718 unlink (filename) ;
Chris@40 719 puts ("ok") ;
Chris@40 720 } /* double_int_big_test */
Chris@40 721
Chris@40 722