1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-01-12 15:45:54 +01:00

Move library tree where it belongs

This commit is contained in:
ra
2010-01-24 09:19:39 +00:00
parent e74978ba77
commit 58caf78a86
6020 changed files with 2790154 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
AM_CFLAGS = -I../libtwolame/
# This is just sample code - don't install it
noinst_PROGRAMS = @STWOLAME_BIN@
EXTRA_PROGRAMS = stwolame
stwolame_SOURCES = \
simplefrontend.c \
audio_wave.h \
audio_wave.c
stwolame_LDADD = $(top_srcdir)/libtwolame/libtwolame.la

View File

@@ -0,0 +1,455 @@
# Makefile.in generated by automake 1.10.2 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
EXTRA_PROGRAMS = stwolame$(EXEEXT)
subdir = simplefrontend
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__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/build/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/build/config.h
CONFIG_CLEAN_FILES =
PROGRAMS = $(noinst_PROGRAMS)
am_stwolame_OBJECTS = simplefrontend.$(OBJEXT) audio_wave.$(OBJEXT)
stwolame_OBJECTS = $(am_stwolame_OBJECTS)
stwolame_DEPENDENCIES = $(top_srcdir)/libtwolame/libtwolame.la
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/build
depcomp = $(SHELL) $(top_srcdir)/build/depcomp
am__depfiles_maybe = depfiles
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
SOURCES = $(stwolame_SOURCES)
DIST_SOURCES = $(stwolame_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DSYMUTIL = @DSYMUTIL@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
NMEDIT = @NMEDIT@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
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@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
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../libtwolame/
# This is just sample code - don't install it
noinst_PROGRAMS = @STWOLAME_BIN@
stwolame_SOURCES = \
simplefrontend.c \
audio_wave.h \
audio_wave.c
stwolame_LDADD = $(top_srcdir)/libtwolame/libtwolame.la
all: all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu simplefrontend/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu simplefrontend/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
clean-noinstPROGRAMS:
@list='$(noinst_PROGRAMS)'; for p in $$list; do \
f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
echo " rm -f $$p $$f"; \
rm -f $$p $$f ; \
done
stwolame$(EXEEXT): $(stwolame_OBJECTS) $(stwolame_DEPENDENCIES)
@rm -f stwolame$(EXEEXT)
$(LINK) $(stwolame_OBJECTS) $(stwolame_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audio_wave.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/simplefrontend.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(PROGRAMS)
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \
mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-exec-am:
install-html: install-html-am
install-info: install-info-am
install-man:
install-pdf: install-pdf-am
install-ps: install-ps-am
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am:
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libtool clean-noinstPROGRAMS ctags distclean \
distclean-compile distclean-generic distclean-libtool \
distclean-tags distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
pdf pdf-am ps ps-am tags uninstall uninstall-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@@ -0,0 +1,249 @@
/*
* TwoLAME: an optimized MPEG Audio Layer Two encoder
*
* Copyright (C) 2001-2004 Michael Cheng
* Copyright (C) 2004-2006 The TwoLAME Project
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* 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: audio_wave.c,v 1.3 2008-02-01 19:44:37 richardash1981 Exp $
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "audio_wave.h"
/*****************************************************************************
*
* Routines to determine byte order (of this machine) and swap bytes
*
*****************************************************************************/
enum byte_order { order_unknown, order_bigEndian, order_littleEndian };
static enum byte_order DetermineByteOrder (void)
{
char s[sizeof (long) + 1];
union {
long longval;
char charval[sizeof (long)];
} probe;
probe.longval = 0x41424344L; /* ABCD in ASCII */
strncpy (s, probe.charval, sizeof (long));
s[sizeof (long)] = '\0';
/* fprintf( stderr, "byte order is %s\n", s ); */
if (strcmp (s, "ABCD") == 0)
return order_bigEndian;
else if (strcmp (s, "DCBA") == 0)
return order_littleEndian;
else
return order_unknown;
}
static void SwapBytesInWords (short *loc, int words)
{
int i;
short thisval;
char *dst, *src;
src = (char *) &thisval;
for (i = 0; i < words; i++) {
thisval = *loc;
dst = (char *) loc++;
dst[0] = src[1];
dst[1] = src[0];
}
}
/*****************************************************************************
*
* Read in specified number of samples
*
*****************************************************************************/
int wave_get_samples (wave_info_t *wave_info, short int pcm[], int numSamples)
{
int samples_read;
FILE *file = wave_info->soundfile;
samples_read = fread (pcm, sizeof(short int), numSamples, file);
if (wave_info->byteswap) {
SwapBytesInWords (pcm, samples_read);
}
return (samples_read/wave_info->channels);
}
/*****************************************************************************
*
* parse the wave header.
* returns NULL if not open failed
* returns a wave_info_t * if wave header successfully parsed.
* needs to fill in : samplerate + channels
*
* POST: wave_info->soundfile is set to be at the start of the
* PCM audio data
*
*****************************************************************************/
wave_info_t *wave_init (char *inPath)
{
unsigned char wave_header_buffer[40]; //HH fixed
int wave_header_read = 0;
int wave_header_stereo = -1;
int wave_header_16bit = -1;
unsigned long samplerate;
enum byte_order NativeByteOrder = order_unknown;
wave_info_t *wave_info = NULL;
FILE *file;
if ( (file = fopen(inPath, "rb"))==NULL) {
fprintf(stdout,"WAV: cannot open input file: %s\n", inPath);
return(NULL);
}
/************** WAVE ************************/
/* Nick Burch <The_Leveller@newmail.net> */
/********************************************/
/* Wave File Headers: (Dec) */
/* 8-11 = "WAVE" */
/* 22 = Stereo / Mono */
/* 01 = mono, 02 = stereo */
/* 24 = Sampling Frequency */
/* 32 = Data Rate */
/* 01 = x1 (8bit Mono) */
/* 02 = x2 (8bit Stereo or */
/* 16bit Mono) */
/* 04 = x4 (16bit Stereo) */
/********************************************/
fseek (file, 0, SEEK_SET);
fread (wave_header_buffer, 1, 40, file);
if (wave_header_buffer[8] == 'W' && wave_header_buffer[9] == 'A'
&& wave_header_buffer[10] == 'V' && wave_header_buffer[11] == 'E') {
fprintf (stderr, "Parsing Wave File Header\n");
if (NativeByteOrder == order_unknown) {
NativeByteOrder = DetermineByteOrder ();
if (NativeByteOrder == order_unknown) {
fprintf (stderr, "byte order not determined\n");
fclose(file); return(NULL);
}
}
if (NativeByteOrder == order_littleEndian) {
samplerate = *(unsigned long *) (&wave_header_buffer[24]);
} else {
samplerate = wave_header_buffer[27] +
(wave_header_buffer[26] << 8) +
(wave_header_buffer[25] << 16) + (wave_header_buffer[24] << 24);
}
/* Wave File */
wave_header_read = 1;
switch (samplerate) {
case 44100:
case 48000:
case 32000:
case 24000:
case 22050:
case 16000:
fprintf (stderr, ">>> %ld Hz sampling freq selected\n", samplerate);
break;
default:
/* Unknown Unsupported Frequency */
fprintf (stderr, ">>> Unknown samp freq %ld Hz in Wave Header\n",
samplerate);
fprintf (stderr, ">>> Default 44.1 kHz samp freq selected\n");
samplerate = 44100;
break;
}
if ((long) wave_header_buffer[22] == 1) {
fprintf (stderr, ">>> Input Wave File is Mono\n");
wave_header_stereo = 0;
}
if ((long) wave_header_buffer[22] == 2) {
fprintf (stderr, ">>> Input Wave File is Stereo\n");
wave_header_stereo = 1;
}
if ((long) wave_header_buffer[32] == 1) {
fprintf (stderr, ">>> Input Wave File is 8 Bit\n");
wave_header_16bit = 0;
fprintf (stderr, "Input File must be 16 Bit! Please Re-sample");
fclose(file); return(NULL);
}
if ((long) wave_header_buffer[32] == 2) {
if (wave_header_stereo == 1) {
fprintf (stderr, ">>> Input Wave File is 8 Bit\n");
wave_header_16bit = 0;
fprintf (stderr, "Input File must be 16 Bit! Please Re-sample");
fclose(file); return(NULL);
} else {
/* fprintf(stderr, ">>> Input Wave File is 16 Bit\n" ); */
wave_header_16bit = 1;
}
}
if ((long) wave_header_buffer[32] == 4) {
/* fprintf(stderr, ">>> Input Wave File is 16 Bit\n" ); */
wave_header_16bit = 1;
}
/* should probably use the wave header to determine size here FIXME MFC Feb 2003 */
if (fseek (file, 44, SEEK_SET) != 0) {
/* there's a way of calculating the size of the
wave header. i'll just jump 44 to start with */
fprintf (stderr, "Could not seek to PCM sound data in \"%s\".\n", inPath);
fclose(file); return(NULL);
}
// Successfully processed the wave header
wave_info = (wave_info_t *)calloc(1, sizeof(wave_info_t));
wave_info->soundfile = file;
if (wave_header_stereo == 1)
wave_info->channels = 2;
else wave_info->channels = 1;
wave_info->samplerate = samplerate;
// UNKNOWN. But we really should be able to work
// it out. FIX THIS. MFC May03.
wave_info->num_samples = -1;
// Enable byte swap for big endian machines
if (NativeByteOrder == order_bigEndian)
wave_info->byteswap = 1;
else wave_info->byteswap = 0;
return(wave_info);
}
// not a wave file
fclose(file); return(NULL);
}
/* vim:ts=4:sw=4:nowrap: */

View File

@@ -0,0 +1,41 @@
/*
* TwoLAME: an optimized MPEG Audio Layer Two encoder
*
* Copyright (C) 2001-2004 Michael Cheng
* Copyright (C) 2004-2006 The TwoLAME Project
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* 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: audio_wave.h,v 1.3 2008-02-01 19:44:37 richardash1981 Exp $
*
*/
typedef struct wave_info_struct
{
FILE *soundfile;
short channels; // 1 - mono . 2 - stereo. d'uh.
unsigned long num_samples; // total number of samples/channel if available
short samplesize; // 8 bit or 16bit. could probably just auto scale. but i think
// we'll just ignore 8bit sound. MFC May03
int samplerate; // in Hz
int byteswap;
}
wave_info_t;
wave_info_t *wave_init(char *inPath);
int wave_get_samples(wave_info_t *wave_info, short int pcm[], int num_samples);
// vim:ts=4:sw=4:nowrap:

View File

@@ -0,0 +1,149 @@
/*
* TwoLAME: an optimized MPEG Audio Layer Two encoder
*
* Copyright (C) 2001-2004 Michael Cheng
* Copyright (C) 2004-2006 The TwoLAME Project
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* 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: simplefrontend.c,v 1.3 2008-02-01 19:44:37 richardash1981 Exp $
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <twolame.h>
#include "audio_wave.h"
#define MP2BUFSIZE (16384)
#define AUDIOBUFSIZE (9216)
void usage (void) {
fprintf(stdout,"stwolame <input wavefile> <output mp2 file>\n");
exit (1);
}
int main (int argc, char **argv) {
twolame_options *encodeOptions;
char *inputfilename = argv[1];
char *outputfilename = argv[2];
FILE *outfile;
short int *pcmaudio;
unsigned char *mp2buffer;
int num_samples=0;
int mp2fill_size=0;
int frames=0;
wave_info_t *wave_info = NULL;
if (argc != 3) usage();
/* Allocate some space for the PCM audio data */
if ( (pcmaudio=(short *)calloc(AUDIOBUFSIZE, sizeof(short)))==NULL) {
fprintf(stdout,"pcmaudio alloc failed\n");
exit(99);
}
/* Allocate some space for the encoded MP2 audio data */
if ( (mp2buffer=(unsigned char *)calloc(MP2BUFSIZE, sizeof(unsigned char)))==NULL) {
fprintf(stdout,"mp2buffer alloc failed\n");
exit(99);
}
/* grab a set of default encode options */
encodeOptions = twolame_init();
fprintf(stdout,"Using libtwolame version %s.\n", get_twolame_version());
/* Open the wave file */
if ( (wave_info = wave_init(inputfilename)) == NULL ) {
fprintf(stdout,"Not a recognised WAV file.\n");
exit(99);
}
// Use sound file to over-ride preferences for
// mono/stereo and sampling-frequency
twolame_set_num_channels(encodeOptions, wave_info->channels);
if (wave_info->channels == 1) {
twolame_set_mode(encodeOptions, TWOLAME_MONO);
} else {
twolame_set_mode(encodeOptions, TWOLAME_JOINT_STEREO);
}
/* Set the input and output sample rate to the same */
twolame_set_in_samplerate(encodeOptions, wave_info->samplerate);
twolame_set_out_samplerate(encodeOptions, wave_info->samplerate);
/* Set the bitrate to 160 kbps */
twolame_set_bitrate(encodeOptions, 160);
/* initialise twolame with this set of options */
if (twolame_init_params( encodeOptions ) != 0) {
fprintf(stderr, "Error: configuring libtwolame encoder failed.\n");
exit(99);
}
/* Open the output file for the encoded MP2 data */
if ((outfile = fopen(outputfilename, "wb"))==0) {
fprintf(stdout,"error opening output file %s\n",outputfilename);
exit(99);
}
// Read num_samples of audio data *per channel* from the input file
while ( (num_samples = wave_get_samples(wave_info, pcmaudio, AUDIOBUFSIZE)) != 0 ) {
// Encode the audio!
mp2fill_size = twolame_encode_buffer_interleaved(encodeOptions, pcmaudio, num_samples, mp2buffer, MP2BUFSIZE);
// Write the MPEG bitstream to the file
fwrite(mp2buffer, sizeof(unsigned char), mp2fill_size, outfile);
// Display the number of MPEG audio frames we have encoded
frames += (num_samples/TWOLAME_SAMPLES_PER_FRAME);
fprintf(stdout,"[%04i]\r", frames);
fflush(stdout);
}
/* flush any remaining audio. (don't send any new audio data)
There should only ever be a max of 1 frame on a flush.
There may be zero frames if the audio data was an exact
multiple of 1152 */
mp2fill_size = twolame_encode_flush(encodeOptions, mp2buffer, MP2BUFSIZE);
fwrite(mp2buffer, sizeof(unsigned char), mp2fill_size, outfile);
twolame_close( &encodeOptions );
free(pcmaudio);
fprintf(stdout,"\nFinished nicely.\n");
return(0);
}
/* vim:ts=4:sw=4:nowrap: */