mirror of
https://github.com/cookiengineer/audacity
synced 2026-01-23 17:25:54 +01:00
Update libsndfile to 1.0.29pre2+git
This pulls in MANY (over 890) changes compared to our from our current 1.0.24 version.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2008-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2008-2016 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
@@ -34,14 +34,25 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <float.h>
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#define BLOCK_SIZE 512
|
||||
#define BLOCK_SIZE 4096
|
||||
|
||||
#ifdef DBL_DECIMAL_DIG
|
||||
#define OP_DBL_Digs (DBL_DECIMAL_DIG)
|
||||
#else
|
||||
#ifdef DECIMAL_DIG
|
||||
#define OP_DBL_Digs (DECIMAL_DIG)
|
||||
#else
|
||||
#define OP_DBL_Digs (DBL_DIG + 3)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static void
|
||||
print_usage (char *progname)
|
||||
{ printf ("\nUsage : %s <input file> <output file>\n", progname) ;
|
||||
{ printf ("\nUsage : %s [--full-precision] <input file> <output file>\n", progname) ;
|
||||
puts ("\n"
|
||||
" Where the output file will contain a line for each frame\n"
|
||||
" and a column for each channel.\n"
|
||||
@@ -50,14 +61,20 @@ print_usage (char *progname)
|
||||
} /* print_usage */
|
||||
|
||||
static void
|
||||
convert_to_text (SNDFILE * infile, FILE * outfile, int channels)
|
||||
{ float buf [channels * BLOCK_SIZE] ;
|
||||
convert_to_text (SNDFILE * infile, FILE * outfile, int channels, int full_precision)
|
||||
{ float buf [BLOCK_SIZE] ;
|
||||
sf_count_t frames ;
|
||||
int k, m, readcount ;
|
||||
|
||||
while ((readcount = sf_readf_float (infile, buf, BLOCK_SIZE)) > 0)
|
||||
frames = BLOCK_SIZE / channels ;
|
||||
|
||||
while ((readcount = sf_readf_float (infile, buf, frames)) > 0)
|
||||
{ for (k = 0 ; k < readcount ; k++)
|
||||
{ for (m = 0 ; m < channels ; m++)
|
||||
fprintf (outfile, " % 12.10f", buf [k * channels + m]) ;
|
||||
if (full_precision)
|
||||
fprintf (outfile, " %.*e", OP_DBL_Digs - 1, buf [k * channels + m]) ;
|
||||
else
|
||||
fprintf (outfile, " % 12.10f", buf [k * channels + m]) ;
|
||||
fprintf (outfile, "\n") ;
|
||||
} ;
|
||||
} ;
|
||||
@@ -68,16 +85,27 @@ convert_to_text (SNDFILE * infile, FILE * outfile, int channels)
|
||||
int
|
||||
main (int argc, char * argv [])
|
||||
{ char *progname, *infilename, *outfilename ;
|
||||
SNDFILE *infile = NULL ;
|
||||
SNDFILE *infile = NULL ;
|
||||
FILE *outfile = NULL ;
|
||||
SF_INFO sfinfo ;
|
||||
SF_INFO sfinfo ;
|
||||
int full_precision = 0 ;
|
||||
|
||||
progname = strrchr (argv [0], '/') ;
|
||||
progname = progname ? progname + 1 : argv [0] ;
|
||||
|
||||
if (argc != 3)
|
||||
{ print_usage (progname) ;
|
||||
return 1 ;
|
||||
switch (argc)
|
||||
{ case 4 :
|
||||
if (!strcmp ("--full-precision", argv [3]))
|
||||
{ print_usage (progname) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
full_precision = 1 ;
|
||||
argv++ ;
|
||||
case 3 :
|
||||
break ;
|
||||
default:
|
||||
print_usage (progname) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
infilename = argv [1] ;
|
||||
@@ -101,6 +129,8 @@ main (int argc, char * argv [])
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
if ((infile = sf_open (infilename, SFM_READ, &sfinfo)) == NULL)
|
||||
{ printf ("Not able to open input file %s.\n", infilename) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
@@ -116,7 +146,7 @@ main (int argc, char * argv [])
|
||||
fprintf (outfile, "# Converted from file %s.\n", infilename) ;
|
||||
fprintf (outfile, "# Channels %d, Sample rate %d\n", sfinfo.channels, sfinfo.samplerate) ;
|
||||
|
||||
convert_to_text (infile, outfile, sfinfo.channels) ;
|
||||
convert_to_text (infile, outfile, sfinfo.channels, full_precision) ;
|
||||
|
||||
sf_close (infile) ;
|
||||
fclose (outfile) ;
|
||||
|
||||
Reference in New Issue
Block a user