Chris@40: [+ AutoGen5 template c +] Chris@40: /* Chris@40: ** Copyright (C) 1999-2012 Erik de Castro Lopo Chris@40: ** Chris@40: ** This program is free software; you can redistribute it and/or modify Chris@40: ** it under the terms of the GNU General Public License as published by Chris@40: ** the Free Software Foundation; either version 2 of the License, or Chris@40: ** (at your option) any later version. Chris@40: ** Chris@40: ** This program is distributed in the hope that it will be useful, Chris@40: ** but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@40: ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@40: ** GNU General Public License for more details. Chris@40: ** Chris@40: ** You should have received a copy of the GNU General Public License Chris@40: ** along with this program; if not, write to the Free Software Chris@40: ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Chris@40: */ Chris@40: Chris@40: #include "sfconfig.h" Chris@40: Chris@40: #include Chris@40: #include Chris@40: #include Chris@40: #include Chris@40: #include Chris@40: Chris@40: #if HAVE_UNISTD_H Chris@40: #include Chris@40: #endif Chris@40: Chris@40: #include Chris@40: Chris@40: #include "utils.h" Chris@40: Chris@40: #ifndef M_PI Chris@40: #define M_PI 3.14159265358979323846264338 Chris@40: #endif Chris@40: Chris@40: #define HALF_BUFFER_SIZE (1 << 12) Chris@40: #define BUFFER_SIZE (2 * HALF_BUFFER_SIZE) Chris@40: Chris@40: #define SINE_AMP 1.1 Chris@40: #define MAX_ERROR 0.0202 Chris@40: Chris@40: [+ FOR float_type +] Chris@40: [+ FOR data_type Chris@40: +]static void [+ (get "float_short_name") +]_scale_clip_test_[+ (get "name") +] (const char *filename, int filetype, float maxval) ; Chris@40: [+ ENDFOR data_type Chris@40: +][+ ENDFOR float_type +] Chris@40: Chris@40: [+ FOR float_type +] Chris@40: [+ FOR int_type Chris@40: +]static void [+ (get "float_short_name") +]_[+ (get "int_type_name") +]_clip_read_test (const char *filename, int filetype) ; Chris@40: [+ ENDFOR int_type Chris@40: +][+ ENDFOR float_type +] Chris@40: Chris@40: [+ FOR int_type +] Chris@40: [+ FOR float_type Chris@40: +]static void [+ (get "int_type_name") +]_[+ (get "float_short_name") +]_scale_write_test (const char *filename, int filetype) ; Chris@40: [+ ENDFOR float_type Chris@40: +][+ ENDFOR int_type +] Chris@40: Chris@40: typedef union Chris@40: { double dbl [BUFFER_SIZE] ; Chris@40: float flt [BUFFER_SIZE] ; Chris@40: int i [BUFFER_SIZE] ; Chris@40: short s [BUFFER_SIZE] ; Chris@40: } BUFFER ; Chris@40: Chris@40: /* Data buffer. */ Chris@40: static BUFFER buffer_out ; Chris@40: static BUFFER buffer_in ; Chris@40: Chris@40: int Chris@40: main (void) Chris@40: { Chris@40: flt_scale_clip_test_08 ("scale_clip_s8.au", SF_FORMAT_AU | SF_FORMAT_PCM_S8, 1.0 * 0x80) ; Chris@40: flt_scale_clip_test_08 ("scale_clip_u8.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_U8, 1.0 * 0x80) ; Chris@40: Chris@40: dbl_scale_clip_test_08 ("scale_clip_s8.au", SF_FORMAT_AU | SF_FORMAT_PCM_S8, 1.0 * 0x80) ; Chris@40: dbl_scale_clip_test_08 ("scale_clip_u8.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_U8, 1.0 * 0x80) ; Chris@40: Chris@40: /* Chris@40: ** Now use SF_FORMAT_AU where possible because it allows both Chris@40: ** big and little endian files. Chris@40: */ Chris@40: Chris@40: flt_scale_clip_test_16 ("scale_clip_be16.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_PCM_16, 1.0 * 0x8000) ; Chris@40: flt_scale_clip_test_16 ("scale_clip_le16.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_PCM_16, 1.0 * 0x8000) ; Chris@40: flt_scale_clip_test_24 ("scale_clip_be24.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_PCM_24, 1.0 * 0x800000) ; Chris@40: flt_scale_clip_test_24 ("scale_clip_le24.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_PCM_24, 1.0 * 0x800000) ; Chris@40: flt_scale_clip_test_32 ("scale_clip_be32.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_PCM_32, 1.0 * 0x80000000) ; Chris@40: flt_scale_clip_test_32 ("scale_clip_le32.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_PCM_32, 1.0 * 0x80000000) ; Chris@40: Chris@40: dbl_scale_clip_test_16 ("scale_clip_be16.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_PCM_16, 1.0 * 0x8000) ; Chris@40: dbl_scale_clip_test_16 ("scale_clip_le16.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_PCM_16, 1.0 * 0x8000) ; Chris@40: dbl_scale_clip_test_24 ("scale_clip_be24.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_PCM_24, 1.0 * 0x800000) ; Chris@40: dbl_scale_clip_test_24 ("scale_clip_le24.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_PCM_24, 1.0 * 0x800000) ; Chris@40: dbl_scale_clip_test_32 ("scale_clip_be32.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_PCM_32, 1.0 * 0x80000000) ; Chris@40: dbl_scale_clip_test_32 ("scale_clip_le32.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_PCM_32, 1.0 * 0x80000000) ; Chris@40: Chris@40: flt_short_clip_read_test ("flt_short.au" , SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_FLOAT) ; Chris@40: flt_int_clip_read_test ("flt_int.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_FLOAT) ; Chris@40: dbl_short_clip_read_test ("dbl_short.au" , SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_DOUBLE) ; Chris@40: dbl_int_clip_read_test ("dbl_int.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_DOUBLE) ; Chris@40: Chris@40: short_flt_scale_write_test ("short_flt.au" , SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_FLOAT) ; Chris@40: int_flt_scale_write_test ("int_flt.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_FLOAT) ; Chris@40: short_dbl_scale_write_test ("short_dbl.au" , SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_DOUBLE) ; Chris@40: int_dbl_scale_write_test ("int_dbl.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_DOUBLE) ; Chris@40: Chris@40: return 0 ; Chris@40: } /* main */ Chris@40: Chris@40: /*============================================================================================ Chris@40: ** Here are the test functions. Chris@40: */ Chris@40: Chris@40: [+ FOR float_type +] Chris@40: [+ FOR data_type Chris@40: +]static void Chris@40: [+ (get "float_short_name") +]_scale_clip_test_[+ (get "name") +] (const char *filename, int filetype, float maxval) Chris@40: { SNDFILE *file ; Chris@40: SF_INFO sfinfo ; Chris@40: int k ; Chris@40: [+ (get "float_type_name") +] *data_out, *data_in ; Chris@40: double diff, clip_max_diff ; Chris@40: Chris@40: print_test_name ("[+ (get "float_short_name") +]_scale_clip_test_[+ (get "name") +]", filename) ; Chris@40: Chris@40: data_out = buffer_out.[+ (get "float_short_name") +] ; Chris@40: data_in = buffer_in.[+ (get "float_short_name") +] ; Chris@40: Chris@40: for (k = 0 ; k < HALF_BUFFER_SIZE ; k++) Chris@40: { data_out [k] = 1.2 * sin (2 * M_PI * k / HALF_BUFFER_SIZE) ; Chris@40: data_out [k + HALF_BUFFER_SIZE] = data_out [k] * maxval ; Chris@40: } ; Chris@40: Chris@40: sfinfo.samplerate = 44100 ; Chris@40: sfinfo.frames = 123456789 ; /* Wrong length. Library should correct this on sf_close. */ Chris@40: sfinfo.channels = 1 ; Chris@40: sfinfo.format = filetype ; Chris@40: Chris@40: /* Chris@40: ** Write two versions of the data: Chris@40: ** normalized and clipped Chris@40: ** un-normalized and clipped. Chris@40: */ Chris@40: Chris@40: file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; Chris@40: sf_command (file, SFC_SET_CLIPPING, NULL, SF_TRUE) ; Chris@40: test_write_[+ (get "float_type_name") +]_or_die (file, 0, data_out, HALF_BUFFER_SIZE, __LINE__) ; Chris@40: sf_command (file, SFC_SET_NORM_[+ (get "float_upper_name") +], NULL, SF_FALSE) ; Chris@40: test_write_[+ (get "float_type_name") +]_or_die (file, 0, data_out + HALF_BUFFER_SIZE, HALF_BUFFER_SIZE, __LINE__) ; Chris@40: sf_close (file) ; Chris@40: Chris@40: memset (&buffer_in, 0, sizeof (buffer_in)) ; Chris@40: Chris@40: file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; Chris@40: Chris@40: sfinfo.format &= (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK) ; Chris@40: Chris@40: if (sfinfo.format != (filetype & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK))) Chris@40: { printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n\n", __LINE__, filetype, sfinfo.format) ; Chris@40: exit (1) ; Chris@40: } ; Chris@40: Chris@40: if (sfinfo.frames != BUFFER_SIZE) Chris@40: { printf ("\n\nLine %d: Incorrect number of frames in file (%d => %" PRId64 ").\n\n", __LINE__, BUFFER_SIZE, sfinfo.frames) ; Chris@40: exit (1) ; Chris@40: } ; Chris@40: Chris@40: if (sfinfo.channels != 1) Chris@40: { printf ("\n\nLine %d: Incorrect number of channels in file.\n\n", __LINE__) ; Chris@40: exit (1) ; Chris@40: } ; Chris@40: Chris@40: check_log_buffer_or_die (file, __LINE__) ; Chris@40: Chris@40: test_read_[+ (get "float_type_name") +]_or_die (file, 0, data_in, HALF_BUFFER_SIZE, __LINE__) ; Chris@40: sf_command (file, SFC_SET_NORM_[+ (get "float_upper_name") +], NULL, SF_FALSE) ; Chris@40: test_read_[+ (get "float_type_name") +]_or_die (file, 0, data_in + HALF_BUFFER_SIZE, HALF_BUFFER_SIZE, __LINE__) ; Chris@40: sf_close (file) ; Chris@40: Chris@40: /* Check normalized version. */ Chris@40: clip_max_diff = 0.0 ; Chris@40: for (k = 0 ; k < HALF_BUFFER_SIZE ; k++) Chris@40: { if (fabs (data_in [k]) > 1.0) Chris@40: { printf ("\n\nLine %d: Input sample %d/%d (%f) has not been clipped.\n\n", __LINE__, k, BUFFER_SIZE, data_in [k]) ; Chris@40: exit (1) ; Chris@40: } ; Chris@40: Chris@40: if (data_out [k] * data_in [k] < 0.0) Chris@40: { printf ("\n\nLine %d: Data wrap around at index %d/%d.\n\n", __LINE__, k, BUFFER_SIZE) ; Chris@40: exit (1) ; Chris@40: } ; Chris@40: Chris@40: if (fabs (data_out [k]) > 1.0) Chris@40: continue ; Chris@40: Chris@40: diff = fabs (data_out [k] - data_in [k]) ; Chris@40: if (diff > clip_max_diff) Chris@40: clip_max_diff = diff ; Chris@40: } ; Chris@40: Chris@40: if (clip_max_diff < 1e-20) Chris@40: { printf ("\n\nLine %d: Clipping difference (%e) too small (normalized).\n\n", __LINE__, clip_max_diff) ; Chris@40: exit (1) ; Chris@40: } ; Chris@40: Chris@40: if (clip_max_diff > [+ (get "error_val") +]) Chris@40: { printf ("\n\nLine %d: Clipping difference (%e) too large (normalized).\n\n", __LINE__, clip_max_diff) ; Chris@40: exit (1) ; Chris@40: } ; Chris@40: Chris@40: /* Check the un-normalized data. */ Chris@40: clip_max_diff = 0.0 ; Chris@40: for (k = HALF_BUFFER_SIZE ; k < BUFFER_SIZE ; k++) Chris@40: { if (fabs (data_in [k]) > maxval) Chris@40: { printf ("\n\nLine %d: Input sample %d/%d (%f) has not been clipped.\n\n", __LINE__, k, BUFFER_SIZE, data_in [k]) ; Chris@40: exit (1) ; Chris@40: } ; Chris@40: Chris@40: if (data_out [k] * data_in [k] < 0.0) Chris@40: { printf ("\n\nLine %d: Data wrap around at index %d/%d.\n\n", __LINE__, k, BUFFER_SIZE) ; Chris@40: exit (1) ; Chris@40: } ; Chris@40: Chris@40: if (fabs (data_out [k]) > maxval) Chris@40: continue ; Chris@40: Chris@40: diff = fabs (data_out [k] - data_in [k]) ; Chris@40: if (diff > clip_max_diff) Chris@40: clip_max_diff = diff ; Chris@40: } ; Chris@40: Chris@40: if (clip_max_diff < 1e-20) Chris@40: { printf ("\n\nLine %d: Clipping difference (%e) too small (un-normalized).\n\n", __LINE__, clip_max_diff) ; Chris@40: exit (1) ; Chris@40: } ; Chris@40: Chris@40: if (clip_max_diff > 1.0) Chris@40: { printf ("\n\nLine %d: Clipping difference (%e) too large (un-normalised).\n\n", __LINE__, clip_max_diff) ; Chris@40: exit (1) ; Chris@40: } ; Chris@40: Chris@40: printf ("ok\n") ; Chris@40: unlink (filename) ; Chris@40: } /* [+ (get "float_short_name") +]_scale_clip_test_[+ (get "name") +] */ Chris@40: Chris@40: [+ ENDFOR data_type Chris@40: +] Chris@40: [+ ENDFOR float_type +] Chris@40: Chris@40: /*============================================================================== Chris@40: */ Chris@40: Chris@40: [+ FOR float_type +] Chris@40: [+ FOR int_type Chris@40: +]static void [+ (get "float_short_name") +]_[+ (get "int_type_name") +]_clip_read_test (const char *filename, int filetype) Chris@40: { SNDFILE *file ; Chris@40: SF_INFO sfinfo ; Chris@40: [+ (get "float_type_name") +] *data_out ; Chris@40: [+ (get "int_type_name") +] *data_in, max_value ; Chris@40: int k ; Chris@40: Chris@40: print_test_name ("[+ (get "float_short_name") +]_[+ (get "int_type_name") +]_clip_read_test", filename) ; Chris@40: Chris@40: data_out = buffer_out.[+ (get "float_short_name") +] ; Chris@40: data_in = buffer_in.[+ (get "int_short_name") +] ; Chris@40: Chris@40: for (k = 0 ; k < BUFFER_SIZE ; k++) Chris@40: data_out [k] = 0.995 * sin (4 * M_PI * k / BUFFER_SIZE) ; Chris@40: data_out [BUFFER_SIZE / 8] = 1.0 ; Chris@40: data_out [3 * BUFFER_SIZE / 8] = -1.000000001 ; Chris@40: data_out [5 * BUFFER_SIZE / 8] = 1.0 ; Chris@40: data_out [7 * BUFFER_SIZE / 8] = -1.000000001 ; Chris@40: Chris@40: memset (&sfinfo, 0, sizeof (sfinfo)) ; Chris@40: sfinfo.samplerate = 44100 ; Chris@40: sfinfo.frames = 123456789 ; /* Wrong length. Library should correct this on sf_close. */ Chris@40: sfinfo.channels = 1 ; Chris@40: sfinfo.format = filetype ; Chris@40: Chris@40: /* Save unclipped data to the file. */ Chris@40: file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; Chris@40: test_write_[+ (get "float_type_name") +]_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ; Chris@40: sf_close (file) ; Chris@40: Chris@40: memset (&sfinfo, 0, sizeof (sfinfo)) ; Chris@40: Chris@40: file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; Chris@40: sf_command (file, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ; Chris@40: Chris@40: sfinfo.format &= (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK) ; Chris@40: Chris@40: if (sfinfo.format != (filetype & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK))) Chris@40: { printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n\n", __LINE__, filetype, sfinfo.format) ; Chris@40: exit (1) ; Chris@40: } ; Chris@40: Chris@40: if (sfinfo.frames != BUFFER_SIZE) Chris@40: { printf ("\n\nLine %d: Incorrect number of frames in file (%d => %" PRId64 ").\n\n", __LINE__, BUFFER_SIZE, sfinfo.frames) ; Chris@40: exit (1) ; Chris@40: } ; Chris@40: Chris@40: if (sfinfo.channels != 1) Chris@40: { printf ("\n\nLine %d: Incorrect number of channels in file.\n\n", __LINE__) ; Chris@40: exit (1) ; Chris@40: } ; Chris@40: Chris@40: check_log_buffer_or_die (file, __LINE__) ; Chris@40: Chris@40: sf_command (file, SFC_SET_CLIPPING, NULL, SF_TRUE) ; Chris@40: test_read_[+ (get "int_type_name") +]_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ; Chris@40: /*-sf_command (file, SFC_SET_NORM_[+ (get "float_upper_name") +], NULL, SF_FALSE) ;-*/ Chris@40: sf_close (file) ; Chris@40: Chris@40: /* Check the first half. */ Chris@40: max_value = 0 ; Chris@40: for (k = 0 ; k < sfinfo.frames ; k++) Chris@40: { /* Check if data_out has different sign from data_in. */ Chris@40: if ((data_out [k] < 0.0 && data_in [k] > 0) || (data_out [k] > 0.0 && data_in [k] < 0)) Chris@40: { printf ("\n\nLine %d: Data wrap around at index %d/%d (%f -> %d).\n\n", __LINE__, k, BUFFER_SIZE, data_out [k], data_in [k]) ; Chris@40: exit (1) ; Chris@40: } ; Chris@40: max_value = (max_value > abs (data_in [k])) ? max_value : abs (data_in [k]) ; Chris@40: } ; Chris@40: Chris@40: unlink (filename) ; Chris@40: puts ("ok") ; Chris@40: } /* [+ (get "float_short_name") +]_[+ (get "int_type_name") +]_clip_read_test */ Chris@40: [+ ENDFOR int_type Chris@40: +][+ ENDFOR float_type +] Chris@40: Chris@40: /*============================================================================== Chris@40: */ Chris@40: Chris@40: [+ FOR int_type +] Chris@40: [+ FOR float_type Chris@40: +]static void [+ (get "int_type_name") +]_[+ (get "float_short_name") +]_scale_write_test (const char *filename, int filetype) Chris@40: { SNDFILE *file ; Chris@40: SF_INFO sfinfo ; Chris@40: [+ (get "int_type_name") +] *data_out ; Chris@40: [+ (get "float_type_name") +] *data_in, max_value ; Chris@40: int k ; Chris@40: Chris@40: print_test_name ("[+ (get "int_type_name") +]_[+ (get "float_short_name") +]_clip_write_test", filename) ; Chris@40: Chris@40: data_out = buffer_out.[+ (get "int_short_name") +] ; Chris@40: data_in = buffer_in.[+ (get "float_short_name") +] ; Chris@40: Chris@40: for (k = 0 ; k < BUFFER_SIZE ; k++) Chris@40: data_out [k] = [+ (get "float_to_int") +] ([+ (get "int_max_value") +] * 0.995 * sin (4 * M_PI * k / BUFFER_SIZE)) ; Chris@40: Chris@40: memset (&sfinfo, 0, sizeof (sfinfo)) ; Chris@40: sfinfo.samplerate = 44100 ; Chris@40: sfinfo.frames = 123456789 ; /* Wrong length. Library should correct this on sf_close. */ Chris@40: sfinfo.channels = 1 ; Chris@40: sfinfo.format = filetype ; Chris@40: Chris@40: file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ; Chris@40: test_write_[+ (get "int_type_name") +]_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ; Chris@40: sf_command (file, SFC_SET_SCALE_INT_FLOAT_WRITE, NULL, SF_TRUE) ; Chris@40: test_write_[+ (get "int_type_name") +]_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ; Chris@40: sf_command (file, SFC_SET_SCALE_INT_FLOAT_WRITE, NULL, SF_FALSE) ; Chris@40: test_write_[+ (get "int_type_name") +]_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ; Chris@40: sf_close (file) ; Chris@40: Chris@40: memset (&sfinfo, 0, sizeof (sfinfo)) ; Chris@40: Chris@40: file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; Chris@40: Chris@40: sfinfo.format &= (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK) ; Chris@40: Chris@40: if (sfinfo.format != (filetype & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK))) Chris@40: { printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n\n", __LINE__, filetype, sfinfo.format) ; Chris@40: exit (1) ; Chris@40: } ; Chris@40: Chris@40: if (sfinfo.frames != 3 * BUFFER_SIZE) Chris@40: { printf ("\n\nLine %d: Incorrect number of frames in file (%d => %" PRId64 ").\n\n", __LINE__, 3 * BUFFER_SIZE, sfinfo.frames) ; Chris@40: exit (1) ; Chris@40: } ; Chris@40: Chris@40: if (sfinfo.channels != 1) Chris@40: { printf ("\n\nLine %d: Incorrect number of channels in file.\n\n", __LINE__) ; Chris@40: exit (1) ; Chris@40: } ; Chris@40: Chris@40: check_log_buffer_or_die (file, __LINE__) ; Chris@40: Chris@40: /* Check the first section. */ Chris@40: test_read_[+ (get "float_type_name") +]_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ; Chris@40: Chris@40: max_value = 0.0 ; Chris@40: for (k = 0 ; k < BUFFER_SIZE ; k++) Chris@40: max_value = (max_value > fabs (data_in [k])) ? max_value : fabs (data_in [k]) ; Chris@40: Chris@40: if (max_value < 1000.0) Chris@40: { printf ("\n\nLine %d: Max value (%f) < 1000.0.\n\n", __LINE__, max_value) ; Chris@40: exit (1) ; Chris@40: } ; Chris@40: Chris@40: /* Check the second section. */ Chris@40: test_read_[+ (get "float_type_name") +]_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ; Chris@40: Chris@40: max_value = 0.0 ; Chris@40: for (k = 0 ; k < BUFFER_SIZE ; k++) Chris@40: max_value = (max_value > fabs (data_in [k])) ? max_value : fabs (data_in [k]) ; Chris@40: Chris@40: if (max_value > 1.0) Chris@40: { printf ("\n\nLine %d: Max value (%f) > 1.0.\n\n", __LINE__, max_value) ; Chris@40: exit (1) ; Chris@40: } ; Chris@40: Chris@40: /* Check the third section. */ Chris@40: test_read_[+ (get "float_type_name") +]_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ; Chris@40: Chris@40: max_value = 0.0 ; Chris@40: for (k = 0 ; k < BUFFER_SIZE ; k++) Chris@40: max_value = (max_value > fabs (data_in [k])) ? max_value : fabs (data_in [k]) ; Chris@40: Chris@40: if (max_value < 1000.0) Chris@40: { printf ("\n\nLine %d: Max value (%f) < 1000.0.\n\n", __LINE__, max_value) ; Chris@40: exit (1) ; Chris@40: } ; Chris@40: Chris@40: sf_close (file) ; Chris@40: Chris@40: unlink (filename) ; Chris@40: puts ("ok") ; Chris@40: } /* [+ (get "int_type_name") +]_[+ (get "float_short_name") +]_scale_write_test */ Chris@40: [+ ENDFOR float_type Chris@40: +][+ ENDFOR int_type +] Chris@40: Chris@40: