Merge from -mdev branch.

This commit is contained in:
Erik de Castro Lopo 2007-10-28 22:10:39 +11:00
commit 966c9cfbcb
21 changed files with 524 additions and 237 deletions

View File

@ -1,7 +1,54 @@
2007-10-26 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/sd2.c
Identify sample-rate/sample-size/channels by resource id.
2007-10-25 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/broadcast.c src/common.h src/sndfile.c
Improvements to handling of broadcast info in WAV files. Thanks to Frederic
Cornu and other for their input.
2007-10-24 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/FLAC/include/share/alloc.h
Mingw fix for SIZE_T_MAX from Uli Franke.
2007-10-23 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* tests/open_fail_test.c tests/error_test.c tests/Makefile.am
Move tests from open_fail_test.c to error_test.c and remove the former.
2007-10-22 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* tests/scale_clip_test.(def|tpl)
Add tests for SFC_SET_INT_FLOAT_WRITE command.
* doc/command.html
Add docs for SFC_SET_INT_FLOAT_WRITE command.
* examples/sndfile-play.c tests/dft_cmp.c
Fix gcc-4.2 warning messages.
2007-10-21 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/sndfile.h.in src/sndfile.c
Add command SFC_GET_CURRENT_SF_INFO.
* src/sndfile.h.in src/sndfile.c src/create_symbols_file.py
Remove function sf_get_info (only ever in pre-release code).
* tests/command_test.c
Add test for SFC_GET_CURRENT_SF_INFO.
2007-10-15 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/wav.c
Add parsing of 'exif' chunks. Orignally coded by Trent Apted.
Add parsing of 'exif' chunks. Originally coded by Trent Apted.
* configure.ac
Put config stuff in Cfg directory.
Remove check for inttypes.h.
2007-10-10 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
@ -132,6 +179,12 @@
* src/sndfile.h.in tests/string_test.c src/flac.c
Add string type SF_STR_LICENSE, update test and use for FLAC files.
* src/sndfile.h.in
Add definition for SFC_SET_SCALE_FLOAT_INT_WRITE command.
* src/common.h src/double64.c src/float32.c src/sndfile.c
Add support for SFC_SET_SCALE_FLOAT_INT_WRITE (still needs testing).
2007-07-12 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/flac.c

View File

