mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-10 16:43:33 +02:00
Update twolame to 0.3.13.
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
|
||||
AM_CFLAGS = -I$(top_srcdir)/build/ -I$(top_srcdir)/libtwolame/ @SNDFILE_CFLAGS@
|
||||
AM_LDFLAGS = @SNDFILE_LIBS@
|
||||
|
||||
AM_CFLAGS = -I$(top_srcdir)/build/ -I$(top_srcdir)/libtwolame/ $(SNDFILE_CFLAGS) $(WARNING_CFLAGS)
|
||||
AM_LDFLAGS = $(SNDFILE_LIBS)
|
||||
|
||||
bin_PROGRAMS = @TWOLAME_BIN@
|
||||
EXTRA_PROGRAMS = twolame
|
||||
|
||||
twolame_SOURCES = frontend.c frontend.h audioin_raw.c audioin_sndfile.c
|
||||
twolame_LDADD = $(top_srcdir)/libtwolame/libtwolame.la
|
||||
twolame_LDADD = $(top_builddir)/libtwolame/libtwolame.la
|
||||
|
@@ -32,17 +32,20 @@ PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
target_triplet = @target@
|
||||
EXTRA_PROGRAMS = twolame$(EXEEXT)
|
||||
subdir = frontend
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/build/m4/libtool.m4 \
|
||||
$(top_srcdir)/build/m4/pkg.m4 $(top_srcdir)/configure.ac
|
||||
am__aclocal_m4_deps = $(top_srcdir)/build-scripts/libtool.m4 \
|
||||
$(top_srcdir)/build-scripts/ltoptions.m4 \
|
||||
$(top_srcdir)/build-scripts/ltsugar.m4 \
|
||||
$(top_srcdir)/build-scripts/ltversion.m4 \
|
||||
$(top_srcdir)/build-scripts/lt~obsolete.m4 \
|
||||
$(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/build/mkinstalldirs
|
||||
CONFIG_HEADER = $(top_builddir)/build/config.h
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/libtwolame/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
am__installdirs = "$(DESTDIR)$(bindir)"
|
||||
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
|
||||
@@ -50,9 +53,9 @@ PROGRAMS = $(bin_PROGRAMS)
|
||||
am_twolame_OBJECTS = frontend.$(OBJEXT) audioin_raw.$(OBJEXT) \
|
||||
audioin_sndfile.$(OBJEXT)
|
||||
twolame_OBJECTS = $(am_twolame_OBJECTS)
|
||||
twolame_DEPENDENCIES = $(top_srcdir)/libtwolame/libtwolame.la
|
||||
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/build
|
||||
depcomp = $(SHELL) $(top_srcdir)/build/depcomp
|
||||
twolame_DEPENDENCIES = $(top_builddir)/libtwolame/libtwolame.la
|
||||
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/libtwolame
|
||||
depcomp = $(SHELL) $(top_srcdir)/build-scripts/depcomp
|
||||
am__depfiles_maybe = depfiles
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
@@ -80,46 +83,53 @@ CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
ECHO = @ECHO@
|
||||
DUMPBIN = @DUMPBIN@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
F77 = @F77@
|
||||
FFLAGS = @FFLAGS@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LD = @LD@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIPO = @LIPO@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MANIFEST_TOOL = @MANIFEST_TOOL@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NM = @NM@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
OTOOL = @OTOOL@
|
||||
OTOOL64 = @OTOOL64@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_URL = @PACKAGE_URL@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_ASCIIDOC = @PATH_ASCIIDOC@
|
||||
PATH_DOXYGEN = @PATH_DOXYGEN@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
PATH_XMLTO = @PATH_XMLTO@
|
||||
PKG_CONFIG = @PKG_CONFIG@
|
||||
RANLIB = @RANLIB@
|
||||
SED = @SED@
|
||||
@@ -128,17 +138,17 @@ SHELL = @SHELL@
|
||||
SNDFILE_CFLAGS = @SNDFILE_CFLAGS@
|
||||
SNDFILE_LIBS = @SNDFILE_LIBS@
|
||||
STRIP = @STRIP@
|
||||
STWOLAME_BIN = @STWOLAME_BIN@
|
||||
TWOLAME_BIN = @TWOLAME_BIN@
|
||||
TWOLAME_SO_VERSION = @TWOLAME_SO_VERSION@
|
||||
VERSION = @VERSION@
|
||||
WARNING_CFLAGS = @WARNING_CFLAGS@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_CXX = @ac_ct_CXX@
|
||||
ac_ct_F77 = @ac_ct_F77@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
@@ -180,19 +190,15 @@ sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target = @target@
|
||||
target_alias = @target_alias@
|
||||
target_cpu = @target_cpu@
|
||||
target_os = @target_os@
|
||||
target_vendor = @target_vendor@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
AM_CFLAGS = -I$(top_srcdir)/build/ -I$(top_srcdir)/libtwolame/ @SNDFILE_CFLAGS@
|
||||
AM_LDFLAGS = @SNDFILE_LIBS@
|
||||
AM_CFLAGS = -I$(top_srcdir)/build/ -I$(top_srcdir)/libtwolame/ $(SNDFILE_CFLAGS) $(WARNING_CFLAGS)
|
||||
AM_LDFLAGS = $(SNDFILE_LIBS)
|
||||
bin_PROGRAMS = @TWOLAME_BIN@
|
||||
twolame_SOURCES = frontend.c frontend.h audioin_raw.c audioin_sndfile.c
|
||||
twolame_LDADD = $(top_srcdir)/libtwolame/libtwolame.la
|
||||
twolame_LDADD = $(top_builddir)/libtwolame/libtwolame.la
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
|
@@ -17,7 +17,7 @@
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* $Id: audioin_raw.c,v 1.1 2008-02-01 19:44:25 richardash1981 Exp $
|
||||
* $Id: frontend.h 156 2007-03-20 23:57:35Z nhumfrey $
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -31,86 +31,86 @@
|
||||
/* We still use libsndfiles' SF_INFO structure for convenience */
|
||||
|
||||
|
||||
static void print_info_raw(struct audioin_s *audioin )
|
||||
static void print_info_raw(struct audioin_s *audioin)
|
||||
{
|
||||
|
||||
fprintf(stderr, "Raw input format: %d channels, %d-bit, %d Hz\n",
|
||||
audioin->sfinfo->channels, audioin->samplesize, audioin->sfinfo->samplerate );
|
||||
|
||||
fprintf(stderr, "Raw input format: %d channels, %d-bit, %d Hz\n",
|
||||
audioin->sfinfo->channels, audioin->samplesize, audioin->sfinfo->samplerate);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Read in some audio samples into buffer */
|
||||
static int read_raw( audioin_t* audioin, short *buffer, int samples)
|
||||
static int read_raw(audioin_t * audioin, short *buffer, int samples)
|
||||
{
|
||||
FILE* file = audioin->file;
|
||||
|
||||
if (audioin->samplesize==16) {
|
||||
return fread( buffer, 2, samples, file );
|
||||
} else {
|
||||
fprintf(stderr, "Error: sorry %d-bit samples are not supported at the moment.\n", audioin->samplesize);
|
||||
}
|
||||
|
||||
// Error
|
||||
return -1;
|
||||
FILE *file = audioin->file;
|
||||
|
||||
if (audioin->samplesize == 16) {
|
||||
return fread(buffer, 2, samples, file);
|
||||
} else {
|
||||
fprintf(stderr, "Error: sorry %d-bit samples are not supported at the moment.\n",
|
||||
audioin->samplesize);
|
||||
}
|
||||
|
||||
// Error
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* Return error string (or NULL) */
|
||||
static const char* error_str_raw( audioin_t* audioin )
|
||||
static const char *error_str_raw(audioin_t * audioin)
|
||||
{
|
||||
FILE* file = audioin->file;
|
||||
int error = ferror( file );
|
||||
if (error==0) return NULL;
|
||||
return strerror(error);
|
||||
FILE *file = audioin->file;
|
||||
int error = ferror(file);
|
||||
if (error == 0)
|
||||
return NULL;
|
||||
return strerror(error);
|
||||
}
|
||||
|
||||
|
||||
static int close_raw( audioin_t* audioin )
|
||||
static int close_raw(audioin_t * audioin)
|
||||
{
|
||||
FILE* file = audioin->file;
|
||||
FILE *file = audioin->file;
|
||||
|
||||
free( audioin );
|
||||
|
||||
return fclose( file );
|
||||
free(audioin);
|
||||
|
||||
return fclose(file);
|
||||
}
|
||||
|
||||
|
||||
audioin_t* open_audioin_raw( char* filename, SF_INFO *sfinfo, int samplesize )
|
||||
audioin_t *open_audioin_raw(char *filename, SF_INFO * sfinfo, int samplesize)
|
||||
{
|
||||
audioin_t* audioin = NULL;
|
||||
audioin_t *audioin = NULL;
|
||||
|
||||
|
||||
// Allocate memory for structure
|
||||
audioin = malloc( sizeof( audioin_t ) );
|
||||
if (audioin==NULL) {
|
||||
fprintf(stderr, "Failed to allocate memory for audioin_t structure.\n");
|
||||
exit(ERR_MEM_ALLOC);
|
||||
}
|
||||
|
||||
// Open the input file by filename
|
||||
if (strcmp(filename, "-") == 0) {
|
||||
// Use STDIN
|
||||
audioin->file = stdin;
|
||||
} else {
|
||||
audioin->file = fopen(filename, "rb");
|
||||
}
|
||||
// Allocate memory for structure
|
||||
audioin = malloc(sizeof(audioin_t));
|
||||
if (audioin == NULL) {
|
||||
fprintf(stderr, "Failed to allocate memory for audioin_t structure.\n");
|
||||
exit(ERR_MEM_ALLOC);
|
||||
}
|
||||
// Open the input file by filename
|
||||
if (strcmp(filename, "-") == 0) {
|
||||
// Use STDIN
|
||||
audioin->file = stdin;
|
||||
} else {
|
||||
audioin->file = fopen(filename, "rb");
|
||||
}
|
||||
|
||||
// Check for errors
|
||||
if (audioin->file == NULL) {
|
||||
fprintf(stderr, "Failed to open input file (%s):\n", filename);
|
||||
fprintf(stderr, " %s\n", strerror(errno));
|
||||
exit(ERR_OPENING_INPUT);
|
||||
}
|
||||
|
||||
// Fill-in data structure
|
||||
audioin->samplesize = samplesize;
|
||||
audioin->sfinfo = sfinfo;
|
||||
audioin->print_info = print_info_raw;
|
||||
audioin->read = read_raw;
|
||||
audioin->error_str = error_str_raw;
|
||||
audioin->close = close_raw;
|
||||
// Check for errors
|
||||
if (audioin->file == NULL) {
|
||||
fprintf(stderr, "Failed to open input file (%s):\n", filename);
|
||||
fprintf(stderr, " %s\n", strerror(errno));
|
||||
exit(ERR_OPENING_INPUT);
|
||||
}
|
||||
// Fill-in data structure
|
||||
audioin->samplesize = samplesize;
|
||||
audioin->sfinfo = sfinfo;
|
||||
audioin->print_info = print_info_raw;
|
||||
audioin->read = read_raw;
|
||||
audioin->error_str = error_str_raw;
|
||||
audioin->close = close_raw;
|
||||
|
||||
|
||||
return audioin;
|
||||
return audioin;
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* $Id: audioin_sndfile.c,v 1.1 2008-02-01 19:44:26 richardash1981 Exp $
|
||||
* $Id: frontend.h 156 2007-03-20 23:57:35Z nhumfrey $
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -33,26 +33,31 @@
|
||||
format_duration_string()
|
||||
Create human readable duration string from libsndfile info
|
||||
*/
|
||||
static char* format_duration_string( SF_INFO *sfinfo )
|
||||
static char *format_duration_string(SF_INFO * sfinfo)
|
||||
{
|
||||
float seconds;
|
||||
int minutes;
|
||||
char * string = malloc( MAX_NAME_SIZE );
|
||||
|
||||
if (sfinfo->frames==0 || sfinfo->samplerate==0) {
|
||||
snprintf( string, MAX_NAME_SIZE, "Unknown" );
|
||||
return string;
|
||||
}
|
||||
|
||||
// Calculate the number of minutes and seconds
|
||||
seconds = sfinfo->frames / sfinfo->samplerate;
|
||||
minutes = (seconds / 60 );
|
||||
seconds -= (minutes * 60);
|
||||
float seconds = 0.0f;
|
||||
char *string = NULL;
|
||||
int minutes = 0;
|
||||
|
||||
string = malloc(MAX_NAME_SIZE);
|
||||
if (!string) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Create a string out of it
|
||||
snprintf( string, MAX_NAME_SIZE, "%imin %1.1fsec", minutes, seconds);
|
||||
if (sfinfo->frames == 0 || sfinfo->samplerate == 0) {
|
||||
snprintf(string, MAX_NAME_SIZE, "Unknown");
|
||||
return string;
|
||||
}
|
||||
|
||||
return string;
|
||||
// Calculate the number of minutes and seconds
|
||||
seconds = sfinfo->frames / sfinfo->samplerate;
|
||||
minutes = (seconds / 60);
|
||||
seconds -= (minutes * 60);
|
||||
|
||||
// Create a string out of it
|
||||
snprintf(string, MAX_NAME_SIZE, "%imin %1.1fsec", minutes, seconds);
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,97 +66,95 @@ static char* format_duration_string( SF_INFO *sfinfo )
|
||||
print_info_sndfile()
|
||||
Display information about input file
|
||||
*/
|
||||
static void print_info_sndfile(struct audioin_s *audioin )
|
||||
static void print_info_sndfile(struct audioin_s *audioin)
|
||||
{
|
||||
SNDFILE* file = audioin->file;
|
||||
SF_FORMAT_INFO format_info;
|
||||
SF_FORMAT_INFO subformat_info;
|
||||
char sndlibver[128];
|
||||
char *duration = NULL;
|
||||
|
||||
// Get the format
|
||||
format_info.format = audioin->sfinfo->format & SF_FORMAT_TYPEMASK;
|
||||
sf_command (file, SFC_GET_FORMAT_INFO, &format_info, sizeof(format_info)) ;
|
||||
SNDFILE *file = audioin->file;
|
||||
SF_FORMAT_INFO format_info;
|
||||
SF_FORMAT_INFO subformat_info;
|
||||
char sndlibver[128];
|
||||
char *duration = NULL;
|
||||
|
||||
// Get the sub-format info
|
||||
subformat_info.format = audioin->sfinfo->format & SF_FORMAT_SUBMASK;
|
||||
sf_command (file, SFC_GET_FORMAT_INFO, &subformat_info, sizeof(subformat_info)) ;
|
||||
// Get the format
|
||||
format_info.format = audioin->sfinfo->format & SF_FORMAT_TYPEMASK;
|
||||
sf_command(file, SFC_GET_FORMAT_INFO, &format_info, sizeof(format_info));
|
||||
|
||||
// Get the version of libsndfile
|
||||
sf_command (file, SFC_GET_LIB_VERSION, sndlibver, sizeof(sndlibver));
|
||||
// Get the sub-format info
|
||||
subformat_info.format = audioin->sfinfo->format & SF_FORMAT_SUBMASK;
|
||||
sf_command(file, SFC_GET_FORMAT_INFO, &subformat_info, sizeof(subformat_info));
|
||||
|
||||
// Get human readable duration of the input file
|
||||
duration = format_duration_string( audioin->sfinfo );
|
||||
// Get the version of libsndfile
|
||||
sf_command(file, SFC_GET_LIB_VERSION, sndlibver, sizeof(sndlibver));
|
||||
|
||||
fprintf(stderr, "Input Format: %s, %s\n", format_info.name, subformat_info.name );
|
||||
fprintf(stderr, "Input Duration: %s\n", duration );
|
||||
fprintf(stderr, "Input Library: %s\n", sndlibver);
|
||||
|
||||
free( duration );
|
||||
// Get human readable duration of the input file
|
||||
duration = format_duration_string(audioin->sfinfo);
|
||||
|
||||
fprintf(stderr, "Input Format: %s, %s\n", format_info.name, subformat_info.name);
|
||||
fprintf(stderr, "Input Duration: %s\n", duration);
|
||||
fprintf(stderr, "Input Library: %s\n", sndlibver);
|
||||
|
||||
free(duration);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Read in some audio samples into buffer */
|
||||
static int read_sndfile( audioin_t* audioin, short *buffer, int samples)
|
||||
static int read_sndfile(audioin_t * audioin, short *buffer, int samples)
|
||||
{
|
||||
SNDFILE* file = audioin->file;
|
||||
return sf_read_short( file, buffer, samples );
|
||||
SNDFILE *file = audioin->file;
|
||||
return sf_read_short(file, buffer, samples);
|
||||
}
|
||||
|
||||
|
||||
/* Return error string (or NULL) */
|
||||
static const char* error_str_sndfile( audioin_t* audioin )
|
||||
static const char *error_str_sndfile(audioin_t * audioin)
|
||||
{
|
||||
SNDFILE* file = audioin->file;
|
||||
|
||||
if (sf_error(file) == SF_ERR_NO_ERROR) {
|
||||
// No error
|
||||
return NULL;
|
||||
} else {
|
||||
// Return error string
|
||||
return sf_strerror( file );
|
||||
}
|
||||
SNDFILE *file = audioin->file;
|
||||
|
||||
if (sf_error(file) == SF_ERR_NO_ERROR) {
|
||||
// No error
|
||||
return NULL;
|
||||
} else {
|
||||
// Return error string
|
||||
return sf_strerror(file);
|
||||
}
|
||||
}
|
||||
|
||||
static int close_sndfile( audioin_t* audioin )
|
||||
static int close_sndfile(audioin_t * audioin)
|
||||
{
|
||||
SNDFILE* file = audioin->file;
|
||||
SNDFILE *file = audioin->file;
|
||||
|
||||
free( audioin );
|
||||
|
||||
return sf_close( file );
|
||||
free(audioin);
|
||||
|
||||
return sf_close(file);
|
||||
}
|
||||
|
||||
audioin_t* open_audioin_sndfile( char* filename, SF_INFO *sfinfo )
|
||||
audioin_t *open_audioin_sndfile(char *filename, SF_INFO * sfinfo)
|
||||
{
|
||||
audioin_t* audioin = NULL;
|
||||
audioin_t *audioin = NULL;
|
||||
|
||||
// Allocate memory for structure
|
||||
audioin = malloc( sizeof( audioin_t ) );
|
||||
if (audioin==NULL) {
|
||||
fprintf(stderr, "Failed to allocate memory for audioin_t structure.\n");
|
||||
exit(ERR_MEM_ALLOC);
|
||||
}
|
||||
|
||||
// Open the input file by filename
|
||||
audioin->file = sf_open(filename, SFM_READ, sfinfo);
|
||||
// Allocate memory for structure
|
||||
audioin = malloc(sizeof(audioin_t));
|
||||
if (audioin == NULL) {
|
||||
fprintf(stderr, "Failed to allocate memory for audioin_t structure.\n");
|
||||
exit(ERR_MEM_ALLOC);
|
||||
}
|
||||
// Open the input file by filename
|
||||
audioin->file = sf_open(filename, SFM_READ, sfinfo);
|
||||
|
||||
// Check for errors
|
||||
if (audioin->file == NULL) {
|
||||
fprintf(stderr, "Failed to open input file (%s):\n", filename);
|
||||
fprintf(stderr, " %s\n", sf_strerror(NULL));
|
||||
exit(ERR_OPENING_INPUT);
|
||||
}
|
||||
|
||||
// Fill-in data structure
|
||||
audioin->samplesize = 0;
|
||||
audioin->sfinfo = sfinfo;
|
||||
audioin->print_info = print_info_sndfile;
|
||||
audioin->read = read_sndfile;
|
||||
audioin->error_str = error_str_sndfile;
|
||||
audioin->close = close_sndfile;
|
||||
// Check for errors
|
||||
if (audioin->file == NULL) {
|
||||
fprintf(stderr, "Failed to open input file (%s):\n", filename);
|
||||
fprintf(stderr, " %s\n", sf_strerror(NULL));
|
||||
exit(ERR_OPENING_INPUT);
|
||||
}
|
||||
// Fill-in data structure
|
||||
audioin->samplesize = 0;
|
||||
audioin->sfinfo = sfinfo;
|
||||
audioin->print_info = print_info_sndfile;
|
||||
audioin->read = read_sndfile;
|
||||
audioin->error_str = error_str_sndfile;
|
||||
audioin->close = close_sndfile;
|
||||
|
||||
|
||||
return audioin;
|
||||
return audioin;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -17,7 +17,7 @@
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* $Id: frontend.h,v 1.1 2008-02-01 19:44:26 richardash1981 Exp $
|
||||
* $Id: frontend.h 156 2007-03-20 23:57:35Z nhumfrey $
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -38,48 +38,47 @@
|
||||
/*
|
||||
Result codes
|
||||
*/
|
||||
#define ERR_NO_ERROR (0) // No Error (encoded ok)
|
||||
#define ERR_NO_ENCODE (1) // No Error (no encoding performed)
|
||||
#define ERR_OPENING_INPUT (2) // Error opening input file
|
||||
#define ERR_OPENING_OUTPUT (4) // Error opening output file
|
||||
#define ERR_MEM_ALLOC (6) // Error allocating memory
|
||||
#define ERR_INVALID_PARAM (8) // Error in chosen encoding parameters
|
||||
#define ERR_READING_INPUT (10) // Error reading input
|
||||
#define ERR_ENCODING (12) // Error occured during encoding
|
||||
#define ERR_WRITING_OUTPUT (14) // Error occured writing to output file
|
||||
#define ERR_NO_ERROR (0) // No Error (encoded ok)
|
||||
#define ERR_NO_ENCODE (1) // No Error (no encoding performed)
|
||||
#define ERR_OPENING_INPUT (2) // Error opening input file
|
||||
#define ERR_OPENING_OUTPUT (4) // Error opening output file
|
||||
#define ERR_MEM_ALLOC (6) // Error allocating memory
|
||||
#define ERR_INVALID_PARAM (8) // Error in chosen encoding parameters
|
||||
#define ERR_READING_INPUT (10) // Error reading input
|
||||
#define ERR_ENCODING (12) // Error occured during encoding
|
||||
#define ERR_WRITING_OUTPUT (14) // Error occured writing to output file
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct audioin_s {
|
||||
|
||||
// Display information about input stream
|
||||
void (*print_info)(struct audioin_s *);
|
||||
// Display information about input stream
|
||||
void (*print_info) (struct audioin_s *);
|
||||
|
||||
// Read in some audio
|
||||
int (*read)(struct audioin_s *, short *buffer, int samples);
|
||||
|
||||
// Return error string (if any)
|
||||
const char* (*error_str)(struct audioin_s *);
|
||||
|
||||
// Close the inout stream
|
||||
int (*close)(struct audioin_s *);
|
||||
// Read in some audio
|
||||
int (*read) (struct audioin_s *, short *buffer, int samples);
|
||||
|
||||
// Return error string (if any)
|
||||
const char *(*error_str) (struct audioin_s *);
|
||||
|
||||
// Close the inout stream
|
||||
int (*close) (struct audioin_s *);
|
||||
|
||||
|
||||
// Pointer to file / input stream
|
||||
void* file;
|
||||
|
||||
// Pointer to linsndfile info structure
|
||||
SF_INFO* sfinfo;
|
||||
|
||||
// Size of the samples (in bits)
|
||||
int samplesize;
|
||||
// Pointer to file / input stream
|
||||
void *file;
|
||||
|
||||
// Pointer to linsndfile info structure
|
||||
SF_INFO *sfinfo;
|
||||
|
||||
// Size of the samples (in bits)
|
||||
int samplesize;
|
||||
|
||||
} audioin_t;
|
||||
|
||||
|
||||
|
||||
/* Initialisers */
|
||||
audioin_t* open_audioin_sndfile( char* filename, SF_INFO *sfinfo );
|
||||
audioin_t* open_audioin_raw( char* filename, SF_INFO *sfinfo, int samplesize);
|
||||
|
||||
audioin_t *open_audioin_sndfile(char *filename, SF_INFO * sfinfo);
|
||||
audioin_t *open_audioin_raw(char *filename, SF_INFO * sfinfo, int samplesize);
|
||||
|
Reference in New Issue
Block a user