@ -108,9 +108,6 @@ AC_ARG_ENABLE(bow-docs,
AC_ARG_ENABLE(sqlite,
AC_HELP_STRING([--disable-sqlite], [disable use of sqlite]))
AC_ARG_ENABLE(flac,
AC_HELP_STRING([--disable-flac], [disable use of FLAC]))
AC_ARG_ENABLE(alsa,
AC_HELP_STRING([--disable-alsa], [disable use of ALSA]))

View File

@ -95,6 +95,13 @@
<TD>Set/clear the scale factor when integer (short/int) data is read from a file
containing floating point data.</TD>
</TR>
<TR>
<TD><A HREF="#SFC_SET_SCALE_INT_FLOAT_WRITE">SFC_SET_SCALE_INT_FLOAT_WRITE</A></TD>
<TD>Set/clear the scale factor when integer (short/int) data is written to a file
as floating point data.</TD>
</TR>
<TR>
<TD><A HREF="#SFC_GET_SIMPLE_FORMAT_COUNT">SFC_GET_SIMPLE_FORMAT_COUNT</A></TD>
<TD>Retrieve the number of simple formats supported by libsndfile.</TD>
@ -603,6 +610,33 @@ Example:
</DL>
<!-- ========================================================================= -->
<A NAME="SFC_SET_SCALE_INT_FLOAT_WRITE"></A>
<H2><BR><B>SFC_SET_SCALE_INT_FLOAT_WRITE</B></H2>
<P>
Set/clear the scale factor when integer (short/int) data is written to a file
as floating point data.
</P>
<P>
Parameters:
</P>
<PRE>
sndfile : A valid SNDFILE* pointer
cmd : SFC_SET_SCALE_FLOAT_INT_READ
data : NULL
datasize : TRUE or FALSE
</PRE>
<P>
Example:
</P>
<PRE>
sf_command (sndfile, SFC_SET_SCALE_INT_FLOAT_WRITE, NULL, SF_TRUE) ;
</PRE>
<DL>
<DT>Return value: </DT>
<DD>Returns the previous SFC_SET_SCALE_INT_FLOAT_WRITE setting for this file.
</DL>
<!-- ========================================================================= -->
<A NAME="SFC_GET_SIMPLE_FORMAT_COUNT"></A>
<H2><BR><B>SFC_GET_SIMPLE_FORMAT_COUNT</B></H2>

View File

@ -270,7 +270,6 @@ static int
alsa_write_float (snd_pcm_t *alsa_dev, float *data, int frames, int channels)
{ static int epipe_count = 0 ;
snd_pcm_status_t *status ;
int total = 0 ;
int retval ;
@ -302,8 +301,11 @@ alsa_write_float (snd_pcm_t *alsa_dev, float *data, int frames, int channels)
} ;
epipe_count += 100 ;
#if 0
if (0)
{ snd_pcm_status_alloca (&status) ;
{ snd_pcm_status_t *status ;
snd_pcm_status_alloca (&status) ;
if ((retval = snd_pcm_status (alsa_dev, status)) < 0)
fprintf (stderr, "alsa_out: xrun. can't determine length\n") ;
else if (snd_pcm_status_get_state (status) == SND_PCM_STATE_XRUN)
@ -319,6 +321,7 @@ alsa_write_float (snd_pcm_t *alsa_dev, float *data, int frames, int channels)
else
fprintf (stderr, "alsa_write_float: xrun. can't determine length\n") ;
} ;
#endif
snd_pcm_prepare (alsa_dev) ;
break ;

View File

@ -35,7 +35,7 @@
#ifndef SIZE_MAX
# ifndef SIZE_T_MAX
# ifdef _MSC_VER
# if defined(_MSC_VER) || defined(__MINGW32__)
# define SIZE_T_MAX UINT_MAX
# else
# error

View File

@ -1,6 +1,6 @@
/*
** Copyright (C) 2006 Paul Davis <paul@linuxaudiosystems.com>
** Copyright (C) 2006 Erik de Castro Lopo <erikd@mega-nerd.com>
** Copyright (C) 2006, 2007 Erik de Castro Lopo <erikd@mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@ -47,9 +47,28 @@ broadcast_info_copy (SF_BROADCAST_INFO* dst, SF_BROADCAST_INFO* src)
} /* broadcast_info_copy */
int
broadcast_add_coding_history (SF_BROADCAST_INFO* bext, unsigned int channels, unsigned int samplerate)
{ char chnstr [16] ;
int count ;
broadcast_add_coding_history (SF_BROADCAST_INFO* bext, unsigned int channels, unsigned int samplerate, int format)
{ const char *newline ;
char chnstr [16], history [2 * sizeof (bext->coding_history)] ;
int count, width, current_history_len ;
/*
** From : http://www.sr.se/utveckling/tu/bwf/docs/codhist2.htm
**
** Parameter Variable string <allowed option> Unit
** ==========================================================================================
** Coding Algorithm A=<ANALOGUE, PCM, MPEG1L1, MPEG1L2, MPEG1L3,
** MPEG2L1, MPEG2L2, MPEG2L3>
** Sampling frequency F=<11000,22050,24000,32000,44100,48000> [Hz]
** Bit-rate B=<any bit-rate allowed in MPEG 2 (ISO/IEC [kbit/s per channel]
** 13818-3)>
** Word Length W=<8, 12, 14, 16, 18, 20, 22, 24> [bits]
** Mode M=<mono, stereo, dual-mono, joint-stereo>
** Text, free string T=<a free ASCII-text string for in house use.
** This string should contain no commas (ASCII
** 2Chex). Examples of the contents: ID-No; codec
** type; A/D type>
*/
switch (channels)
{ case 0 :
@ -63,27 +82,76 @@ broadcast_add_coding_history (SF_BROADCAST_INFO* bext, unsigned int channels, un
strncpy (chnstr, "stereo", sizeof (chnstr)) ;
break ;
default :
LSF_SNPRINTF (chnstr, sizeof (chnstr), "%uchn", channels) ;
break ;
}
count = LSF_SNPRINTF (bext->coding_history, sizeof (bext->coding_history), "F=%u,A=PCM,M=%s,W=24,T=%s-%s", samplerate, chnstr, PACKAGE, VERSION) ;
if (count >= SIGNED_SIZEOF (bext->coding_history))
bext->coding_history_size = sizeof (bext->coding_history) ;
else
{ count += count & 1 ;
bext->coding_history_size = count ;
default :
LSF_SNPRINTF (chnstr, sizeof (chnstr), "%uchn", channels) ;
break ;
} ;
switch (format & SF_FORMAT_SUBMASK)
{ case SF_FORMAT_PCM_U8 :
case SF_FORMAT_PCM_S8 :
width = 8 ;
break ;
case SF_FORMAT_PCM_16 :
width = 16 ;
break ;
case SF_FORMAT_PCM_24 :
width = 24 ;
break ;
case SF_FORMAT_PCM_32 :
width = 32 ;
break ;
case SF_FORMAT_FLOAT :
width = 24 ; /* Bits in the mantissa + 1 */
break ;
case SF_FORMAT_DOUBLE :
width = 53 ; /* Bits in the mantissa + 1 */
break ;
case SF_FORMAT_ULAW :
case SF_FORMAT_ALAW :
width = 12 ;
break ;
default :
width = 42 ;
break ;
} ;
/* Make sure its a terminated C string. */
bext->coding_history [sizeof (bext->coding_history) - 1] = 0 ;
current_history_len = strlen (bext->coding_history) ;
newline = "" ;
if (current_history_len != 0 && bext->coding_history [current_history_len - 1] != '\n')
newline = "\n" ;
memset (history, 0, sizeof (history)) ;
count = LSF_SNPRINTF (history, sizeof (history), "%s%sF=%u,A=PCM,M=%s,W=%hu,T=%s-%s\n", bext->coding_history, newline, samplerate, chnstr, width, PACKAGE, VERSION) ;
while (count >= SIGNED_SIZEOF (bext->coding_history))
{ /* Coding history is too long, delete oldest part. */
const char *cptr ;
/* Entries should be delimited by a newline, so find first newline. */
if ((cptr = strchr (history, '\n')) == NULL)
{ /* Ooops, fail to safe and leave a message. */
count = snprintf (history, sizeof (bext->coding_history), "Something went wrong!\n") ;
break ;
} ;
cptr ++ ;
count -= cptr - history ;
memmove (history, cptr, count) ;
} ;
/* Zero out end of history chunk. */
memset (history + count, 0, sizeof (history) - count) ;
/* Now copy from temporary storage to bext->coding_history. */
memcpy (bext->coding_history, history, sizeof (bext->coding_history)) ;
count += count & 1 ;
bext->coding_history_size = count ;
return SF_TRUE ;
} /* broadcast_add_coding_history */
/*
** Do not edit or modify anything in this comment block.
** The following line is a file identity tag for the GNU Arch
** revision control system.
**
** arch-tag: 4b3b69c7-d710-4424-9da0-5048534a0beb
*/

View File

@ -283,6 +283,8 @@ typedef struct sf_private_tag
int float_int_mult ;
float float_max ;
int scale_int_float ;
/* Vairables for handling pipes. */
int is_pipe ; /* True if file is a pipe. */
sf_count_t pipeoffset ; /* Number of bytes read from a pipe. */
@ -748,7 +750,7 @@ void psf_get_date_str (char *str, int maxlen) ;
SF_BROADCAST_INFO* broadcast_info_alloc (void) ;
int broadcast_info_copy (SF_BROADCAST_INFO* dst, SF_BROADCAST_INFO* src) ;
int broadcast_add_coding_history (SF_BROADCAST_INFO* bext, unsigned int channels, unsigned int samplerate) ;
int broadcast_add_coding_history (SF_BROADCAST_INFO* bext, unsigned int channels, unsigned int samplerate, int format) ;
typedef struct
{ int channels ;

View File

@ -69,7 +69,6 @@ ALL_SYMBOLS = (
( "sf_strerror", 50 ),
( "sf_get_string", 60 ),
( "sf_set_string", 61 ),
( "sf_get_info", 68 ),
( "sf_open_fd", 70 ),
( "sf_open_virtual", 80 ),
( "sf_write_sync", 90 )

View File

@ -529,16 +529,16 @@ d2f_array (const double *src, int count, float *dest)
} /* d2f_array */
static inline void
s2d_array (const short *src, double *dest, int count)
s2d_array (const short *src, double *dest, int count, double scale)
{ while (--count >= 0)
{ dest [count] = src [count] ;
{ dest [count] = scale * src [count] ;
} ;
} /* s2d_array */
static inline void
i2d_array (const int *src, double *dest, int count)
i2d_array (const int *src, double *dest, int count, double scale)
{ while (--count >= 0)
{ dest [count] = src [count] ;
{ dest [count] = scale * src [count] ;
} ;
} /* i2d_array */
@ -669,14 +669,16 @@ static sf_count_t
host_write_s2d (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
{ int bufferlen, writecount ;
sf_count_t total = 0 ;
double scale ;
scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / 0x8000 ;
bufferlen = ARRAY_LEN (psf->u.dbuf) ;
while (len > 0)
{ if (len < bufferlen)
bufferlen = (int) len ;
s2d_array (ptr + total, psf->u.dbuf, bufferlen) ;
s2d_array (ptr + total, psf->u.dbuf, bufferlen, scale) ;
if (psf->peak_info)
double64_peak_update (psf, psf->u.dbuf, bufferlen, total / psf->sf.channels) ;
@ -698,13 +700,15 @@ static sf_count_t
host_write_i2d (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
{ int bufferlen, writecount ;
sf_count_t total = 0 ;
double scale ;
scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / (8.0 * 0x10000000) ;
bufferlen = ARRAY_LEN (psf->u.dbuf) ;
while (len > 0)
{ if (len < bufferlen)
bufferlen = (int) len ;
i2d_array (ptr + total, psf->u.dbuf, bufferlen) ;
i2d_array (ptr + total, psf->u.dbuf, bufferlen, scale) ;
if (psf->peak_info)
double64_peak_update (psf, psf->u.dbuf, bufferlen, total / psf->sf.channels) ;
@ -901,13 +905,15 @@ static sf_count_t
replace_write_s2d (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
{ int bufferlen, writecount ;
sf_count_t total = 0 ;
double scale ;
scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / 0x8000 ;
bufferlen = ARRAY_LEN (psf->u.dbuf) ;
while (len > 0)
{ if (len < bufferlen)
bufferlen = (int) len ;
s2d_array (ptr + total, psf->u.dbuf, bufferlen) ;
s2d_array (ptr + total, psf->u.dbuf, bufferlen, scale) ;
if (psf->peak_info)
double64_peak_update (psf, psf->u.dbuf, bufferlen, total / psf->sf.channels) ;
@ -931,13 +937,15 @@ static sf_count_t
replace_write_i2d (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
{ int bufferlen, writecount ;
sf_count_t total = 0 ;
double scale ;
scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / (8.0 * 0x10000000) ;
bufferlen = ARRAY_LEN (psf->u.dbuf) ;
while (len > 0)
{ if (len < bufferlen)
bufferlen = (int) len ;
i2d_array (ptr + total, psf->u.dbuf, bufferlen) ;
i2d_array (ptr + total, psf->u.dbuf, bufferlen, scale) ;
if (psf->peak_info)
double64_peak_update (psf, psf->u.dbuf, bufferlen, total / psf->sf.channels) ;

View File

@ -480,17 +480,16 @@ f2d_array (const float *src, int count, double *dest)
} /* f2d_array */
static inline void
s2f_array (const short *src, float *dest, int count)
s2f_array (const short *src, float *dest, int count, float scale)
{ while (--count >= 0)
{ dest [count] = src [count] ;
{ dest [count] = scale * src [count] ;
} ;
} /* s2f_array */
static inline void
i2f_array (const int *src, float *dest, int count)
i2f_array (const int *src, float *dest, int count, float scale)
{ while (--count >= 0)
{ dest [count] = src [count] ;
{ dest [count] = scale * src [count] ;
} ;
} /* i2f_array */
@ -619,13 +618,16 @@ static sf_count_t
host_write_s2f (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
{ int bufferlen, writecount ;
sf_count_t total = 0 ;
float scale ;
/* Erik */
scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / 0x8000 ;
bufferlen = ARRAY_LEN (psf->u.fbuf) ;
while (len > 0)
{ if (len < bufferlen)
bufferlen = (int) len ;
s2f_array (ptr + total, psf->u.fbuf, bufferlen) ;
s2f_array (ptr + total, psf->u.fbuf, bufferlen, scale) ;
if (psf->peak_info)
float32_peak_update (psf, psf->u.fbuf, bufferlen, total / psf->sf.channels) ;
@ -647,13 +649,15 @@ static sf_count_t
host_write_i2f (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
{ int bufferlen, writecount ;
sf_count_t total = 0 ;
float scale ;
scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / (8.0 * 0x10000000) ;
bufferlen = ARRAY_LEN (psf->u.fbuf) ;
while (len > 0)
{ if (len < bufferlen)
bufferlen = (int) len ;
i2f_array (ptr + total, psf->u.fbuf, bufferlen) ;
i2f_array (ptr + total, psf->u.fbuf, bufferlen, scale) ;
if (psf->peak_info)
float32_peak_update (psf, psf->u.fbuf, bufferlen, total / psf->sf.channels) ;
@ -851,13 +855,15 @@ static sf_count_t
replace_write_s2f (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
{ int bufferlen, writecount ;
sf_count_t total = 0 ;
float scale ;
scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / 0x8000 ;
bufferlen = ARRAY_LEN (psf->u.fbuf) ;
while (len > 0)
{ if (len < bufferlen)
bufferlen = (int) len ;
s2f_array (ptr + total, psf->u.fbuf, bufferlen) ;
s2f_array (ptr + total, psf->u.fbuf, bufferlen, scale) ;
if (psf->peak_info)
float32_peak_update (psf, psf->u.fbuf, bufferlen, total / psf->sf.channels) ;
@ -881,13 +887,15 @@ static sf_count_t
replace_write_i2f (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
{ int bufferlen, writecount ;
sf_count_t total = 0 ;
float scale ;
scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / (8.0 * 0x10000000) ;
bufferlen = ARRAY_LEN (psf->u.fbuf) ;
while (len > 0)
{ if (len < bufferlen)
bufferlen = (int) len ;
i2f_array (ptr + total, psf->u.fbuf, bufferlen) ;
i2f_array (ptr + total, psf->u.fbuf, bufferlen, scale) ;
if (psf->peak_info)
float32_peak_update (psf, psf->u.fbuf, bufferlen, total / psf->sf.channels) ;
@ -986,10 +994,3 @@ f2bf_array (float *buffer, int count)
} ;
} /* f2bf_array */
/*
** Do not edit or modify anything in this comment block.
** The arch-tag line is a file identity tag for the GNU Arch
** revision control system.
**
** arch-tag: b6c34917-488c-4145-9648-f4371fc4c889
*/

View File

@ -1,5 +1,5 @@
/*
** Copyright (C) 2001-2006 Erik de Castro Lopo <erikd@mega-nerd.com>
** Copyright (C) 2001-2007 Erik de Castro Lopo <erikd@mega-nerd.com>
** Copyright (C) 2004 Paavo Jumppanen
**
** This program is free software; you can redistribute it and/or modify
@ -533,9 +533,9 @@ parse_str_rsrc (SF_PRIVATE *psf, SD2_RSRC * rsrc)
psf_log_printf (psf, "Finding parameters :\n") ;
str_offset = rsrc->string_offset ;
psf_log_printf (psf, " Name Offset RsrcId dlen slen Value\n") ;
psf_log_printf (psf, " Offset RsrcId dlen slen Value\n") ;
for (k = 0 ; k < rsrc->str_count ; k++)
for (k = 0 ; k < rsrc->str_count + 2 ; k++)
{ int slen ;
slen = read_char (rsrc->rsrc_data, str_offset) ;
@ -547,28 +547,33 @@ parse_str_rsrc (SF_PRIVATE *psf, SD2_RSRC * rsrc)
data_offset = rsrc->data_offset + read_int (rsrc->rsrc_data, rsrc->item_offset + k * 12 + 4) ;
if (data_offset < 0 || data_offset > rsrc->rsrc_len)
{ psf_log_printf (psf, "Bad data offset (%d)\n", data_offset) ;
return SFE_SD2_BAD_DATA_OFFSET ;
break ;
} ;
data_len = read_int (rsrc->rsrc_data, data_offset) ;
if (data_len < 0 || data_len > rsrc->rsrc_len)
{ psf_log_printf (psf, "Bad data length (%d).\n", data_len) ;
return SFE_SD2_BAD_RSRC ;
break ;
} ;
slen = read_char (rsrc->rsrc_data, data_offset + 4) ;
read_str (rsrc->rsrc_data, data_offset + 5, value, SF_MIN (SIGNED_SIZEOF (value), slen + 1)) ;
psf_log_printf (psf, " %-12s 0x%04x %4d %2d %2d '%s'\n", name, data_offset, rsrc_id, data_len, slen, value) ;
psf_log_printf (psf, " 0x%04x %4d %3d %3d '%s'\n", data_offset, rsrc_id, data_len, slen, value) ;
if (strcmp (name, "sample-size") == 0 && rsrc->sample_size == 0)
if (rsrc_id == 1000 && rsrc->sample_size == 0)
rsrc->sample_size = strtol (value, NULL, 10) ;
else if (strcmp (name, "sample-rate") == 0 && rsrc->sample_rate == 0)
else if (rsrc_id == 1001 && rsrc->sample_rate == 0)
rsrc->sample_rate = strtol (value, NULL, 10) ;
else if (strcmp (name, "channels") == 0 && rsrc->channels == 0)
else if (rsrc_id == 1002 && rsrc->channels == 0)
rsrc->channels = strtol (value, NULL, 10) ;
} ;
psf_log_printf (psf, "Found Parameters :\n") ;
psf_log_printf (psf, " sample-size : %d\n", rsrc->sample_size) ;
psf_log_printf (psf, " sample-rate : %d\n", rsrc->sample_rate) ;
psf_log_printf (psf, " channels : %d\n", rsrc->channels) ;
if (rsrc->sample_rate <= 4 && rsrc->sample_size > 4)
{ int temp ;
@ -615,10 +620,3 @@ parse_str_rsrc (SF_PRIVATE *psf, SD2_RSRC * rsrc)
return 0 ;
} /* parse_str_rsrc */
/*
** Do not edit or modify anything in this comment block.
** The arch-tag line is a file identity tag for the GNU Arch
** revision control system.
**
** arch-tag: 1ee183e5-6b9f-4c2c-bd0a-24f35595cefc
*/

View File

@ -865,6 +865,12 @@ sf_command (SNDFILE *sndfile, int command, void *data, int datasize)
psf->norm_float = (datasize) ? SF_TRUE : SF_FALSE ;
return old_value ;
case SFC_GET_CURRENT_SF_INFO :
if (data == NULL || datasize != SIGNED_SIZEOF (SF_INFO))
return (sf_errno = SFE_BAD_CONTROL_CMD) ;
memcpy (data, &psf->sf, sizeof (SF_INFO)) ;
break ;
case SFC_SET_NORM_DOUBLE :
old_value = psf->norm_double ;
psf->norm_double = (datasize) ? SF_TRUE : SF_FALSE ;
@ -884,6 +890,11 @@ sf_command (SNDFILE *sndfile, int command, void *data, int datasize)
psf->float_max = psf_calc_signal_max (psf, SF_FALSE) ;
return old_value ;
case SFC_SET_SCALE_INT_FLOAT_WRITE :
old_value = psf->scale_int_float ;
psf->scale_int_float = (datasize != 0) ? SF_TRUE : SF_FALSE ;
return old_value ;
case SFC_SET_ADD_PEAK_CHUNK :
{ int format = psf->sf.format & SF_FORMAT_TYPEMASK ;
@ -1080,7 +1091,7 @@ sf_command (SNDFILE *sndfile, int command, void *data, int datasize)
psf->broadcast_info = broadcast_info_alloc () ;
broadcast_info_copy (psf->broadcast_info, data) ;
broadcast_add_coding_history (psf->broadcast_info, psf->sf.channels, psf->sf.samplerate) ;
broadcast_add_coding_history (psf->broadcast_info, psf->sf.channels, psf->sf.samplerate, psf->sf.format) ;
if (psf->write_header)
psf->write_header (psf, SF_TRUE) ;
@ -1241,23 +1252,6 @@ sf_seek (SNDFILE *sndfile, sf_count_t offset, int whence)
/*------------------------------------------------------------------------------
*/
int
sf_get_info (SNDFILE * sndfile, SF_INFO * info)
{ SF_PRIVATE *psf ;
if (info == NULL)
return SF_FALSE ;
if ((psf = (SF_PRIVATE*) sndfile) == NULL)
return SF_FALSE ;
if (psf->Magick != SNDFILE_MAGICK)
return SF_FALSE ;
/* Need to correct psf->sf.frames ???? */
memcpy (info, &psf->sf, sizeof (SF_INFO)) ;
return SF_TRUE ;
} /* sf_get_info */
const char*
sf_get_string (SNDFILE *sndfile, int str_type)
{ SF_PRIVATE *psf ;
@ -2753,10 +2747,3 @@ error_exit :
return NULL ;
} /* psf_open_file */
/*
** Do not edit or modify anything in this comment block.
** The arch-tag line is a file identity tag for the GNU Arch
** revision control system.
**
** arch-tag: cd4f9e91-a8ec-4154-9bf6-fe4b8c69a615
*/

View File

@ -124,12 +124,15 @@ enum
enum
{ SFC_GET_LIB_VERSION = 0x1000,
SFC_GET_LOG_INFO = 0x1001,
SFC_GET_CURRENT_SF_INFO = 0x1002,
SFC_GET_NORM_DOUBLE = 0x1010,
SFC_GET_NORM_FLOAT = 0x1011,
SFC_SET_NORM_DOUBLE = 0x1012,
SFC_SET_NORM_FLOAT = 0x1013,
SFC_SET_SCALE_FLOAT_INT_READ = 0x1014,
SFC_SET_SCALE_INT_FLOAT_WRITE = 0x1015,
SFC_GET_SIMPLE_FORMAT_COUNT = 0x1020,
SFC_GET_SIMPLE_FORMAT = 0x1021,
@ -524,12 +527,6 @@ int sf_format_check (const SF_INFO *info) ;
sf_count_t sf_seek (SNDFILE *sndfile, sf_count_t frames, int whence) ;
/* Retrieve the SF_INFO struct for the given SNDFILE. Returns SF_FALSE on
** failure, SF_TRUE otherwise.
*/
int sf_get_info (SNDFILE * sndfile, SF_INFO * info) ;
/* Functions for retrieving and setting string data within sound files.
** Not all file types support this features; AIFF and WAV do. For both
** functions, the str_type parameter must be one of the SF_STR_* values

View File

@ -1613,7 +1613,7 @@ wav_read_acid_chunk (SF_PRIVATE *psf, unsigned int chunklen)
return 0 ;
} /* wav_read_acid_chunk */
int
static int
wav_read_bext_chunk (SF_PRIVATE *psf, unsigned int chunksize)
{
SF_BROADCAST_INFO* b ;

View File

@ -10,7 +10,7 @@ noinst_PROGRAMS = sfversion floating_point_test write_read_test \
lossy_comp_test error_test ulaw_test alaw_test dwvw_test \
peak_chunk_test command_test stdin_test stdout_test stdio_test \
pcm_test headerless_test pipe_test benchmark header_test misc_test \
raw_test string_test open_fail_test multi_file_test dither_test \
raw_test string_test multi_file_test dither_test \
scale_clip_test win32_test fix_this aiff_rw_test virtual_io_test \
locale_test largefile_test win32_ordinal_test ogg_test vorbis_test \
$(CPP_TEST)
@ -101,9 +101,6 @@ string_test_LDADD = $(SNDFILEDIR)/libsndfile.la
dither_test_SOURCES = dither_test.c utils.c
dither_test_LDADD = $(SNDFILEDIR)/libsndfile.la
open_fail_test_SOURCES = open_fail_test.c utils.c
open_fail_test_LDADD = $(SNDFILEDIR)/libsndfile.la
multi_file_test_SOURCES = multi_file_test.c utils.c
multi_file_test_LDADD = $(SNDFILEDIR)/libsndfile.la
@ -217,7 +214,6 @@ wav-tests: write_read_test lossy_comp_test peak_chunk_test header_test misc_test
./misc_test wav
./string_test wav
./multi_file_test wav
./open_fail_test wav
@echo "----------------------------------------------------------------------"
@echo " `./sfversion` passed tests on WAV files."
@echo "----------------------------------------------------------------------"

View File

@ -36,14 +36,15 @@
#define BUFFER_LEN (1<<10)
#define LOG_BUFFER_SIZE 1024
static void float_norm_test (const char *filename) ;
static void double_norm_test (const char *filename) ;
static void format_tests (void) ;
static void calc_peak_test (int filetype, const char *filename) ;
static void truncate_test (const char *filename, int filetype) ;
static void instrument_test (const char *filename, int filetype) ;
static void channel_map_test (const char *filename, int filetype) ;
static void broadcast_test (const char *filename, int filetype) ;
static void float_norm_test (const char *filename) ;
static void double_norm_test (const char *filename) ;
static void format_tests (void) ;
static void calc_peak_test (int filetype, const char *filename) ;
static void truncate_test (const char *filename, int filetype) ;
static void instrument_test (const char *filename, int filetype) ;
static void channel_map_test (const char *filename, int filetype) ;
static void broadcast_test (const char *filename, int filetype) ;
static void current_sf_info_test (const char *filename) ;
/* Force the start of this buffer to be double aligned. Sparc-solaris will
** choke if its not.
@ -130,6 +131,11 @@ main (int argc, char *argv [])
test_count++ ;
} ;
if (do_all || strcmp (argv [1], "current_sf_info") == 0)
{ current_sf_info_test ("current.wav") ;
test_count++ ;
} ;
if (test_count == 0)
{ printf ("Mono : ************************************\n") ;
printf ("Mono : * No '%s' test defined.\n", argv [1]) ;
@ -870,11 +876,52 @@ channel_map_test (const char *filename, int filetype)
puts ("ok") ;
} /* channel_map_test */
static void
current_sf_info_test (const char *filename)
{ SNDFILE *outfile, *infile ;
SF_INFO outinfo, ininfo ;
sf_count_t last_count ;
print_test_name ("current_sf_info_test", filename) ;
outinfo.samplerate = 44100 ;
outinfo.format = (SF_FORMAT_WAV | SF_FORMAT_PCM_16) ;
outinfo.channels = 1 ;
outinfo.frames = 0 ;
outfile = test_open_file_or_die (filename, SFM_WRITE, &outinfo, SF_TRUE, __LINE__) ;
sf_command (outfile, SFC_SET_UPDATE_HEADER_AUTO, NULL, 0) ;
exit_if_true (outinfo.frames != 0,
"\n\nLine %d : Initial sfinfo.frames is not zero.\n\n", __LINE__
) ;
test_write_double_or_die (outfile, 0, double_data, BUFFER_LEN, __LINE__) ;
sf_command (outfile, SFC_GET_CURRENT_SF_INFO, &outinfo, sizeof (outinfo)) ;
exit_if_true (outinfo.frames != BUFFER_LEN,
"\n\nLine %d : Initial sfinfo.frames (%ld) should be %d.\n\n", __LINE__,
SF_COUNT_TO_LONG (outinfo.frames), BUFFER_LEN
) ;
/* Read file making sure no channel map exists. */
infile = test_open_file_or_die (filename, SFM_READ, &ininfo, SF_TRUE, __LINE__) ;
last_count = ininfo.frames ;
test_write_double_or_die (outfile, 0, double_data, BUFFER_LEN, __LINE__) ;
sf_command (infile, SFC_GET_CURRENT_SF_INFO, &ininfo, sizeof (ininfo)) ;
exit_if_true (ininfo.frames != BUFFER_LEN,
"\n\nLine %d : Initial sfinfo.frames (%ld) should be %d.\n\n", __LINE__,
SF_COUNT_TO_LONG (ininfo.frames), BUFFER_LEN
) ;
sf_close (outfile) ;
sf_close (infile) ;
unlink (filename) ;
puts ("ok") ;
} /* current_sf_info_test */
/*
** Do not edit or modify anything in this comment block.
** The following line is a file identity tag for the GNU Arch
** revision control system.
**
** arch-tag: 59e5d452-8dae-45aa-99aa-b78dc0deba1c
*/

View File

@ -42,11 +42,6 @@ dft_cmp_float (int linenum, const float *in_data, const float *test_data, int le
static double test [DFT_DATA_LENGTH] ;
unsigned k ;
if (! orig || ! test)
{ printf ("Error (line %d) : dft_cmp_float : Bad input arrays.\n", linenum) ;
return 1 ;
} ;
if (len != DFT_DATA_LENGTH)
{ printf ("Error (line %d) : dft_cmp_float : Bad input array length.\n", linenum) ;
return 1 ;

View File

@ -33,17 +33,6 @@
#define BUFFER_SIZE (1<<15)
#define SHORT_BUFFER (256)
static void error_number_test (void) ;
static void error_value_test (void) ;
int
main (void)
{ error_number_test () ;
error_value_test () ;
return 0 ;
} /* main */
static void
error_number_test (void)
{ const char *noerror, *errstr ;
@ -104,10 +93,90 @@ error_value_test (void)
return ;
} /* error_value_test */
/*
** Do not edit or modify anything in this comment block.
** The arch-tag line is a file identity tag for the GNU Arch
** revision control system.
**
** arch-tag: 799eba74-b505-49d9-89a6-22a7f51a31b4
*/
static void
no_file_test (const char * filename)
{ SNDFILE *sndfile ;
SF_INFO sfinfo ;
print_test_name (__func__, filename) ;
unlink (filename) ;
memset (&sfinfo, 0, sizeof (sfinfo)) ;
sndfile = sf_open (filename, SFM_READ, &sfinfo) ;
exit_if_true (sndfile != NULL, "\n\nLine %d : should not have received a valid SNDFILE* pointer.\n", __LINE__) ;
unlink (filename) ;
puts ("ok") ;
} /* no_file_test */
static void
zero_length_test (const char *filename)
{ SNDFILE *sndfile ;
SF_INFO sfinfo ;
FILE *file ;
print_test_name (__func__, filename) ;
/* Create a zero length file. */
file = fopen (filename, "w") ;
exit_if_true (file == NULL, "\n\nLine %d : fopen ('%s') failed.\n", __LINE__, filename) ;
fclose (file) ;
memset (&sfinfo, 0, sizeof (sfinfo)) ;
sndfile = sf_open (filename, SFM_READ, &sfinfo) ;
exit_if_true (sndfile != NULL, "\n\nLine %d : should not have received a valid SNDFILE* pointer.\n", __LINE__) ;
exit_if_true (0 && sf_error (NULL) != SF_ERR_UNRECOGNISED_FORMAT,
"\n\nLine %3d : Error : %s\n should be : %s\n", __LINE__,
sf_strerror (NULL), sf_error_number (SF_ERR_UNRECOGNISED_FORMAT)) ;
unlink (filename) ;
puts ("ok") ;
} /* zero_length_test */
static void
bad_wav_test (const char * filename)
{ SNDFILE *sndfile ;
SF_INFO sfinfo ;
FILE *file ;
const char data [] = "RIFF WAVEfmt " ;
print_test_name (__func__, filename) ;
if ((file = fopen (filename, "w")) == NULL)
{ printf ("\n\nLine %d : fopen returned NULL.\n", __LINE__) ;
exit (1) ;
} ;
fwrite (data, sizeof (data), 1, file) ;
fclose (file) ;
memset (&sfinfo, 0, sizeof (sfinfo)) ;
sndfile = sf_open (filename, SFM_READ, &sfinfo) ;
if (sndfile)
{ printf ("\n\nLine %d : should not have received a valid SNDFILE* pointer.\n", __LINE__) ;
exit (1) ;
} ;
unlink (filename) ;
puts ("ok") ;
} /* bad_wav_test */
int
main (void)
{
error_number_test () ;
error_value_test () ;
no_file_test ("no_file.wav") ;
zero_length_test ("zero_length.wav") ;
bad_wav_test ("bad_wav.wav") ;
return 0 ;
} /* main */

View File

@ -1,81 +0,0 @@
/*
** Copyright (C) 2003,2004 Erik de Castro Lopo <erikd@mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "sfconfig.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sndfile.h>
#include "utils.h"
int
main (void)
{ SNDFILE *sndfile ;
SF_INFO sfinfo ;
FILE *bad_file ;
const char *bad_wav = "bad_wav.wav" ;
const char bad_data [] = "RIFF WAVEfmt " ;
print_test_name ("open_fail_test", bad_wav) ;
memset (&sfinfo, 0, sizeof (sfinfo)) ;
sndfile = sf_open ("let's hope this file doesn't exist", SFM_READ, &sfinfo) ;
if (sndfile)
{ printf ("Line %d: should not have received a valid SNDFILE* pointer.\n", __LINE__) ;
exit (1) ;
} ;
if ((bad_file = fopen (bad_wav, "w")) == NULL)
{ printf ("Line %d: fopen returned NULL.\n", __LINE__) ;
exit (1) ;
} ;
fwrite (bad_data, sizeof (bad_data), 1, bad_file) ;
fclose (bad_file) ;
sndfile = sf_open (bad_wav, SFM_READ, &sfinfo) ;
if (sndfile)
{ printf ("Line %d: should not have received a valid SNDFILE* pointer.\n", __LINE__) ;
exit (1) ;
} ;
unlink (bad_wav) ;
puts ("ok") ;
return 0 ;
} /* main */
/*
** Do not edit or modify anything in this comment block.
** The arch-tag line is a file identity tag for the GNU Arch
** revision control system.
**
** arch-tag: 24440323-00b1-4e4b-87c5-0e3b7e9605e9
*/

View File

@ -4,12 +4,14 @@ float_type = {
float_type_name = "float" ;
float_short_name = "flt" ;
float_upper_name = "FLOAT" ;
float_to_int = "lrintf" ;
} ;
float_type = {
float_type_name = "double" ;
float_short_name = "dbl" ;
float_upper_name = "DOUBLE" ;
float_to_int = "lrint" ;
} ;

View File

@ -1,6 +1,6 @@
[+ AutoGen5 template c +]
/*
** Copyright (C) 1999-2006 Erik de Castro Lopo <erikd@mega-nerd.com>
** Copyright (C) 1999-2007 Erik de Castro Lopo <erikd@mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -51,10 +51,16 @@
[+ FOR float_type +]
[+ FOR int_type
+]static void [+ (get "float_type_name") +]_[+ (get "int_type_name") +]_clip_test (const char *filename, int filetype) ;
+]static void [+ (get "float_short_name") +]_[+ (get "int_type_name") +]_clip_read_test (const char *filename, int filetype) ;
[+ ENDFOR int_type
+][+ ENDFOR float_type +]
[+ FOR int_type +]
[+ FOR float_type
+]static void [+ (get "int_type_name") +]_[+ (get "float_short_name") +]_scale_write_test (const char *filename, int filetype) ;
[+ ENDFOR float_type
+][+ ENDFOR int_type +]
typedef union
{ double dbl [BUFFER_SIZE] ;
float flt [BUFFER_SIZE] ;
@ -94,10 +100,15 @@ main (void)
dbl_scale_clip_test_32 ("scale_clip_be32.au", SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_PCM_32, 1.0 * 0x80000000) ;
dbl_scale_clip_test_32 ("scale_clip_le32.au", SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_PCM_32, 1.0 * 0x80000000) ;
float_int_clip_test ("flt_int.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_FLOAT) ;
float_short_clip_test ("flt_short.au" , SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_FLOAT) ;
double_int_clip_test ("dbl_int.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_DOUBLE) ;
double_short_clip_test ("dbl_short.au" , SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_DOUBLE) ;
flt_short_clip_read_test ("flt_short.au" , SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_FLOAT) ;
flt_int_clip_read_test ("flt_int.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_FLOAT) ;
dbl_short_clip_read_test ("dbl_short.au" , SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_DOUBLE) ;
dbl_int_clip_read_test ("dbl_int.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_DOUBLE) ;
short_flt_scale_write_test ("short_flt.au" , SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_FLOAT) ;
int_flt_scale_write_test ("int_flt.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_FLOAT) ;
short_dbl_scale_write_test ("short_dbl.au" , SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_DOUBLE) ;
int_dbl_scale_write_test ("int_dbl.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_DOUBLE) ;
return 0 ;
} /* main */
@ -247,14 +258,14 @@ main (void)
[+ FOR float_type +]
[+ FOR int_type
+]static void [+ (get "float_type_name") +]_[+ (get "int_type_name") +]_clip_test (const char *filename, int filetype)
+]static void [+ (get "float_short_name") +]_[+ (get "int_type_name") +]_clip_read_test (const char *filename, int filetype)
{ SNDFILE *file ;
SF_INFO sfinfo ;
[+ (get "float_type_name") +] *data_out ;
[+ (get "int_type_name") +] *data_in, max_value ;
int k ;
print_test_name ("[+ (get "float_type_name") +]_[+ (get "int_type_name") +]_clip_test", filename) ;
print_test_name ("[+ (get "float_short_name") +]_[+ (get "int_type_name") +]_clip_read_test", filename) ;
data_out = buffer_out.[+ (get "float_short_name") +] ;
data_in = buffer_in.[+ (get "int_short_name") +] ;
@ -319,8 +330,109 @@ main (void)
unlink (filename) ;
puts ("ok") ;
} /* [+ (get "float_type_name") +]_[+ (get "int_type_name") +]_clip_test */
} /* [+ (get "float_short_name") +]_[+ (get "int_type_name") +]_clip_read_test */
[+ ENDFOR int_type
+][+ ENDFOR float_type +]
/*==============================================================================
*/
[+ FOR int_type +]
[+ FOR float_type
+]static void [+ (get "int_type_name") +]_[+ (get "float_short_name") +]_scale_write_test (const char *filename, int filetype)
{ SNDFILE *file ;
SF_INFO sfinfo ;
[+ (get "int_type_name") +] *data_out ;
[+ (get "float_type_name") +] *data_in, max_value ;
int k ;
print_test_name ("[+ (get "int_type_name") +]_[+ (get "float_short_name") +]_clip_write_test", filename) ;
data_out = buffer_out.[+ (get "int_short_name") +] ;
data_in = buffer_in.[+ (get "float_short_name") +] ;
for (k = 0 ; k < BUFFER_SIZE ; k++)
data_out [k] = [+ (get "float_to_int") +] ([+ (get "int_max_value") +] * 0.995 * sin (4 * M_PI * k / BUFFER_SIZE)) ;
memset (&sfinfo, 0, sizeof (sfinfo)) ;
sfinfo.samplerate = 44100 ;
sfinfo.frames = 123456789 ; /* Wrong length. Library should correct this on sf_close. */
sfinfo.channels = 1 ;
sfinfo.format = filetype ;
file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
test_write_[+ (get "int_type_name") +]_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ;
sf_command (file, SFC_SET_SCALE_INT_FLOAT_WRITE, NULL, SF_TRUE) ;
test_write_[+ (get "int_type_name") +]_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ;
sf_command (file, SFC_SET_SCALE_INT_FLOAT_WRITE, NULL, SF_FALSE) ;
test_write_[+ (get "int_type_name") +]_or_die (file, 0, data_out, BUFFER_SIZE, __LINE__) ;
sf_close (file) ;
memset (&sfinfo, 0, sizeof (sfinfo)) ;
file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
sfinfo.format &= (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK) ;
if (sfinfo.format != (filetype & (SF_FORMAT_TYPEMASK | SF_FORMAT_SUBMASK)))
{ printf ("\n\nLine %d: Returned format incorrect (0x%08X => 0x%08X).\n\n", __LINE__, filetype, sfinfo.format) ;
exit (1) ;
} ;
if (sfinfo.frames != 3 * BUFFER_SIZE)
{ printf ("\n\nLine %d: Incorrect number of frames in file (%d => %ld).\n\n", __LINE__, 3 * BUFFER_SIZE, SF_COUNT_TO_LONG (sfinfo.frames)) ;
exit (1) ;
} ;
if (sfinfo.channels != 1)
{ printf ("\n\nLine %d: Incorrect number of channels in file.\n\n", __LINE__) ;
exit (1) ;
} ;
check_log_buffer_or_die (file, __LINE__) ;
/* Check the first section. */
test_read_[+ (get "float_type_name") +]_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ;
max_value = 0.0 ;
for (k = 0 ; k < BUFFER_SIZE ; k++)
max_value = (max_value > fabs (data_in [k])) ? max_value : fabs (data_in [k]) ;
if (max_value < 1000.0)
{ printf ("\n\nLine %d: Max value (%f) < 1000.0.\n\n", __LINE__, max_value) ;
exit (1) ;
} ;
/* Check the second section. */
test_read_[+ (get "float_type_name") +]_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ;
max_value = 0.0 ;
for (k = 0 ; k < BUFFER_SIZE ; k++)
max_value = (max_value > fabs (data_in [k])) ? max_value : fabs (data_in [k]) ;
if (max_value > 1.0)
{ printf ("\n\nLine %d: Max value (%f) > 1.0.\n\n", __LINE__, max_value) ;
exit (1) ;
} ;
/* Check the third section. */
test_read_[+ (get "float_type_name") +]_or_die (file, 0, data_in, BUFFER_SIZE, __LINE__) ;
max_value = 0.0 ;
for (k = 0 ; k < BUFFER_SIZE ; k++)
max_value = (max_value > fabs (data_in [k])) ? max_value : fabs (data_in [k]) ;
if (max_value < 1000.0)
{ printf ("\n\nLine %d: Max value (%f) < 1000.0.\n\n", __LINE__, max_value) ;
exit (1) ;
} ;
sf_close (file) ;
unlink (filename) ;
puts ("ok") ;
} /* [+ (get "int_type_name") +]_[+ (get "float_short_name") +]_scale_write_test */
[+ ENDFOR float_type
+][+ ENDFOR int_type +]